Search in sources :

Example 56 with Library

use of org.hl7.fhir.dstu3.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);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Patient(org.hl7.fhir.r4.model.Patient) MeasureReport(org.hl7.fhir.r4.model.MeasureReport) BooleanParameter(com.ibm.cohort.cql.evaluation.parameters.BooleanParameter) Measure(org.hl7.fhir.r4.model.Measure) ConceptParameter(com.ibm.cohort.cql.evaluation.parameters.ConceptParameter) RatioParameter(com.ibm.cohort.cql.evaluation.parameters.RatioParameter) IntegerParameter(com.ibm.cohort.cql.evaluation.parameters.IntegerParameter) DateParameter(com.ibm.cohort.cql.evaluation.parameters.DateParameter) CodeParameter(com.ibm.cohort.cql.evaluation.parameters.CodeParameter) Parameter(com.ibm.cohort.cql.evaluation.parameters.Parameter) DatetimeParameter(com.ibm.cohort.cql.evaluation.parameters.DatetimeParameter) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) DecimalParameter(com.ibm.cohort.cql.evaluation.parameters.DecimalParameter) QuantityParameter(com.ibm.cohort.cql.evaluation.parameters.QuantityParameter) StringParameter(com.ibm.cohort.cql.evaluation.parameters.StringParameter) TimeParameter(com.ibm.cohort.cql.evaluation.parameters.TimeParameter) BooleanParameter(com.ibm.cohort.cql.evaluation.parameters.BooleanParameter) Library(org.hl7.fhir.r4.model.Library) Test(org.junit.Test)

Example 57 with Library

use of org.hl7.fhir.dstu3.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));
}
Also used : CapabilityStatement(org.hl7.fhir.r4.model.CapabilityStatement) Measure(org.hl7.fhir.r4.model.Measure) Patient(org.hl7.fhir.r4.model.Patient) MeasureReport(org.hl7.fhir.r4.model.MeasureReport) Library(org.hl7.fhir.r4.model.Library) MeasureEvidenceOptions(com.ibm.cohort.engine.measure.evidence.MeasureEvidenceOptions) Test(org.junit.Test)

Example 58 with Library

use of org.hl7.fhir.dstu3.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;
}
Also used : Measure(org.hl7.fhir.r4.model.Measure)

Example 59 with Library

use of org.hl7.fhir.dstu3.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;
}
Also used : Measure(org.hl7.fhir.r4.model.Measure)

Example 60 with Library

use of org.hl7.fhir.dstu3.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;
}
Also used : Bundle(org.hl7.fhir.r4.model.Bundle) Library(org.hl7.fhir.r4.model.Library)

Aggregations

Library (org.hl7.fhir.r4.model.Library)130 Test (org.junit.Test)85 Measure (org.hl7.fhir.r4.model.Measure)60 Patient (org.hl7.fhir.r4.model.Patient)41 HashMap (java.util.HashMap)36 Test (org.junit.jupiter.api.Test)34 ArrayList (java.util.ArrayList)32 Library (org.hl7.fhir.dstu3.model.Library)23 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)21 ByteArrayOutputStream (java.io.ByteArrayOutputStream)21 CapabilityStatement (org.hl7.fhir.r4.model.CapabilityStatement)21 MeasureReport (org.hl7.fhir.r4.model.MeasureReport)21 StringType (org.hl7.fhir.r4.model.StringType)21 IOException (java.io.IOException)20 VersionedIdentifier (org.cqframework.cql.elm.execution.VersionedIdentifier)20 FhirContext (ca.uhn.fhir.context.FhirContext)19 IParser (ca.uhn.fhir.parser.IParser)19 MeasureEvidenceOptions (com.ibm.cohort.engine.measure.evidence.MeasureEvidenceOptions)19 Bundle (org.hl7.fhir.r4.model.Bundle)19 Parameter (com.ibm.cohort.cql.evaluation.parameters.Parameter)18