use of org.hl7.fhir.r5.model.Library 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);
}
use of org.hl7.fhir.r5.model.Library in project quality-measure-and-cohort-service by Alvearie.
the class MeasureEvaluatorTest method in_populations_no_evaluated_resources_returned.
@Test
public void in_populations_no_evaluated_resources_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());
assertNotNull(report);
assertTrue(report.getEvaluatedResource().isEmpty());
assertEquals(null, report.getExtensionByUrl(CDMConstants.EVIDENCE_URL));
}
use of org.hl7.fhir.r5.model.Library in project quality-measure-and-cohort-service by Alvearie.
the class MeasureTestBase method getCohortMeasure.
public Measure getCohortMeasure(String measureName, Library library, String expression) throws Exception {
Measure measure = getTemplateMeasure(measureName, library, MeasureScoring.COHORT);
Measure.MeasureGroupComponent group = new Measure.MeasureGroupComponent();
addPopulations(group, Collections.singletonMap(MeasurePopulationType.INITIALPOPULATION, expression));
measure.addGroup(group);
return measure;
}
use of org.hl7.fhir.r5.model.Library in project quality-measure-and-cohort-service by Alvearie.
the class MeasureTestBase method getProportionMeasure.
public Measure getProportionMeasure(String measureName, Library library, Map<MeasurePopulationType, String> expressionsByPopType) throws Exception {
Measure measure = getTemplateMeasure(measureName, library, MeasureScoring.PROPORTION);
Measure.MeasureGroupComponent group = new Measure.MeasureGroupComponent();
addPopulations(group, expressionsByPopType);
measure.addGroup(group);
return measure;
}
use of org.hl7.fhir.r5.model.Library in project quality-measure-and-cohort-service by Alvearie.
the class MeasureTestBase method mockLibraryRetrieval.
protected Library mockLibraryRetrieval(String libraryName, String libraryVersion, String... cqlResource) throws Exception {
Library library = getLibrary(libraryName, libraryVersion, cqlResource);
mockFhirResourceRetrieval(library);
Bundle bundle = getBundle(library);
String url = URLEncoder.encode(library.getUrl(), StandardCharsets.UTF_8.toString());
if (library.getVersion() != null) {
url += "&version=" + library.getVersion();
}
mockFhirResourceRetrieval("/Library?url=" + url + "&_format=json", bundle);
mockFhirResourceRetrieval("/Library?name%3Aexact=" + library.getName() + "&_format=json", bundle);
mockFhirResourceRetrieval("/Library?name%3Aexact=" + library.getName() + "&version=" + library.getVersion() + "&_format=json", bundle);
return library;
}
Aggregations