Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions healthcare/fhir/createFhirResource.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2020, Google, LLC
* Copyright 2020 Google LLC
* Licensed under the Apache License, Version 2.0 (the `License`);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand Down Expand Up @@ -30,6 +30,7 @@ function main(
scopes: ['https://www.googleapis.com/auth/cloud-platform'],
}),
headers: {'Content-Type': 'application/fhir+json'},
responseType: 'json',
});

async function createFhirResource() {
Expand All @@ -50,13 +51,17 @@ function main(
// const resourceType = 'Patient';
const parent = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/fhirStores/${fhirStoreId}`;

const request = {parent, type: resourceType, requestBody: body};
const resource =
await healthcare.projects.locations.datasets.fhirStores.fhir.create(
request
);
console.log(`Created FHIR resource with ID ${resource.data.id}`);
console.log(resource.data);
try {
const request = {parent, type: resourceType, requestBody: body};
const resource =
await healthcare.projects.locations.datasets.fhirStores.fhir.create(
request
);
console.log(`Created FHIR resource with ID ${resource.data.id}`);
console.log(resource.data);
} catch (error) {
console.error('Error creating FHIR resource:', error.message || error);
}
}

createFhirResource();
Expand Down
Loading