How to serialize the response back from FHIR read endpoint

9 views
Skip to first unread message

Abhijit Mazumder

unread,
Jun 10, 2024, 11:31:03 AM6/10/24
to GCP Healthcare Discuss
Hi,
  This is how I am reading the resource
const name = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/fhirStores/${fhirStoreId}/fhir/${resourceType}/${resourceId}`;
const request = {name};

const resource =
await healthcare.projects.locations.datasets.fhirStores.fhir.read(
request
);
console.log(`Got resource:\n`, resource.data.text());

The response I am getting is

 Promise {
  '{\n' +
    '  "id": "94b39b5b-48ed-497c-a242-a7cf798395e2",\n' +
    '  "meta": {\n' +
    '    "lastUpdated": "2024-06-10T13:35:39.358817+00:00",\n' +
    '    "versionId": "MTcxODAyNjUzOTM1ODgxNzAwMA"\n' +
    '  },\n' +
    '  "organization": {\n' +
    '    "reference": "Organization/29e3d12d-2f38-49e9-adce-a15e01634055"\n' +
    '  },\n' +
    '  "practitioner": {\n' +
    '    "reference": "Practitioner/47668024-02ec-4ec7-a0a9-f144074d7a39"\n' +
    '  },\n' +
    '  "resourceType": "PractitionerRole",\n' +
    '  "specialty": [\n' +
    '    {\n' +
    '      "coding": [\n' +
    '        {\n' +
    '          "code": "277745000",\n' +
    '          "display": "Pediatrician (occupation)",\n' +
    '          "system": "http://snomed.info/sct"\n' +
    '        }\n' +
    '      ]\n' +
    '    }\n' +
    '  ]\n' +
    '}'
}

How do I serialize this into a json object?
Thanks,
Abhijit

Abhijit Mazumder

unread,
Jun 10, 2024, 10:47:22 PM6/10/24
to GCP Healthcare Discuss
Sorry silly me. 😀. I am not awaiting. It’s weird though that to get the text we need to await 

--
You received this message because you are subscribed to a topic in the Google Groups "GCP Healthcare Discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gcp-healthcare-discuss/6YXD23IdC4Y/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gcp-healthcare-di...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gcp-healthcare-discuss/138b9376-00ed-4d31-a4c1-a957cdbdcfe9n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages