Skip to content

Commit

Permalink
Merge branch 'master' into renovate/google-cloud-speech-4.x
Browse files Browse the repository at this point in the history
  • Loading branch information
ricalo authored Jun 5, 2020
2 parents 61a40c1 + 44949e4 commit 7e8a12f
Show file tree
Hide file tree
Showing 33 changed files with 255 additions and 280 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ env_vars: {
# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
value: "gcr.io/cloud-devrel-kokoro-resources/node:8-user"
value: "gcr.io/cloud-devrel-kokoro-resources/node:12-user"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
13 changes: 6 additions & 7 deletions healthcare/fhir/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ Run the following command to install the library dependencies for Node.js:
## FHIR resources

Commands:
createFhirResource.js <projectId> <cloudRegion> <datasetId> Creates a FHIR resource.
<fhirStoreId> <resourceType>
deleteFhirResource.js <projectId> <cloudRegion> <datasetId> Deletes a FHIR resource.
<fhirStoreId> <resourceType> <resourceId>
deleteFhirResourcePurge.js <projectId> <cloudRegion> <datasetId> Deletes all historical versions of a FHIR resource.
Expand All @@ -57,14 +59,11 @@ Run the following command to install the library dependencies for Node.js:
<fhirStoreId> <resourceType>
updateFhirResource.js <projectId> <cloudRegion> <datasetId> Updates the entire contents of a resource.
<fhirStoreId> <resourceType> <resourceId>
patchFhirResource.js <projectId> <cloudRegion> <datasetId> Updates part of a resource.
<fhirStoreId> <resourceType> <resourceId>
executeFhirBundle.js <projectId> <cloudRegion> <datasetId> Executes all the requests in the given Bundle.
<fhirStoreId> <bundleFile>

Commands:
fhir_resources.js createResource <datasetId> <fhirStoreId> Creates a new resource in a FHIR store.
<resourceType>
fhir_resources.js patchResource <datasetId> <fhirStoreId> Patches an existing resource in a FHIR store.
<resourceType> <resourceId>
fhir_resources.js executeBundle <datasetId> <fhirStoreId> Executes all the requests in the given Bundle.
<bundleFile>

Options:
--version Show version number [boolean]
Expand Down
66 changes: 66 additions & 0 deletions healthcare/fhir/createFhirResource.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/**
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an `AS IS` BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

function main(
projectId = process.env.GCLOUD_PROJECT,
cloudRegion = 'us-central1',
datasetId,
fhirStoreId,
resourceType,
) {
// [START healthcare_create_fhir_resource]
const {google} = require('googleapis');
const healthcare = google.healthcare('v1');

async function createFhirResource() {
const auth = await google.auth.getClient({
scopes: ['https://www.googleapis.com/auth/cloud-platform'],
});

// Replace the following body with the data for the resource you want to
// create.
const body = {
"name": [{"use": "official", "family": "Smith", "given": ["Darcy"]}],
"gender": "female",
"birthDate": "1970-01-01",
"resourceType": "Patient",
};

google.options({auth, headers: {'Content-Type': 'application/fhir+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 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);
}

createFhirResource();
// [END healthcare_create_fhir_resource]
}

// node createFhirResource.js <projectId> <cloudRegion> <datasetId> <fhirStoreId> <resourceType>
main(...process.argv.slice(2));
2 changes: 1 addition & 1 deletion healthcare/fhir/deleteFhirResource.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const main = (
await healthcare.projects.locations.datasets.fhirStores.fhir.delete(
request
);
console.log(`Deleted FHIR resource ${resourceType}`);
console.log(`Deleted FHIR resource`);
};

deleteFhirResource();
Expand Down
2 changes: 1 addition & 1 deletion healthcare/fhir/deleteFhirResourcePurge.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const main = (
await healthcare.projects.locations.datasets.fhirStores.fhir.ResourcePurge(
request
);
console.log(`Deleted all historical versions of ${resourceType} resource`);
console.log(`Deleted all historical versions of resource`);
};

deleteFhirResourcePurge();
Expand Down
60 changes: 60 additions & 0 deletions healthcare/fhir/executeFhirBundle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an `AS IS` BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

function main(
projectId = process.env.GCLOUD_PROJECT,
cloudRegion = 'us-central1',
datasetId,
fhirStoreId,
bundleFile
) {
// [START healthcare_fhir_execute_bundle]
const {google} = require('googleapis');
const healthcare = google.healthcare('v1');
const fs = require('fs');

async function executeFhirBundle() {
const auth = await google.auth.getClient({
scopes: ['https://www.googleapis.com/auth/cloud-platform'],
});

google.options({auth, headers: {'Content-Type': 'application/fhir+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 bundleFile = 'bundle.json';
const parent = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/fhirStores/${fhirStoreId}`;

const bundle = JSON.parse(fs.readFileSync(bundleFile));

const request = {parent, requestBody: bundle};
const resource = await healthcare.projects.locations.datasets.fhirStores.fhir.executeBundle(
request
);
console.log(`FHIR bundle executed`);
console.log(resource.data);
}

executeFhirBundle();
// [END healthcare_fhir_execute_bundle]
}

// node executeFhirBundle.js <projectId> <cloudRegion> <datasetId> <fhirStoreId> <bundleFile>
main(...process.argv.slice(2));
Loading

0 comments on commit 7e8a12f

Please sign in to comment.