Search in sources :

Example 6 with BundleEntryRequestComponent

use of org.hl7.fhir.r4.model.Bundle.BundleEntryRequestComponent in project geoprism-registry by terraframe.

the class ListTypeFhirExporter method createEntries.

private static void createEntries(Bundle bundle, Facility facility, Identifier identifier) {
    Resource[] resources = new Resource[] { facility.getOrganization(), facility.getLocation() };
    for (Resource resource : resources) {
        IdType resourceID = resource.getIdElement();
        BundleEntryComponent entry = bundle.addEntry();
        entry.setFullUrl(resource.fhirType() + "/" + resourceID.getIdPart());
        entry.setResource(resource);
        BundleEntryRequestComponent request = entry.getRequest();
        request.setMethod(HTTPVerb.PUT);
        request.setUrl(resource.getResourceType().name() + "?identifier=" + identifier.getSystem() + "|" + identifier.getValue());
        entry.setRequest(request);
    }
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) BundleEntryRequestComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryRequestComponent) Resource(org.hl7.fhir.r4.model.Resource) IdType(org.hl7.fhir.r4.model.IdType)

Example 7 with BundleEntryRequestComponent

use of org.hl7.fhir.r4.model.Bundle.BundleEntryRequestComponent in project pathling by aehrc.

the class TranslateMapping method toRequestBundle.

/**
 * Converts {@link TerminologyService#translate} parameters to a batch request Bundle.
 *
 * @param codings The list of codings to be translated
 * @param conceptMapUrl The concept map url
 * @param reverse If reverse translation is required
 * @return The batch Bundle for the requested parameters
 */
@Nonnull
public static Bundle toRequestBundle(@Nonnull final Iterable<SimpleCoding> codings, @Nonnull final String conceptMapUrl, final boolean reverse) {
    final Bundle translateBatch = new Bundle();
    translateBatch.setType(BundleType.BATCH);
    codings.forEach(coding -> {
        final BundleEntryComponent entry = translateBatch.addEntry();
        final BundleEntryRequestComponent request = entry.getRequest();
        request.setMethod(HTTPVerb.POST);
        request.setUrl("ConceptMap/$translate");
        final Parameters parameters = new Parameters();
        entry.setResource(parameters);
        parameters.addParameter().setName("url").setValue(new UriType(conceptMapUrl));
        parameters.addParameter("reverse", reverse);
        parameters.addParameter().setName("coding").setValue(coding.toCoding());
    });
    return translateBatch;
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) BundleEntryRequestComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryRequestComponent) Nonnull(javax.annotation.Nonnull)

Example 8 with BundleEntryRequestComponent

use of org.hl7.fhir.r4.model.Bundle.BundleEntryRequestComponent in project pathling by aehrc.

the class BatchProvider method processEntry.

private void processEntry(final Map<ResourceType, List<IBaseResource>> resourcesForUpdate, final Bundle response, final BundleEntryComponent entry) {
    final Resource resource = entry.getResource();
    final BundleEntryRequestComponent request = entry.getRequest();
    if (resource == null || request == null || request.isEmpty()) {
        return;
    }
    checkUserInput(request.getMethod().toString().equals("PUT"), "Only update requests are supported for use within the batch operation");
    final String urlErrorMessage = "The URL for an update request must refer to the code of a " + "supported resource type, and must look like this: [resource type]/[id]";
    checkUserInput(UPDATE_URL.matcher(request.getUrl()).matches(), urlErrorMessage);
    final List<String> urlComponents = List.of(request.getUrl().split("/"));
    checkUserInput(urlComponents.size() == 2, urlErrorMessage);
    final String resourceTypeCode = urlComponents.get(0);
    final String urlId = urlComponents.get(1);
    final ResourceType resourceType = validateResourceType(entry, resourceTypeCode, urlErrorMessage);
    final IBaseResource preparedResource = prepareResourceForUpdate(resource, urlId);
    addToResourceMap(resourcesForUpdate, resourceType, preparedResource);
    addResponse(response, preparedResource);
}
Also used : BundleEntryRequestComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryRequestComponent) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Resource(org.hl7.fhir.r4.model.Resource) ResourceType(org.hl7.fhir.r4.model.Enumerations.ResourceType) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource)

Example 9 with BundleEntryRequestComponent

use of org.hl7.fhir.r4.model.Bundle.BundleEntryRequestComponent in project CRD by HL7-DaVinci.

the class QueryBatchRequest method buildQueryBatchRequestBundle.

/**
 * Builds a query batch request bundle based on the given references to request.
 *
 * @param resourceReferences
 * @return
 */
private static Bundle buildQueryBatchRequestBundle(List<String> resourceReferences) {
    // http://build.fhir.org/ig/HL7/davinci-crd/hooks.html#fhir-resource-access
    Bundle queryBatchBundle = new Bundle();
    queryBatchBundle.setType(BundleType.BATCH);
    for (String reference : resourceReferences) {
        if (reference.contains(PRACTIONER_ROLE)) {
            reference = QueryBatchRequest.buildPractionerRoleQuery(reference);
        }
        BundleEntryComponent entry = new BundleEntryComponent();
        BundleEntryRequestComponent request = new BundleEntryRequestComponent();
        request.setMethod(HTTPVerb.GET);
        request.setUrl(reference);
        entry.setRequest(request);
        queryBatchBundle.addEntry(entry);
    }
    return queryBatchBundle;
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) BundleEntryRequestComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryRequestComponent) Bundle(org.hl7.fhir.r4.model.Bundle)

Aggregations

BundleEntryRequestComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryRequestComponent)6 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)5 Resource (org.hl7.fhir.r4.model.Resource)3 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)2 Bundle (org.hl7.fhir.r4.model.Bundle)2 CommaSeparatedStringBuilder (org.hl7.fhir.utilities.CommaSeparatedStringBuilder)2 Operation (ca.uhn.fhir.rest.annotation.Operation)1 IVersionSpecificBundleFactory (ca.uhn.fhir.rest.api.IVersionSpecificBundleFactory)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Nonnull (javax.annotation.Nonnull)1 BundleEntryComponent (org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent)1 BundleEntryRequestComponent (org.hl7.fhir.dstu3.model.Bundle.BundleEntryRequestComponent)1 Identifier (org.hl7.fhir.dstu3.model.Identifier)1 Property (org.hl7.fhir.dstu3.model.Property)1 HTTPVerb (org.hl7.fhir.r4.model.Bundle.HTTPVerb)1 HTTPVerbEnumFactory (org.hl7.fhir.r4.model.Bundle.HTTPVerbEnumFactory)1 Enumeration (org.hl7.fhir.r4.model.Enumeration)1 ResourceType (org.hl7.fhir.r4.model.Enumerations.ResourceType)1 IdType (org.hl7.fhir.r4.model.IdType)1