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);
}
}
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;
}
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);
}
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;
}
Aggregations