Search in sources :

Example 16 with MeasureReport

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

the class MeasureSupplementalDataEvaluationTest method testProcessAccumulators.

@Test
public void testProcessAccumulators() {
    Map<String, Map<String, Integer>> sdeAccumulators = getSexSDEAccumulators();
    MeasureReport report = new MeasureReport();
    MeasureSupplementalDataEvaluation.processAccumulators(report, sdeAccumulators, true, new ArrayList<>());
    assertNotNull(report);
    // EvaluatedResource should contain a reference to an observation record created for supplemental data
    assertEquals(1, report.getEvaluatedResource().size());
    // The observation record mentioned previously should exist within the contained resources of the measure report
    assertEquals(1, report.getContained().size());
    assertTrue(report.getContained().get(0) instanceof Observation);
    Observation obs = (Observation) report.getContained().get(0);
    // For a single patient, the code of the observation should be the supplemental data text
    assertEquals(MeasureSupplementalDataEvaluation.SDE_SEX, obs.getCode().getText());
    // For a single patient, the value of the observation should be the result of the appropriate define
    assertTrue(obs.getValue() instanceof CodeableConcept);
    assertEquals(MALE_CODE, ((CodeableConcept) obs.getValue()).getCoding().get(0).getCode());
    // Within the observation, there should be 1 extension, with two further nested extensions
    Extension obsExt = obs.getExtensionByUrl(MeasureSupplementalDataEvaluation.CQF_MEASUREINFO_URL);
    assertNotNull(obsExt);
    assertEquals(2, obsExt.getExtension().size());
    Extension measureNestedExt = obsExt.getExtensionByUrl(MeasureSupplementalDataEvaluation.MEASURE);
    assertTrue(measureNestedExt.getValue() instanceof CanonicalType);
    assertEquals(MeasureSupplementalDataEvaluation.CQFMEASURES_URL + report.getMeasure(), ((CanonicalType) measureNestedExt.getValue()).asStringValue());
    Extension populationNestedExt = obsExt.getExtensionByUrl(MeasureSupplementalDataEvaluation.POPULATION_ID);
    assertEquals(MeasureSupplementalDataEvaluation.SDE_SEX, ((StringType) populationNestedExt.getValue()).asStringValue());
}
Also used : Extension(org.hl7.fhir.r4.model.Extension) Observation(org.hl7.fhir.r4.model.Observation) MeasureReport(org.hl7.fhir.r4.model.MeasureReport) HashMap(java.util.HashMap) Map(java.util.Map) CanonicalType(org.hl7.fhir.r4.model.CanonicalType) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.Test)

Example 17 with MeasureReport

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

the class CDMMeasureEvaluationTest method testSetReportMeasureToMeasureId__measureFromBundleWithoutMetaVersion__onlyMeasurePortionWithoutHistoryOnReport.

@Test
public void testSetReportMeasureToMeasureId__measureFromBundleWithoutMetaVersion__onlyMeasurePortionWithoutHistoryOnReport() {
    MeasureReport report = new MeasureReport();
    String bundleInput = "{\"resourceType\":\"Bundle\",\"id\":\"98765\",\"entry\":[{\"fullUrl\":\"https://full-url-to/fhir-server/api/v4/Measure/id1\",\"resource\":{\"resourceType\":\"Measure\",\"id\":\"id1\"}}]}";
    Measure measure = (Measure) fhirParser.parseResource(Bundle.class, bundleInput).getEntryFirstRep().getResource();
    CDMMeasureEvaluation.setReportMeasureToMeasureId(report, measure);
    assertEquals("Measure/id1", report.getMeasure());
}
Also used : Bundle(org.hl7.fhir.r4.model.Bundle) Measure(org.hl7.fhir.r4.model.Measure) MeasureReport(org.hl7.fhir.r4.model.MeasureReport) Test(org.junit.Test)

Example 18 with MeasureReport

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

the class CDMMeasureEvaluationTest method testSetReportMeasureToMeasureId__noMetaVersion__noHistoryInMeasureOnReport.

@Test
public void testSetReportMeasureToMeasureId__noMetaVersion__noHistoryInMeasureOnReport() {
    MeasureReport report = new MeasureReport();
    String measureInput = "{\"resourceType\":\"Measure\",\"id\":\"id1\"}";
    Measure measure = fhirParser.parseResource(Measure.class, measureInput);
    CDMMeasureEvaluation.setReportMeasureToMeasureId(report, measure);
    assertEquals("Measure/id1", report.getMeasure());
}
Also used : Measure(org.hl7.fhir.r4.model.Measure) MeasureReport(org.hl7.fhir.r4.model.MeasureReport) Test(org.junit.Test)

Example 19 with MeasureReport

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

the class CDMMeasureEvaluationTest method testSetReportMeasureToMeasureId__includesMetaVersion__hasHistoryInMeasureOnReport.

@Test
public void testSetReportMeasureToMeasureId__includesMetaVersion__hasHistoryInMeasureOnReport() {
    MeasureReport report = new MeasureReport();
    String measureInput = "{\"resourceType\":\"Measure\",\"id\":\"id1\",\"meta\":{\"versionId\":\"2\"}}";
    Measure measure = fhirParser.parseResource(Measure.class, measureInput);
    CDMMeasureEvaluation.setReportMeasureToMeasureId(report, measure);
    assertEquals("Measure/id1/_history/2", report.getMeasure());
}
Also used : Measure(org.hl7.fhir.r4.model.Measure) MeasureReport(org.hl7.fhir.r4.model.MeasureReport) Test(org.junit.Test)

Example 20 with MeasureReport

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

the class CDMMeasureEvaluationTest method testDefinesOnMeasureReport.

@Test
public void testDefinesOnMeasureReport() {
    MeasureReport report = new MeasureReport();
    Map<VersionedIdentifier, Map<String, Object>> expectedResults = setupTestExpectedResultsContext();
    CDMContext defineContext = setupTestDefineContext(expectedResults);
    CDMMeasureEvaluation.addDefineEvaluationToReport(report, defineContext, DefineReturnOptions.ALL);
    assertEquals(5, report.getExtension().size());
    int index = 0;
    for (Entry<VersionedIdentifier, Map<String, Object>> expectedLibraryResults : expectedResults.entrySet()) {
        for (Entry<String, Object> defineResult : expectedLibraryResults.getValue().entrySet()) {
            Extension extension = report.getExtension().get(index++);
            assertEquals(MeasureEvidenceHelper.createEvidenceKey(expectedLibraryResults.getKey(), defineResult.getKey()), extension.getExtensionByUrl(CDMConstants.EVIDENCE_TEXT_URL).getValue().primitiveValue());
            // hack because Type does not return equals for 2 identical objects :(
            Type returnType = extension.getExtensionByUrl(CDMConstants.EVIDENCE_VALUE_URL).getValue();
            if (defineResult.getValue() instanceof Boolean) {
                assertTrue(returnType.isBooleanPrimitive());
                assertEquals(defineResult.getValue(), ((BooleanType) returnType).booleanValue());
            } else if (defineResult.getValue() instanceof String) {
                assertTrue(returnType.isPrimitive());
                assertEquals(defineResult.getValue(), returnType.primitiveValue());
            } else if (defineResult.getValue() instanceof DomainResource) {
                assertTrue(returnType instanceof Reference);
            }
        }
    }
}
Also used : DomainResource(org.hl7.fhir.r4.model.DomainResource) Reference(org.hl7.fhir.r4.model.Reference) MeasureReport(org.hl7.fhir.r4.model.MeasureReport) Extension(org.hl7.fhir.r4.model.Extension) VersionedIdentifier(org.cqframework.cql.elm.execution.VersionedIdentifier) Type(org.hl7.fhir.r4.model.Type) BooleanType(org.hl7.fhir.r4.model.BooleanType) CDMContext(com.ibm.cohort.engine.cqfruler.CDMContext) HashMap(java.util.HashMap) Map(java.util.Map) AbstractMap(java.util.AbstractMap) Test(org.junit.Test)

Aggregations

MeasureReport (org.hl7.fhir.r4.model.MeasureReport)51 Test (org.junit.Test)35 Measure (org.hl7.fhir.r4.model.Measure)31 Patient (org.hl7.fhir.r4.model.Patient)29 Library (org.hl7.fhir.r4.model.Library)23 HashMap (java.util.HashMap)19 CapabilityStatement (org.hl7.fhir.r4.model.CapabilityStatement)18 Extension (org.hl7.fhir.r4.model.Extension)17 MeasureEvidenceOptions (com.ibm.cohort.engine.measure.evidence.MeasureEvidenceOptions)16 StringType (org.hl7.fhir.r4.model.StringType)16 Test (org.junit.jupiter.api.Test)16 ArrayList (java.util.ArrayList)15 Map (java.util.Map)13 Bundle (org.hl7.fhir.r4.model.Bundle)13 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)13 BooleanType (org.hl7.fhir.r4.model.BooleanType)10 CanonicalType (org.hl7.fhir.r4.model.CanonicalType)10 MeasurePopulationType (org.opencds.cqf.common.evaluation.MeasurePopulationType)10 BooleanParameter (com.ibm.cohort.cql.evaluation.parameters.BooleanParameter)9 CodeParameter (com.ibm.cohort.cql.evaluation.parameters.CodeParameter)9