Skip to content

Commit 96caeeb

Browse files
noerogfhinkel
authored andcommitted
Additional FHIR resource methods broken out from original file (#1393)
* Additional FHIR resource methods broken out from original file and also adding new ones * Fix delete resource purge region tags/method name.
1 parent 28fd540 commit 96caeeb

14 files changed

Lines changed: 730 additions & 339 deletions

healthcare/fhir/README.md

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,35 @@ Run the following command to install the library dependencies for Node.js:
3636

3737
## FHIR resources
3838

39+
Commands:
40+
deleteFhirResource.js <projectId> <cloudRegion> <datasetId> Deletes a FHIR resource.
41+
<fhirStoreId> <resourceType> <resourceId>
42+
deleteFhirResourcePurge.js <projectId> <cloudRegion> <datasetId> Deletes all historical versions of a FHIR resource.
43+
<fhirStoreId> <resourceType> <resourceId>
44+
getFhirResourceHistory.js <projectId> <cloudRegion> <datasetId> Gets the contents of a version of a FHIR resource by version ID.
45+
<fhirStoreId> <resourceType> <resourceId> <versionId>
46+
getFhirResource.js <projectId> <cloudRegion> <datasetId> Gets a FHIR resource.
47+
<fhirStoreId> <resourceType> <resourceId>
48+
getFhirStoreCapabilities.js <projectId> <cloudRegion> <datasetId> Gets the capabilities statement for a FHIR store.
49+
<fhirStoreId>
50+
getPatientEverything.js <projectId> <cloudRegion> <datasetId> Retrieves all resources in the patient compartment for a Patient resource.
51+
<fhirStoreId> <patientId>
52+
listFhirResourceHistory.js <projectId> <cloudRegion> <datasetId> Lists all the versions of a resource
53+
<fhirStoreId> <resourceType> <resourceId> (including the current version and deleted versions) from the FHIR store.
54+
searchFhirResourcesGet.js <projectId> <cloudRegion> <datasetId> Searches for FHIR resources using GET methods.
55+
<fhirStoreId> <resourceType>
56+
searchFhirResourcesPost.js <projectId> <cloudRegion> <datasetId> Searches for FHIR resources using the POST method.
57+
<fhirStoreId> <resourceType>
58+
updateFhirResource.js <projectId> <cloudRegion> <datasetId> Updates the entire contents of a resource.
59+
<fhirStoreId> <resourceType> <resourceId>
60+
3961
Commands:
4062
fhir_resources.js createResource <datasetId> <fhirStoreId> Creates a new resource in a FHIR store.
4163
<resourceType>
42-
fhir_resources.js updateResource <datasetId> <fhirStoreId> Updates an existing resource in a FHIR store.
43-
<resourceType> <resourceId>
4464
fhir_resources.js patchResource <datasetId> <fhirStoreId> Patches an existing resource in a FHIR store.
4565
<resourceType> <resourceId>
46-
fhir_resources.js deleteResource <datasetId> <fhirStoreId> Deletes a FHIR resource or returns NOT_FOUND if it
47-
<resourceType> <resourceId> doesn't exist.
48-
fhir_resources.js getResource <datasetId> <fhirStoreId> Gets a FHIR resource.
49-
<resourceType> <resourceId>
50-
fhir_resources.js searchResourcesGet <datasetId> Searches resources in the given FHIR store using the
51-
<fhirStoreId> <resourceType> searchResources GET method.
52-
fhir_resources.js searchResourcesPost <datasetId> Searches resources in the given FHIR store using the
53-
<fhirStoreId> <resourceType> _search POST method.
54-
fhir_resources.js getPatientEverything <datasetId> Gets all the resources in the patient compartment.
55-
<fhirStoreId> <resourceId>
66+
fhir_resources.js executeBundle <datasetId> <fhirStoreId> Executes all the requests in the given Bundle.
67+
<bundleFile>
5668

5769
Options:
5870
--version Show version number [boolean]
@@ -64,3 +76,4 @@ Run the following command to install the library dependencies for Node.js:
6476
--help Show help [boolean]
6577

6678
For more information, see https://cloud.google.com/healthcare/docs
79+
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**
2+
* Copyright 2019, 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+
/* eslint-disable no-warning-comments */
17+
18+
'use strict';
19+
20+
function main(
21+
projectId = process.env.GCLOUD_PROJECT,
22+
cloudRegion = 'us-central1',
23+
datasetId,
24+
fhirStoreId,
25+
resourceType,
26+
resourceId
27+
) {
28+
// [START healthcare_delete_fhir_resource]
29+
const {google} = require('googleapis');
30+
const healthcare = google.healthcare('v1beta1');
31+
32+
async function deleteFhirResource() {
33+
const auth = await google.auth.getClient({
34+
scopes: ['https://www.googleapis.com/auth/cloud-platform'],
35+
});
36+
google.options({auth});
37+
38+
// TODO(developer): uncomment these lines before running the sample
39+
// const cloudRegion = 'us-central1';
40+
// const projectId = 'adjective-noun-123';
41+
// const datasetId = 'my-dataset';
42+
// const fhirStoreId = 'my-fhir-store';
43+
// const resourceType = 'Patient';
44+
// const resourceId = '9a664e07-79a4-4c2e-04ed-e996c75484e1;
45+
const name = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/fhirStores/${fhirStoreId}/fhir/${resourceType}/${resourceId}`;
46+
const request = {name};
47+
48+
await healthcare.projects.locations.datasets.fhirStores.fhir.delete(
49+
request
50+
);
51+
console.log(`Deleted FHIR resource ${resourceType}`);
52+
}
53+
54+
deleteFhirResource();
55+
// [END healthcare_delete_fhir_resource]
56+
}
57+
58+
// node deleteFhirResource.js <projectId> <cloudRegion> <datasetId> <fhirStoreId> <resourceType> <resourceId>
59+
main(...process.argv.slice(2));
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**
2+
* Copyright 2019, 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+
/* eslint-disable no-warning-comments */
17+
18+
'use strict';
19+
20+
function main(
21+
projectId = process.env.GCLOUD_PROJECT,
22+
cloudRegion = 'us-central1',
23+
datasetId,
24+
fhirStoreId,
25+
resourceType,
26+
resourceId
27+
) {
28+
// [START healthcare_delete_resource_purge]
29+
const {google} = require('googleapis');
30+
const healthcare = google.healthcare('v1beta1');
31+
32+
async function deleteFhirResourcePurge() {
33+
const auth = await google.auth.getClient({
34+
scopes: ['https://www.googleapis.com/auth/cloud-platform'],
35+
});
36+
google.options({auth});
37+
38+
// TODO(developer): uncomment these lines before running the sample
39+
// const cloudRegion = 'us-central1';
40+
// const projectId = 'adjective-noun-123';
41+
// const datasetId = 'my-dataset';
42+
// const fhirStoreId = 'my-fhir-store';
43+
// const resourceType = 'Patient';
44+
// const resourceId = '9a664e07-79a4-4c2e-04ed-e996c75484e1;
45+
const name = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/fhirStores/${fhirStoreId}/fhir/${resourceType}/${resourceId}`;
46+
const request = {name};
47+
48+
await healthcare.projects.locations.datasets.fhirStores.fhir.ResourcePurge(
49+
request
50+
);
51+
console.log(`Deleted all historical versions of ${resourceType} resource`);
52+
}
53+
54+
deleteFhirResourcePurge();
55+
// [END healthcare_delete_resource_purge]
56+
}
57+
58+
// node deleteFhirResourcePurge.js <projectId> <cloudRegion> <datasetId> <fhirStoreId> <resourceType> <resourceId>
59+
main(...process.argv.slice(2));

0 commit comments

Comments
 (0)