All examples can be run in Postman. Here's web view of these examples.
For most of Operations in FHIR you manipulate a resource as a whole (create, update, delete operations). But sometimes you want to update specific data elements in a resource and do not care about the rest. In other words, you need an element/attribute level operation.
patch operation you can update a part of resource by sending a declarative description of operations which should be performed on an existing resource. To describe this operations in Aidbox you can use different notations (methods):
merge-patch — simple merge semantics (read more in RFC);
json-patch — advanced JSON transformation (read more in RFC);
You can specify a
patch method by the
content-type header or by the
If method is not specified, Aidbox will try to guess it by the following algorithm:
if the payload is an array —
fhir-patchin the future)
content-typeheader in the table above
Let's suppose we've created a Patient resource with the id
POST /PatientresourceType: Patientid: pt-1active: truename:- given: ['John']family: Doeuse: official- given: ['Johny']family: Doetelecom:- system: phonevalue: '(03) 5555 6473'use: workrank: 1birthDate: '1979-01-01'# 200id: pt-1resourceType: Patientname:- use: officialgiven:- Johnfamily: Doe- given:- Johnyfamily: Doeactive: truetelecom:- use: workrank: 1value: "(03) 5555 6473"system: phonebirthDate: '1979-01-01'
Let's say we want to switch
active flag to false and remove
PATCH /Patient/pt-1?_method=merge-patchactive: falsetelecom: null# 200id: pt-1resourceType: Patientname:- use: officialgiven:- Johnfamily: Doe- given:- Johnyfamily: Doeactive: falsebirthDate: '1979-01-01'
With JSON patch, we can do more sophisticated transformations — change first
given name, delete second
name, and change the
active attribute value to
PATCH /Patient/pt-1- op: replacepath: '/name/0/given/0'value: Nikolai- op: removepath: '/name/1'- op: replacepath: '/active'value: true# 200# response 200id: pt-1resourceType: Patientname:- use: officialgiven:- Nikolaifamily: Doeactive: truebirthDate: '1979-01-01'