core.medplumclient.patchresource | Medplum

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 PatchOperation The JSONPatch operations.
options MedplumRequestOptions (Optional) Optional fetch options.

Returns:

Promise< WithId <ExtractResource>>
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.

See the JSONPatch specification for full details.