use of com.ibm.cohort.cql.evaluation.parameters.Parameter in project quality-measure-and-cohort-service by Alvearie.
the class CohortEvaluationTest method when_serialize_deserialize___properties_are_unchanged.
@Test
public void when_serialize_deserialize___properties_are_unchanged() throws Exception {
FhirServerConfig dataServerConfig = new FhirServerConfig();
dataServerConfig.setEndpoint("dataserver");
FhirServerConfig termServerConfig = new FhirServerConfig();
termServerConfig.setEndpoint("termserver");
Map<String, Parameter> parameterOverrides = new HashMap<>();
parameterOverrides.put("Measurement Period", new IntervalParameter(new DateParameter("2019-07-04"), true, new DateParameter("2020-07-04"), true));
CohortEvaluation evaluation = new CohortEvaluation();
evaluation.setDataServerConfig(dataServerConfig);
evaluation.setTerminologyServerConfig(termServerConfig);
evaluation.setPatientIds("patientId");
evaluation.setParameters(parameterOverrides);
evaluation.setLoggingLevel(CqlDebug.TRACE);
evaluation.setEntrypoint("test-1.0.0.cql");
evaluation.setDefineToRun("fakeDefine");
ObjectMapper om = new ObjectMapper();
String serialized = om.writeValueAsString(evaluation);
CohortEvaluation deserialized = om.readValue(serialized, CohortEvaluation.class);
assertEquals(evaluation, deserialized);
}
use of com.ibm.cohort.cql.evaluation.parameters.Parameter in project quality-measure-and-cohort-service by Alvearie.
the class MeasureEvaluatorTest method not_in_denominator___caregaps_evaluated_correctly.
@Test
public void not_in_denominator___caregaps_evaluated_correctly() throws Exception {
Map<String, Parameter> parameters = new HashMap<>();
parameters.put("InDenominator", new BooleanParameter(false));
expectationsByPopulationType.put(MeasurePopulationType.DENOMINATOR, 0);
Map<String, Integer> expectationsByCareGap = new HashMap<>();
expectationsByCareGap.put("CareGap1", 0);
expectationsByCareGap.put("CareGap2", 0);
runCareGapTest(parameters, expectationsByCareGap);
}
use of com.ibm.cohort.cql.evaluation.parameters.Parameter in project quality-measure-and-cohort-service by Alvearie.
the class MeasureEvaluatorTest method measure_report_generated___datetime_parameters_on_report_in_utc.
@Test
public void measure_report_generated___datetime_parameters_on_report_in_utc() throws Exception {
CapabilityStatement metadata = getCapabilityStatement();
mockFhirResourceRetrieval("/metadata?_format=json", metadata);
Patient patient = getPatient("123", AdministrativeGender.MALE, "1970-10-10");
mockFhirResourceRetrieval(patient);
Library library = mockLibraryRetrieval("TestDummyPopulations", DEFAULT_VERSION, "cql/fhir-measure/test-dummy-populations.xml", ELM_MIME_TYPE);
String fhirDefaultDatetimeParamterName = "fhirDatetimeParamDefault";
String fhirTimezoneDatetimeParameterName = "fhirDatetimeParamGMTPlus4";
Measure measure = getCohortMeasure("CohortMeasureName", library, INITIAL_POPULATION);
measure.addExtension(createParameterExtension(fhirDefaultDatetimeParamterName, new DateTimeType("2020-04-04")));
measure.addExtension(createParameterExtension(fhirTimezoneDatetimeParameterName, new DateTimeType("2020-04-04T00:00:00.0+04:00")));
mockFhirResourceRetrieval(measure);
String javaDefaultDatetimeParamterName = "javaDatetimeParamDefault";
String javaTimezoneDatetimeParameterName = "javaDatetimeParamGMTPlus4";
Map<String, Parameter> parameterMap = new HashMap<>();
parameterMap.put(javaDefaultDatetimeParamterName, new DatetimeParameter("2020-01-01"));
parameterMap.put(javaTimezoneDatetimeParameterName, new DatetimeParameter("2020-01-01T00:00:00.0+04:00"));
MeasureReport report = evaluator.evaluatePatientMeasure(measure.getId(), patient.getId(), parameterMap);
assertNotNull(report);
Map<String, DateTimeType> parameterNames = report.getExtension().stream().filter(x -> x.getUrl().equals(MEASURE_PARAMETER_VALUE_URL)).map(x -> (ParameterDefinition) x.getValue()).filter(x -> x.getExtensionByUrl(PARAMETER_VALUE_URL).getValue() instanceof DateTimeType).collect(Collectors.toMap(ParameterDefinition::getName, x -> (DateTimeType) x.getExtensionByUrl(PARAMETER_VALUE_URL).getValue()));
DateTimeType javaDefaultResult = parameterNames.get(javaDefaultDatetimeParamterName);
DateTimeType javaTimezoneResult = parameterNames.get(javaTimezoneDatetimeParameterName);
assertTrue(new DateTimeType("2020-01-01T00:00:00.000Z").equalsUsingFhirPathRules(javaDefaultResult));
assertEquals(TimeZone.getTimeZone("UTC"), javaDefaultResult.getTimeZone());
assertTrue(new DateTimeType("2019-12-31T20:00:00.000Z").equalsUsingFhirPathRules(javaTimezoneResult));
assertEquals(TimeZone.getTimeZone("UTC"), javaTimezoneResult.getTimeZone());
DateTimeType fhirDefaultResult = parameterNames.get(fhirDefaultDatetimeParamterName);
DateTimeType fhirTimezoneResult = parameterNames.get(fhirTimezoneDatetimeParameterName);
assertTrue(new DateTimeType("2020-04-04T00:00:00.000Z").equalsUsingFhirPathRules(fhirDefaultResult));
assertEquals(TimeZone.getTimeZone("UTC"), fhirDefaultResult.getTimeZone());
assertTrue(new DateTimeType("2020-04-03T20:00:00.000Z").equalsUsingFhirPathRules(fhirTimezoneResult));
assertEquals(TimeZone.getTimeZone("UTC"), fhirTimezoneResult.getTimeZone());
}
use of com.ibm.cohort.cql.evaluation.parameters.Parameter in project quality-measure-and-cohort-service by Alvearie.
the class MeasureEvaluatorTest method in_one_initial_population_for_two_measures___two_measure_reports_returned.
@Test
public void in_one_initial_population_for_two_measures___two_measure_reports_returned() throws Exception {
CapabilityStatement metadata = getCapabilityStatement();
mockFhirResourceRetrieval("/metadata?_format=json", metadata);
Patient patient = getPatient("123", AdministrativeGender.MALE, "1970-10-10");
mockFhirResourceRetrieval(patient);
Library library = mockLibraryRetrieval("TestDummyPopulations", DEFAULT_VERSION, "cql/fhir-measure/test-dummy-populations.cql");
String measure1Name = "ProportionMeasureName1";
Measure measure1 = getCareGapMeasure(measure1Name, library, expressionsByPopulationType, "CareGap1", "CareGap2");
mockFhirResourceRetrieval(measure1);
String measure2Name = "ProportionMeasureName2";
Measure measure2 = getCareGapMeasure(measure2Name, library, expressionsByPopulationType, "CareGap1", "CareGap2");
mockFhirResourceRetrieval(measure2);
Map<String, Parameter> passingParameters = new HashMap<>();
passingParameters.put("InInitialPopulation", new BooleanParameter(true));
Map<String, Parameter> failingParameters = new HashMap<>();
failingParameters.put("InInitialPopulation", new BooleanParameter(false));
List<MeasureContext> measureContexts = new ArrayList<>();
measureContexts.add(new MeasureContext(measure1.getId(), passingParameters));
measureContexts.add(new MeasureContext(measure2.getId(), failingParameters));
List<MeasureReport> measureReports = evaluator.evaluatePatientMeasures(patient.getId(), measureContexts);
assertEquals(2, measureReports.size());
// Make sure reports have measure references with meta version included
assertEquals("Measure/" + measure1Name + "/_history/" + MeasureTestBase.MEASURE_META_VERSION_ID, measureReports.get(0).getMeasure());
assertEquals("Measure/" + measure2Name + "/_history/" + MeasureTestBase.MEASURE_META_VERSION_ID, measureReports.get(1).getMeasure());
}
use of com.ibm.cohort.cql.evaluation.parameters.Parameter in project quality-measure-and-cohort-service by Alvearie.
the class MeasureEvaluatorTest method in_numerator_and_numerator_exclusions___caregaps_evaluated_correctly.
@Test
public void in_numerator_and_numerator_exclusions___caregaps_evaluated_correctly() throws Exception {
Map<String, Parameter> parameters = new HashMap<>();
parameters.put("InNumerator", new BooleanParameter(true));
parameters.put("InNumeratorExclusion", new BooleanParameter(true));
expectationsByPopulationType.put(MeasurePopulationType.NUMERATOR, 0);
expectationsByPopulationType.put(MeasurePopulationType.NUMERATOREXCLUSION, 1);
Map<String, Integer> expectationsByCareGap = new HashMap<>();
expectationsByCareGap.put("CareGap1", 0);
expectationsByCareGap.put("CareGap2", 1);
runCareGapTest(parameters, expectationsByCareGap);
}
Aggregations