Bundling FHIR resources - AWS HealthLake

Bundling FHIR resources

A FHIR Bundle is a container for a collection of FHIR resources in AWS HealthLake. Bundling is performed using a batch interaction in one of the following ways:

  • FHIR resource changes are processed and logged as independent entities.

  • FHIR resource changes are processed and logged as a single entity.

You can bundle FHIR resources of the same or different types, and they can include a mix of other FHIR interactions defined in this chapter (e.g. create, read, update, delete, and search). For additional information, see Resource Bundle in the FHIR R4 documentation.

Bundling FHIR resources as independent entities

To bundle FHIR resources as independent entities

  1. Collect HealthLake region and datastoreId values. For more information, see Getting data store properties.

  2. Construct a URL for the request using the collected values for HealthLake region and datastoreId. Do not specify a FHIR resource type in the URL. To view the entire URL path in the following example, scroll over the Copy button.

    POST https://healthlake.region.amazonaws.com/datastore/datastoreId/r4/
  3. Construct a JSON body for the request, specifying each HTTP verb as part of the method elements. The following example uses a batch type interaction with the Bundle resource to create new Patient and Medication resources. All required sections are commented accordingly. For the purpose of this procedure, save the file as batch-independent.json.

    { "resourceType": "Bundle", "id": "bundle-batch", "meta": { "lastUpdated": "2014-08-18T01:43:30Z" }, "type": "batch", "entry": [ { "resource": { "resourceType": "Patient", "meta": { "lastUpdated": "2022-06-03T17:53:36.724Z" }, "text": { "status": "generated", "div": "Some narrative" }, "active": true, "name": [ { "use": "official", "family": "Jackson", "given": [ "Mateo", "James" ] } ], "gender": "male", "birthDate": "1974-12-25" }, "request": { "method": "POST", "url": "Patient" } }, { "resource": { "resourceType": "Medication", "id": "med0310", "contained": [ { "resourceType": "Substance", "id": "sub03", "code": { "coding": [ { "system": "http://snomed.info/sct", "code": "55452001", "display": "Oxycodone (substance)" } ] } } ], "code": { "coding": [ { "system": "http://snomed.info/sct", "code": "430127000", "display": "Oral Form Oxycodone (product)" } ] }, "form": { "coding": [ { "system": "http://snomed.info/sct", "code": "385055001", "display": "Tablet dose form (qualifier value)" } ] }, "ingredient": [ { "itemReference": { "reference": "#sub03" }, "strength": { "numerator": { "value": 5, "system": "http://unitsofmeasure.org", "code": "mg" }, "denominator": { "value": 1, "system": "http://terminology.hl7.org/CodeSystem/v3-orderableDrugForm", "code": "TAB" } } } ] }, "request": { "method": "POST", "url": "Medication" } } ] }
  4. Send the request. The FHIR Bundle batch type uses a POST request with either AWS Signature Version 4 or SMART on FHIR authorization. The following code example uses the curl command line tool for demonstration purposes.

    curl

    SigV4 authorization

    curl --request POST \ 'https://healthlake.region.amazonaws.com/datastore/datastoreId/r4/ \ --aws-sigv4 'aws:amz:region:healthlake' \ --user "$AWS_ACCESS_KEY_ID:$AWS_SECRET_ACCESS_KEY" \ --header "x-amz-security-token:$AWS_SESSION_TOKEN" \ --header 'Accept: application/json' \ --data @batch-type.json

    The server returns a response showing the Patient and Medication resources created as a result of the Bundle batch type request.

Bundling FHIR resources as a single entity

To bundle FHIR resources as a single entity

  1. Collect HealthLake region and datastoreId values. For more information, see Getting data store properties.

  2. Construct a URL for the request using the collected values for HealthLake region and datastoreId. Include the FHIR resource type Bundle as part of the URL. To view the entire URL path in the following example, scroll over the Copy button.

    POST https://healthlake.region.amazonaws.com/datastore/datastoreId/r4/Bundle
  3. Construct a JSON body for the request, specifying the FHIR resources to group together. The following example groups two Patient resources in HealthLake. For the purpose of this procedure, save the file as batch-single.json.

    { "resourceType": "Bundle", "id": "bundle-batch", "meta": { "lastUpdated": "2018-03-11T11:22:16Z" }, "type": "document", "entry": [ { "resource": { "resourceType": "Patient", "name": [ { "family": "Smith", "given": [ "Jane" ] } ], "gender": "female", "address": [ { "line": [ "123 Main St." ], "city": "Anycity", "state": "Any State", "postalCode": "12345" } ] } }, { "resource": { "resourceType": "Patient", "name": [ { "family": "Jackson", "given": [ "Mateo" ] } ], "gender": "male", "address": [ { "line": [ "1234 Main St." ], "city": "Anycity", "state": "Any State", "postalCode": "12345" } ] } } ] }
  4. Send the request. The FHIR Bundle document type uses a POST request with AWS Signature Version 4 signing protocol. The following code example uses the curl command line tool for demonstration purposes.

    curl

    SigV4 authorization

    curl --request POST \ 'https://healthlake.region.amazonaws.com/datastore/datastoreId/r4/Bundle \ --aws-sigv4 'aws:amz:region:healthlake' \ --user "$AWS_ACCESS_KEY_ID:$AWS_SECRET_ACCESS_KEY" \ --header "x-amz-security-token:$AWS_SESSION_TOKEN" \ --header 'Accept: application/json' \ --data @document-type.json

    The server returns a response showing two Patient resources created as a result of the Bundle document type request.