Bundle multiple related resources
A common use for FHIR bundle transactions is to persist a collection of related resources to a server. For example, if you have a collection of Observation resources with the same patient as subject, you could place them inside a single FHIR bundle transaction and send them together to a server.
The simplest way to send related resources in a single bundle is to use client-assigned IDs. When using this form, the server is instructed to use the IDs supplied in the requests. Any references between resources simply use these client-assigned IDs. Resources may also have references to other resources which already exist on the server.
Sample Transaction bundle with client-assigned ID on three resources: a patient, and two observations for this patient.
{
"resourceType": "Bundle",
"type": "transaction",
"entry": [ {
"fullUrl": "Patient/PTA",
"resource": {
"resourceType": "Patient",
"id": "PTA",
"identifier": [ {
"system": "http://acme.org/mrns",
"value": "013872"
} ],
"name": [ {
"family": "Simpson",
"given": [ "Homer" ]
} ]
},
"request": {
"method": "PUT",
"url": "Patient/PTA"
}
}, {
"fullUrl": "Observation/OB1",
"resource": {
"resourceType": "Observation",
"id": "OB1",
"status": "final",
"code": {
"coding": [ {
"system": "http://loinc",
"code": "29463-7",
"display": "Body Weight"
} ]
},
"subject": {
"reference": "Patient/PTA"
},
"effectiveDateTime": "2022-02-23",
"valueQuantity": {
"value": 67.1,
"unit": "kg",
"system": "http://unitsofmeasure.org",
"code": "kg"
}
},
"request": {
"method": "PUT",
"url": "Observation/OB1"
}
}, {
"fullUrl": "Observation/OB2",
"resource": {
"resourceType": "Observation",
"id": "OB2",
"status": "final",
"code": {
"coding": [ {
"system": "http://loinc",
"code": "29463-7",
"display": "Body Weight"
} ]
},
"subject": {
"reference": "Patient/PTA"
},
"effectiveDateTime": "2019-12-29",
"valueQuantity": {
"value": 72.4,
"unit": "kg",
"system": "http://unitsofmeasure.org",
"code": "kg"
}
},
"request": {
"method": "PUT",
"url": "Observation/OB2"
}
} ]
}
Parent topic: FHIR Bundle transactions and batches