core.medplumclient.patchresource
Home > @medplum/core > MedplumClient > patchResource
MedplumClient.patchResource() method
Updates a FHIR resource using JSONPatch operations.
The return value is the updated resource, including the ID and meta.
Signature:
patchResource<RT extends ResourceType>(resourceType: RT, id: string, operations: PatchOperation[], options?: MedplumRequestOptions): Promise<WithId<ExtractResource<RT>>>;
Parameters
Parameter | Type | Description |
---|---|---|
resourceType | RT | The FHIR resource type. |
id | string | The resource ID. |
operations | The JSONPatch operations. | |
options | (Optional) Optional fetch options. |
Returns:
Promise<WithId<ExtractResource<RT>>>
The result of the patch operations.
Example
Example:
const result = await medplum.patchResource('Patient', '123', [
{op: 'replace', path: '/name/0/family', value: 'Smith'},
]);
console.log(result.meta.versionId);
See the FHIR "update" operation for full details: https://www.hl7.org/fhir/http.html\#patch
See the JSONPatch specification for full details: https://tools.ietf.org/html/rfc6902