use of com.ibm.cohort.cql.library.CqlVersionedIdentifier in project quality-measure-and-cohort-service by Alvearie.
the class CqlTemporalTests method cannotFindEncountersThatDontExist.
@Test
public void cannotFindEncountersThatDontExist() throws Exception {
Patient patient = getPatient("123", Enumerations.AdministrativeGender.FEMALE, null);
FhirServerConfig fhirConfig = getFhirServerConfig();
Bundle bundle = new Bundle();
Bundle.BundleEntryComponent firstEncounter = new Bundle.BundleEntryComponent();
firstEncounter.setResource(ENCOUNTER_1);
Bundle.BundleEntryComponent secondEncounter = new Bundle.BundleEntryComponent();
secondEncounter.setResource(ENCOUNTER_3);
bundle.addEntry(firstEncounter);
bundle.addEntry(secondEncounter);
mockFhirResourceRetrieval("/Encounter?subject=Patient%2F123&_format=json", getFhirParser(), bundle, fhirConfig);
CqlEvaluator evaluator = setupTestFor(patient, "cql.temporal", ClasspathCqlLibraryProvider.FHIR_HELPERS_CLASSPATH);
String expression = "ValidEncounters2";
CqlEvaluationResult actual = evaluator.evaluate(new CqlVersionedIdentifier("Test3", "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.cql.library.CqlVersionedIdentifier in project quality-measure-and-cohort-service by Alvearie.
the class CqlTemporalTests method cannotFindEventWithoutExistenceOfThirdEvent.
@Test
public void cannotFindEventWithoutExistenceOfThirdEvent() 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(2);
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, false);
Assert.assertEquals(expected, actual.getExpressionResults());
}
use of com.ibm.cohort.cql.library.CqlVersionedIdentifier in project quality-measure-and-cohort-service by Alvearie.
the class CqlTemporalTests method eventHappensWithin4Days.
@Test
public void eventHappensWithin4Days() throws Exception {
Patient patient = getPatient("123", Enumerations.AdministrativeGender.FEMALE, null);
FhirServerConfig fhirConfig = getFhirServerConfig();
Observation observationIN = new Observation();
DateTimeType observationEffective = new DateTimeType(new Date());
observationEffective.setYear(2015);
observationEffective.setMonth(1);
observationEffective.setDay(15);
observationIN.setEffective(observationEffective);
observationIN.setId("FIRST");
Observation observationOUT = new Observation();
DateTimeType observationEffective2 = new DateTimeType(new Date());
observationEffective2.setYear(2015);
observationEffective2.setMonth(1);
observationEffective2.setDay(16);
observationOUT.setEffective(observationEffective2);
observationOUT.setId("SECOND");
Bundle bundle = new Bundle();
Bundle.BundleEntryComponent firstEncounter = new Bundle.BundleEntryComponent();
firstEncounter.setResource(observationIN);
Bundle.BundleEntryComponent secondEncounter = new Bundle.BundleEntryComponent();
secondEncounter.setResource(observationOUT);
bundle.addEntry(firstEncounter);
bundle.addEntry(secondEncounter);
mockFhirResourceRetrieval("/Observation?subject=Patient%2F123&_format=json", getFhirParser(), bundle, fhirConfig);
mockFhirResourceRetrieval("/Condition?subject=Patient%2F123&_format=json", getFhirParser(), CONDITION_IN, fhirConfig);
CqlEvaluator evaluator = setupTestFor(patient, "cql.temporal", ClasspathCqlLibraryProvider.FHIR_HELPERS_CLASSPATH);
String expression = "ValidObservation within 4 days";
CqlEvaluationResult actual = evaluator.evaluate(new CqlVersionedIdentifier("Test5", "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.cql.library.CqlVersionedIdentifier in project quality-measure-and-cohort-service by Alvearie.
the class CqlTemporalTests method doesNotFindEventAfterSecondEvent.
@Test
public void doesNotFindEventAfterSecondEvent() throws Exception {
Patient patient = getPatient("123", Enumerations.AdministrativeGender.FEMALE, null);
Observation observationOUT = new Observation();
DateTimeType observationEffective2 = new DateTimeType(new Date());
observationEffective2.setYear(2017);
observationEffective2.setMonth(1);
observationEffective2.setDay(15);
observationOUT.setEffective(observationEffective2);
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(), observationOUT, fhirConfig);
CqlEvaluator evaluator = setupTestFor(patient, "cql.temporal", ClasspathCqlLibraryProvider.FHIR_HELPERS_CLASSPATH);
String expression = "Observations Exist";
CqlEvaluationResult actual = evaluator.evaluate(new CqlVersionedIdentifier("Test1", "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.cql.library.CqlVersionedIdentifier in project quality-measure-and-cohort-service by Alvearie.
the class CqlTemporalTests method confirmCanFindEventAfterSecondEvent.
@Test
public void confirmCanFindEventAfterSecondEvent() throws Exception {
Patient patient = getPatient("123", Enumerations.AdministrativeGender.FEMALE, null);
Observation observationIN = new Observation();
DateTimeType observationEffective = new DateTimeType(new Date());
observationEffective.setYear(2015);
observationEffective.setMonth(1);
observationEffective.setDay(15);
observationIN.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(), observationIN, fhirConfig);
CqlEvaluator evaluator = setupTestFor(patient, "cql.temporal", ClasspathCqlLibraryProvider.FHIR_HELPERS_CLASSPATH);
String expression = "Observations Exist";
CqlEvaluationResult actual = evaluator.evaluate(new CqlVersionedIdentifier("Test1", "1.0.0"), null, newPatientContext("123"), Collections.singleton(expression));
Map<String, Object> expected = new HashMap<>();
expected.put(expression, true);
Assert.assertEquals(expected, actual.getExpressionResults());
}
Aggregations