Patch a FHIR resource

Patch a FHIR resource.

Documentation pages that include this code sample

To view the code sample used in context, see the following documentation:

Code sample


const {google} = require('googleapis');
const healthcare ='v1');

async function patchFhirResource() {
  const auth = await google.auth.getClient({
    scopes: [''],
  // TODO(developer): replace patchOptions with your desired JSON patch body
  const patchOptions = [{op: 'replace', path: '/active', value: false}];
    headers: {'Content-Type': 'application/json-patch+json'},

  // TODO(developer): uncomment these lines before running the sample
  // const cloudRegion = 'us-central1';
  // const projectId = 'adjective-noun-123';
  // const datasetId = 'my-dataset';
  // const fhirStoreId = 'my-fhir-store';
  // const resourceType = 'Patient';
  // const resourceId = '16e8a860-33b3-49be-9b03-de979feed14a';
  const name = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/fhirStores/${fhirStoreId}/fhir/${resourceType}/${resourceId}`;
  const request = {
    requestBody: patchOptions,

  await healthcare.projects.locations.datasets.fhirStores.fhir.patch(request);
  console.log(`Patched ${resourceType} resource`);


What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser