use of org.hl7.fhir.dstu3.model.MeasureReport 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 org.hl7.fhir.dstu3.model.MeasureReport in project quality-measure-and-cohort-service by Alvearie.
the class MeasureEvaluatorTest method in_populations_evaluated_boolean_define_only_returned.
@Test
public void in_populations_evaluated_boolean_define_only_returned() throws Exception {
CapabilityStatement metadata = getCapabilityStatement();
mockFhirResourceRetrieval("/metadata?_format=json", metadata);
Patient patient = getPatient("123", AdministrativeGender.MALE, "1970-10-10");
mockFhirResourceRetrieval(patient);
Library library = setupDefineReturnLibrary();
expressionsByPopulationType.clear();
expressionsByPopulationType.put(MeasurePopulationType.INITIALPOPULATION, INITIAL_POPULATION);
expressionsByPopulationType.put(MeasurePopulationType.DENOMINATOR, DENOMINATOR);
expressionsByPopulationType.put(MeasurePopulationType.NUMERATOR, NUMERATOR);
Measure measure = getProportionMeasure("ProportionMeasureName", library, expressionsByPopulationType);
mockFhirResourceRetrieval(measure);
MeasureReport report = evaluator.evaluatePatientMeasure(measure.getId(), patient.getId(), null, new MeasureEvidenceOptions(false, DefineReturnOptions.BOOLEAN));
assertNotNull(report);
assertTrue(report.getEvaluatedResource().isEmpty());
assertFalse(report.getExtensionsByUrl(CDMConstants.EVIDENCE_URL).isEmpty());
}
use of org.hl7.fhir.dstu3.model.MeasureReport in project quality-measure-and-cohort-service by Alvearie.
the class MeasureEvaluatorTest method in_initial_population_when_engine_run_in_utc__engine_defaults_to_utc.
@Test
public void in_initial_population_when_engine_run_in_utc__engine_defaults_to_utc() throws Exception {
CapabilityStatement metadata = getCapabilityStatement();
mockFhirResourceRetrieval("/metadata?_format=json", metadata);
Patient patient = getPatient("123", AdministrativeGender.MALE, "1970-10-10");
mockFhirResourceRetrieval(patient);
// Test CQL written to pass when engine run with a timezone of UTC
// and should fail otherwise
Library library = mockLibraryRetrieval("TestDatetimeDefaultTimezones", DEFAULT_VERSION, "cql/fhir-measure/test-datetime-default-timezones.cql", "text/cql");
Measure measure = getCohortMeasure("CohortMeasureName", library, INITIAL_POPULATION);
mockFhirResourceRetrieval(measure);
MeasureReport report = evaluator.evaluatePatientMeasure(measure.getId(), patient.getId(), null, new MeasureEvidenceOptions(false, DefineReturnOptions.BOOLEAN));
assertNotNull(report);
report.getExtension().stream().filter(x -> x.getUrl().equals(CDMConstants.EVIDENCE_URL)).forEach(x -> validateBooleanEvidence(x, true));
}
use of org.hl7.fhir.dstu3.model.MeasureReport in project quality-measure-and-cohort-service by Alvearie.
the class MeasureEvaluatorTest method in_populations_evaluated_define_only_returned.
@Test
public void in_populations_evaluated_define_only_returned() throws Exception {
CapabilityStatement metadata = getCapabilityStatement();
mockFhirResourceRetrieval("/metadata?_format=json", metadata);
Patient patient = getPatient("123", AdministrativeGender.MALE, "1970-10-10");
mockFhirResourceRetrieval(patient);
Library library = setupDefineReturnLibrary();
expressionsByPopulationType.clear();
expressionsByPopulationType.put(MeasurePopulationType.INITIALPOPULATION, INITIAL_POPULATION);
expressionsByPopulationType.put(MeasurePopulationType.DENOMINATOR, DENOMINATOR);
expressionsByPopulationType.put(MeasurePopulationType.NUMERATOR, NUMERATOR);
Measure measure = getProportionMeasure("ProportionMeasureName", library, expressionsByPopulationType);
mockFhirResourceRetrieval(measure);
MeasureReport report = evaluator.evaluatePatientMeasure(measure.getId(), patient.getId(), null, new MeasureEvidenceOptions(false, DefineReturnOptions.ALL));
assertNotNull(report);
assertTrue(report.getEvaluatedResource().isEmpty());
assertFalse(report.getExtensionsByUrl(CDMConstants.EVIDENCE_URL).isEmpty());
}
use of org.hl7.fhir.dstu3.model.MeasureReport in project quality-measure-and-cohort-service by Alvearie.
the class MeasureEvaluatorTest method measure_default_valid.
@Test
public void measure_default_valid() throws Exception {
CapabilityStatement metadata = getCapabilityStatement();
mockFhirResourceRetrieval("/metadata?_format=json", metadata);
Patient patient = getPatient("123", AdministrativeGender.MALE, "1970-10-10");
mockFhirResourceRetrieval(patient);
Library library = mockLibraryRetrieval("TestAdultMales", DEFAULT_VERSION, "cql/fhir-measure/test-parameter-defaults.cql");
expressionsByPopulationType.clear();
expressionsByPopulationType.put(MeasurePopulationType.INITIALPOPULATION, INITIAL_POPULATION);
expressionsByPopulationType.put(MeasurePopulationType.DENOMINATOR, DENOMINATOR);
expressionsByPopulationType.put(MeasurePopulationType.NUMERATOR, NUMERATOR);
Measure measure = getProportionMeasure("ProportionMeasureName", library, expressionsByPopulationType);
measure.addExtension(createMeasureParameter("SomeAge", new IntegerType(20)));
mockFhirResourceRetrieval(measure);
MeasureReport report = evaluator.evaluatePatientMeasure(measure.getId(), patient.getId(), null, new MeasureEvidenceOptions());
assertNotNull(report);
}
Aggregations