use of org.hl7.fhir.r5.model.CapabilityStatement in project quality-measure-and-cohort-service by Alvearie.
the class MeasureEvaluatorTest method in_populations_defines_returned.
@Test
public void in_populations_defines_returned() throws Exception {
CapabilityStatement metadata = getCapabilityStatement();
mockFhirResourceRetrieval("/metadata?_format=json", metadata);
Patient patient = getPatient("123", AdministrativeGender.MALE, "1970-10-10");
// Add 2 names to test list
HumanName name1 = new HumanName();
name1.setFamily("Jones");
HumanName name2 = new HumanName();
name2.setFamily("Smith");
patient.setName(Arrays.asList(name1, name2));
// Add marital status to test codeable concept
CodeableConcept maritalStatus = new CodeableConcept();
Coding maritalCoding = new Coding();
maritalCoding.setCode("M");
maritalCoding.setSystem("http://terminology.hl7.org/CodeSystem/v3-MaritalStatus");
maritalCoding.setDisplay("Married");
maritalStatus.setCoding(Arrays.asList(maritalCoding));
maritalStatus.setText("Married");
patient.setMaritalStatus(maritalStatus);
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(true, DefineReturnOptions.ALL));
assertNotNull(report);
assertFalse(report.getEvaluatedResource().isEmpty());
List<Extension> returnedExtensions = report.getExtensionsByUrl(CDMConstants.EVIDENCE_URL);
assertFalse(returnedExtensions.isEmpty());
assertEquals(30, returnedExtensions.size());
}
use of org.hl7.fhir.r5.model.CapabilityStatement in project quality-measure-and-cohort-service by Alvearie.
the class MeasureEvaluatorTest method measure_default_unsupported_type.
@Test(expected = UnsupportedFhirTypeException.class)
public void measure_default_unsupported_type() 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);
Address unsupportedType = new Address();
unsupportedType.setCity("Cleaveland");
measure.addExtension(createMeasureParameter("SomeAge", unsupportedType));
mockFhirResourceRetrieval(measure);
evaluator.evaluatePatientMeasure(measure.getId(), patient.getId(), null, new MeasureEvidenceOptions());
}
use of org.hl7.fhir.r5.model.CapabilityStatement in project quality-measure-and-cohort-service by Alvearie.
the class MeasureEvaluatorTest method in_initial_population_denominator_and_nothing_else___proportion_evaluated_correctly.
@Test
public void in_initial_population_denominator_and_nothing_else___proportion_evaluated_correctly() 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");
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);
assertNotNull(report);
assertEquals(expressionsByPopulationType.size(), report.getGroupFirstRep().getPopulation().size());
for (MeasureReport.MeasureReportGroupPopulationComponent pop : report.getGroupFirstRep().getPopulation()) {
MeasurePopulationType type = MeasurePopulationType.fromCode(pop.getCode().getCodingFirstRep().getCode());
switch(type) {
case INITIALPOPULATION:
assertEquals(1, pop.getCount());
break;
case DENOMINATOR:
assertEquals(1, pop.getCount());
break;
case NUMERATOR:
assertEquals(0, pop.getCount());
break;
default:
fail("Unexpected population type in result");
}
}
}
use of org.hl7.fhir.r5.model.CapabilityStatement in project quality-measure-and-cohort-service by Alvearie.
the class MeasureEvaluatorTest method elm_in_initial_population___cohort_evaluated_correctly.
@Test
public void elm_in_initial_population___cohort_evaluated_correctly() 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);
Measure measure = getCohortMeasure("CohortMeasureName", library, INITIAL_POPULATION);
mockFhirResourceRetrieval(measure);
MeasureReport report = evaluator.evaluatePatientMeasure(measure.getId(), patient.getId(), null);
assertNotNull(report);
assertEquals(1, report.getGroupFirstRep().getPopulationFirstRep().getCount());
verify(1, getRequestedFor(urlEqualTo("/Patient/123?_format=json")));
// These ensure that the cache is working
verify(1, getRequestedFor(urlMatching("/Library\\?url=http.*&_format=json")));
verify(1, getRequestedFor(urlEqualTo("/Library?name%3Aexact=" + library.getName() + "&version=1.0.0&_format=json")));
}
use of org.hl7.fhir.r5.model.CapabilityStatement in project quality-measure-and-cohort-service by Alvearie.
the class MeasureEvaluatorTest method runCareGapTest.
private void runCareGapTest(Map<String, Parameter> parameters, Map<String, Integer> careGapExpectations) throws ParseException, 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");
Measure measure = getCareGapMeasure("ProportionMeasureName", library, expressionsByPopulationType, "CareGap1", "CareGap2");
mockFhirResourceRetrieval(measure);
MeasureReport report = evaluator.evaluatePatientMeasure(measure.getId(), patient.getId(), parameters);
assertNotNull(report);
assertPopulationExpectations(measure, report, careGapExpectations);
}
Aggregations