use of com.ibm.cohort.cql.evaluation.parameters.Parameter in project quality-measure-and-cohort-service by Alvearie.
the class DefaultMeasurementPeriodStrategyTest method parameter_null_map_null__value_is_calulated.
@Test
public void parameter_null_map_null__value_is_calulated() throws Exception {
Calendar c = Calendar.getInstance();
c.clear();
c.set(2020, Calendar.AUGUST, 15);
Measure measure = new Measure();
Map<String, Parameter> parameterOverrides = null;
Pair<String, String> result = new DefaultMeasurementPeriodStrategy().setNow(c.getTime()).getMeasurementPeriod(measure, parameterOverrides);
DateFormat sdf = new SimpleDateFormat(DefaultMeasurementPeriodStrategy.TARGET_DATE_FORMAT);
assertEquals("Unexpected end", result.getRight(), sdf.format(c.getTime()));
}
use of com.ibm.cohort.cql.evaluation.parameters.Parameter in project quality-measure-and-cohort-service by Alvearie.
the class DefaultMeasurementPeriodStrategyTest method runGetMeasurementPeriodTest.
private void runGetMeasurementPeriodTest(String parameterName, String start, String end) {
Measure measure = new Measure();
Map<String, Parameter> parameterOverrides = Collections.singletonMap(parameterName, new IntervalParameter(new DateParameter(start), true, new DateParameter(end), true));
Pair<String, String> result = new DefaultMeasurementPeriodStrategy().setMeasurementPeriodParameter(parameterName).getMeasurementPeriod(measure, parameterOverrides);
assertEquals("Unexpected start", result.getLeft(), start);
assertEquals("Unexpected end", result.getRight(), end);
}
use of com.ibm.cohort.cql.evaluation.parameters.Parameter in project quality-measure-and-cohort-service by Alvearie.
the class MeasureContextTest method when_invalid_parameters___fails_validation.
@Test
public void when_invalid_parameters___fails_validation() {
Map<String, Parameter> parameters = new HashMap<>();
parameters.put("Measurement Period", new IntervalParameter());
MeasureContext context = new MeasureContext("measureId", parameters);
Set<ConstraintViolation<MeasureContext>> violations = validator.validate(context);
printViolations(violations);
assertEquals(2, violations.size());
}
use of com.ibm.cohort.cql.evaluation.parameters.Parameter in project quality-measure-and-cohort-service by Alvearie.
the class MeasureEvaluatorTest method id_based_library_link___successfully_loaded_and_evaluated.
@Test
public void id_based_library_link___successfully_loaded_and_evaluated() throws Exception {
mockFhirResourceRetrieval("/metadata?_format=json", getCapabilityStatement());
Patient patient = getPatient("123", AdministrativeGender.MALE, "1970-10-10");
mockFhirResourceRetrieval(patient);
Library library = mockLibraryRetrieval("TestDummyPopulations", DEFAULT_VERSION, "cql/fhir-measure/test-dummy-populations.cql");
Measure measure = getCareGapMeasure("IDBasedLibraryMeasure", library, expressionsByPopulationType, "CareGap1", "CareGap2");
measure.setLibrary(Arrays.asList(new CanonicalType("Library/" + library.getId())));
mockFhirResourceRetrieval(measure);
Map<String, Parameter> passingParameters = new HashMap<>();
passingParameters.put("InInitialPopulation", new BooleanParameter(true));
List<MeasureContext> measureContexts = new ArrayList<>();
measureContexts.add(new MeasureContext(measure.getId(), passingParameters));
List<MeasureReport> reports = evaluator.evaluatePatientMeasures(patient.getId(), measureContexts);
assertEquals(1, reports.size());
MeasureReport report = reports.get(0);
verifyStandardPopulationCounts(report);
verify(1, getRequestedFor(urlEqualTo("/Library/" + library.getId() + "?_format=json")));
}
use of com.ibm.cohort.cql.evaluation.parameters.Parameter in project quality-measure-and-cohort-service by Alvearie.
the class MeasureEvaluatorTest method multilevel_library_dependencies___successfully_loaded_and_evaluated.
@Test
public void multilevel_library_dependencies___successfully_loaded_and_evaluated() throws Exception {
mockFhirResourceRetrieval("/metadata?_format=json", getCapabilityStatement());
Patient patient = getPatient("123", AdministrativeGender.MALE, "1970-10-10");
mockFhirResourceRetrieval(patient);
Library nestedHelperLibrary = mockLibraryRetrieval("NestedChild", DEFAULT_VERSION, "cql/fhir-measure-nested-libraries/test-nested-child.cql");
Library helperLibrary = mockLibraryRetrieval("Child", DEFAULT_VERSION, "cql/fhir-measure-nested-libraries/test-child.cql");
helperLibrary.addRelatedArtifact(asRelation(nestedHelperLibrary));
Library library = mockLibraryRetrieval("Parent", DEFAULT_VERSION, "cql/fhir-measure-nested-libraries/test-parent.cql");
library.addRelatedArtifact(asRelation(helperLibrary));
Measure measure = getCareGapMeasure("NestedLibraryMeasure", library, expressionsByPopulationType, "CareGap1", "CareGap2");
mockFhirResourceRetrieval(measure);
Map<String, Parameter> passingParameters = new HashMap<>();
passingParameters.put("InInitialPopulation", new BooleanParameter(true));
List<MeasureContext> measureContexts = new ArrayList<>();
measureContexts.add(new MeasureContext(measure.getId(), passingParameters));
List<MeasureReport> reports = evaluator.evaluatePatientMeasures(patient.getId(), measureContexts);
assertEquals(1, reports.size());
MeasureReport report = reports.get(0);
verifyStandardPopulationCounts(report);
}
Aggregations