Skip to content

Commit

Permalink
Migrates Workflow to CQL Evaluator 3.0.0-PRE9-SNAPSHOT (#2259)
Browse files Browse the repository at this point in the history
* Updates dependencies

* Updates test cases

* Removes moxy and antlr from dependencies.

* Migrates the workflow to the new API

* Migrates workflow testing to the new API

* Fixes workflow benchmark module

* Fixes workflow benchmark module

* Adds contents.txt file to all test repos so it can be loaded on androidTest

* Normalizes path before trying to open files

* Uses contents.txt when running tests on Android

* Spotless

* Updating Json and XML comparisons to pass when elements are just out of order.

* Ignores testANCDT17 for now
  • Loading branch information
vitorpamplona committed Oct 11, 2023
1 parent ab27ca0 commit 633b482
Show file tree
Hide file tree
Showing 287 changed files with 286,878 additions and 153,644 deletions.
33 changes: 9 additions & 24 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,11 @@ object Dependencies {
}

object Cql {
const val openCdsGroup = "org.opencds.cqf.cql"
const val translatorGroup = "info.cqframework"

const val engine = "$openCdsGroup:engine:${Versions.Cql.engine}"
const val engineJackson = "$openCdsGroup:engine.jackson:${Versions.Cql.engine}"

const val evaluator = "$openCdsGroup:evaluator:${Versions.Cql.evaluator}"
const val evaluatorBuilder = "$openCdsGroup:evaluator.builder:${Versions.Cql.evaluator}"
const val evaluatorDagger = "$openCdsGroup:evaluator.dagger:${Versions.Cql.evaluator}"
const val evaluatorPlanDef = "$openCdsGroup:evaluator.plandefinition:${Versions.Cql.evaluator}"
const val translatorCqlToElm = "$translatorGroup:cql-to-elm:${Versions.Cql.translator}"
const val translatorElm = "$translatorGroup:elm:${Versions.Cql.translator}"
const val translatorModel = "$translatorGroup:model:${Versions.Cql.translator}"

const val translatorElmJackson = "$translatorGroup:elm-jackson:${Versions.Cql.translator}"
const val translatorModelJackson = "$translatorGroup:model-jackson:${Versions.Cql.translator}"
const val evaluator = "org.opencds.cqf.fhir:cqf-fhir-cr:${Versions.Cql.clinicalReasoning}"
const val evaluatorFhirJackson =
"org.opencds.cqf.fhir:cqf-fhir-jackson:${Versions.Cql.clinicalReasoning}"
const val evaluatorFhirUtilities =
"org.opencds.cqf.fhir:cqf-fhir-utility:${Versions.Cql.clinicalReasoning}"
}

object Glide {
Expand Down Expand Up @@ -84,10 +73,6 @@ object Dependencies {
const val fhirCoreConvertors =
"ca.uhn.hapi.fhir:org.hl7.fhir.convertors:${Versions.hapiFhirCore}"

// Runtime dependency that is required to run FhirPath (also requires minSDK of 26).
// Version 3.0 uses java.lang.System.Logger, which is not available on Android
// Replace for Guava when this PR gets merged: https://github.com/hapifhir/hapi-fhir/pull/3977
const val caffeine = "com.github.ben-manes.caffeine:caffeine:${Versions.caffeine}"
const val guavaCaching = "ca.uhn.hapi.fhir:hapi-fhir-caching-guava:${Versions.hapiFhir}"
}

Expand Down Expand Up @@ -230,9 +215,7 @@ object Dependencies {
}

object Cql {
const val engine = "2.4.0"
const val evaluator = "2.4.0"
const val translator = "2.4.0"
const val clinicalReasoning = "3.0.0-PRE9-SNAPSHOT"
}

object Glide {
Expand All @@ -245,7 +228,7 @@ object Dependencies {
}

const val androidFhirCommon = "0.1.0-alpha05"
const val androidFhirEngine = "0.1.0-beta03"
const val androidFhirEngine = "0.1.0-beta04"
const val androidFhirKnowledge = "0.1.0-alpha01"
const val apacheCommonsCompress = "1.21"
const val desugarJdkLibs = "2.0.3"
Expand Down Expand Up @@ -309,6 +292,8 @@ object Dependencies {
exclude(module = "javax.json")
exclude(module = "jcl-over-slf4j")
exclude(group = "org.apache.httpcomponents")
exclude(group = "org.antlr", module = "antlr4")
exclude(group = "org.eclipse.persistence", module = "org.eclipse.persistence.moxy")
}

fun Configuration.forceGuava() {
Expand Down
4 changes: 0 additions & 4 deletions buildSrc/src/main/kotlin/LicenseeConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ fun Project.configureLicensee() {
allowDependency("org.javassist", "javassist", "3.29.0-GA") {
because("Multi-licensed under Apache. https://github.com/jboss-javassist/javassist")
}
// Remove once Evaluator 3 migration is over
allowDependency("org.javassist", "javassist", "3.20.0-GA") {
because("Multi-licensed under Apache. https://github.com/jboss-javassist/javassist")
}

// xpp3 (HAPI FHIR transitive dep)
allowDependency("xpp3", "xpp3_xpath", "1.1.4c") {
Expand Down
35 changes: 5 additions & 30 deletions knowledge/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Dependencies.guava
import Dependencies.forceGuava
import java.net.URL

plugins {
Expand Down Expand Up @@ -71,33 +71,7 @@ configurations {
all {
exclude(module = "xpp3")
exclude(module = "xpp3_min")
exclude(
module = "hapi-fhir-structures-r4b",
)
resolutionStrategy {
force(Dependencies.guava)
force("ca.uhn.hapi.fhir:hapi-fhir-base:6.0.1")
force("ca.uhn.hapi.fhir:hapi-fhir-client:6.0.1")
force("ca.uhn.hapi.fhir:org.hl7.fhir.convertors:6.0.22")

force("ca.uhn.hapi.fhir:hapi-fhir-structures-dstu2:6.0.1")
force("ca.uhn.hapi.fhir:org.hl7.fhir.dstu2016may:6.0.22")
force("ca.uhn.hapi.fhir:hapi-fhir-structures-dstu3:6.0.1")
force("ca.uhn.hapi.fhir:hapi-fhir-structures-r4:6.0.1")
force("ca.uhn.hapi.fhir:hapi-fhir-structures-r5:6.0.1")
force("ca.uhn.hapi.fhir:org.hl7.fhir.utilities:6.0.22")

force("ca.uhn.hapi.fhir:org.hl7.fhir.dstu2:6.0.22")
force("ca.uhn.hapi.fhir:org.hl7.fhir.dstu3:6.0.22")
force("ca.uhn.hapi.fhir:org.hl7.fhir.r4:6.0.22")
force("ca.uhn.hapi.fhir:org.hl7.fhir.r4b:6.0.22")
force("ca.uhn.hapi.fhir:org.hl7.fhir.r5:6.0.22")

force("ca.uhn.hapi.fhir:hapi-fhir-validation:6.0.1")
force("ca.uhn.hapi.fhir:hapi-fhir-validation-resources-dstu3:6.0.1")
force("ca.uhn.hapi.fhir:hapi-fhir-validation-resources-r4:6.0.1")
force("ca.uhn.hapi.fhir:hapi-fhir-validation-resources-r5:6.0.1")
}
forceGuava()
}
}

Expand All @@ -109,7 +83,8 @@ dependencies {
androidTestImplementation(Dependencies.junit)
androidTestImplementation(Dependencies.truth)

api("ca.uhn.hapi.fhir:hapi-fhir-structures-r4:6.0.1") { exclude(module = "junit") }
api(Dependencies.HapiFhir.structuresR4) { exclude(module = "junit") }
api(Dependencies.HapiFhir.guavaCaching)

coreLibraryDesugaring(Dependencies.desugarJdkLibs)

Expand All @@ -120,7 +95,7 @@ dependencies {
implementation(Dependencies.Room.runtime)
implementation(Dependencies.timber)
implementation(Dependencies.http)
implementation("ca.uhn.hapi.fhir:org.hl7.fhir.convertors:6.0.22")
implementation(Dependencies.HapiFhir.fhirCoreConvertors)
implementation(Dependencies.apacheCommonsCompress)

kapt(Dependencies.Room.compiler)
Expand Down
44 changes: 9 additions & 35 deletions workflow-testing/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import Dependencies.forceGuava
import Dependencies.forceHapiVersion
import Dependencies.forceJacksonVersion
import Dependencies.removeIncompatibleDependencies

plugins {
Expand All @@ -15,46 +18,17 @@ android {
configurations {
all {
removeIncompatibleDependencies()
exclude(
module = "hapi-fhir-structures-r4b",
)
resolutionStrategy {
force(Dependencies.guava)
force("ca.uhn.hapi.fhir:hapi-fhir-base:6.0.1")
force("ca.uhn.hapi.fhir:hapi-fhir-client:6.0.1")
force("ca.uhn.hapi.fhir:org.hl7.fhir.convertors:5.6.36")

force("ca.uhn.hapi.fhir:hapi-fhir-structures-dstu2:6.0.1")
force("ca.uhn.hapi.fhir:org.hl7.fhir.dstu2016may:5.6.36")
force("ca.uhn.hapi.fhir:hapi-fhir-structures-dstu3:6.0.1")
force("ca.uhn.hapi.fhir:hapi-fhir-structures-r4:6.0.1")
force("ca.uhn.hapi.fhir:hapi-fhir-structures-r5:6.0.1")
force("ca.uhn.hapi.fhir:org.hl7.fhir.utilities:5.6.36")

force("ca.uhn.hapi.fhir:org.hl7.fhir.dstu2:5.6.36")
force("ca.uhn.hapi.fhir:org.hl7.fhir.dstu3:5.6.36")
force("ca.uhn.hapi.fhir:org.hl7.fhir.r4:5.6.36")
force("ca.uhn.hapi.fhir:org.hl7.fhir.r4b:5.6.36")
force("ca.uhn.hapi.fhir:org.hl7.fhir.r5:5.6.36")

force("ca.uhn.hapi.fhir:hapi-fhir-validation:6.0.1")
force("ca.uhn.hapi.fhir:hapi-fhir-validation-resources-dstu3:6.0.1")
force("ca.uhn.hapi.fhir:hapi-fhir-validation-resources-r4:6.0.1")
force("ca.uhn.hapi.fhir:hapi-fhir-validation-resources-r5:6.0.1")
}
forceGuava()
forceHapiVersion()
forceJacksonVersion()
}
}

dependencies {
compileOnly(Dependencies.Cql.engine)
compileOnly(Dependencies.Cql.evaluator)
compileOnly(Dependencies.Cql.evaluatorBuilder)
compileOnly(Dependencies.Cql.evaluatorDagger)
compileOnly(Dependencies.Cql.evaluatorPlanDef)
compileOnly(Dependencies.Cql.translatorCqlToElm)
compileOnly(Dependencies.Cql.translatorElm)
compileOnly(Dependencies.Cql.translatorModel)
compileOnly(Dependencies.androidFhirEngine) { exclude(module = "truth") }
compileOnly(Dependencies.Cql.evaluatorFhirJackson)
compileOnly(Dependencies.Cql.evaluatorFhirUtilities)
compileOnly(project(":engine")) { exclude(module = "truth") }

// Forces the most recent version of jackson, ignoring what dependencies use.
// Remove these lines when HAPI 6.4 becomes available.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,15 @@ package com.google.android.fhir.workflow.testing
import ca.uhn.fhir.context.FhirContext
import ca.uhn.fhir.context.FhirVersionEnum
import java.io.InputStream
import java.io.StringReader
import org.cqframework.cql.cql2elm.CqlTranslator
import org.cqframework.cql.cql2elm.CqlTranslatorOptions
import org.cqframework.cql.cql2elm.LibraryManager
import org.cqframework.cql.cql2elm.ModelManager
import org.cqframework.cql.cql2elm.quick.FhirLibrarySourceProvider
import org.fhir.ucum.UcumEssenceService
import org.hl7.fhir.instance.model.api.IBaseResource
import org.hl7.fhir.r4.model.Attachment
import org.hl7.fhir.r4.model.Enumerations
import org.hl7.fhir.r4.model.Library
import org.junit.Assert.fail
import org.opencds.cqf.cql.engine.serializing.CqlLibraryReaderFactory
import org.skyscreamer.jsonassert.JSONAssert

object CqlBuilder : Loadable() {
Expand Down Expand Up @@ -64,14 +60,7 @@ object CqlBuilder : Loadable() {
librarySourceLoader.registerProvider(FhirLibrarySourceProvider())
}

val translator =
CqlTranslator.fromText(
cqlText,
modelManager,
libraryManager,
UcumEssenceService(this::class.java.getResourceAsStream("/ucum-essence.xml")),
*CqlTranslatorOptions.defaultOptions().options.toTypedArray(),
)
val translator = CqlTranslator.fromText(cqlText, libraryManager)

// Helper makes sure the test CQL compiles. Reports an error if it doesn't
if (translator.errors.isNotEmpty()) {
Expand Down Expand Up @@ -144,6 +133,8 @@ object CqlBuilder : Loadable() {
* @param jsonElm the JSON representation of the ELM Library
* @return the assembled FHIR Library
*/

/*
fun buildJsonLib(jsonElm: InputStream): Library {
val strLib = load(jsonElm)
val elmLibrary =
Expand All @@ -156,6 +147,7 @@ object CqlBuilder : Loadable() {
elmLibrary.identifier.version,
)
}
*/

/**
* Compiles a CQL Text into ELM and assembles a FHIR Library that includes a Base64 representation
Expand Down Expand Up @@ -205,7 +197,7 @@ object CqlBuilder : Loadable() {
expectedElmJsonAsset = load(expectedElmJsonAssetName)

// JSONAssert ignores property order and whitespace/tabs
JSONAssert.assertEquals(expectedElmJsonAsset, translator.toJson(), true)
JSONAssert.assertEquals(expectedElmJsonAsset, translator.toJson(), false)
return this
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ class FhirEngineProviderTestRule : TestRule {
override fun apply(base: Statement, description: Description): Statement {
return object : Statement() {
override fun evaluate() {
com.google.android.fhir.FhirEngineProvider.init(
com.google.android.fhir.FhirEngineConfiguration(testMode = true),
FhirEngineProvider.init(
FhirEngineConfiguration(testMode = true),
)
try {
base.evaluate()
} finally {
com.google.android.fhir.FhirEngineProvider.cleanup()
FhirEngineProvider.cleanup()
}
}
}
Expand Down
Loading

0 comments on commit 633b482

Please sign in to comment.