Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/srdc/onfhir
Browse files Browse the repository at this point in the history
  • Loading branch information
Tuncay Namli committed Jan 20, 2025
2 parents be61401 + a79e5f4 commit 740865b
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 23 deletions.
9 changes: 8 additions & 1 deletion docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#!/usr/bin/env bash

JAVA_CMD="java -Xms256m -Xmx3g -jar "
# Set default Java options
DEFAULT_JAVA_OPTIONS="-Xms256m -Xmx3g"

# Use environment variable if provided, otherwise use default value
JAVA_OPTIONS="${JAVA_OPTIONS:-$DEFAULT_JAVA_OPTIONS}"

# Construct JAVA_CMD with Java options
JAVA_CMD="java $JAVA_OPTIONS -jar "

# Configure application.conf path
if [ ! -z "$APP_CONF_FILE" ]; then
Expand Down
47 changes: 32 additions & 15 deletions onfhir-common/src/main/scala/io/onfhir/api/util/IOUtil.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ object IOUtil {

/**
* Read a FHIR resource from given path or default path (within project resources)
* @param resourcePath Given file path
* @param defaultPath Default resource path (within project resources)
* @param rtype Resource type
*
* @param resourcePath Given file path
* @param defaultPath Default resource path (within project resources)
* @param rtype Resource type
* @return
*/
def readResource(resourcePath: Option[String], defaultPath: String, rtype: String): Resource = {
Expand All @@ -43,7 +44,8 @@ object IOUtil {

/**
* Read a FHIR resource from given File path
* @param filePath File path
*
* @param filePath File path
* @return
*/
def readResource(filePath: String): Resource = {
Expand All @@ -52,7 +54,8 @@ object IOUtil {

/**
* Read a FHIR resource from project resources with a path
* @param resourcePath Resource path
*
* @param resourcePath Resource path
* @return
*/
def readInnerResource(resourcePath: String): Resource = {
Expand Down Expand Up @@ -93,7 +96,7 @@ object IOUtil {
if (!givenFile.isDirectory)
throw new InitializationException(s"Given path '$path' is not a folder or zip file ...")
//Given as folder
getFilesFromFolder(folder = givenFile, withExtension = None, recursively = Some(true))
getFilesFromFolder(folder = givenFile, recursively = true, ignoreHidden = true, withExtension = None)
.map(file => {
try {
parseResource(new InputStreamReader(BOMInputStream.builder.setInputStream(new FileInputStream(file)).get()), file.getAbsolutePath)
Expand All @@ -120,19 +123,30 @@ object IOUtil {
* Get the list of files from the given folder.
*
* @param folder The folder to retrieve the files from.
* @param recursively If true, the folder will be searched recursively to retrieve all files within.
* @param ignoreHidden If true, hidden files and directories will be excluded from the result.
* @param withExtension An optional extension (e.g., .json) if the files need to be filtered.
* @param recursively If exists and true, the folder will be searched recursively to retrieve all files within.
* @return
* @return A sequence of files matching the criteria.
*/
def getFilesFromFolder(folder: File, withExtension: Option[String], recursively: Option[Boolean]): Seq[File] = {
def getFilesFromFolder(
folder: File,
recursively: Boolean,
ignoreHidden: Boolean,
withExtension: Option[String]
): Seq[File] = {
if (folder.exists && folder.isDirectory) {
val files = folder.listFiles().toSeq // List all available files in the given folder

// Filter hidden files if ignoreHidden is true
val nonHiddenFiles = if (ignoreHidden) files.filterNot(f => f.isHidden || f.getName.startsWith(".")) else files

val filteredFiles = withExtension
.map(ext => files.filter(_.getName.endsWith(ext))).getOrElse(files)
.map(ext => nonHiddenFiles.filter(_.getName.endsWith(ext))).getOrElse(nonHiddenFiles)
.filterNot(_.isDirectory)
if (recursively.contains(true)) {
val subFolders = files.filter(_.isDirectory)
filteredFiles ++ subFolders.flatMap(f => getFilesFromFolder(f, withExtension, recursively))

if (recursively) {
val subFolders = nonHiddenFiles.filter(_.isDirectory)
filteredFiles ++ subFolders.flatMap(f => getFilesFromFolder(f, recursively, ignoreHidden, withExtension))
} else {
filteredFiles
}
Expand All @@ -141,8 +155,10 @@ object IOUtil {
}
}


/**
* Given a filename, removes its extension if an extension exists (e.g., admissions.json -> admissions)
*
* @param fileName
* @return
*/
Expand Down Expand Up @@ -254,8 +270,9 @@ object IOUtil {

/**
* Parse a JSON resource
* @param reader Reader
* @param path File path it is read from
*
* @param reader Reader
* @param path File path it is read from
* @return
*/
private def parseResource(reader: Reader, path: String): Resource = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ abstract class BaseFhirConfigurator extends IFhirVersionConfigurator {
//Get the parser for parsing FHIR foundation resources
val foundationResourceParser = getFoundationResourceParser(fhirConfig.FHIR_COMPLEX_TYPES, fhirConfig.FHIR_PRIMITIVE_TYPES)

logger.info("Reading FHIR foundation resources to start configuration of onFhir server ...")
logger.info("Reading FHIR foundation resources to start configuration of onFHIR server ...")
//Read the StructureDefinitions for all supported profiles
val profileResources = configReader.getInfrastructureResources(FHIR_STRUCTURE_DEFINITION)
//Read the ValueSet definitions to be used in this server (within the profiles)
Expand Down
2 changes: 1 addition & 1 deletion onfhir-core/src/main/scala/io/onfhir/Onfhir.scala
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class Onfhir(
logger.info("OnFhir server is gracefully terminated...")
case Failure(exception) => logger.error("Problem while gracefully terminating OnFhir server!", exception)
}
logger.info("OnFhir FHIR server started on host {} and port {}", OnfhirConfig.serverHost, OnfhirConfig.serverPort)
logger.info("onFHIR FHIR server started on host {} and port {}", OnfhirConfig.serverHost, OnfhirConfig.serverPort)
//Wait for a shutdown signal
Await.ready(waitForShutdownSignal(), Duration.Inf)
fhirServerBinding.terminate(FiniteDuration.apply(60L, TimeUnit.SECONDS))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class FhirPathAggFunctions(context:FhirPathEnvironment, current:Seq[FhirPathResu
.flatMap(c => {
val result = new FhirPathExpressionEvaluator(context, Seq(c)).visit(expr)
if (result.length > 1)
throw new FhirPathException(s"Invalid function call 'min', the expression ${expr.getText} does not return a single value or Nil!")
throw new FhirPathException(s"Invalid function call 'max', the expression ${expr.getText} does not return a single value or Nil!")
result.headOption
})

Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
<akka.version>2.8.5</akka.version>
<!--mongodb.scala.version>4.11.1</mongodb.scala.version-->
<mongodb.scala.version>5.1.3</mongodb.scala.version>
<mongo.embedded.version>4.12.0</mongo.embedded.version>
<mongo.embedded.version>4.18.1</mongo.embedded.version>
<json4s.version>3.7.0-M11</json4s.version>
<scala.xml.version>2.2.0</scala.xml.version>
<logback.version>1.4.14</logback.version>
Expand All @@ -122,9 +122,9 @@
<specs2.version>4.20.4</specs2.version>
<nimbus-jose.version>9.37.3</nimbus-jose.version>
<nimbus-oidc.version>11.9.1</nimbus-oidc.version>
<apache-commons-lang.version>3.14.0</apache-commons-lang.version>
<apache-commons-io.version>2.15.1</apache-commons-io.version>
<apache-commons-text.version>1.11.0</apache-commons-text.version>
<apache-commons-lang.version>3.17.0</apache-commons-lang.version>
<apache-commons-io.version>2.18.0</apache-commons-io.version>
<apache-commons-text.version>1.13.0</apache-commons-text.version>
<reflections.version>0.10.2</reflections.version>

<!-- release plugin versions -->
Expand Down

0 comments on commit 740865b

Please sign in to comment.