google-api-nodejs-client
google-api-nodejs-client copied to clipboard
FHIR Seach and Query String/Params
Environment details
- OS: macOS Mojave 10.14.6
- Node.js version: v12.18.2
- npm version: 6.14.5
-
googleapis
version: ^60.0.1
How do you query the FHIR store using a query string after the FHIR resource name? This produces an OperationOutcome that states the resource type is invalid.
const parent = `projects/${PROJECT_ID}/locations/${CLOUD_REGION}/datasets/${DATASET_ID}/fhirStores/${FHIR_STORE_ID}`
const medDispResourceType = `MedicationDispense?subject=Patient/${patientId}&status=completed`
const medDispResources = await googleFhirClient.search({
parent,
requestBody: {
resourceType: medDispResourceType
}
} )
@tripott forgive me, I'm not terribly familiar with the FHIR API. The resourceType you're trying to pass - is it common for it to include querystring parameters like that? There's a lot of weird here, as compared to other googleapis. I'm reading this doc: https://cloud.google.com/healthcare/docs/reference/rest/v1/projects.locations.datasets.fhirStores.fhir/search
It's usually a good idea to try getting your query to work first in the API explorer on that page, just to make sure we have an apples to apples comparison.
Based on the way we're generating the API, it looks like we default to POST, which means it doesn't expect to get the resourceType in the path... which makes passing querystring parameters along with it even weirder. One idea is to try manually overriding the querystring parameters, something like:
const parent = `projects/${PROJECT_ID}/locations/${CLOUD_REGION}/datasets/${DATASET_ID}/fhirStores/${FHIR_STORE_ID}`
const res = await googleFhirClient.search({
parent,
requestBody: {
resourceType: 'MedicationDispense'
}
}, {
params: {
subject: `Patient/${patientId}`,
status: 'completed',
}
})
Let us know how it goes!
I ran into a similar issue while trying to use this api to build complex FHIR searches.
Specifically, I am trying to retrieve all patients that reference a specific managingOrganization.
Using the code snippet above as a jumping off point, here's something I have working right now:
const res = await googleFhirClient.search({
parent: fhirStoreUrl,
resourceType: "Patient",
organization: `Organization/${someOrgId}`
})
When I inspect res.request
, I get this back (some values replaced for security):
{
responseURL: 'https://healthcare.googleapis.com/v1/projects/our-project-id/locations/our-location/datasets/our_dataset/fhirStores/our_fhir_store/fhir/_search?resourceType=Patient&organization=Organization%2FsomeOrgId'
}
This is what I was hoping to build, so I am happy for now, though I do wish there was better documentation for handling search params using this api.