Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional FHIR resource methods broken out from original file #1393

Merged
merged 2 commits into from
Jul 8, 2019
Merged
Show file tree
Hide file tree
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
37 changes: 25 additions & 12 deletions healthcare/fhir/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,35 @@ Run the following command to install the library dependencies for Node.js:

## FHIR resources

Commands:
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.
<fhirStoreId> <resourceType> <resourceId>
getFhirResourceHistory.js <projectId> <cloudRegion> <datasetId> Gets the contents of a version of a FHIR resource by version ID.
<fhirStoreId> <resourceType> <resourceId> <versionId>
getFhirResource.js <projectId> <cloudRegion> <datasetId> Gets a FHIR resource.
<fhirStoreId> <resourceType> <resourceId>
getFhirStoreCapabilities.js <projectId> <cloudRegion> <datasetId> Gets the capabilities statement for a FHIR store.
<fhirStoreId>
getPatientEverything.js <projectId> <cloudRegion> <datasetId> Retrieves all resources in the patient compartment for a Patient resource.
<fhirStoreId> <patientId>
listFhirResourceHistory.js <projectId> <cloudRegion> <datasetId> Lists all the versions of a resource
<fhirStoreId> <resourceType> <resourceId> (including the current version and deleted versions) from the FHIR store.
searchFhirResourcesGet.js <projectId> <cloudRegion> <datasetId> Searches for FHIR resources using GET methods.
<fhirStoreId> <resourceType>
searchFhirResourcesPost.js <projectId> <cloudRegion> <datasetId> Searches for FHIR resources using the POST method.
<fhirStoreId> <resourceType>
updateFhirResource.js <projectId> <cloudRegion> <datasetId> Updates the entire contents of a resource.
<fhirStoreId> <resourceType> <resourceId>

Commands:
fhir_resources.js createResource <datasetId> <fhirStoreId> Creates a new resource in a FHIR store.
<resourceType>
fhir_resources.js updateResource <datasetId> <fhirStoreId> Updates an existing resource in a FHIR store.
<resourceType> <resourceId>
fhir_resources.js patchResource <datasetId> <fhirStoreId> Patches an existing resource in a FHIR store.
<resourceType> <resourceId>
fhir_resources.js deleteResource <datasetId> <fhirStoreId> Deletes a FHIR resource or returns NOT_FOUND if it
<resourceType> <resourceId> doesn't exist.
fhir_resources.js getResource <datasetId> <fhirStoreId> Gets a FHIR resource.
<resourceType> <resourceId>
fhir_resources.js searchResourcesGet <datasetId> Searches resources in the given FHIR store using the
<fhirStoreId> <resourceType> searchResources GET method.
fhir_resources.js searchResourcesPost <datasetId> Searches resources in the given FHIR store using the
<fhirStoreId> <resourceType> _search POST method.
fhir_resources.js getPatientEverything <datasetId> Gets all the resources in the patient compartment.
<fhirStoreId> <resourceId>
fhir_resources.js executeBundle <datasetId> <fhirStoreId> Executes all the requests in the given Bundle.
<bundleFile>

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

For more information, see https://cloud.google.com/healthcare/docs

59 changes: 59 additions & 0 deletions healthcare/fhir/deleteFhirResource.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* Copyright 2019, 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.
*/

/* eslint-disable no-warning-comments */

'use strict';

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

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

// 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 resourceId = '9a664e07-79a4-4c2e-04ed-e996c75484e1;
const name = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/fhirStores/${fhirStoreId}/fhir/${resourceType}/${resourceId}`;
const request = {name};

await healthcare.projects.locations.datasets.fhirStores.fhir.delete(
request
);
console.log(`Deleted FHIR resource ${resourceType}`);
}

deleteFhirResource();
// [END healthcare_delete_fhir_resource]
}

// node deleteFhirResource.js <projectId> <cloudRegion> <datasetId> <fhirStoreId> <resourceType> <resourceId>
main(...process.argv.slice(2));
59 changes: 59 additions & 0 deletions healthcare/fhir/deleteFhirResourcePurge.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* Copyright 2019, 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.
*/

/* eslint-disable no-warning-comments */

'use strict';

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

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

// 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 resourceId = '9a664e07-79a4-4c2e-04ed-e996c75484e1;
const name = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/fhirStores/${fhirStoreId}/fhir/${resourceType}/${resourceId}`;
const request = {name};

await healthcare.projects.locations.datasets.fhirStores.fhir.ResourcePurge(
request
);
console.log(`Deleted all historical versions of ${resourceType} resource`);
}

deleteFhirResourcePurge();
// [END healthcare_delete_resource_purge]
}

// node deleteFhirResourcePurge.js <projectId> <cloudRegion> <datasetId> <fhirStoreId> <resourceType> <resourceId>
main(...process.argv.slice(2));
Loading