Patch Resource
CRUD Operations
Patch Resource
Partially update a FHIR resource using JSON Patch
PATCH
Patch Resource
Applies partial modifications to a resource without replacing it entirely. Unlike PUT, only the specified fields are changed.
Supported Operations:
Endpoint
The FHIR resource type (e.g.,
Patient, Observation, Encounter)The logical ID of the resource to patch
Headers
Patch format:
application/json-patch+json- JSON Patch (RFC 6902)application/fhir+json- FHIRPath Patch (Parameters resource)
Response format:
application/fhir+json (default) or application/fhir+xmlConditional patch. Only patch if current version matches this ETag.Example:
W/"5"Response style:
return=representation(default) - Return full patched resourcereturn=minimal- Return headers onlyreturn=OperationOutcome- Return OperationOutcome
Query Parameters
For conditional patch. Patch the resource matching these search parameters.Example:
?identifier=http://hospital.example/mrn|12345Request Body
JSON Patch Format (Recommended)
Array of patch operations following RFC 6902:add- Add a value (creates if missing, appends to arrays)remove- Remove a valuereplace- Replace a value (must exist)move- Move a value from one path to anothercopy- Copy a value from one path to anothertest- Assert a value matches (fails patch if doesn’t match)
FHIRPath Patch Format
FHIR Parameters resource with FHIRPath expressions:Format Support: Most servers support JSON Patch. FHIRPath Patch support varies. Check the server’s CapabilityStatement.
Response
200 OK
Resource patched successfully.New version number (incremented)
ISO 8601 timestamp of this patch
400 Bad Request
Invalid patch operation or resulting resource invalid.404 Not Found
Resource doesn’t exist.412 Precondition Failed
Conditional patch failed (multiple matches or If-Match mismatch).422 Unprocessable Entity
Patch applied but resulting resource violates validation rules.Examples
JSON Patch Path Syntax
Paths use JSON Pointer notation (RFC 6901):| Path | Meaning |
|---|---|
/name | Root-level name field |
/name/0 | First element of name array |
/name/0/given | given field of first name |
/name/0/given/0 | First given name |
/telecom/- | Append to telecom array (add only) |
Best Practices
Test Operation: Use the Fails if
test operation to verify a field has an expected value before applying changes. This provides additional safety:active is not currently false.Common Use Cases
Update Single Field
Add Contact Information
Remove Sensitive Data
Conditional Update with Safety
See Also
Update Resource
Full resource replacement with PUT
Read Resource
Get current version before patching
JSON Patch RFC
Official JSON Patch specification
Learn FHIR CRUD
Understand FHIR patch semantics
Authorizations
Bearer token authentication
Path Parameters
The FHIR resource type (e.g., Patient, Observation, Encounter)
The logical ID of the resource