use of com.ibm.cohort.fhir.client.config.FhirServerConfig in project quality-measure-and-cohort-service by Alvearie.
the class CqlTemporalTests method confirmCanFindEventWithExistenceOfThirdEvent.
@Test
public void confirmCanFindEventWithExistenceOfThirdEvent() throws Exception {
Patient patient = getPatient("123", Enumerations.AdministrativeGender.FEMALE, null);
Observation observation = new Observation();
DateTimeType observationEffective = new DateTimeType(new Date());
observationEffective.setYear(2015);
observationEffective.setMonth(0);
observationEffective.setDay(5);
observation.setEffective(observationEffective);
FhirServerConfig fhirConfig = getFhirServerConfig();
mockFhirResourceRetrieval("/Condition?subject=Patient%2F123&_format=json", getFhirParser(), CONDITION_IN, fhirConfig);
mockFhirResourceRetrieval("/Encounter?subject=Patient%2F123&_format=json", getFhirParser(), ENCOUNTER_1, fhirConfig);
mockFhirResourceRetrieval("/Observation?subject=Patient%2F123&_format=json", getFhirParser(), observation, fhirConfig);
CqlEvaluator evaluator = setupTestFor(patient, "cql.temporal", ClasspathCqlLibraryProvider.FHIR_HELPERS_CLASSPATH);
String expression = "ObservationWithin30DaysOfCondition";
CqlEvaluationResult actual = evaluator.evaluate(new CqlVersionedIdentifier("Test2", "1.0.0"), null, newPatientContext("123"), Collections.singleton(expression));
Map<String, Object> expected = new HashMap<>();
expected.put(expression, true);
Assert.assertEquals(expected, actual.getExpressionResults());
}
use of com.ibm.cohort.fhir.client.config.FhirServerConfig in project quality-measure-and-cohort-service by Alvearie.
the class CqlTemporalTests method anEventDoesFollow.
@Test
public void anEventDoesFollow() throws Exception {
Patient patient = getPatient("123", Enumerations.AdministrativeGender.FEMALE, null);
FhirServerConfig fhirConfig = getFhirServerConfig();
mockFhirResourceRetrieval("/Encounter?subject=Patient%2F123&_format=json", getFhirParser(), ENCOUNTER_1, fhirConfig);
mockFhirResourceRetrieval("/Condition?subject=Patient%2F123&_format=json", getFhirParser(), CONDITION_IN, fhirConfig);
CqlEvaluator evaluator = setupTestFor(patient, "cql.temporal", ClasspathCqlLibraryProvider.FHIR_HELPERS_CLASSPATH);
String expression = "NotFollowedByCondition";
CqlEvaluationResult actual = evaluator.evaluate(new CqlVersionedIdentifier("Test4", "1.0.0"), null, newPatientContext("123"), Collections.singleton(expression));
Map<String, Object> expected = new HashMap<>();
expected.put(expression, false);
Assert.assertEquals(expected, actual.getExpressionResults());
}
use of com.ibm.cohort.fhir.client.config.FhirServerConfig in project quality-measure-and-cohort-service by Alvearie.
the class CohortCLITest method testMainZippedLibrariesMultiFolderWithExtraEntriesFiltered.
@Test
public void testMainZippedLibrariesMultiFolderWithExtraEntriesFiltered() throws Exception {
FhirServerConfig fhirConfig = getFhirServerConfig();
IParser encoder = getFhirParser();
mockFhirResourceRetrieval("/metadata?_format=json", encoder, getCapabilityStatement(), fhirConfig);
Patient patient = getPatient("123", Enumerations.AdministrativeGender.FEMALE, 65);
mockFhirResourceRetrieval(patient);
File tmpFile = new File("target/fhir-stub.json");
ObjectMapper om = new ObjectMapper();
try (Writer w = new FileWriter(tmpFile)) {
w.write(om.writeValueAsString(fhirConfig));
}
try {
PrintStream originalOut = System.out;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (PrintStream captureOut = new PrintStream(baos)) {
System.setOut(captureOut);
CohortCLI.main(new String[] { "-d", tmpFile.getAbsolutePath(), "-t", tmpFile.getAbsolutePath(), "-f", "src/test/resources/cql/zip-with-folders/cohorts.zip", "--filter", "cohorts/ci_colorectal_cancer_screening_v1_0_0_cql", "-l", "CI_Colorectal-Cancer", "-v", "Screening", "-e", "Individuals 50-75 years of age", "-c", "123", "-s", "CQL" });
} finally {
System.setOut(originalOut);
}
String output = new String(baos.toByteArray());
String[] lines = output.split("\r?\n");
assertEquals(output, 4, lines.length);
System.out.println(output);
verify(1, getRequestedFor(urlEqualTo("/Patient/123?_format=json")));
} finally {
tmpFile.delete();
}
}
use of com.ibm.cohort.fhir.client.config.FhirServerConfig in project quality-measure-and-cohort-service by Alvearie.
the class CohortCLITest method testMainZippedLibrariesMultiFolderWithExtraEntriesFilteredNoneFound.
@Test(expected = IllegalArgumentException.class)
public void testMainZippedLibrariesMultiFolderWithExtraEntriesFilteredNoneFound() throws Exception {
FhirServerConfig fhirConfig = getFhirServerConfig();
IParser encoder = getFhirParser();
mockFhirResourceRetrieval("/metadata?_format=json", encoder, getCapabilityStatement(), fhirConfig);
Patient patient = getPatient("123", Enumerations.AdministrativeGender.FEMALE, 65);
mockFhirResourceRetrieval(patient);
File tmpFile = new File("target/fhir-stub.json");
ObjectMapper om = new ObjectMapper();
try (Writer w = new FileWriter(tmpFile)) {
w.write(om.writeValueAsString(fhirConfig));
}
try {
PrintStream originalOut = System.out;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (PrintStream captureOut = new PrintStream(baos)) {
System.setOut(captureOut);
CohortCLI.main(new String[] { "-d", tmpFile.getAbsolutePath(), "-t", tmpFile.getAbsolutePath(), "-f", "src/test/resources/cql/zip-with-folders/cohorts.zip", "--filter", "does-not-exist", "-l", "CI_Colorectal-Cancer", "-v", "Screening", "-e", "Individuals 50-75 years of age", "-c", "123", "-s", "CQL" });
fail("Execution should not reach this point");
} finally {
System.setOut(originalOut);
}
} finally {
tmpFile.delete();
}
}
use of com.ibm.cohort.fhir.client.config.FhirServerConfig in project quality-measure-and-cohort-service by Alvearie.
the class CohortCLITest method testMainZippedLibrariesWithCompilation.
@Test
public void testMainZippedLibrariesWithCompilation() throws Exception {
FhirServerConfig fhirConfig = getFhirServerConfig();
IParser encoder = getFhirParser();
mockFhirResourceRetrieval("/metadata?_format=json", encoder, getCapabilityStatement(), fhirConfig);
Patient justRight = getPatient("123", Enumerations.AdministrativeGender.FEMALE, "1978-05-06");
mockFhirResourceRetrieval(justRight);
Patient tooOld = getPatient("456", Enumerations.AdministrativeGender.FEMALE, "1900-08-01");
mockFhirResourceRetrieval(tooOld);
Patient tooManly = getPatient("789", Enumerations.AdministrativeGender.MALE, "1978-05-06");
mockFhirResourceRetrieval(tooManly);
File tmpFile = new File("target/fhir-stub.json");
ObjectMapper om = new ObjectMapper();
try (Writer w = new FileWriter(tmpFile)) {
w.write(om.writeValueAsString(fhirConfig));
}
try {
PrintStream originalOut = System.out;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try (PrintStream captureOut = new PrintStream(baos)) {
System.setOut(captureOut);
CohortCLI.main(new String[] { "-d", tmpFile.getAbsolutePath(), "-t", tmpFile.getAbsolutePath(), "-f", "src/test/resources/cql/zip/breast_cancer_screening_v1_0_0_cql.zip", "-l", "Breast-Cancer", "-v", "Screening", "-e", "Female", "-e", "40-65 years of age", "-e", "MeetsInclusionCriteria", "-c", "123", "-c", "456", "-c", "789", "-s", "CQL" });
} finally {
System.setOut(originalOut);
}
String output = new String(baos.toByteArray());
String[] lines = output.split("\r?\n");
assertEquals(output, 16, lines.length);
System.out.println(output);
verify(1, getRequestedFor(urlEqualTo("/Patient/123?_format=json")));
verify(1, getRequestedFor(urlEqualTo("/Patient/456?_format=json")));
verify(1, getRequestedFor(urlEqualTo("/Patient/789?_format=json")));
} finally {
tmpFile.delete();
}
}
Aggregations