|
| 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 | +const main = ( |
| 21 | + projectId = process.env.GCLOUD_PROJECT, |
| 22 | + cloudRegion = 'us-central1', |
| 23 | + datasetId, |
| 24 | + dicomStoreId |
| 25 | +) => { |
| 26 | + // [START healthcare_dicomweb_search_studies] |
| 27 | + const {google} = require('googleapis'); |
| 28 | + const healthcare = google.healthcare('v1beta1'); |
| 29 | + |
| 30 | + const dicomWebSearchStudies = async () => { |
| 31 | + const auth = await google.auth.getClient({ |
| 32 | + scopes: ['https://www.googleapis.com/auth/cloud-platform'], |
| 33 | + }); |
| 34 | + |
| 35 | + google.options({ |
| 36 | + auth, |
| 37 | + // Refine your search by appending DICOM tags to the |
| 38 | + // request in the form of query parameters. This sample |
| 39 | + // searches for studies containing a patient's name. |
| 40 | + params: {PatientName: 'Sally Zhang'}, |
| 41 | + headers: {Accept: 'application/dicom+json'}, |
| 42 | + }); |
| 43 | + |
| 44 | + // TODO(developer): uncomment these lines before running the sample |
| 45 | + // const cloudRegion = 'us-central1'; |
| 46 | + // const projectId = 'adjective-noun-123'; |
| 47 | + // const datasetId = 'my-dataset'; |
| 48 | + // const dicomStoreId = 'my-dicom-store'; |
| 49 | + const parent = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/dicomStores/${dicomStoreId}`; |
| 50 | + const dicomWebPath = `studies`; |
| 51 | + const request = {parent, dicomWebPath}; |
| 52 | + |
| 53 | + const studies = await healthcare.projects.locations.datasets.dicomStores.searchForStudies( |
| 54 | + request |
| 55 | + ); |
| 56 | + console.log(studies); |
| 57 | + |
| 58 | + console.log(`Found ${studies.data.length} studies:`); |
| 59 | + console.log(JSON.stringify(studies.data)); |
| 60 | + }; |
| 61 | + |
| 62 | + dicomWebSearchStudies(); |
| 63 | + // [END healthcare_dicomweb_search_studies] |
| 64 | +}; |
| 65 | + |
| 66 | +// node dicomWebSearchStudies.js <projectId> <cloudRegion> <datasetId> <dicomStoreId> |
| 67 | +main(...process.argv.slice(2)); |
0 commit comments