Perform FHIR JSON Patch to update specific fields of a resource without replacing the entire resource
domain: hl7.org · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗
In-depth guide
FHIR Bulk Data $export gotchas — the full failure-mode walkthrough related to hl7.org, checked against official docs, with linked verified routes.
Steps
Confirm the server supports PATCH by checking the CapabilityStatement for patch in the interaction list for the target resource type
Read the current resource with GET [base]/[ResourceType]/[id] and note the current versionId from meta.versionId for optimistic concurrency
Construct a JSON Patch document (RFC 6902) as a JSON array of patch operations: op (add, remove, replace, move, copy, test), path (JSON Pointer to the target field), and value
Send PATCH [base]/[ResourceType]/[id] with Content-Type: application/json-patch+json and the If-Match: W/"[versionId]" header to enforce optimistic locking
On 200 OK or 204, parse the updated resource from the response body (if returned) or re-read the resource to confirm the patch was applied correctly
Handle 412 Precondition Failed (version conflict) by re-reading the resource, rebasing the patch if still applicable, and retrying
Known gotchas
JSON Patch paths use JSON Pointer syntax (RFC 6901) where array elements are addressed by zero-based index (e.g., /name/0/family); incorrect paths cause 400 errors
Omitting the If-Match header may be accepted by some servers but leaves the operation non-idempotent and subject to lost-update races; always include it in production
Some FHIR servers require the test operation at the start of the patch array to validate preconditions before applying mutations; verify server behavior and add test ops for critical fields
Give your agent this knowledge — and 15,800+ more routes
One MCP install gives any agent live access to the full route map across 5,800+ domains, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp
Need this verified for your stack — or a route we don't have yet?