Search in sources :

Example 21 with Quantity

use of org.hl7.fhir.r4.model.Quantity in project cqf-ruler by DBCG.

the class ActivityDefinitionApplyProvider method resolveMedicationRequest.

private MedicationRequest resolveMedicationRequest(ActivityDefinition activityDefinition, String patientId) throws ActivityDefinitionApplyException {
    // intent, medication, and subject are required
    MedicationRequest medicationRequest = new MedicationRequest();
    medicationRequest.setIntent(MedicationRequest.MedicationRequestIntent.ORDER);
    medicationRequest.setSubject(new Reference(patientId));
    if (activityDefinition.hasProduct()) {
        medicationRequest.setMedication(activityDefinition.getProduct());
    } else {
        throw new ActivityDefinitionApplyException("Missing required product property");
    }
    if (activityDefinition.hasDosage()) {
        medicationRequest.setDosageInstruction(activityDefinition.getDosage());
    }
    if (activityDefinition.hasBodySite()) {
        throw new ActivityDefinitionApplyException("BodySite does not map to " + activityDefinition.getKind());
    }
    if (activityDefinition.hasCode()) {
        throw new ActivityDefinitionApplyException("Code does not map to " + activityDefinition.getKind());
    }
    if (activityDefinition.hasQuantity()) {
        throw new ActivityDefinitionApplyException("Quantity does not map to " + activityDefinition.getKind());
    }
    return medicationRequest;
}
Also used : MedicationRequest(org.hl7.fhir.dstu3.model.MedicationRequest) Reference(org.hl7.fhir.dstu3.model.Reference)

Example 22 with Quantity

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

the class CQLToFHIRMeasureReportHelperTest method testRatio.

@Test
public void testRatio() {
    String unit = "ml";
    BigDecimal amount1 = new BigDecimal("4.0");
    Quantity quantity1 = new Quantity().withUnit(unit).withValue(amount1);
    BigDecimal amount2 = new BigDecimal("7.0");
    Quantity quantity2 = new Quantity().withUnit(unit).withValue(amount2);
    Ratio ratio = new Ratio().setNumerator(quantity1).setDenominator(quantity2);
    IBaseDatatype fhirTypeValue = CQLToFHIRMeasureReportHelper.getFhirTypeValue(ratio);
    assertTrue(fhirTypeValue instanceof org.hl7.fhir.r4.model.Ratio);
    org.hl7.fhir.r4.model.Ratio castResult = (org.hl7.fhir.r4.model.Ratio) fhirTypeValue;
    verifyBaseTypeAsQuantity(castResult.getNumerator(), amount1, unit);
    verifyBaseTypeAsQuantity(castResult.getDenominator(), amount2, unit);
}
Also used : IBaseDatatype(org.hl7.fhir.instance.model.api.IBaseDatatype) Quantity(org.opencds.cqf.cql.engine.runtime.Quantity) Ratio(org.opencds.cqf.cql.engine.runtime.Ratio) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 23 with Quantity

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

the class CQLToFHIRMeasureReportHelperTest method testIntervalQuantity_shouldReturnRange.

@Test
public void testIntervalQuantity_shouldReturnRange() {
    String unit = "ml";
    BigDecimal startAmount = new BigDecimal("4.0");
    BigDecimal endAmount = new BigDecimal("5.0");
    Quantity startQuantity = new Quantity().withUnit(unit).withValue(startAmount);
    Quantity endQuantity = new Quantity().withUnit(unit).withValue(endAmount);
    IBaseDatatype fhirTypeValue = CQLToFHIRMeasureReportHelper.getFhirTypeValue(new Interval(startQuantity, true, endQuantity, true));
    assertTrue(fhirTypeValue instanceof Range);
    Range castResult = (Range) fhirTypeValue;
    verifyBaseTypeAsQuantity(castResult.getLow(), startAmount, unit);
    verifyBaseTypeAsQuantity(castResult.getHigh(), endAmount, unit);
}
Also used : IBaseDatatype(org.hl7.fhir.instance.model.api.IBaseDatatype) Quantity(org.opencds.cqf.cql.engine.runtime.Quantity) Range(org.hl7.fhir.r4.model.Range) BigDecimal(java.math.BigDecimal) Interval(org.opencds.cqf.cql.engine.runtime.Interval) Test(org.junit.Test)

Example 24 with Quantity

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

the class MeasureEvaluatorTest method measure_report_generated___FHIR_measure_parameters_on_measure_report.

@Test
public void measure_report_generated___FHIR_measure_parameters_on_measure_report() 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);
    Map<String, Type> measureParameters = new HashMap<>();
    measureParameters.put("base64Param", new Base64BinaryType("AAA"));
    measureParameters.put("booleanParam", new BooleanType(false));
    measureParameters.put("dateParam", new DateType("2020-01-01"));
    measureParameters.put("dateTimeParam", new DateTimeType("2020-01-01T12:00:00"));
    measureParameters.put("decimalParam", new DecimalType(12.0));
    measureParameters.put("instantParam", new InstantType("2020-01-01T12:00:00-04:00"));
    measureParameters.put("integerParam", new IntegerType(1));
    measureParameters.put("stringParam", new StringType("str"));
    measureParameters.put("timeParam", new TimeType("05:30:00"));
    measureParameters.put("uriParam", new UriType("abcde"));
    measureParameters.put("codeableConceptParam", new CodeableConcept().setText("display").addCoding(new Coding().setCode("val").setSystem("sys").setDisplay("display")));
    measureParameters.put("codingParam", new Coding().setCode("v").setSystem("s").setDisplay("d"));
    measureParameters.put("periodParam", new Period().setStart(new Date(1)).setEnd(new Date(2)));
    measureParameters.put("quantityParam", new Quantity().setValue(1).setUnit("g"));
    measureParameters.put("rangeParam", new Range().setLow(new Quantity().setUnit("g").setValue(1)).setHigh(new Quantity().setUnit("g").setValue(5)));
    measureParameters.put("ratioParam", new Ratio().setNumerator(new Quantity().setUnit("g").setValue(1)).setDenominator(new Quantity().setUnit("g").setValue(5)));
    List<Extension> parameterExtensions = measureParameters.entrySet().stream().map(x -> createMeasureParameter(x.getKey(), x.getValue())).collect(Collectors.toList());
    measure.setExtension(parameterExtensions);
    mockFhirResourceRetrieval(measure);
    MeasureReport report = evaluator.evaluatePatientMeasure(measure.getId(), patient.getId(), null);
    assertNotNull(report);
    List<String> parameterNames = report.getExtension().stream().filter(x -> x.getUrl().equals(MEASURE_PARAMETER_VALUE_URL)).map(x -> (ParameterDefinition) x.getValue()).map(ParameterDefinition::getName).collect(Collectors.toList());
    // Expected parameters are the ones listed above, plus the special parameters
    // measurement period and product line
    assertEquals(measureParameters.size() + 2, parameterNames.size());
    assertTrue(parameterNames.containsAll(measureParameters.keySet()));
    assertTrue(parameterNames.contains(CDMConstants.MEASUREMENT_PERIOD));
    assertTrue(parameterNames.contains(CDMConstants.PRODUCT_LINE));
}
Also used : Arrays(java.util.Arrays) Date(java.util.Date) PARAMETER_VALUE_URL(com.ibm.cohort.engine.cdm.CDMConstants.PARAMETER_VALUE_URL) Range(org.hl7.fhir.r4.model.Range) StringUtils(org.apache.commons.lang3.StringUtils) ConceptParameter(com.ibm.cohort.cql.evaluation.parameters.ConceptParameter) InvalidOperatorArgument(org.opencds.cqf.cql.engine.exception.InvalidOperatorArgument) CapabilityStatement(org.hl7.fhir.r4.model.CapabilityStatement) HumanName(org.hl7.fhir.r4.model.HumanName) RatioParameter(com.ibm.cohort.cql.evaluation.parameters.RatioParameter) Map(java.util.Map) StringType(org.hl7.fhir.r4.model.StringType) Assert.fail(org.junit.Assert.fail) ParseException(java.text.ParseException) IntegerType(org.hl7.fhir.r4.model.IntegerType) Patient(org.hl7.fhir.r4.model.Patient) DefineReturnOptions(com.ibm.cohort.engine.measure.evidence.MeasureEvidenceOptions.DefineReturnOptions) IntegerParameter(com.ibm.cohort.cql.evaluation.parameters.IntegerParameter) DateParameter(com.ibm.cohort.cql.evaluation.parameters.DateParameter) DateType(org.hl7.fhir.r4.model.DateType) TimeZone(java.util.TimeZone) CodeParameter(com.ibm.cohort.cql.evaluation.parameters.CodeParameter) Period(org.hl7.fhir.r4.model.Period) MEASURE_PARAMETER_URL(com.ibm.cohort.engine.cdm.CDMConstants.MEASURE_PARAMETER_URL) ParameterDefinition(org.hl7.fhir.r4.model.ParameterDefinition) Collectors(java.util.stream.Collectors) PARAMETER_DEFAULT_URL(com.ibm.cohort.engine.cdm.CDMConstants.PARAMETER_DEFAULT_URL) TimeType(org.hl7.fhir.r4.model.TimeType) List(java.util.List) BooleanType(org.hl7.fhir.r4.model.BooleanType) Assert.assertFalse(org.junit.Assert.assertFalse) Coding(org.hl7.fhir.r4.model.Coding) WireMock.getRequestedFor(com.github.tomakehurst.wiremock.client.WireMock.getRequestedFor) Extension(org.hl7.fhir.r4.model.Extension) UriType(org.hl7.fhir.r4.model.UriType) Parameter(com.ibm.cohort.cql.evaluation.parameters.Parameter) UnsupportedFhirTypeException(com.ibm.cohort.engine.measure.parameter.UnsupportedFhirTypeException) DatetimeParameter(com.ibm.cohort.cql.evaluation.parameters.DatetimeParameter) Type(org.hl7.fhir.r4.model.Type) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) HashMap(java.util.HashMap) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) DecimalParameter(com.ibm.cohort.cql.evaluation.parameters.DecimalParameter) Measure(org.hl7.fhir.r4.model.Measure) ArrayList(java.util.ArrayList) Address(org.hl7.fhir.r4.model.Address) Base64BinaryType(org.hl7.fhir.r4.model.Base64BinaryType) QuantityParameter(com.ibm.cohort.cql.evaluation.parameters.QuantityParameter) MEASURE_PARAMETER_VALUE_URL(com.ibm.cohort.engine.cdm.CDMConstants.MEASURE_PARAMETER_VALUE_URL) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Quantity(org.hl7.fhir.r4.model.Quantity) Ratio(org.hl7.fhir.r4.model.Ratio) MeasureSupplementalDataEvaluation(com.ibm.cohort.engine.cqfruler.MeasureSupplementalDataEvaluation) DecimalType(org.hl7.fhir.r4.model.DecimalType) Before(org.junit.Before) MeasureEvidenceOptions(com.ibm.cohort.engine.measure.evidence.MeasureEvidenceOptions) StringParameter(com.ibm.cohort.cql.evaluation.parameters.StringParameter) Assert.assertNotNull(org.junit.Assert.assertNotNull) ListResource(org.hl7.fhir.r4.model.ListResource) Library(org.hl7.fhir.r4.model.Library) Assert.assertTrue(org.junit.Assert.assertTrue) Matchers(org.hamcrest.Matchers) CanonicalType(org.hl7.fhir.r4.model.CanonicalType) Test(org.junit.Test) TimeParameter(com.ibm.cohort.cql.evaluation.parameters.TimeParameter) WireMock.verify(com.github.tomakehurst.wiremock.client.WireMock.verify) WireMock.urlMatching(com.github.tomakehurst.wiremock.client.WireMock.urlMatching) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) CDMConstants(com.ibm.cohort.engine.cdm.CDMConstants) MeasurePopulationType(org.opencds.cqf.common.evaluation.MeasurePopulationType) InstantType(org.hl7.fhir.r4.model.InstantType) AdministrativeGender(org.hl7.fhir.r4.model.Enumerations.AdministrativeGender) BooleanParameter(com.ibm.cohort.cql.evaluation.parameters.BooleanParameter) MeasureReport(org.hl7.fhir.r4.model.MeasureReport) WireMock.urlEqualTo(com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo) Assert.assertEquals(org.junit.Assert.assertEquals) HashMap(java.util.HashMap) StringType(org.hl7.fhir.r4.model.StringType) TimeType(org.hl7.fhir.r4.model.TimeType) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) UriType(org.hl7.fhir.r4.model.UriType) Coding(org.hl7.fhir.r4.model.Coding) CapabilityStatement(org.hl7.fhir.r4.model.CapabilityStatement) Measure(org.hl7.fhir.r4.model.Measure) Ratio(org.hl7.fhir.r4.model.Ratio) InstantType(org.hl7.fhir.r4.model.InstantType) DateType(org.hl7.fhir.r4.model.DateType) BooleanType(org.hl7.fhir.r4.model.BooleanType) Patient(org.hl7.fhir.r4.model.Patient) Period(org.hl7.fhir.r4.model.Period) Quantity(org.hl7.fhir.r4.model.Quantity) MeasureReport(org.hl7.fhir.r4.model.MeasureReport) Range(org.hl7.fhir.r4.model.Range) Date(java.util.Date) IntegerType(org.hl7.fhir.r4.model.IntegerType) Extension(org.hl7.fhir.r4.model.Extension) StringType(org.hl7.fhir.r4.model.StringType) IntegerType(org.hl7.fhir.r4.model.IntegerType) DateType(org.hl7.fhir.r4.model.DateType) TimeType(org.hl7.fhir.r4.model.TimeType) BooleanType(org.hl7.fhir.r4.model.BooleanType) UriType(org.hl7.fhir.r4.model.UriType) Type(org.hl7.fhir.r4.model.Type) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) Base64BinaryType(org.hl7.fhir.r4.model.Base64BinaryType) DecimalType(org.hl7.fhir.r4.model.DecimalType) CanonicalType(org.hl7.fhir.r4.model.CanonicalType) MeasurePopulationType(org.opencds.cqf.common.evaluation.MeasurePopulationType) InstantType(org.hl7.fhir.r4.model.InstantType) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) DecimalType(org.hl7.fhir.r4.model.DecimalType) Library(org.hl7.fhir.r4.model.Library) Base64BinaryType(org.hl7.fhir.r4.model.Base64BinaryType) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.Test)

Example 25 with Quantity

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

the class MeasureEvaluation method evaluate.

protected MeasureReport evaluate(Measure measure, Context context, List<Patient> patients, MeasureReport.MeasureReportType type, boolean isSingle, boolean includeEvaluatedResources) {
    MeasureReportBuilder reportBuilder = new MeasureReportBuilder();
    reportBuilder.buildStatus("complete");
    reportBuilder.buildType(type);
    reportBuilder.buildMeasureReference(measure.getIdElement().getResourceType() + "/" + measure.getIdElement().getIdPart());
    if (type == MeasureReport.MeasureReportType.INDIVIDUAL && CollectionUtils.isNotEmpty(patients)) {
        IdType patientId = patients.get(0).getIdElement();
        reportBuilder.buildPatientReference(patientId.getResourceType() + "/" + patientId.getIdPart());
    }
    reportBuilder.buildPeriod(measurementPeriod);
    MeasureReport report = reportBuilder.build();
    Map<String, Resource> resources = new HashMap<>();
    Map<String, Set<String>> codeToResourceMap = new HashMap<>();
    MeasureScoring measureScoring = MeasureScoring.fromCode(measure.getScoring().getCodingFirstRep().getCode());
    if (measureScoring == null) {
        throw new RuntimeException("Measure scoring is required in order to calculate.");
    }
    List<Measure.MeasureSupplementalDataComponent> sde = measure.getSupplementalData();
    Map<String, Map<String, Integer>> sdeAccumulators = new HashMap<>();
    for (Measure.MeasureGroupComponent group : measure.getGroup()) {
        MeasureReport.MeasureReportGroupComponent reportGroup = new MeasureReport.MeasureReportGroupComponent();
        reportGroup.setId(group.getId());
        report.getGroup().add(reportGroup);
        // Declare variables to avoid a hash lookup on every patient
        // TODO: Isn't quite right, there may be multiple initial populations for a
        // ratio measure...
        Measure.MeasureGroupPopulationComponent initialPopulationCriteria = null;
        Measure.MeasureGroupPopulationComponent numeratorCriteria = null;
        Measure.MeasureGroupPopulationComponent numeratorExclusionCriteria = null;
        Measure.MeasureGroupPopulationComponent denominatorCriteria = null;
        Measure.MeasureGroupPopulationComponent denominatorExclusionCriteria = null;
        Measure.MeasureGroupPopulationComponent denominatorExceptionCriteria = null;
        Map<String, Resource> initialPopulation = null;
        Map<String, Resource> numerator = null;
        Map<String, Resource> numeratorExclusion = null;
        Map<String, Resource> denominator = null;
        Map<String, Resource> denominatorExclusion = null;
        Map<String, Resource> denominatorException = null;
        Map<String, Patient> initialPopulationPatients = null;
        Map<String, Patient> numeratorPatients = null;
        Map<String, Patient> numeratorExclusionPatients = null;
        Map<String, Patient> denominatorPatients = null;
        Map<String, Patient> denominatorExclusionPatients = null;
        Map<String, Patient> denominatorExceptionPatients = null;
        for (Measure.MeasureGroupPopulationComponent pop : group.getPopulation()) {
            MeasurePopulationType populationType = MeasurePopulationType.fromCode(pop.getCode().getCodingFirstRep().getCode());
            if (populationType != null) {
                switch(populationType) {
                    case INITIALPOPULATION:
                        initialPopulationCriteria = pop;
                        initialPopulation = new HashMap<>();
                        if (type == MeasureReport.MeasureReportType.SUBJECTLIST) {
                            initialPopulationPatients = new HashMap<>();
                        }
                        break;
                    case NUMERATOR:
                        numeratorCriteria = pop;
                        numerator = new HashMap<>();
                        if (type == MeasureReport.MeasureReportType.SUBJECTLIST) {
                            numeratorPatients = new HashMap<>();
                        }
                        break;
                    case NUMERATOREXCLUSION:
                        numeratorExclusionCriteria = pop;
                        numeratorExclusion = new HashMap<>();
                        if (type == MeasureReport.MeasureReportType.SUBJECTLIST) {
                            numeratorExclusionPatients = new HashMap<>();
                        }
                        break;
                    case DENOMINATOR:
                        denominatorCriteria = pop;
                        denominator = new HashMap<>();
                        if (type == MeasureReport.MeasureReportType.SUBJECTLIST) {
                            denominatorPatients = new HashMap<>();
                        }
                        break;
                    case DENOMINATOREXCLUSION:
                        denominatorExclusionCriteria = pop;
                        denominatorExclusion = new HashMap<>();
                        if (type == MeasureReport.MeasureReportType.SUBJECTLIST) {
                            denominatorExclusionPatients = new HashMap<>();
                        }
                        break;
                    case DENOMINATOREXCEPTION:
                        denominatorExceptionCriteria = pop;
                        denominatorException = new HashMap<>();
                        if (type == MeasureReport.MeasureReportType.SUBJECTLIST) {
                            denominatorExceptionPatients = new HashMap<>();
                        }
                        break;
                    default:
                        throw new UnsupportedOperationException("Measure population, observation and measure population exclusion are used for continuous-variable scoring measures which are not supported");
                }
            }
        }
        switch(measureScoring) {
            case PROPORTION:
            case RATIO:
                {
                    // For each patient in the initial population
                    for (Patient patient : patients) {
                        // Are they in the initial population?
                        boolean inInitialPopulation = evaluatePopulationCriteria(context, patient, initialPopulationCriteria, initialPopulation, initialPopulationPatients, null, null, null);
                        populateResourceMap(context, MeasurePopulationType.INITIALPOPULATION, resources, codeToResourceMap, includeEvaluatedResources);
                        if (inInitialPopulation) {
                            // Are they in the denominator?
                            boolean inDenominator = evaluatePopulationCriteria(context, patient, denominatorCriteria, denominator, denominatorPatients, denominatorExclusionCriteria, denominatorExclusion, denominatorExclusionPatients);
                            populateResourceMap(context, MeasurePopulationType.DENOMINATOR, resources, codeToResourceMap, includeEvaluatedResources);
                            if (inDenominator) {
                                // Are they in the numerator?
                                boolean inNumerator = evaluatePopulationCriteria(context, patient, numeratorCriteria, numerator, numeratorPatients, numeratorExclusionCriteria, numeratorExclusion, numeratorExclusionPatients);
                                populateResourceMap(context, MeasurePopulationType.NUMERATOR, resources, codeToResourceMap, includeEvaluatedResources);
                                if (!inNumerator && inDenominator && (denominatorExceptionCriteria != null)) {
                                    // Are they in the denominator exception?
                                    boolean inException = false;
                                    for (Resource resource : evaluateCriteria(context, patient, denominatorExceptionCriteria)) {
                                        inException = true;
                                        denominatorException.put(resource.getIdElement().getIdPart(), resource);
                                        denominator.remove(resource.getIdElement().getIdPart());
                                        populateResourceMap(context, MeasurePopulationType.DENOMINATOREXCEPTION, resources, codeToResourceMap, includeEvaluatedResources);
                                    }
                                    if (inException) {
                                        if (denominatorExceptionPatients != null) {
                                            denominatorExceptionPatients.put(patient.getIdElement().getIdPart(), patient);
                                        }
                                        if (denominatorPatients != null) {
                                            denominatorPatients.remove(patient.getIdElement().getIdPart());
                                        }
                                    }
                                }
                            }
                        }
                        MeasureSupplementalDataEvaluation.populateSDEAccumulators(context, patient, sdeAccumulators, sde);
                    }
                    // Calculate actual measure score, Count(numerator) / Count(denominator)
                    if (numerator != null && MapUtils.isNotEmpty(denominator)) {
                        reportGroup.setMeasureScore(new Quantity(numerator.size() / (double) denominator.size()));
                    }
                    break;
                }
            case COHORT:
                {
                    // For each patient in the patient list
                    for (Patient patient : patients) {
                        evaluatePopulationCriteria(context, patient, initialPopulationCriteria, initialPopulation, initialPopulationPatients, null, null, null);
                        populateResourceMap(context, MeasurePopulationType.INITIALPOPULATION, resources, codeToResourceMap, includeEvaluatedResources);
                        MeasureSupplementalDataEvaluation.populateSDEAccumulators(context, patient, sdeAccumulators, sde);
                    }
                    break;
                }
            case CONTINUOUSVARIABLE:
                throw new UnsupportedOperationException("Scoring type CONTINUOUSVARIABLE is not supported");
        }
        // Add population reports for each group
        addPopulationCriteriaReport(report, reportGroup, initialPopulationCriteria, initialPopulation != null ? initialPopulation.size() : 0, initialPopulationPatients != null ? initialPopulationPatients.values() : null);
        addPopulationCriteriaReport(report, reportGroup, numeratorCriteria, numerator != null ? numerator.size() : 0, numeratorPatients != null ? numeratorPatients.values() : null);
        addPopulationCriteriaReport(report, reportGroup, numeratorExclusionCriteria, numeratorExclusion != null ? numeratorExclusion.size() : 0, numeratorExclusionPatients != null ? numeratorExclusionPatients.values() : null);
        addPopulationCriteriaReport(report, reportGroup, denominatorCriteria, denominator != null ? denominator.size() : 0, denominatorPatients != null ? denominatorPatients.values() : null);
        addPopulationCriteriaReport(report, reportGroup, denominatorExclusionCriteria, denominatorExclusion != null ? denominatorExclusion.size() : 0, denominatorExclusionPatients != null ? denominatorExclusionPatients.values() : null);
        addPopulationCriteriaReport(report, reportGroup, denominatorExceptionCriteria, denominatorException != null ? denominatorException.size() : 0, denominatorExceptionPatients != null ? denominatorExceptionPatients.values() : null);
    }
    for (Entry<String, Set<String>> entry : codeToResourceMap.entrySet()) {
        ListResource list = new ListResource();
        for (String element : entry.getValue()) {
            ListResource.ListEntryComponent comp = new ListEntryComponent();
            comp.setItem(new Reference('#' + element));
            list.addEntry(comp);
        }
        if (!list.isEmpty()) {
            list.setId(UUID.randomUUID().toString());
            list.setTitle(entry.getKey());
            resources.put(list.getId(), list);
        }
    }
    if (MapUtils.isNotEmpty(resources)) {
        List<Reference> evaluatedResourceIds = new ArrayList<>();
        resources.forEach((key, resource) -> {
            evaluatedResourceIds.add(new Reference(resource.getId()));
        });
        report.setEvaluatedResource(evaluatedResourceIds);
    }
    if (MapUtils.isNotEmpty(sdeAccumulators)) {
        report = MeasureSupplementalDataEvaluation.processAccumulators(report, sdeAccumulators, isSingle, patients);
    }
    return report;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) MeasureScoring(org.opencds.cqf.common.evaluation.MeasureScoring) ListEntryComponent(org.hl7.fhir.r4.model.ListResource.ListEntryComponent) Measure(org.hl7.fhir.r4.model.Measure) ListEntryComponent(org.hl7.fhir.r4.model.ListResource.ListEntryComponent) Reference(org.hl7.fhir.r4.model.Reference) MeasureReportBuilder(com.ibm.cohort.engine.r4.builder.MeasureReportBuilder) ListResource(org.hl7.fhir.r4.model.ListResource) Resource(org.hl7.fhir.r4.model.Resource) Patient(org.hl7.fhir.r4.model.Patient) Quantity(org.hl7.fhir.r4.model.Quantity) MeasureReport(org.hl7.fhir.r4.model.MeasureReport) IdType(org.hl7.fhir.r4.model.IdType) ListResource(org.hl7.fhir.r4.model.ListResource) HashMap(java.util.HashMap) Map(java.util.Map) MeasurePopulationType(org.opencds.cqf.common.evaluation.MeasurePopulationType)

Aggregations

Quantity (org.hl7.fhir.r4.model.Quantity)58 ArrayList (java.util.ArrayList)47 Test (org.junit.jupiter.api.Test)40 BigDecimal (java.math.BigDecimal)39 Quantity (org.hl7.fhir.dstu3.model.Quantity)39 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)37 Test (org.junit.Test)25 List (java.util.List)24 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)23 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)23 NotImplementedException (org.apache.commons.lang3.NotImplementedException)19 FHIRException (org.hl7.fhir.exceptions.FHIRException)18 PathEngineException (org.hl7.fhir.exceptions.PathEngineException)18 Observation (org.hl7.fhir.r4.model.Observation)18 UcumException (org.fhir.ucum.UcumException)16 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)16 Resource (org.hl7.fhir.r4.model.Resource)16 Quantity (org.hl7.fhir.r5.model.Quantity)16 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)15 Coding (org.hl7.fhir.r4.model.Coding)13