Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { google } from 'googleapis';
- import * as fs from 'fs';
- const healthcare = google.healthcare({
- version: 'v1',
- auth: new google.auth.GoogleAuth({
- scopes: ['https://www.googleapis.com/auth/cloud-platform'],
- }),
- });
- const projectID = 'TODO_PROJECT';
- const location = 'TODO_LOCATION';
- const datasetID = 'TODO_DATASET';
- const sourceStoreID = 'TODO_SOURCE';
- const destStoreID = 'TODO_DEST';
- const inputFile = 'multipart-request.file';
- const sourceStore = `projects/${projectID}/locations/${location}/datasets/${datasetID}/dicomStores/${sourceStoreID}`;
- const destinationStore = `projects/${projectID}/locations/${location}/datasets/${datasetID}/dicomStores/${destStoreID}`;
- async function waitForOperation(name) {
- while (true) {
- const op = await healthcare.projects.locations.datasets.operations.get({
- name,
- });
- if (op.data.done) {
- console.log(op.data);
- return
- }
- }
- }
- async function main() {
- console.log('running');
- try {
- const input = fs.createReadStream(inputFile);
- const res = await healthcare.projects.locations.datasets.dicomStores.storeInstances(
- {
- parent: sourceStore,
- dicomWebPath: 'studies',
- requestBody: input,
- },
- {
- headers: {
- 'Content-Type': 'multipart/related; type="application/dicom+json"; boundary=DICOMwebBoundary',
- Accept: 'application/dicom+json',
- },
- })
- console.log(res.data);
- const op = await healthcare.projects.locations.datasets.dicomStores.deidentify({
- sourceStore: sourceStore,
- destinationStore: destinationStore,
- resource: {
- config: {
- dicom: {
- filterProfile: 'DEIDENTIFY_TAG_CONTENTS'
- },
- text: {
- transformations: [
- {
- infoTypes: ['PERSON_NAME'],
- characterMaskConfig: { maskingCharacter: '*' }
- },
- ]
- },
- image: {
- textRedactionMode: 'REDACT_SENSITIVE_TEXT',
- },
- },
- filterConfig: {},
- },
- });
- await waitForOperation(op.data.name);
- const instances = await healthcare.projects.locations.datasets.dicomStores.searchForInstances(
- {
- parent: destinationStore,
- dicomWebPath: 'instances',
- },
- {
- headers: {
- 'Accept': 'application/dicom+json,multipart/related'
- }
- })
- console.log(JSON.stringify(instances.data));
- } catch (e) {
- console.error(e);
- }
- };
- await main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement