## MedplumClient.patchResource() method

Updates a FHIR resource using JSONPatch operations.

The return value is the updated resource, including the ID and meta.

**Signature:**

```typescript
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](/content/docs/sdk/core.patchoperation) | The JSONPatch operations.                             |
| options        | [MedplumRequestOptions](/content/docs/sdk/core.medplumrequestoptions) | _(Optional)_ Optional fetch options.                 |

**Returns:**

Promise< [WithId](/content/docs/sdk/core.withid) <ExtractResource<RT>>>  
The result of the patch operations.

## Example

Example:

```typescript
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](https://www.hl7.org/fhir/http.html#patch) for full details.

See the [JSONPatch specification](https://tools.ietf.org/html/rfc6902) for full details.
