forked from joelplourde3/clin-pipelines
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FhirServer.scala
48 lines (38 loc) · 1.73 KB
/
FhirServer.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package bio.ferlab.clin.etl.fhir.testutils
import bio.ferlab.clin.etl.conf.FerloadConf
import bio.ferlab.clin.etl.fhir.IClinFhirClient
import bio.ferlab.clin.etl.fhir.testutils.FhirTestUtils.getClass
import bio.ferlab.clin.etl.fhir.testutils.containers.FhirServerContainer
import ca.uhn.fhir.context.{FhirContext, PerformanceOptionsEnum}
import ca.uhn.fhir.parser.IParser
import ca.uhn.fhir.rest.client.api.{IGenericClient, ServerValidationModeEnum}
import org.scalatest.{BeforeAndAfter, BeforeAndAfterAll, TestSuite}
import org.slf4j.{Logger, LoggerFactory}
trait FhirServer {
val fhirPort: Int = FhirServerContainer.startIfNotRunning()
val fhirBaseUrl = s"http://localhost:$fhirPort/fhir"
val fhirContext: FhirContext = FhirContext.forR4()
fhirContext.setPerformanceOptions(PerformanceOptionsEnum.DEFERRED_MODEL_SCANNING)
fhirContext.getRestfulClientFactory.setServerValidationMode(ServerValidationModeEnum.NEVER)
val parser: IParser = fhirContext.newJsonParser().setPrettyPrint(true)
implicit val clinClient: IClinFhirClient = fhirContext.newRestfulClient(classOf[IClinFhirClient], fhirBaseUrl)
implicit val fhirClient: IGenericClient = fhirContext.newRestfulGenericClient(fhirBaseUrl)
}
trait FhirServerSuite extends FhirServer with TestSuite with BeforeAndAfterAll with BeforeAndAfter {
implicit val ferloadConf: FerloadConf = FerloadConf("https://objectstore.cqgc.qc.ca")
before {
FhirTestUtils.init()
}
after {
FhirTestUtils.clearAll()
}
}
object StartFhirServer extends App with FhirServer {
val LOGGER: Logger = LoggerFactory.getLogger(getClass)
LOGGER.info("Fhir Server is started")
while (true) {
}
}
object test extends FhirServer with App {
FhirTestUtils.loadPatients(lastName = "River", firstName = "Jack")
}