Patch
Updating a part of your resource
In most 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.
With the patch
operation, you can update a part of a resource by sending a declarative description of operations that should be performed on an existing resource. To describe these 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);
Patch Method
You can specify a patch
method by the content-type
header or by the _method
parameter.
method | parameter | header |
---|---|---|
json-patch |
| application/json-patch+json |
merge-patch |
| application/merge-patch+json |
If the method is not specified, Aidbox will try to guess it by the following algorithm:
if the payload is an array —
json-patch
else
merge-patch
Operation Description
Patch Operation
PATCH
[base-url]/<resourceType>/<id>
Path Parameters
Name | Type | Description |
---|---|---|
_method | string |
or
|
Headers
Name | Type | Description |
---|---|---|
content-type | string | See the
header in the table above |
Request Body
JSON or YAML representation of transformation rules in accordance with_method
Example
You can exercise this tutorial using REST Console — just copy/paste queries into your console!
Let's suppose we've created a Patient resource with the id pt-1
You can copy/paste this request into REST Console of Aidbox.Cloud.
Merge Patch
Let's say we want to switch to an active
flag to false and remove telecom
:
JSON Patch
With JSON patch, we can do more sophisticated transformations — change the first given
name, delete the second name
, and change the active
attribute value to true
:
Response:
Last updated