Patching data

You can patch data to make a small change to a resource without needing to re-upload the entire content. For example, a resource status field might be changed by an application with no other changes needed.

Oracle HDR FHIR support the following syntaxes:

  • FHIR Patch—This is the most expressive syntax for patching and is recommended for use. It uses a format described in the FHIR specification as FHIR Patch.
  • JSON Patch—This syntax expresses a change set in JSON using RFC 6902.

Patch using FHIR Patch

The FHIR Patch format can be used to specify rules for inserting, modifying, and removing data from FHIR resources. See FHIR Patch for details about the format.

Example: FHIR Patch used to update a patient birth date

The following example shows a FHIR Patch being used to update a patient birth date.

Table 11-5 FHIR Patch to update patient birth date

Category Description
HTTP Method PATCH
Content-Type application/fhir+json
URL http(s)://HOSTNAME:PORT/oracle-fhir-server/fhir/Patient/123/
Request Body
{
  "resourceType": "Parameters",
  "parameter": [ {
    "name": "operation",
    "part": [ {
      "name": "type",
      "valueCode": "replace"
    }, {
      "name": "path",
      "valueString": "Patient.birthDate"
    }, {
      "name": "value",
      "valueDate": "1975-09-09"
    } ]
  } ]
}

Example: FHIR Patch as part of FHIR transaction

A FHIR Patch may also be submitted as a part of a FHIR transaction.

Table 11-6 FHIR Patch as part of FHIR transaction

Category Description
HTTP Method POST
Content-Type application/fhir+json
URL http(s)://HOSTNAME:PORT/oracle-fhir-server/fhir/
Request Body
{
  "resourceType": "Bundle",
  "type": "transaction",
  "entry": [ {
    "fullUrl": "Patient/123",
    "resource": {
      "resourceType": "Parameters",
      "parameter": [ {
        "name": "operation",
        "part": [ {
          "name": "type",
          "valueCode": "replace"
        }, {
          "name": "path",
          "valueString": "Patient.birthDate"
        }, {
          "name": "value",
          "valueDate": "1930-01-01"
        } ]
      } ]
    },
    "request": {
      "method": "PATCH",
      "url": "Patient/123"
    }
  } ]
}

Example: Patch Using JSONPatch

The following example shows a JSONPatch being used to update an Observation status:

Table 11-7 Patch Using JSONPatch

Category Description
HTTP Method PATCH
Content-Type application/json-patch+json
URL http(s)://HOSTNAME:PORT/oracle-fhir-server/fhir/Observation/123
Request Body
[
 { 
   "op": "replace", 
   "path": "/status", 
   "value": "in-progress" 
 }
]

Note:

If you are using "op": "add", you need to suffix the path with /- (e.g. "path": "/identifier/-").

Example: JSONPatch also be submitted as a part of a FHIR transaction

A JSONPatch may also be submitted as a part of a FHIR transaction using a Binary resource as the payload in order to update the contents.

Table 11-8 JSONPatch submitted as part of a FHIR transaction

Category Description
HTTP Method POST
Content-Type application/fhir+json
URL http(s)://HOSTNAME:PORT/oracle-fhir-server/fhir/
Request Body
{
  "resourceType": "Bundle",
  "type": "transaction",
  "entry": [
    {
      "fullUrl": "Patient/1",
      "resource": {
        "resourceType": "Binary",
        "contentType": "application/json-patch+json",
        "data": "WyB7ICJvcCI6InJlcGxhY2UiLCAicGF0aCI6Ii9hY3RpdmUiLCAidmFsdWUiOmZhbHNlIH0gXQ=="
      },
      "request": {
        "method": "PATCH",
        "url": "Patient/1"
      }
    }
  ]
}