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

healthcare API: update FHIR samples from v1beta1 to v1 #1733

Merged
merged 5 commits into from
Apr 21, 2020
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
2 changes: 1 addition & 1 deletion healthcare/fhir/createFhirStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const main = (
) => {
// [START healthcare_create_fhir_store]
const {google} = require('googleapis');
const healthcare = google.healthcare('v1beta1');
const healthcare = google.healthcare('v1');

const createFhirStore = async () => {
const auth = await google.auth.getClient({
Expand Down
2 changes: 1 addition & 1 deletion healthcare/fhir/deleteFhirResource.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const main = (
) => {
// [START healthcare_delete_resource]
const {google} = require('googleapis');
const healthcare = google.healthcare('v1beta1');
const healthcare = google.healthcare('v1');

const deleteFhirResource = async () => {
const auth = await google.auth.getClient({
Expand Down
2 changes: 1 addition & 1 deletion healthcare/fhir/deleteFhirResourcePurge.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const main = (
) => {
// [START healthcare_delete_resource_purge]
const {google} = require('googleapis');
const healthcare = google.healthcare('v1beta1');
const healthcare = google.healthcare('v1');

const deleteFhirResourcePurge = async () => {
const auth = await google.auth.getClient({
Expand Down
2 changes: 1 addition & 1 deletion healthcare/fhir/deleteFhirStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const main = (
) => {
// [START healthcare_delete_fhir_store]
const {google} = require('googleapis');
const healthcare = google.healthcare('v1beta1');
const healthcare = google.healthcare('v1');

const deleteFhirStore = async () => {
const auth = await google.auth.getClient({
Expand Down
2 changes: 1 addition & 1 deletion healthcare/fhir/exportFhirResources.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const main = (
) => {
// [START healthcare_export_fhir_resources_gcs]
const {google} = require('googleapis');
const healthcare = google.healthcare('v1beta1');
const healthcare = google.healthcare('v1');
const sleep = require('../sleep');

const exportFhirResourcesGcs = async () => {
Expand Down
2 changes: 1 addition & 1 deletion healthcare/fhir/fhir_resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
const {GoogleToken} = require('gtoken');
const request = require('request-promise');

const BASE_URL = 'https://healthcare.googleapis.com/v1beta1';
const BASE_URL = 'https://healthcare.googleapis.com/v1';

// [START healthcare_get_token]
const getToken = (serviceAccountJson, cb) => {
Expand Down
2 changes: 1 addition & 1 deletion healthcare/fhir/getFhirResource.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const main = (
) => {
// [START healthcare_get_resource]
const {google} = require('googleapis');
const healthcare = google.healthcare('v1beta1');
const healthcare = google.healthcare('v1');

const getFhirResource = async () => {
const auth = await google.auth.getClient({
Expand Down
2 changes: 1 addition & 1 deletion healthcare/fhir/getFhirResourceHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const main = (
) => {
// [START healthcare_get_resource_history]
const {google} = require('googleapis');
const healthcare = google.healthcare('v1beta1');
const healthcare = google.healthcare('v1');

const getFhirResourceHistory = async () => {
const auth = await google.auth.getClient({
Expand Down
2 changes: 1 addition & 1 deletion healthcare/fhir/getFhirStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const main = (
) => {
// [START healthcare_get_fhir_store]
const {google} = require('googleapis');
const healthcare = google.healthcare('v1beta1');
const healthcare = google.healthcare('v1');

const getFhirStore = async () => {
const auth = await google.auth.getClient({
Expand Down
2 changes: 1 addition & 1 deletion healthcare/fhir/getFhirStoreCapabilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const main = (
) => {
// [START healthcare_get_metadata]
const {google} = require('googleapis');
const healthcare = google.healthcare('v1beta1');
const healthcare = google.healthcare('v1');

const getFhirStoreCapabilities = async () => {
const auth = await google.auth.getClient({
Expand Down
2 changes: 1 addition & 1 deletion healthcare/fhir/getFhirStoreIamPolicy.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const main = (
) => {
// [START healthcare_fhir_store_get_iam_policy]
const {google} = require('googleapis');
const healthcare = google.healthcare('v1beta1');
const healthcare = google.healthcare('v1');

const getFhirStoreIamPolicy = async () => {
const auth = await google.auth.getClient({
Expand Down
2 changes: 1 addition & 1 deletion healthcare/fhir/getPatientEverything.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const main = (
) => {
// [START healthcare_get_patient_everything]
const {google} = require('googleapis');
const healthcare = google.healthcare('v1beta1');
const healthcare = google.healthcare('v1');

const getPatientEverything = async () => {
const auth = await google.auth.getClient({
Expand Down
2 changes: 1 addition & 1 deletion healthcare/fhir/importFhirResources.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const main = (
) => {
// [START healthcare_import_fhir_resources]
const {google} = require('googleapis');
const healthcare = google.healthcare('v1beta1');
const healthcare = google.healthcare('v1');
const sleep = require('../sleep');

const importFhirResources = async () => {
Expand Down
2 changes: 1 addition & 1 deletion healthcare/fhir/listFhirResourceHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const main = (
) => {
// [START healthcare_list_resource_history]
const {google} = require('googleapis');
const healthcare = google.healthcare('v1beta1');
const healthcare = google.healthcare('v1');

const listFhirResourceHistory = async () => {
const auth = await google.auth.getClient({
Expand Down
2 changes: 1 addition & 1 deletion healthcare/fhir/listFhirStores.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const main = (
) => {
// [START healthcare_list_fhir_stores]
const {google} = require('googleapis');
const healthcare = google.healthcare('v1beta1');
const healthcare = google.healthcare('v1');

const listFhirStores = async () => {
const auth = await google.auth.getClient({
Expand Down
2 changes: 1 addition & 1 deletion healthcare/fhir/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"mocha": "^7.0.0"
},
"dependencies": {
"googleapis": "^48.0.0",
"googleapis": "^49.0.0",
"uuid": "^7.0.0",
"yargs": "^15.0.0",
"gtoken": "^5.0.0",
Expand Down
2 changes: 1 addition & 1 deletion healthcare/fhir/patchFhirStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const main = (
) => {
// [START healthcare_patch_fhir_store]
const {google} = require('googleapis');
const healthcare = google.healthcare('v1beta1');
const healthcare = google.healthcare('v1');

const patchFhirStore = async () => {
const auth = await google.auth.getClient({
Expand Down
2 changes: 1 addition & 1 deletion healthcare/fhir/searchFhirResourcesGet.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const main = (
) => {
// [START healthcare_search_resources_get]
const {google} = require('googleapis');
const healthcare = google.healthcare('v1beta1');
const healthcare = google.healthcare('v1');

const searchFhirResourcesGet = async () => {
const auth = await google.auth.getClient({
Expand Down
2 changes: 1 addition & 1 deletion healthcare/fhir/searchFhirResourcesPost.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const main = (
) => {
// [START healthcare_search_resources_post]
const {google} = require('googleapis');
const healthcare = google.healthcare('v1beta1');
const healthcare = google.healthcare('v1');

const searchFhirResourcesPost = async () => {
const auth = await google.auth.getClient({
Expand Down
2 changes: 1 addition & 1 deletion healthcare/fhir/setFhirStoreIamPolicy.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const main = (
) => {
// [START healthcare_fhir_store_set_iam_policy]
const {google} = require('googleapis');
const healthcare = google.healthcare('v1beta1');
const healthcare = google.healthcare('v1');

const setFhirStoreIamPolicy = async () => {
const auth = await google.auth.getClient({
Expand Down
28 changes: 14 additions & 14 deletions healthcare/fhir/system-test/fhir_resources.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,26 +45,26 @@ before(() => {
);
execSync(
`node createDataset.js ${projectId} ${cloudRegion} ${datasetId}`,
cwdDatasets
{cwd: cwdDatasets}
);
});
after(() => {
try {
execSync(
`node deleteDataset.js ${projectId} ${cloudRegion} ${datasetId}`,
cwdDatasets
{cwd: cwdDatasets}
);
} catch (err) {} // Ignore error
});

it('should create a FHIR resource', () => {
execSync(
`node createFhirStore.js ${projectId} ${cloudRegion} ${datasetId} ${fhirStoreId}`,
cwd
{cwd}
);
const output = execSync(
`node fhir_resources.js createResource ${datasetId} ${fhirStoreId} ${resourceType}`,
cwd
{cwd}
);
const createdResource = new RegExp(
`Created FHIR resource ${resourceType} with ID (.*).`
Expand All @@ -76,7 +76,7 @@ it('should create a FHIR resource', () => {
it('should get a FHIR resource', () => {
const output = execSync(
`node getFhirResource.js ${projectId} ${cloudRegion} ${datasetId} ${fhirStoreId} ${resourceType} ${resourceId}`,
cwd
{cwd}
);
assert.strictEqual(
new RegExp(`Got ${resourceType} resource`).test(output),
Expand All @@ -87,7 +87,7 @@ it('should get a FHIR resource', () => {
it('should list and get a FHIR resource history', () => {
let output = execSync(
`node listFhirResourceHistory.js ${projectId} ${cloudRegion} ${datasetId} ${fhirStoreId} ${resourceType} ${resourceId}`,
cwd
{cwd}
);
assert.ok(output.includes('versionId'));

Expand All @@ -105,15 +105,15 @@ it('should list and get a FHIR resource history', () => {

output = execSync(
`node getFhirResourceHistory.js ${projectId} ${cloudRegion} ${datasetId} ${fhirStoreId} ${resourceType} ${resourceId} ${versionId}`,
cwd
{cwd}
);
assert.ok(output.includes(versionId));
});

it('should get everything in Patient compartment', () => {
const output = execSync(
`node getPatientEverything.js ${projectId} ${cloudRegion} ${datasetId} ${fhirStoreId} ${resourceId}`,
cwd
{cwd}
);
assert.strictEqual(
new RegExp(`Got all resources in patient ${resourceId} compartment`).test(
Expand All @@ -126,7 +126,7 @@ it('should get everything in Patient compartment', () => {
it('should update a FHIR resource', () => {
const output = execSync(
`node updateFhirResource.js ${projectId} ${cloudRegion} ${datasetId} ${fhirStoreId} ${resourceType} ${resourceId}`,
cwd
{cwd}
);
assert.strictEqual(
new RegExp(`Updated ${resourceType} resource`).test(output),
Expand All @@ -137,7 +137,7 @@ it('should update a FHIR resource', () => {
it('should patch a FHIR resource', () => {
const output = execSync(
`node fhir_resources.js patchResource ${datasetId} ${fhirStoreId} ${resourceType} ${resourceId}`,
cwd
{cwd}
);
assert.strictEqual(output, `Patched ${resourceType} resource`);
});
Expand All @@ -159,7 +159,7 @@ it('should search for FHIR resources using POST', () => {
it('should purge all historical versions of a FHIR resource', () => {
const output = execSync(
`node deleteFhirResourcePurge.js ${projectId} ${cloudRegion} ${datasetId} ${fhirStoreId} ${resourceType} ${resourceId}`,
cwd
{cwd}
);
assert.strictEqual(
output,
Expand All @@ -170,21 +170,21 @@ it('should purge all historical versions of a FHIR resource', () => {
it('should execute a Bundle', () => {
const output = execSync(
`node fhir_resources.js executeBundle ${datasetId} ${fhirStoreId} ${bundleFile}`,
cwd
{cwd}
);
assert.strictEqual(new RegExp('Executed Bundle').test(output), true);
});

it('should delete a FHIR resource', () => {
const output = execSync(
`node deleteFhirResource.js ${projectId} ${cloudRegion} ${datasetId} ${fhirStoreId} ${resourceType} ${resourceId}`,
cwd
{cwd}
);
assert.strictEqual(output, `Deleted FHIR resource ${resourceType}`);

// Clean up
execSync(
`node deleteFhirStore.js ${projectId} ${cloudRegion} ${datasetId} ${fhirStoreId}`,
cwd
{cwd}
);
});
20 changes: 10 additions & 10 deletions healthcare/fhir/system-test/fhir_stores.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ before(async () => {
console.log(`Topic ${topic.name} created.`);
execSync(
`node createDataset.js ${projectId} ${cloudRegion} ${datasetId}`,
cwdDatasets
{cwd: cwdDatasets}
);
});

Expand All @@ -78,55 +78,55 @@ after(async () => {
console.log(`Topic ${topicName} deleted.`);
execSync(
`node deleteDataset.js ${projectId} ${cloudRegion} ${datasetId}`,
cwdDatasets
{cwd: cwdDatasets}
);
} catch (err) {} // Ignore error
});

it('should create a FHIR store', () => {
const output = execSync(
`node createFhirStore.js ${projectId} ${cloudRegion} ${datasetId} ${fhirStoreId}`,
cwd
{cwd}
);
assert.ok(output.includes('Created FHIR store'));
});

it('should get a FHIR store', () => {
const output = execSync(
`node getFhirStore.js ${projectId} ${cloudRegion} ${datasetId} ${fhirStoreId}`,
cwd
{cwd}
);
assert.ok(output.includes('name'));
});

it('should list FHIR stores', () => {
const output = execSync(
`node listFhirStores.js ${projectId} ${cloudRegion} ${datasetId}`,
cwd
{cwd}
);
assert.ok(output.includes('fhirStores'));
});

it('should patch a FHIR store', () => {
const output = execSync(
`node patchFhirStore.js ${projectId} ${cloudRegion} ${datasetId} ${fhirStoreId} ${topicName}`,
cwd
{cwd}
);
assert.ok(output.includes('Patched FHIR store'));
});

it('should import FHIR resources into a FHIR store from Cloud Storage', () => {
const output = execSync(
`node importFhirResources.js ${projectId} ${cloudRegion} ${datasetId} ${fhirStoreId} ${gcsUri}`,
cwd
{cwd}
);
assert.ok(output.includes('Import FHIR resources succeeded'));
});

it('should export FHIR resources from a FHIR store to Cloud Storage', () => {
const output = execSync(
`node exportFhirResources.js ${projectId} ${cloudRegion} ${datasetId} ${fhirStoreId} ${gcsUri}`,
cwd
{cwd}
);
assert.ok(output.includes('Exported FHIR resources successfully'));
});
Expand All @@ -137,7 +137,7 @@ it('should create and get a FHIR store IAM policy', () => {

let output = execSync(
`node setFhirStoreIamPolicy.js ${projectId} ${cloudRegion} ${datasetId} ${fhirStoreId} ${localMember} ${localRole}`,
cwd
{cwd}
);
assert.ok(output.includes, 'ETAG');

Expand All @@ -150,7 +150,7 @@ it('should create and get a FHIR store IAM policy', () => {
it('should delete a FHIR store', () => {
const output = execSync(
`node deleteFhirStore.js ${projectId} ${cloudRegion} ${datasetId} ${fhirStoreId}`,
cwd
{cwd}
);
assert.ok(output.includes('Deleted FHIR store'));
});
2 changes: 1 addition & 1 deletion healthcare/fhir/updateFhirResource.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const main = (
) => {
// [START healthcare_update_resource]
const {google} = require('googleapis');
const healthcare = google.healthcare('v1beta1');
const healthcare = google.healthcare('v1');

const updateFhirResource = async () => {
const auth = await google.auth.getClient({
Expand Down