Transactions
As stated previously, transaction bundles are atomic, meaning that if one action fails, all actions will fail. Additionally, transaction bundles allow you to reference resources that have been created in the same transaction. Meaning you can create a Patient and then reference that Patient in a Practitioner (or other resource within the Bundle).
Resolving entry dependencies
To reference a resource that has been created in the same transaction, you must use the fullUrl
property on the entry.
This property is used to reference the resource in the same transaction. The following example will demonstrate how to reference a resource in the same transaction.
Example
In this example, we will create two resources: a Patient and a Practitioner. The Patient will reference the Practitioner created in this transaction using the fullUrl
property.
This reference will be stored in the Patient's generalPractitioner
property.
- Request
- Response
{
"resourceType": "Bundle",
"type": "transaction",
"entry": [
{
"fullUrl": "urn:oid:2",
"request": {
"method": "POST",
"url": "Patient"
},
"resource": {
"resourceType": "Patient",
"generalPractitioner": [
{
"reference": "urn:oid:1"
}
]
}
},
{
"fullUrl": "urn:oid:1",
"request": {
"method": "POST",
"url": "Practitioner"
},
"resource": {
"resourceType": "Practitioner",
"name": [
{
"given": ["Bob"]
}
]
}
}
]
}
{
"resourceType": "Bundle",
"type": "transaction-response",
"entry": [
{
"response": {
"status": "201",
"location": "Patient/c5eb209c-65b6-4ab2-831d-ff06cf4122f2"
},
"resource": {
"id": "c5eb209c-65b6-4ab2-831d-ff06cf4122f2",
"meta": {
"extension": [
{
"url": "https://iguhealth.app/version-sequence",
"valueInteger": 160
},
{
"url": "https://iguhealth.app/author",
"valueString": "public-user"
}
],
"versionId": "160",
"lastUpdated": "2023-10-19T21:47:38.329+00:00"
},
"resourceType": "Patient",
"generalPractitioner": [
{
"reference": "Practitioner/7140f899-446d-4495-8d82-70565a452bd3"
}
]
}
},
{
"response": {
"status": "201",
"location": "Practitioner/7140f899-446d-4495-8d82-70565a452bd3"
},
"resource": {
"id": "7140f899-446d-4495-8d82-70565a452bd3",
"meta": {
"extension": [
{
"url": "https://iguhealth.app/version-sequence",
"valueInteger": 159
},
{
"url": "https://iguhealth.app/author",
"valueString": "public-user"
}
],
"versionId": "159",
"lastUpdated": "2023-10-19T21:47:38.329+00:00"
},
"name": [
{
"given": ["Bob"]
}
],
"resourceType": "Practitioner"
}
}
]
}
Limitations
We currently limit transaction bundle size to 20 entries. This is to prevent users from submitting large transactions that may take a long time to process.