Skip to content

Commit 7e8a12f

Browse files
authored
Merge branch 'master' into renovate/google-cloud-speech-4.x
2 parents 61a40c1 + 44949e4 commit 7e8a12f

33 files changed

+255
-280
lines changed

.kokoro/appengine/node8/common.cfg renamed to .kokoro/appengine/node12/common.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ env_vars: {
1818
# Configure the docker image for kokoro-trampoline.
1919
env_vars: {
2020
key: "TRAMPOLINE_IMAGE"
21-
value: "gcr.io/cloud-devrel-kokoro-resources/node:8-user"
21+
value: "gcr.io/cloud-devrel-kokoro-resources/node:12-user"
2222
}

healthcare/fhir/README.md

+6-7
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ Run the following command to install the library dependencies for Node.js:
3737
## FHIR resources
3838

3939
Commands:
40+
createFhirResource.js <projectId> <cloudRegion> <datasetId> Creates a FHIR resource.
41+
<fhirStoreId> <resourceType>
4042
deleteFhirResource.js <projectId> <cloudRegion> <datasetId> Deletes a FHIR resource.
4143
<fhirStoreId> <resourceType> <resourceId>
4244
deleteFhirResourcePurge.js <projectId> <cloudRegion> <datasetId> Deletes all historical versions of a FHIR resource.
@@ -57,14 +59,11 @@ Run the following command to install the library dependencies for Node.js:
5759
<fhirStoreId> <resourceType>
5860
updateFhirResource.js <projectId> <cloudRegion> <datasetId> Updates the entire contents of a resource.
5961
<fhirStoreId> <resourceType> <resourceId>
62+
patchFhirResource.js <projectId> <cloudRegion> <datasetId> Updates part of a resource.
63+
<fhirStoreId> <resourceType> <resourceId>
64+
executeFhirBundle.js <projectId> <cloudRegion> <datasetId> Executes all the requests in the given Bundle.
65+
<fhirStoreId> <bundleFile>
6066

61-
Commands:
62-
fhir_resources.js createResource <datasetId> <fhirStoreId> Creates a new resource in a FHIR store.
63-
<resourceType>
64-
fhir_resources.js patchResource <datasetId> <fhirStoreId> Patches an existing resource in a FHIR store.
65-
<resourceType> <resourceId>
66-
fhir_resources.js executeBundle <datasetId> <fhirStoreId> Executes all the requests in the given Bundle.
67-
<bundleFile>
6867

6968
Options:
7069
--version Show version number [boolean]

healthcare/fhir/createFhirResource.js

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/**
2+
* Copyright 2020, Google, LLC
3+
* Licensed under the Apache License, Version 2.0 (the `License`);
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an `AS IS` BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
'use strict';
17+
18+
function main(
19+
projectId = process.env.GCLOUD_PROJECT,
20+
cloudRegion = 'us-central1',
21+
datasetId,
22+
fhirStoreId,
23+
resourceType,
24+
) {
25+
// [START healthcare_create_fhir_resource]
26+
const {google} = require('googleapis');
27+
const healthcare = google.healthcare('v1');
28+
29+
async function createFhirResource() {
30+
const auth = await google.auth.getClient({
31+
scopes: ['https://www.googleapis.com/auth/cloud-platform'],
32+
});
33+
34+
// Replace the following body with the data for the resource you want to
35+
// create.
36+
const body = {
37+
"name": [{"use": "official", "family": "Smith", "given": ["Darcy"]}],
38+
"gender": "female",
39+
"birthDate": "1970-01-01",
40+
"resourceType": "Patient",
41+
};
42+
43+
google.options({auth, headers: {'Content-Type': 'application/fhir+json'}});
44+
45+
// TODO(developer): uncomment these lines before running the sample
46+
// const cloudRegion = 'us-central1';
47+
// const projectId = 'adjective-noun-123';
48+
// const datasetId = 'my-dataset';
49+
// const fhirStoreId = 'my-fhir-store';
50+
// const resourceType = 'Patient';
51+
const parent = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/fhirStores/${fhirStoreId}`;
52+
53+
const request = {parent, type: resourceType, requestBody: body};
54+
const resource = await healthcare.projects.locations.datasets.fhirStores.fhir.create(
55+
request
56+
);
57+
console.log(`Created FHIR resource with ID ${resource.data.id}`);
58+
console.log(resource.data);
59+
}
60+
61+
createFhirResource();
62+
// [END healthcare_create_fhir_resource]
63+
}
64+
65+
// node createFhirResource.js <projectId> <cloudRegion> <datasetId> <fhirStoreId> <resourceType>
66+
main(...process.argv.slice(2));

healthcare/fhir/deleteFhirResource.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const main = (
5151
await healthcare.projects.locations.datasets.fhirStores.fhir.delete(
5252
request
5353
);
54-
console.log(`Deleted FHIR resource ${resourceType}`);
54+
console.log(`Deleted FHIR resource`);
5555
};
5656

5757
deleteFhirResource();

healthcare/fhir/deleteFhirResourcePurge.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const main = (
4747
await healthcare.projects.locations.datasets.fhirStores.fhir.ResourcePurge(
4848
request
4949
);
50-
console.log(`Deleted all historical versions of ${resourceType} resource`);
50+
console.log(`Deleted all historical versions of resource`);
5151
};
5252

5353
deleteFhirResourcePurge();

healthcare/fhir/executeFhirBundle.js

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* Copyright 2020, Google, LLC
3+
* Licensed under the Apache License, Version 2.0 (the `License`);
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an `AS IS` BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
'use strict';
17+
18+
function main(
19+
projectId = process.env.GCLOUD_PROJECT,
20+
cloudRegion = 'us-central1',
21+
datasetId,
22+
fhirStoreId,
23+
bundleFile
24+
) {
25+
// [START healthcare_fhir_execute_bundle]
26+
const {google} = require('googleapis');
27+
const healthcare = google.healthcare('v1');
28+
const fs = require('fs');
29+
30+
async function executeFhirBundle() {
31+
const auth = await google.auth.getClient({
32+
scopes: ['https://www.googleapis.com/auth/cloud-platform'],
33+
});
34+
35+
google.options({auth, headers: {'Content-Type': 'application/fhir+json'}});
36+
37+
// TODO(developer): uncomment these lines before running the sample
38+
// const cloudRegion = 'us-central1';
39+
// const projectId = 'adjective-noun-123';
40+
// const datasetId = 'my-dataset';
41+
// const fhirStoreId = 'my-fhir-store';
42+
// const bundleFile = 'bundle.json';
43+
const parent = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/fhirStores/${fhirStoreId}`;
44+
45+
const bundle = JSON.parse(fs.readFileSync(bundleFile));
46+
47+
const request = {parent, requestBody: bundle};
48+
const resource = await healthcare.projects.locations.datasets.fhirStores.fhir.executeBundle(
49+
request
50+
);
51+
console.log(`FHIR bundle executed`);
52+
console.log(resource.data);
53+
}
54+
55+
executeFhirBundle();
56+
// [END healthcare_fhir_execute_bundle]
57+
}
58+
59+
// node executeFhirBundle.js <projectId> <cloudRegion> <datasetId> <fhirStoreId> <bundleFile>
60+
main(...process.argv.slice(2));

0 commit comments

Comments
 (0)