You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
nate-watkins opened this issue
May 13, 2024
· 1 comment
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
Hi there- following the example code for creating FHIR resources, it seems the generated types do not match what the api expects.
Running the example code indicates the requestBody is mistyped and should be of type Scehma$HttpBody.
The response is also mistyped as it seems to return a BLOB. Below is the example code with comments added. This was tested using valid config variables.
constgoogle=require('@googleapis/healthcare');consthealthcare=google.healthcare({version: 'v1',auth: newgoogle.auth.GoogleAuth({scopes: ['https://www.googleapis.com/auth/cloud-platform'],}),headers: {'Content-Type': 'application/fhir+json'},});asyncfunctioncreateFhirResource(){// Replace the following body with the data for the resource you want to// create.constbody={name: [{use: 'official',family: 'Smith',given: ['Darcy']}],gender: 'female',birthDate: '1970-01-01',resourceType: 'Patient',};// 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';// Example code request - type errors for `requestBody`, returns 200constrequest={ parent,type: resourceType,requestBody: body};constresource=awaithealthcare.projects.locations.datasets.fhirStores.fhir.create(request);// Modified to satisfy type errors, throws 400// const request = { parent, type: resourceType, requestBody: { data: JSON.stringify(body) } };// const resource = await healthcare.projects.locations.datasets.fhirStores.fhir.create(request);// Example code response - `id` is undefined, `resource.data` is a BLOB. Type error: Property 'id' does not exist on type 'Schema$HttpBody'.// console.log(`Created FHIR resource with ID ${resource.data.id}`);// console.log(resource.data);// Modified to parse response correctly, throws type errorsconsttextData=awaitresource.data.text();constparsedData=JSON.parse(textData);console.log(`Created FHIR resource with ID ${parsedData.id}`);console.log(parsedData);}createFhirResource();
It seems there have been a couple other similar issues in the other api libraries.
See: #1944 and #1168
The text was updated successfully, but these errors were encountered:
nate-watkins
added
priority: p2
Moderately-important priority. Fix may not be included in next release.
type: bug
Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
labels
May 13, 2024
Regarding the response type, it appears it works as expected if the responseType is set to 'json'. I opened an issue in the samples repo for this. The request type remains a mystery.
priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
Environment details
@googleapis/healthcare
version: 16.0.0Hi there- following the example code for creating FHIR resources, it seems the generated types do not match what the api expects.
Running the example code indicates the
requestBody
is mistyped and should be of type Scehma$HttpBody.The response is also mistyped as it seems to return a BLOB. Below is the example code with comments added. This was tested using valid config variables.
It seems there have been a couple other similar issues in the other api libraries.
See: #1944 and #1168
The text was updated successfully, but these errors were encountered: