Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump CQL dependencies #1163

Merged
merged 7 commits into from
Oct 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/ci-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,26 @@ jobs:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}


check_java8:
check_java11:
runs-on: ubuntu-latest
name: Java 8
name: Java 11

steps:
- uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 8
java-version: 11

- name: Gradle cache
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-jdk8-${{ hashFiles('**/*.gradle*') }}
key: ${{ runner.os }}-gradle-jdk11-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-jdk8
${{ runner.os }}-gradle-jdk11

- name: Compile with Gradle
run: ./gradlew assemble
Expand All @@ -80,8 +80,8 @@ jobs:
if: env.SLACK_WEBHOOK_URL
with:
status: custom
job_name: Java 8
author_name: Java 8 Build/Test
job_name: Java 11
author_name: Java 11 Build/Test
fields: workflow,commit,repo,author,took
# see https://action-slack.netlify.app/usecase/02-custom for custom payload info
custom_payload: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 8
java-version: 11

- name: Gradle cache
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-jdk8-${{ hashFiles('**/*.gradle*') }}
key: ${{ runner.os }}-gradle-jdk11-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-jdk8
${{ runner.os }}-gradle-jdk11

- name: Create Artifacts
run: |
Expand Down
73 changes: 38 additions & 35 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
// Apply the java plugin to add support for Java
apply plugin: 'java'

sourceCompatibility = '1.8'
targetCompatibility = '1.8'
sourceCompatibility = '11'

apply plugin: 'application'
apply plugin: 'eclipse'
Expand Down Expand Up @@ -41,42 +40,45 @@ jacoco {

dependencies {
// This dependency is found on compile classpath of this component and consumers.
implementation 'com.google.code.gson:gson:2.8.7'
implementation 'com.jayway.jsonpath:json-path:2.4.0'
implementation 'ca.uhn.hapi.fhir:hapi-fhir-base:5.7.0'
implementation 'ca.uhn.hapi.fhir:hapi-fhir-structures-dstu3:5.7.0'
implementation 'ca.uhn.hapi.fhir:hapi-fhir-structures-dstu2:5.7.0'
implementation 'ca.uhn.hapi.fhir:hapi-fhir-structures-r4:5.7.0'
implementation 'ca.uhn.hapi.fhir:hapi-fhir-client:5.7.0'
implementation 'com.google.code.gson:gson:2.9.0'
implementation 'com.jayway.jsonpath:json-path:2.7.0'
implementation 'ca.uhn.hapi.fhir:hapi-fhir-base:6.1.0'
implementation 'ca.uhn.hapi.fhir:hapi-fhir-structures-dstu3:6.1.0'
implementation 'ca.uhn.hapi.fhir:hapi-fhir-structures-dstu2:6.1.0'
implementation 'ca.uhn.hapi.fhir:hapi-fhir-structures-r4:6.1.0'
implementation 'ca.uhn.hapi.fhir:hapi-fhir-client:6.1.0'
// C-CDA export uses Apache FreeMarker templates
implementation 'org.freemarker:freemarker:2.3.26-incubating'
implementation 'org.freemarker:freemarker:2.3.31'

// google guava for some data structures
implementation 'com.google.guava:guava:30.0-jre'
implementation 'com.google.guava:guava:31.1-jre'
implementation 'guru.nidi:graphviz-java:0.2.4'
// CSV Stuff
implementation 'org.apache.commons:commons-csv:1.5'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-csv:2.8.8'
implementation 'org.yaml:snakeyaml:1.27'
implementation 'org.apache.commons:commons-csv:1.9.0'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-csv:2.13.4'
implementation 'org.yaml:snakeyaml:1.32'
implementation 'org.apache.commons:commons-math3:3.6.1'
implementation 'org.apache.commons:commons-text:1.2'
implementation 'commons-validator:commons-validator:1.4.0'
implementation 'org.apache.commons:commons-text:1.9'
implementation 'commons-validator:commons-validator:1.7'

implementation 'org.opencds.cqf:cql-engine:1.3.12'
implementation 'info.cqframework:cql:1.3.17'
implementation 'info.cqframework:model:1.3.17'
implementation 'info.cqframework:cql-to-elm:1.3.17'
implementation 'org.opencds.cqf.cql:engine.jackson:2.0.0'
implementation 'org.opencds.cqf.cql:engine:2.0.0'
implementation 'info.cqframework:cql:2.1.0'
implementation 'info.cqframework:model:2.1.0'
implementation 'info.cqframework:cql-to-elm:2.1.0'
implementation 'info.cqframework:model-jackson:2.1.0'
implementation 'info.cqframework:elm-jackson:2.1.0'

implementation 'org.springframework:spring-web:5.2.7.RELEASE'
implementation 'com.squareup.okhttp3:okhttp:4.10.0'

// Java 9 no longer includes these APIs by default
implementation 'javax.xml.bind:jaxb-api:2.4.0-b180830.0359'
implementation 'org.glassfish.jaxb:jaxb-runtime:2.3.2'
implementation 'org.glassfish.jaxb:jaxb-runtime:4.0.0'
implementation 'javax.activation:javax.activation-api:1.2.0'

// get rid of SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
// if we switch to a real logging framework we may want to switch this
implementation "org.slf4j:slf4j-api:1.7.9"
implementation "org.slf4j:slf4j-api:2.0.0"
//implementation "org.slf4j:slf4j-nop:1.7.9" // SLF4J seems to already be provided by org.apache.logging.log4j

// ensure transitive dependencies do not use vulnerable log4j
Expand All @@ -88,28 +90,29 @@ dependencies {

// Physiology simulation dependencies
implementation files('lib/sbscl/SimulationCoreLibrary_v1.5_slim.jar')
implementation 'org.sbml.jsbml:jsbml:1.5', {
implementation 'org.sbml.jsbml:jsbml:1.6.1', {
exclude group:'org.apache.logging.log4j', module: 'log4j-slf4j-impl'
}
implementation 'org.apache.commons:commons-math:2.2'

// JfreeChart for drawing physiology charts
implementation 'org.jfree:jfreechart:1.5.0'
implementation 'org.jfree:jfreechart:1.5.3'

// Use JUnit test framework
testImplementation 'junit:junit:4.12'
testImplementation 'junit:junit:4.13.2'
testImplementation fileTree(dir: 'lib/mdhtruntime/mdht', include: '*.jar')
testImplementation fileTree(dir: 'lib/mdhtruntime/non-mdht', include: '*.jar')
testImplementation 'org.mockito:mockito-core:2.19.0'
testImplementation 'org.powermock:powermock-module-junit4:1.7.1'
testImplementation 'org.powermock:powermock-api-mockito2:1.7.1'
testImplementation 'com.github.tomakehurst:wiremock-jre8:2.26.3'
testImplementation 'ca.uhn.hapi.fhir:hapi-fhir-validation:5.7.0'
testImplementation 'ca.uhn.hapi.fhir:hapi-fhir-validation-resources-r4:5.7.0'
testImplementation 'ca.uhn.hapi.fhir:hapi-fhir-validation-resources-dstu3:5.7.0'
testImplementation 'ca.uhn.hapi.fhir:hapi-fhir-validation-resources-dstu2:5.7.0'
testImplementation 'org.mockito:mockito-core:4.7.0'
testImplementation 'org.powermock:powermock-module-junit4:2.0.9'
testImplementation 'org.powermock:powermock-api-mockito2:2.0.9'
testImplementation 'com.github.tomakehurst:wiremock-jre8:2.33.2'
testImplementation 'ca.uhn.hapi.fhir:hapi-fhir-validation:6.1.0'
testImplementation 'ca.uhn.hapi.fhir:hapi-fhir-validation-resources-r4:6.1.0'
testImplementation 'ca.uhn.hapi.fhir:hapi-fhir-validation-resources-dstu3:6.1.0'
testImplementation 'ca.uhn.hapi.fhir:hapi-fhir-validation-resources-dstu2:6.1.0'
testImplementation 'com.helger:ph-schematron:5.6.5'
testImplementation 'com.helger:ph-commons:9.5.4'
testImplementation 'com.helger:ph-commons:9.5.5'
testImplementation 'com.squareup.okhttp3:mockwebserver:4.10.0'
}

// Provide more descriptive test failure output
Expand Down
13 changes: 7 additions & 6 deletions src/main/java/org/mitre/synthea/helpers/ExpressionProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.xml.bind.JAXBException;

import org.cqframework.cql.cql2elm.CqlTranslator;
import org.cqframework.cql.cql2elm.LibraryManager;
Expand All @@ -31,8 +30,9 @@
import org.cqframework.cql.elm.execution.Library;
import org.mitre.synthea.world.agents.Person;
import org.mitre.synthea.world.concepts.VitalSign;
import org.opencds.cqf.cql.execution.Context;
import org.opencds.cqf.cql.execution.CqlLibraryReader;
import org.opencds.cqf.cql.engine.execution.Context;
import org.opencds.cqf.cql.engine.serializing.CqlLibraryReader;
import org.opencds.cqf.cql.engine.serializing.jackson.XmlCqlLibraryReader;
import org.simulator.math.odes.MultiTable;
import org.simulator.math.odes.MultiTable.Block.Column;

Expand Down Expand Up @@ -106,9 +106,10 @@ public ExpressionProcessor(String expression, Map<String,String> paramTypeMap) {
this.elm = cqlToElm(wrappedExpression);
synchronized (ExpressionProcessor.class) {
try {
this.library = CqlLibraryReader.read(new ByteArrayInputStream(
CqlLibraryReader reader = new XmlCqlLibraryReader();
this.library = reader.read(new ByteArrayInputStream(
elm.getBytes(StandardCharsets.UTF_8)));
} catch (IOException | JAXBException ex) {
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}
Expand Down Expand Up @@ -378,7 +379,7 @@ private String convertParameterizedExpressionToCql(String expression) {
.append(paramTypeMap.getOrDefault(paramEntry.getKey(), "Decimal"));
}

wrappedExpression.append("\n\ncontext Patient\n\n");
wrappedExpression.append("\n\ncontext Unfiltered\n\n");

String[] statements = expression.split("\n");

Expand Down
44 changes: 23 additions & 21 deletions src/main/java/org/mitre/synthea/helpers/RandomCodeGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
Expand All @@ -11,19 +13,16 @@
import java.util.Random;

import javax.annotation.Nonnull;

import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.validator.routines.UrlValidator;
import org.mitre.synthea.world.concepts.HealthRecord.Code;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;

import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;

/**
* Generates random codes based upon ValueSet URIs, with the help of a FHIR
Expand All @@ -40,9 +39,8 @@ public abstract class RandomCodeGenerator {
private static final Logger logger = LoggerFactory.getLogger(RandomCodeGenerator.class);
public static Map<String, List<Object>> codeListCache = new HashMap<>();
public static List<Code> selectedCodes = new ArrayList<>();
private static UrlValidator urlValidator = new UrlValidator();

public static RestTemplate restTemplate = new RestTemplate();
private static UrlValidator urlValidator = new UrlValidator(UrlValidator.ALLOW_2_SLASHES);
private static OkHttpClient client = new OkHttpClient();

/**
* Gets a random code from the expansion of a ValueSet.
Expand Down Expand Up @@ -71,22 +69,26 @@ public static Code getCode(String valueSetUri, long seed, Code code) {
@SuppressWarnings("unchecked")
private static synchronized void expandValueSet(String valueSetUri) {
if (!codeListCache.containsKey(valueSetUri)) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<String> request = new HttpEntity<>(headers);
Request request = new Request.Builder()
.url(expandBaseUrl + valueSetUri)
.header("Content-Type", "application/json")
.build();
Map<String, Object> valueSet = null;
try {
ResponseEntity<String> response = restTemplate.exchange(expandBaseUrl + valueSetUri,
HttpMethod.GET, request,
String.class);
Response response = client.newCall(request).execute();
ObjectMapper objectMapper = new ObjectMapper();
valueSet = objectMapper.readValue(response.getBody(),
new TypeReference<Map<String, Object>>() {
ResponseBody body = response.body();
if (body != null) {
valueSet = objectMapper.readValue(body.byteStream(),
new TypeReference<Map<String, Object>>() {
});
} else {
throw new RuntimeException("Value Set Expansion contained no body");
}
} catch (JsonProcessingException e) {
throw new RuntimeException("JsonProcessingException while parsing valueSet response");
} catch (RestClientException e) {
throw new RestClientException("RestClientException while fetching valueSet response");
} catch (IOException e) {
throw new RuntimeException("Issue when expanding the value set", e);
}

Map<String, Object> expansion = (Map<String, Object>) valueSet.get("expansion");
Expand Down
10 changes: 5 additions & 5 deletions src/test/java/org/mitre/synthea/engine/StateTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.withSettings;

import java.io.IOException;
Expand Down Expand Up @@ -178,7 +178,7 @@ public void condition_onset() throws Exception {
// Should pass through this state immediately without calling the record
assertTrue(condition.process(person, time));

verifyZeroInteractions(person.record);
verifyNoInteractions(person.record);
}

@Test
Expand Down Expand Up @@ -301,7 +301,7 @@ public void allergy_onset() throws Exception {
// Should pass through this state immediately without calling the record
assertTrue(allergy.process(person, time));

verifyZeroInteractions(person.record);
verifyNoInteractions(person.record);
}

@Test
Expand Down Expand Up @@ -545,7 +545,7 @@ public void gmfTwoVitalSign() throws Exception {
assertTrue(person.getVitalSign(VitalSign.SYSTOLIC_BLOOD_PRESSURE, time) >= 110);
assertTrue(person.getVitalSign(VitalSign.SYSTOLIC_BLOOD_PRESSURE, time) <= 130);

verifyZeroInteractions(person.record);
verifyNoInteractions(person.record);
}


Expand All @@ -562,7 +562,7 @@ public void vitalsign() throws Exception {

assertEquals(120.0, person.getVitalSign(VitalSign.SYSTOLIC_BLOOD_PRESSURE, time), 0.0);

verifyZeroInteractions(person.record);
verifyNoInteractions(person.record);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
import org.mitre.synthea.world.concepts.HealthRecord.Encounter;
import org.mitre.synthea.world.concepts.HealthRecord.EncounterType;
import org.mitre.synthea.world.geography.Location;
import org.springframework.web.client.RestTemplate;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
Expand Down Expand Up @@ -101,7 +100,6 @@ public void setUp() throws Exception {
Config.set("exporter.fhir_stu3.export", "true");
Config.set("exporter.fhir_dstu2.export", "true");
Config.set("generate.terminology_service_url", mockTerminologyService.baseUrl() + "/fhir");
RandomCodeGenerator.restTemplate = new RestTemplate();

person = new Person(12345L);
time = new SimpleDateFormat("yyyy-MM-dd").parse("2013-06-10").getTime();
Expand Down Expand Up @@ -159,7 +157,7 @@ public void resolveAndExportEncounterCodes()
String reasonCode = "417981005";
String reasonDisplay = "Exposure to blood and/or body fluid";
encounter.reason = new Code(SNOMED_URI, reasonCode, reasonDisplay);
encounter.reason.valueSet = SNOMED_URI + "?fhir_vs=ecl/<418307001";
encounter.reason.valueSet = SNOMED_URI + "?fhir_vs=ecl%2F%3C418307001";
encounter.codes.add(encounter.reason);

String observationDisplay = OBSERVATION_DISPLAY;
Expand Down
Loading