Conditional Create
The FHIR Conditional Create mechanism allows the client to specify a FHIR search URL alongside a resource to create. When processing the create, the server will first check if any resource already exists matching the given search. If no resources match, the create proceeds. If a resource does match, no resource is created.
In a standard REST mechanism, conditional creates place the search URL in the In-None-Exist request header. In a FHIR bundle transaction, this URL goes in Bundle.entry.request.ifNoneExist. Like a normal create, we use the HTTP method/verb of POST.
For example:
{
"resourceType": "Bundle",
"type": "transaction",
"entry": [ {
"fullUrl": "urn:uuid:95dbbf93-5829-46ba-9021-2545a1da3aa5", > Placeholder ID for Patient
"resource": {
"resourceType": "Patient",
"identifier": [ {
"system": "http://acme.org/mrns",
"value": "013872"
} ],
"name": [ {
"family": "Simpson",
"given": [ "Homer" ]
} ]
},
"request": {
"method": "POST",
"url": "Patient",
"ifNoneExist": "Patient?identifier=http://acme.org/mrns|013872" > Search URL for Conditional Create
}
}, {
"fullUrl": "urn:uuid:124ff3c8-f251-4bd9-8c44-cc6568180eae",
"resource": {
"resourceType": "Observation",
"identifier": [ {
"system": "http://acme.org/obs",
"value": "46252"
} ],
"status": "final",
"code": {
"coding": [ {
"system": "http://loinc",
"code": "29463-7",
"display": "Body Weight"
} ]
},
"subject": {
"reference": "urn:uuid:95dbbf93-5829-46ba-9021-2545a1da3aa5" > Reference to Patient Placeholder ID
},
"effectiveDateTime": "2022-02-23",
"valueQuantity": {
"value": 67.1,
"unit": "kg",
"system": "http://unitsofmeasure.org",
"code": "kg"
}
},
"request": {
"method": "POST",
"url": "Observation",
"ifNoneExist": "Observation?identifier=http://acme.org/obs|46252" > Search URL for Conditional Create
}
} ]
}
Parent topic: FHIR Bundle transactions and batches