Patching
SanteDB's REST API supports patching of resources. Patching follows IETF RFC 5789 pattern and has the following rules:
The patch must be applied to a specific instance of a resource
The patch must include the If-Match header with the etag of the last version the client has (and wishes to patch)
Constructing a Patch
The format of a patch in SanteDB is illustrated below:
For example, if we wanted to replace the Legal name of a patient, the patch would be as follows:
Alternately you can simply identify a specific instance to be removed by substituting the use qualifier with a UUID:
Which removes a name with ID : 9fdb557d-2e2f-4fe5-a193-e1cf8cf49bc4 from the patient's name list then replaces it.
You can also patch using JSON, for example, the following patch will remove the tag "favoriteColour" and replace it:
Dealing with Conflicts
You can assert that particular values are present or true prior to performing your patch, additionally the SanteDB service will assert on the etag of the If-Match
header. For example, this patch will change the gender of the patient from MALE to FEMALE, but will only succeed if the etag matches e15be5a372b742ccac35518df7c9a784
and the gender is currently MALE.
If the server does not have the same copy of the patient, then an HTTP 409 (CONFLICT) is returned to the caller.
You may override (or force) the patch to occur by using these sets of headers:
Which will bypass the outcomes of checks.
It is best practice to not append the X-Patch-Force header unless a human is indicating that they would like to force the the patch to succeed.
Difference Operation
You can submit an object to the SanteDB API to get a "diff" of two objects. This operation is invoked using the $diff
operation on the desired instance of the type. For example, to see the instructions it would take to turn patent 9fdb557d-2e2f-4fe5-a193-e1cf8cf49bc4
to 1c8c9aa3-abb8-48ee-992d-8f0c524ce40c
submitting the following request.
Last updated