Skip to main content

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<K extends ResourceType>(resourceType: K, id: string, operations: PatchOperation[], options?: MedplumRequestOptions): Promise<ExtractResource<K>>;

Parameters

Parameter

Type

Description

resourceType

K

The FHIR resource type.

id

string

The resource ID.

operations

PatchOperation[]

The JSONPatch operations.

options

MedplumRequestOptions

(Optional) Optional fetch options.

Returns:

Promise<ExtractResource<K>>

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