Search in sources :

Example 1 with COLLECTION

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);
}
Also used : DaoRegistryOperationProvider(org.opencds.cqf.ruler.provider.DaoRegistryOperationProvider) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) Operation(ca.uhn.fhir.rest.annotation.Operation) Reference(org.hl7.fhir.r4.model.Reference) ArrayList(java.util.ArrayList) RequestDetails(ca.uhn.fhir.rest.api.server.RequestDetails) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) MeasureResourceProvider(ca.uhn.fhir.jpa.rp.r4.MeasureResourceProvider) Map(java.util.Map) OperationParam(ca.uhn.fhir.rest.annotation.OperationParam) Group(org.hl7.fhir.r4.model.Group) Logger(org.slf4j.Logger) IVersionSpecificBundleFactory(ca.uhn.fhir.rest.api.IVersionSpecificBundleFactory) COLLECTION(ca.uhn.fhir.model.valueset.BundleTypeEnum.COLLECTION) DOCUMENT(org.hl7.fhir.r4.model.Bundle.BundleType.DOCUMENT) ListResource(org.hl7.fhir.r4.model.ListResource) Composition(org.hl7.fhir.r4.model.Composition) Collectors(java.util.stream.Collectors) IdType(org.hl7.fhir.r4.model.IdType) Searches(org.opencds.cqf.ruler.utility.Searches) ResourceType(org.hl7.fhir.r4.model.ResourceType) List(java.util.List) MeasureReport(org.hl7.fhir.r4.model.MeasureReport) Bundle(org.hl7.fhir.r4.model.Bundle) Composition(org.hl7.fhir.r4.model.Composition) HashMap(java.util.HashMap) Bundle(org.hl7.fhir.r4.model.Bundle) Reference(org.hl7.fhir.r4.model.Reference) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

MeasureResourceProvider (ca.uhn.fhir.jpa.rp.r4.MeasureResourceProvider)1 COLLECTION (ca.uhn.fhir.model.valueset.BundleTypeEnum.COLLECTION)1 Operation (ca.uhn.fhir.rest.annotation.Operation)1 OperationParam (ca.uhn.fhir.rest.annotation.OperationParam)1 IVersionSpecificBundleFactory (ca.uhn.fhir.rest.api.IVersionSpecificBundleFactory)1 RequestDetails (ca.uhn.fhir.rest.api.server.RequestDetails)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)1 Bundle (org.hl7.fhir.r4.model.Bundle)1 DOCUMENT (org.hl7.fhir.r4.model.Bundle.BundleType.DOCUMENT)1 Composition (org.hl7.fhir.r4.model.Composition)1 Group (org.hl7.fhir.r4.model.Group)1 IdType (org.hl7.fhir.r4.model.IdType)1 ListResource (org.hl7.fhir.r4.model.ListResource)1 MeasureReport (org.hl7.fhir.r4.model.MeasureReport)1 Reference (org.hl7.fhir.r4.model.Reference)1