Search in sources :

Example 51 with Library

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

Example 52 with Library

use of org.hl7.fhir.r4b.model.Library 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");
        }
    }
}
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) MeasurePopulationType(org.opencds.cqf.common.evaluation.MeasurePopulationType) Test(org.junit.Test)

Example 53 with Library

use of org.hl7.fhir.r4b.model.Library 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")));
}
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) Test(org.junit.Test)

Example 54 with Library

use of org.hl7.fhir.r4b.model.Library in project quality-measure-and-cohort-service by Alvearie.

the class MeasureEvaluatorTest method setupDefineReturnLibrary.

private Library setupDefineReturnLibrary() throws Exception {
    Library fhirHelpers = mockLibraryRetrieval("FHIRHelpers", "4.0.0", "cql/fhir-helpers/FHIRHelpers.cql");
    Library library2 = mockLibraryRetrieval("TestAdultMales2", DEFAULT_VERSION, "cql/fhir-measure/test-adult-males2.cql");
    Library library3 = mockLibraryRetrieval("TestAdultMales3", DEFAULT_VERSION, "cql/fhir-measure/test-adult-males3.cql");
    Library library = mockLibraryRetrieval("TestAdultMales", DEFAULT_VERSION, "cql/fhir-measure/test-adult-males.cql");
    library.addRelatedArtifact(asRelation(fhirHelpers));
    library.addRelatedArtifact(asRelation(library2));
    library.addRelatedArtifact(asRelation(library3));
    return library;
}
Also used : Library(org.hl7.fhir.r4.model.Library)

Example 55 with Library

use of org.hl7.fhir.r4b.model.Library 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);
}
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)

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