Skip to content

Commit

Permalink
Merge pull request #262 from DBCG/fix-measure-evaluated-resources
Browse files Browse the repository at this point in the history
Fix Measure Report Evaluated Resources.
  • Loading branch information
JPercival authored Oct 6, 2020
2 parents df2359d + a72f949 commit 85ef292
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
package org.opencds.cqf.dstu3.evaluation;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.UUID;
import java.util.*;
import java.util.stream.Collectors;

import org.cqframework.cql.elm.execution.ExpressionDef;
Expand Down Expand Up @@ -278,6 +272,7 @@ private MeasureReport evaluate(Measure measure, Context context, List<Patient> p

HashMap<String, Resource> resources = new HashMap<>();
HashMap<String, HashSet<String>> codeToResourceMap = new HashMap<>();
Set<String> evaluatedResourcesList = new HashSet<>();

MeasureScoring measureScoring = MeasureScoring.fromCode(measure.getScoring().getCodingFirstRep().getCode());
if (measureScoring == null) {
Expand Down Expand Up @@ -545,16 +540,17 @@ private MeasureReport evaluate(Measure measure, Context context, List<Patient> p
}

if (!list.isEmpty()) {
list.setId(UUID.randomUUID().toString());
list.setId("List/" + UUID.randomUUID().toString());
list.setTitle(key);
resources.put(list.getId(), list);
list.getEntry().forEach(listResource -> evaluatedResourcesList.add(listResource.getItem().getReference()));
}
}

if (!resources.isEmpty()) {
List<Reference> evaluatedResourceIds = new ArrayList<>();
resources.forEach((key, resource) -> {
evaluatedResourceIds.add(new Reference(resource.getId()));
evaluatedResourcesList.forEach((resource) -> {
evaluatedResourceIds.add(new Reference(resource));
});

// TODO: DSTU3 Doesn't support this..
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
package org.opencds.cqf.r4.evaluation;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.UUID;
import java.util.*;
import java.util.stream.Collectors;

import org.cqframework.cql.elm.execution.ExpressionDef;
Expand Down Expand Up @@ -280,6 +274,7 @@ private MeasureReport evaluate(Measure measure, Context context, List<Patient> p

HashMap<String, Resource> resources = new HashMap<>();
HashMap<String, HashSet<String>> codeToResourceMap = new HashMap<>();
Set<String> evaluatedResourcesList = new HashSet<>();

MeasureScoring measureScoring = MeasureScoring.fromCode(measure.getScoring().getCodingFirstRep().getCode());
if (measureScoring == null) {
Expand Down Expand Up @@ -545,26 +540,21 @@ private MeasureReport evaluate(Measure measure, Context context, List<Patient> p
}

if (!list.isEmpty()) {
list.setId(UUID.randomUUID().toString());
list.setId("List/" + UUID.randomUUID().toString());
list.setTitle(key);
resources.put(list.getId(), list);
list.getEntry().forEach(listResource -> evaluatedResourcesList.add(listResource.getItem().getReference()));
}
}

if (!resources.isEmpty()) {
if (!evaluatedResourcesList.isEmpty()) {
List<Reference> evaluatedResourceIds = new ArrayList<>();
resources.forEach((key, resource) -> {
evaluatedResourceIds.add(new Reference(resource.getId()));
evaluatedResourcesList.forEach((resource) -> {
evaluatedResourceIds.add(new Reference(resource));
});
report.setEvaluatedResource(evaluatedResourceIds);
/*
FhirMeasureBundler bundler = new FhirMeasureBundler();
org.hl7.fhir.r4.model.Bundle evaluatedResources = bundler.bundle(resources.values());
evaluatedResources.setId(UUID.randomUUID().toString());
report.setEvaluatedResource(Collections.singletonList(new Reference(evaluatedResources.getId())));
report.addContained(evaluatedResources);
*/
}

if (sdeAccumulators.size() > 0) {
report = processAccumulators(report, sdeAccumulators, sde, isSingle, patients);
}
Expand Down

0 comments on commit 85ef292

Please sign in to comment.