use of ca.uhn.fhir.model.valueset.BundleTypeEnum.COLLECTION in project cqf-ruler by DBCG.
the class MeasureDataProcessProvider method gatherEicrs.
private void gatherEicrs(IVersionSpecificBundleFactory bundleFactory, Map<String, Reference> populationSubjectListReferenceMap) {
Map<String, Bundle> eicrs = new HashMap<>();
List<Bundle> documentBundles = search(Bundle.class, Searches.all()).getAllResourcesTyped().stream().filter(x -> x.hasEntry() && DOCUMENT.equals(x.getType())).collect(Collectors.toList());
for (Bundle bundle : documentBundles) {
IBaseResource firstResource = bundle.getEntryFirstRep().getResource();
if (!(firstResource instanceof Composition)) {
logger.debug("Any bundle of type document must have the first entry of type Composition, but found: {}", firstResource);
continue;
}
Composition composition = (Composition) firstResource;
Reference compositionSubject = composition.getSubject();
String[] referenceSplit = compositionSubject.getReference().split("/");
for (Map.Entry<String, Reference> entry : populationSubjectListReferenceMap.entrySet()) {
if (compositionSubject.equals(entry.getValue()) || compositionSubject.getReference().equals(entry.getKey()) || (referenceSplit.length > 1 && referenceSplit[1].equals(entry.getKey()))) {
eicrs.putIfAbsent(entry.getKey(), bundle);
}
}
}
bundleFactory.addResourcesToBundle(eicrs.values().stream().collect(Collectors.toList()), COLLECTION, null, null, null);
}
Aggregations