Search in sources :

Example 1 with FhirUtil

use of org.hl7.gravity.refimpl.sdohexchange.util.FhirUtil in project Gravity-SDOH-Exchange-RI by FHIR.

the class ResourceLoader method getResources.

public Map<Class<? extends Resource>, List<Resource>> getResources(IGenericClient client, List<Reference> references) {
    if (references.isEmpty()) {
        return Collections.emptyMap();
    }
    Bundle loadResourcesBundle = new Bundle();
    loadResourcesBundle.setType(BundleType.TRANSACTION);
    references.stream().map(BaseReference::getReferenceElement).map(element -> element.getResourceType() + "/" + element.getIdPart()).map(FhirUtil::createGetEntry).forEach(loadResourcesBundle::addEntry);
    return client.transaction().withBundle(loadResourcesBundle).execute().getEntry().stream().map(BundleEntryComponent::getResource).filter(Objects::nonNull).collect(Collectors.groupingBy(Resource::getClass));
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Bundle(org.hl7.fhir.r4.model.Bundle)

Aggregations

Bundle (org.hl7.fhir.r4.model.Bundle)1 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)1