Overview
This node enables users to perform a "Patch" operation on FHIR (Fast Healthcare Interoperability Resources) resources via a FHIR server API. The Patch operation allows partial updates to existing FHIR resources by applying a set of changes described in a JSON Patch format or as individual patch parameters.
Common scenarios where this node is beneficial include:
- Updating specific fields of a FHIR resource without sending the entire resource representation.
- Applying complex modifications such as adding, removing, or replacing elements within a resource.
- Integrating with healthcare systems that support FHIR APIs for efficient resource management.
Practical example:
- A user wants to update the address of a Patient resource without modifying other patient details. Using this node's Patch operation, they can specify only the address changes, reducing data transfer and processing overhead.
Properties
Name | Meaning |
---|---|
Authentication | The method used to authenticate with the FHIR server. Options: Basic Auth, Custom Auth, Digest Auth, Header Auth, None, OAuth1, OAuth2, Query Auth. |
Base URL | The base URL of the FHIR server API to which requests will be sent. |
Resource Type | The type of FHIR resource to operate on (e.g., Patient, Observation, etc.). Also supports custom resource types specified as a string. |
ID | The identifier of the specific resource instance to patch. Required for operations like Patch, Delete, Read, Update, etc. |
Specify Patch Body | How to specify the patch content: either using individual fields below ("keypair") or providing a raw JSON patch body ("json"). |
Body | The raw JSON patch body to apply when "Using JSON" is selected for specifying the patch body. |
Patch Parameters | A collection of patch operations defined as parameters when "Using Fields Below" is selected. Each parameter includes: Op (operation type), From (source path for copy/move/test), Path (target path), and Value (value to apply). |
Specify Query Parameters | How to specify query parameters for the request: either using individual fields ("keypair") or providing a raw JSON object ("json"). |
Query Parameters | Collection of query parameters as name-value pairs when "Using Fields Below" is selected. |
JSON | Raw JSON object representing query parameters when "Using JSON" is selected. |
FHIR Path | An optional FHIR Path expression to extract specific data from the response output. |
Ignore SSL Issues | Whether to allow connections even if SSL certificate validation fails (useful for self-signed certificates). |
Output
The node outputs the JSON response from the FHIR server after applying the patch operation. If the response is a FHIR Bundle, it extracts and returns each resource entry separately, preserving pairing information with the input item.
The output json
field contains:
- For single resource responses: the resource JSON object.
- For Bundle responses: an array of resource entries extracted from the bundle.
No binary data output is produced by this node.
Dependencies
- Requires access to a FHIR server supporting the PATCH HTTP method with JSON Patch content type (
application/json-patch+json
). - Requires appropriate authentication credentials configured in n8n according to the selected authentication method.
- Uses internal utilities for HTTP requests with authentication handling.
- Supports optional FHIR Path evaluation on responses, relying on an embedded FHIRPath engine.
Troubleshooting
- Error if More than One Result: When performing a Search operation with this option enabled, if the search returns multiple results, the node throws an error. To resolve, ensure the search query is specific enough to return a single result or disable this option.
- Invalid JSON in Patch Body or Query Parameters: If specifying JSON directly, ensure the JSON is valid and properly formatted.
- SSL Certificate Errors: If connecting to a server with self-signed or invalid SSL certificates, enable "Ignore SSL Issues" to bypass validation.
- Authentication Failures: Verify that the correct authentication method and credentials are provided.
- Unsupported Operation: The node only supports predefined FHIR operations; attempting unsupported operations will result in errors.
- Malformed Patch Parameters: When using keypair patch parameters, ensure all required fields (
op
,path
, and optionallyfrom
andvalue
) are correctly specified.
Links and References
- FHIR Specification - PATCH
- JSON Patch RFC 6902
- FHIRPath Specification
- n8n Documentation - Creating Custom Nodes
- UCUM Units of Measure
Summary of execute() logic
- Retrieves input data items.
- For each item, constructs the HTTP request options based on node parameters:
- Base URL, resource type, resource ID, operation type.
- Patch body specified either as JSON or as a list of patch parameters.
- Query parameters specified either as JSON or key-value pairs.
- Authentication parameters are obtained and applied.
- Sends the HTTP request to the FHIR server.
- Handles special cases:
- For Search operation with "allPages" enabled, iteratively fetches all pages using the "next" link.
- For Search operation with "errorIfMoreThanOneResult" enabled, throws error if multiple results found.
- Optionally applies a FHIR Path expression to extract data from the response.
- Returns the processed results as output items, maintaining pairing with input items.
- Supports error handling with continue-on-fail option.