Creating and managing DICOM stores

This page explains how to create, edit, view, and delete Digital Imaging and Communications in Medicine (DICOM) stores.

Creating a DICOM store

Before you can create a DICOM store, you need to create a dataset.

The following samples show how to create a DICOM store.

Console

To create a DICOM store:
  1. In the GCP Console, go to the Datasets page.

    Go to the Datasets page

  2. Open the dataset where you want to create a DICOM store.
  3. Click Create Data Store.
  4. Enter a name of your choice that's unique in your dataset. If the name is not unique, the data store creation fails.
  5. Select DICOM as the data store type.
  6. Click Create.
  7. If you want to configure a Cloud Pub/Sub topic for the data store, type the topic name. When specifying a Cloud Pub/Sub topic, enter the qualified URI to the topic, as shown in the following sample:
    projects/PROJECT_ID/topics/PUBSUB_TOPIC
    
  8. Click Create.
The new data store appears in the list.

gcloud

To create a DICOM store in the dataset, run the gcloud beta healthcare dicom-stores create command.

  • The DICOM store ID must be unique in the dataset. It can be any Unicode string of 1 to 256 characters consisting of numbers, letters, underscores, dashes, and periods.
  • To notify a Cloud Pub/Sub topic of DICOM store changes, specify an existing Cloud Pub/Sub topic name using the --pubsub-topic argument. When specifying a Cloud Pub/Sub topic, enter the qualified URI to the topic, as shown in the following sample:
    projects/PROJECT_ID/topics/PUBSUB_TOPIC
    

The following sample shows how to create a DICOM store.

gcloud beta healthcare dicom-stores create DICOM_STORE_ID \
  --dataset=DATASET_ID \
  --location=REGION \
  [--pubsub-topic=projects/PROJECT_ID/topics/PUBSUB_TOPIC]

If the request is successful, the command prompt displays the following message:

Created dicomStore [DICOM_STORE_ID].

API

To create a DICOM store, use the projects.locations.datasets.dicomStores.create method.

curl command

To create a DICOM store, make a POST request and specify the following information:

  • The name of the parent dataset
  • A name for the DICOM store. The DICOM store ID must be unique in its parent dataset. It can be any Unicode string of 1 to 256 characters consisting of numbers, letters, underscores, dashes, and periods.
  • An access token
  • Optionally, an existing Cloud Pub/Sub topic to which the Cloud Healthcare API sends notifications of DICOM store changes. See Editing a DICOM store for information on how to configure the Cloud Pub/Sub topic.

The following sample shows a POST request using curl.

curl -X POST \
    --data "" \
    -H "Authorization: Bearer "$(gcloud auth print-access-token) \
    -H "Content-Type: application/json; charset=utf-8" \
    "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/dicomStores?dicomStoreId=DICOM_STORE_ID"

If the request is successful, the server returns a 200 OK HTTP status code and the response in JSON format:

200 OK
{
  "name": "projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID"
}

PowerShell

To create a DICOM store, make a POST request and specify the following information:

  • The name of the parent dataset
  • A name for the DICOM store. The DICOM store ID must be unique in its parent dataset. It can be any Unicode string of 1 to 256 characters consisting of numbers, letters, underscores, dashes, and periods.
  • An access token
  • Optionally, an existing Cloud Pub/Sub topic to which the Cloud Healthcare API sends notifications of DICOM store changes. See Editing a DICOM store for information on how to configure the Cloud Pub/Sub topic.

The following sample shows a POST request using Windows PowerShell.

$cred = gcloud auth print-access-token
$headers = @{ Authorization = "Bearer $cred" }

Invoke-WebRequest `
  -Method Post `
  -Headers $headers `
  -ContentType: "application/json; charset=utf-8" `
  -Uri "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/dicomStores?dicomStoreId=DICOM_STORE_ID" | Select-Object -Expand Content

If the request is successful, the server returns a 200 OK HTTP status code and the response in JSON format:

200 OK
{
  "name": "projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID"
}

Go

import (
	"context"
	"fmt"
	"io"

	healthcare "google.golang.org/api/healthcare/v1beta1"
)

// createDICOMStore creates a DICOM store.
func createDICOMStore(w io.Writer, projectID, location, datasetID, dicomStoreID string) error {
	ctx := context.Background()

	healthcareService, err := healthcare.NewService(ctx)
	if err != nil {
		return fmt.Errorf("healthcare.NewService: %v", err)
	}

	storesService := healthcareService.Projects.Locations.Datasets.DicomStores

	store := &healthcare.DicomStore{}
	parent := fmt.Sprintf("projects/%s/locations/%s/datasets/%s", projectID, location, datasetID)

	resp, err := storesService.Create(parent, store).DicomStoreId(dicomStoreID).Do()
	if err != nil {
		return fmt.Errorf("Create: %v", err)
	}

	fmt.Fprintf(w, "Created DICOM store: %q\n", resp.Name)
	return nil
}

Java

import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
import com.google.api.client.http.HttpHeaders;
import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.services.healthcare.v1beta1.CloudHealthcare;
import com.google.api.services.healthcare.v1beta1.CloudHealthcare.Projects.Locations.Datasets.DicomStores;
import com.google.api.services.healthcare.v1beta1.CloudHealthcareScopes;
import com.google.api.services.healthcare.v1beta1.model.DicomStore;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public class DicomStoreCreate {
  private static final String DATASET_NAME = "projects/%s/locations/%s/datasets/%s";
  private static final JsonFactory JSON_FACTORY = new JacksonFactory();
  private static final NetHttpTransport HTTP_TRANSPORT = new NetHttpTransport();

  public static void dicomStoreCreate(String datasetName, String dicomStoreId) throws IOException {
    // String datasetName =
    //     String.format(DATASET_NAME, "your-project-id", "your-region-id", "your-dataset-id");

    // Initialize the client, which will be used to interact with the service.
    CloudHealthcare client = createClient();

    // Configure the dicomStore to be created.
    Map<String, String> labels = new HashMap<String, String>();
    labels.put("key1", "value1");
    labels.put("key2", "value2");
    DicomStore content = new DicomStore().setLabels(labels);

    // Create request and configure any parameters.
    DicomStores.Create request =
        client
            .projects()
            .locations()
            .datasets()
            .dicomStores()
            .create(datasetName, content)
            .setDicomStoreId(dicomStoreId);

    // Execute the request and process the results.
    DicomStore response = request.execute();
    System.out.println("DICOM store created: " + response.toPrettyString());
  }

  private static CloudHealthcare createClient() throws IOException {
    // Use Application Default Credentials (ADC) to authenticate the requests
    // For more information see https://cloud.google.com/docs/authentication/production
    GoogleCredential credential =
        GoogleCredential.getApplicationDefault(HTTP_TRANSPORT, JSON_FACTORY)
            .createScoped(Collections.singleton(CloudHealthcareScopes.CLOUD_PLATFORM));

    // Create a HttpRequestInitializer, which will provide a baseline configuration to all requests.
    HttpRequestInitializer requestInitializer =
        request -> {
          credential.initialize(request);
          request.setHeaders(new HttpHeaders().set("X-GFE-SSL", "yes"));
          request.setConnectTimeout(60000); // 1 minute connect timeout
          request.setReadTimeout(60000); // 1 minute read timeout
        };

    // Build the client for interacting with the service.
    return new CloudHealthcare.Builder(HTTP_TRANSPORT, JSON_FACTORY, requestInitializer)
        .setApplicationName("your-application-name")
        .build();
  }
}

Node.js

const {google} = require('googleapis');
const healthcare = google.healthcare('v1beta1');

async function createDicomStore() {
  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 dicomStoreId = 'my-dicom-store';
  const parent = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}`;
  const request = {parent, dicomStoreId};

  await healthcare.projects.locations.datasets.dicomStores.create(request);
  console.log(`Created DICOM store: ${dicomStoreId}`);
}

createDicomStore();

Python

def create_dicom_store(
        service_account_json,
        project_id,
        cloud_region,
        dataset_id,
        dicom_store_id):
    """Creates a new DICOM store within the parent dataset."""
    client = get_client(service_account_json)
    dicom_store_parent = 'projects/{}/locations/{}/datasets/{}'.format(
        project_id, cloud_region, dataset_id)

    body = {}

    request = client.projects().locations().datasets().dicomStores().create(
        parent=dicom_store_parent, body=body, dicomStoreId=dicom_store_id)

    try:
        response = request.execute()
        print('Created DICOM store: {}'.format(dicom_store_id))
        return response
    except HttpError as e:
        print('Error, DICOM store not created: {}'.format(e))
        return ""

Editing a DICOM store

The following samples show how to make the following changes to a DICOM store:

  • Edit the Cloud Pub/Sub topic to which the Cloud Healthcare API sends notifications of DICOM store changes.
  • Edit the labels. Labels are key-value pairs that help you organize your GCP resources.
When specifying a Cloud Pub/Sub topic, enter the qualified URI to the topic, as shown in the following sample:
projects/PROJECT_ID/topics/PUBSUB_TOPIC
For notifications to work, you must grant additional permissions to the Cloud Healthcare Service Agent service account. For more information, see DICOM, FHIR, and HL7v2 store Cloud Pub/Sub permissions.

Console

GCP Console does not support editing the Cloud Pub/Sub topic or labels. Instead, use curl, Windows PowerShell, or your preferred language.

gcloud

To update the DICOM store, run the gcloud beta healthcare dicom-stores update command.

The following sample shows how to update the Cloud Pub/Sub topic for the DICOM store. gcloud tool does not support editing labels.

gcloud beta healthcare dicom-stores update DICOM_STORE_ID \
  --dataset=DATASET_ID \
  --location=REGION \
  --pubsub-topic=projects/PROJECT_ID/topics/PUBSUB_TOPIC 

If the request is successful, the command prompt displays the DICOM store details including the new topic name:

Updated dicomStore [DICOM_STORE_ID].
name: projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/dicom-stores/DICOM_STORE_ID
notificationConfig:
pubsubTopic: projects/PROJECT_ID/topics/PUBSUB_TOPIC

API

To edit a DICOM store, use the projects.locations.datasets.dicomStores.patch method.

curl command

To edit a DICOM store, make a PATCH request and specify the following information:

  • The name of the parent dataset
  • The name of the DICOM store
  • The metadata to update. In this example, the qualified URI to the Cloud Pub/Sub topic and the labels to update as a comma-delimited list of key-value pairs.
  • An update mask
  • An access token

The following sample shows a PATCH request using curl.

curl -X PATCH \
    -H "Authorization: Bearer "$(gcloud auth print-access-token) \
    -H "Content-Type: application/json; charset=utf-8" \
    --data "{
      'notificationConfig': {
        'pubsubTopic':'projects/PROJECT_ID/topics/PUBSUB_TOPIC'
      },
      'labels': {
        'KEY1':'VALUE1','KEY2':'VALUE2'
      }
    }" \
    "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID?updateMask=notificationConfig,labels"

If the request is successful, the server returns a 200 OK HTTP status code and the response in JSON format:

200 OK
{
  "name": "projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID",
  "notificationConfig": {
    "pubsubTopic": "projects/PROJECT_ID/topics/PUBSUB_TOPIC"
  },
  'labels': {
    'KEY1':'VALUE1','KEY2':'VALUE2'
  }
}

PowerShell

To edit a DICOM store, make a PATCH request and specify the following information:

  • The name of the parent dataset
  • The name of the DICOM store
  • The metadata to update. In this example, the qualified URI to the Cloud Pub/Sub topic and the labels to update as a comma-delimited list of key-value pairs.
  • An update mask
  • An access token

The following sample shows a PATCH request using Windows PowerShell.

$cred = gcloud auth print-access-token
$headers = @{ Authorization = "Bearer $cred" }

Invoke-WebRequest `
  -Method Patch `
  -Headers $headers `
  -ContentType: "application/json; charset=utf-8" `
  -Body "{
      'notificationConfig': {
        'pubsubTopic': 'projects/PROJECT_ID/topics/PUBSUB_TOPIC'
      },
      'labels': {
        'KEY1':'VALUE1','KEY2':'VALUE2'
      }
  }" `
  -Uri "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID?updateMask=notificationConfig,labels" | Select-Object -Expand Content

If the request is successful, the server returns a 200 OK HTTP status code and the response in JSON format:

200 OK
{
  "name": "projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID",
  "notificationConfig": {
    "pubsubTopic": "projects/PROJECT_ID/topics/PUBSUB_TOPIC"
  },
  'labels': {
    'KEY1':'VALUE1','KEY2':'VALUE2'
  }
}

Go

import (
	"context"
	"fmt"
	"io"

	healthcare "google.golang.org/api/healthcare/v1beta1"
)

// patchDICOMStore updates (patches) a DICOM store by updating its Pub/sub topic name.
func patchDICOMStore(w io.Writer, projectID, location, datasetID, dicomStoreID, topicName string) error {
	ctx := context.Background()

	healthcareService, err := healthcare.NewService(ctx)
	if err != nil {
		return fmt.Errorf("healthcare.NewService: %v", err)
	}

	storesService := healthcareService.Projects.Locations.Datasets.DicomStores

	name := fmt.Sprintf("projects/%s/locations/%s/datasets/%s/dicomStores/%s", projectID, location, datasetID, dicomStoreID)

	if _, err := storesService.Patch(name, &healthcare.DicomStore{
		NotificationConfig: &healthcare.NotificationConfig{
			PubsubTopic: topicName, // format is "projects/*/locations/*/topics/*"
		},
	}).UpdateMask("notificationConfig").Do(); err != nil {
		return fmt.Errorf("Patch: %v", err)
	}

	fmt.Fprintf(w, "Patched DICOM store %s with Pub/sub topic %s\n", datasetID, topicName)

	return nil
}

Java

import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
import com.google.api.client.http.HttpHeaders;
import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.services.healthcare.v1beta1.CloudHealthcare;
import com.google.api.services.healthcare.v1beta1.CloudHealthcare.Projects.Locations.Datasets.DicomStores;
import com.google.api.services.healthcare.v1beta1.CloudHealthcareScopes;
import com.google.api.services.healthcare.v1beta1.model.DicomStore;
import com.google.api.services.healthcare.v1beta1.model.NotificationConfig;
import java.io.IOException;
import java.util.Collections;

public class DicomStorePatch {
  private static final JsonFactory JSON_FACTORY = new JacksonFactory();
  private static final NetHttpTransport HTTP_TRANSPORT = new NetHttpTransport();

  public static void patchDicomStore(String dicomStoreName, String pubsubTopic) throws IOException {
    // String dicomStoreName =
    //    String.format(
    //        DICOM_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-dicom-id");
    // String pubsubTopic = "your-pubsub-topic";

    // Initialize the client, which will be used to interact with the service.
    CloudHealthcare client = createClient();

    // Fetch the initial state of the DICOM store.
    DicomStores.Get getRequest =
        client.projects().locations().datasets().dicomStores().get(dicomStoreName);
    DicomStore store = getRequest.execute();

    // Update the DicomStore fields as needed as needed. For a full list of DicomStore fields, see:
    // https://cloud.google.com/healthcare/docs/reference/rest/v1beta1/projects.locations.datasets.dicomStores#DicomStore
    store.setNotificationConfig(new NotificationConfig().setPubsubTopic(pubsubTopic));

    // Create request and configure any parameters.
    DicomStores.Patch request =
        client
            .projects()
            .locations()
            .datasets()
            .dicomStores()
            .patch(dicomStoreName, store)
            .setUpdateMask("notificationConfig");

    // Execute the request and process the results.
    store = request.execute();
    System.out.println("DICOM store patched: \n" + store.toPrettyString());
  }

  private static CloudHealthcare createClient() throws IOException {
    // Use Application Default Credentials (ADC) to authenticate the requests
    // For more information see https://cloud.google.com/docs/authentication/production
    GoogleCredential credential =
        GoogleCredential.getApplicationDefault(HTTP_TRANSPORT, JSON_FACTORY)
            .createScoped(Collections.singleton(CloudHealthcareScopes.CLOUD_PLATFORM));

    // Create a HttpRequestInitializer, which will provide a baseline configuration to all requests.
    HttpRequestInitializer requestInitializer =
        request -> {
          credential.initialize(request);
          request.setHeaders(new HttpHeaders().set("X-GFE-SSL", "yes"));
          request.setConnectTimeout(60000); // 1 minute connect timeout
          request.setReadTimeout(60000); // 1 minute read timeout
        };

    // Build the client for interacting with the service.
    return new CloudHealthcare.Builder(HTTP_TRANSPORT, JSON_FACTORY, requestInitializer)
        .setApplicationName("your-application-name")
        .build();
  }
}

Node.js

const {google} = require('googleapis');
const healthcare = google.healthcare('v1beta1');

async function patchDicomStore() {
  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 dicomStoreId = 'my-dicom-store';
  // const pubsubTopic = 'my-topic'
  const name = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/dicomStores/${dicomStoreId}`;
  const request = {
    name,
    updateMask: 'notificationConfig',
    resource: {
      notificationConfig: {
        pubsubTopic: `projects/${projectId}/topics/${pubsubTopic}`,
      },
    },
  };

  await healthcare.projects.locations.datasets.dicomStores.patch(request);
  console.log(
    `Patched DICOM store ${dicomStoreId} with Cloud Pub/Sub topic ${pubsubTopic}`
  );
}

patchDicomStore();

Python

def patch_dicom_store(
        service_account_json,
        project_id,
        cloud_region,
        dataset_id,
        dicom_store_id,
        pubsub_topic):
    """Updates the DICOM store."""
    client = get_client(service_account_json)
    dicom_store_parent = 'projects/{}/locations/{}/datasets/{}'.format(
        project_id, cloud_region, dataset_id)
    dicom_store_name = '{}/dicomStores/{}'.format(
        dicom_store_parent, dicom_store_id)

    patch = {
        'notificationConfig': {
            'pubsubTopic': 'projects/{}/locations/{}/topics/{}'.format(
                project_id,
                cloud_region,
                pubsub_topic)}}

    request = client.projects().locations().datasets().dicomStores().patch(
        name=dicom_store_name, updateMask='notificationConfig', body=patch)

    try:
        response = request.execute()
        print(
            'Patched DICOM store {} with Cloud Pub/Sub topic: {}'.format(
                dicom_store_id,
                pubsub_topic))
        return response
    except HttpError as e:
        print('Error, DICOM store not patched: {}'.format(e))
        return ""

Getting DICOM store details

The following samples show how to get details about a DICOM store.

Console

To view a DICOM store's details:
  1. In the GCP Console, go to the Datasets page.

    Go to the Datasets page

  2. Click the ID of the dataset that contains the DICOM store.
  3. Click the name of the DICOM store.
Note: GCP Console does not display the Cloud Pub/Sub topic to which the Healthcare API sends notifications.

gcloud

To view details about a DICOM store, run the gcloud beta healthcare dicom-stores describe command.

The following sample shows how to get details about a DICOM store.

gcloud beta healthcare dicom-stores describe DICOM_STORE_ID \
  --dataset=DATASET_ID \
  --location=REGION 

If the request is successful, the command prompt displays the DICOM store details:

name: projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/dicom-stores/DICOM_STORE_ID

API

To get details about a DICOM store, use the projects.locations.datasets.dicomStores.get method.

curl command

To get details about a DICOM store, make a GET request and specify the following information:

  • The name of the parent dataset
  • The name of the DICOM store
  • An access token

The following sample shows a GET request using curl.

curl -X GET \
     -H "Authorization: Bearer "$(gcloud auth print-access-token) \
     "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID"

If the request is successful, the server returns a 200 OK HTTP status code and the response in JSON format:

200 OK
{
  "name": "projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID"
}

If you configured any fields in the DicomStore resource, they also appear in the response.

PowerShell

To get details about a DICOM store, make a GET request and specify the following information:

  • The name of the parent dataset
  • The name of the DICOM store
  • An access token

The following sample shows a GET request using Windows PowerShell.

$cred = gcloud auth print-access-token
$headers = @{ Authorization = "Bearer $cred" }

Invoke-WebRequest `
  -Method Get `
  -Headers $headers `
  -Uri "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID" | Select-Object -Expand Content

If the request is successful, the server returns a 200 OK HTTP status code and the response in JSON format:

200 OK
{
  "name": "projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID"
}

If you configured any fields in the DicomStore resource, they also appear in the response.

Go

import (
	"context"
	"fmt"
	"io"

	healthcare "google.golang.org/api/healthcare/v1beta1"
)

// getDICOMStore gets a DICOM store.
func getDICOMStore(w io.Writer, projectID, location, datasetID, dicomStoreID string) error {
	ctx := context.Background()

	healthcareService, err := healthcare.NewService(ctx)
	if err != nil {
		return fmt.Errorf("healthcare.NewService: %v", err)
	}

	storesService := healthcareService.Projects.Locations.Datasets.DicomStores

	name := fmt.Sprintf("projects/%s/locations/%s/datasets/%s/dicomStores/%s", projectID, location, datasetID, dicomStoreID)

	store, err := storesService.Get(name).Do()
	if err != nil {
		return fmt.Errorf("Get: %v", err)
	}

	fmt.Fprintf(w, "Got DICOM store: %+v\n", store)
	return nil
}

Java

import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
import com.google.api.client.http.HttpHeaders;
import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.services.healthcare.v1beta1.CloudHealthcare;
import com.google.api.services.healthcare.v1beta1.CloudHealthcare.Projects.Locations.Datasets.DicomStores;
import com.google.api.services.healthcare.v1beta1.CloudHealthcareScopes;
import com.google.api.services.healthcare.v1beta1.model.DicomStore;
import java.io.IOException;
import java.util.Collections;

public class DicomStoreGet {
  private static final String DICOM_NAME = "projects/%s/locations/%s/datasets/%s/dicomStores/%s";
  private static final JsonFactory JSON_FACTORY = new JacksonFactory();
  private static final NetHttpTransport HTTP_TRANSPORT = new NetHttpTransport();

  public static void dicomeStoreGet(String dicomStoreName) throws IOException {
    // String dicomStoreName =
    //    String.format(
    //        DICOM_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-dicom-id");

    // Initialize the client, which will be used to interact with the service.
    CloudHealthcare client = createClient();

    // Create request and configure any parameters.
    DicomStores.Get request =
        client.projects().locations().datasets().dicomStores().get(dicomStoreName);

    // Execute the request and process the results.
    DicomStore store = request.execute();
    System.out.println("DICOM store retrieved: \n" + store.toPrettyString());
  }

  private static CloudHealthcare createClient() throws IOException {
    // Use Application Default Credentials (ADC) to authenticate the requests
    // For more information see https://cloud.google.com/docs/authentication/production
    GoogleCredential credential =
        GoogleCredential.getApplicationDefault(HTTP_TRANSPORT, JSON_FACTORY)
            .createScoped(Collections.singleton(CloudHealthcareScopes.CLOUD_PLATFORM));

    // Create a HttpRequestInitializer, which will provide a baseline configuration to all requests.
    HttpRequestInitializer requestInitializer =
        request -> {
          credential.initialize(request);
          request.setHeaders(new HttpHeaders().set("X-GFE-SSL", "yes"));
          request.setConnectTimeout(60000); // 1 minute connect timeout
          request.setReadTimeout(60000); // 1 minute read timeout
        };

    // Build the client for interacting with the service.
    return new CloudHealthcare.Builder(HTTP_TRANSPORT, JSON_FACTORY, requestInitializer)
        .setApplicationName("your-application-name")
        .build();
  }
}

Node.js

const {google} = require('googleapis');
const healthcare = google.healthcare('v1beta1');

async function getDicomStore() {
  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 dicomStoreId = 'my-dicom-store';
  const name = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/dicomStores/${dicomStoreId}`;
  const request = {name};

  const dicomStore = await healthcare.projects.locations.datasets.dicomStores.get(
    request
  );
  console.log(dicomStore.data);
}

getDicomStore();

Python

def get_dicom_store(
        service_account_json,
        project_id,
        cloud_region,
        dataset_id,
        dicom_store_id):
    """Gets the specified DICOM store."""
    client = get_client(service_account_json)
    dicom_store_parent = 'projects/{}/locations/{}/datasets/{}'.format(
        project_id, cloud_region, dataset_id)
    dicom_store_name = '{}/dicomStores/{}'.format(
        dicom_store_parent, dicom_store_id)

    dicom_stores = client.projects().locations().datasets().dicomStores()
    dicom_store = dicom_stores.get(name=dicom_store_name).execute()

    print('Name: {}'.format(dicom_store.get('name')))
    print('Notification config:')
    if dicom_store.get('notificationConfig') is not None:
        notification_config = dicom_store.get('notificationConfig')
        print('\tCloud Pub/Sub topic: {}'.format(
            notification_config.get('pubsubTopic')))

    return dicom_store

The following samples show how to list the DICOM stores in a dataset.

Console

To view the data stores in a dataset:
  1. In the GCP Console, go to the Datasets page.

    Go to the Datasets page

  2. Click the ID of the dataset whose data stores you want to view.

gcloud

To list the DICOM stores in a dataset, run the gcloud beta healthcare dicom-stores list command.

gcloud beta healthcare dicom-stores list --dataset=DATASET_ID 

If the request is successful, the command prompt lists the DICOM stores:

ID              LOCATION     TOPIC
DICOM_STORE_ID  REGION       projects/PROJECT_ID/topics/PUBSUB_TOPIC

API

To list the DICOM stores in a dataset, use the projects.locations.datasets.dicomStores.list method.

curl command

To list the DICOM stores in a dataset, make a GET request and specify the following information:

  • The name of the parent dataset
  • An access token

The following sample shows a GET request using curl.

curl -X GET \
     -H "Authorization: Bearer "$(gcloud auth print-access-token) \
     "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/dicomStores"

If the request is successful, the server returns a 200 OK HTTP status code and the response in JSON format:

200 OK
{
  "dicomStores": [
    {
      "name": "projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID"
    },
    {
      ...
    }
  ]
}

If you configured any fields in the DicomStore resource, they also appear in the response.

PowerShell

To list the DICOM stores in a dataset, make a GET request and specify the following information:

  • The name of the parent dataset
  • An access token

The following sample shows a GET request using Windows PowerShell.

$cred = gcloud auth print-access-token
$headers = @{ Authorization = "Bearer $cred" }

Invoke-WebRequest `
  -Method Get `
  -Headers $headers `
  -Uri "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/dicomStores" | Select-Object -Expand Content

If the request is successful, the server returns a 200 OK HTTP status code and the response in JSON format:

200 OK
{
  "dicomStores": [
    {
      "name": "projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID"
    },
    {
      ...
    }
  ]
}

If you configured any fields in the DicomStore resource, they also appear in the response.

Go

import (
	"context"
	"fmt"
	"io"

	healthcare "google.golang.org/api/healthcare/v1beta1"
)

// listDICOMStores prints a list of DICOM stores to w.
func listDICOMStores(w io.Writer, projectID, location, datasetID string) error {
	ctx := context.Background()

	healthcareService, err := healthcare.NewService(ctx)
	if err != nil {
		return fmt.Errorf("healthcare.NewService: %v", err)
	}

	storesService := healthcareService.Projects.Locations.Datasets.DicomStores

	parent := fmt.Sprintf("projects/%s/locations/%s/datasets/%s", projectID, location, datasetID)

	resp, err := storesService.List(parent).Do()
	if err != nil {
		return fmt.Errorf("List: %v", err)
	}

	fmt.Fprintln(w, "DICOM Stores:")
	for _, s := range resp.DicomStores {
		fmt.Fprintln(w, s.Name)
	}
	return nil
}

Java

import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
import com.google.api.client.http.HttpHeaders;
import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.services.healthcare.v1beta1.CloudHealthcare;
import com.google.api.services.healthcare.v1beta1.CloudHealthcare.Projects.Locations.Datasets.DicomStores;
import com.google.api.services.healthcare.v1beta1.CloudHealthcareScopes;
import com.google.api.services.healthcare.v1beta1.model.DicomStore;
import com.google.api.services.healthcare.v1beta1.model.ListDicomStoresResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class DicomStoreList {
  private static final String DATASET_NAME = "projects/%s/locations/%s/datasets/%s";
  private static final JsonFactory JSON_FACTORY = new JacksonFactory();
  private static final NetHttpTransport HTTP_TRANSPORT = new NetHttpTransport();

  public static void dicomStoreList(String datasetName) throws IOException {
    // String datasetName =
    //     String.format(DATASET_NAME, "your-project-id", "your-region-id", "your-dataset-id");

    // Initialize the client, which will be used to interact with the service.
    CloudHealthcare client = createClient();

    // Results are paginated, so multiple queries may be required.
    String pageToken = null;
    List<DicomStore> stores = new ArrayList<>();
    do {
      // Create request and configure any parameters.
      DicomStores.List request =
          client
              .projects()
              .locations()
              .datasets()
              .dicomStores()
              .list(datasetName)
              .setPageSize(100) // Specify pageSize up to 1000
              .setPageToken(pageToken);

      // Execute response and collect results.
      ListDicomStoresResponse response = request.execute();
      stores.addAll(response.getDicomStores());

      // Update the page token for the next request.
      pageToken = response.getNextPageToken();
    } while (pageToken != null);

    // Print results.
    System.out.printf("Retrieved %s DICOM stores: \n", stores.size());
    for (DicomStore data : stores) {
      System.out.println("\t" + data.toPrettyString());
    }
  }

  private static CloudHealthcare createClient() throws IOException {
    // Use Application Default Credentials (ADC) to authenticate the requests
    // For more information see https://cloud.google.com/docs/authentication/production
    GoogleCredential credential =
        GoogleCredential.getApplicationDefault(HTTP_TRANSPORT, JSON_FACTORY)
            .createScoped(Collections.singleton(CloudHealthcareScopes.CLOUD_PLATFORM));

    // Create a HttpRequestInitializer, which will provide a baseline configuration to all requests.
    HttpRequestInitializer requestInitializer =
        request -> {
          credential.initialize(request);
          request.setHeaders(new HttpHeaders().set("X-GFE-SSL", "yes"));
          request.setConnectTimeout(60000); // 1 minute connect timeout
          request.setReadTimeout(60000); // 1 minute read timeout
        };

    // Build the client for interacting with the service.
    return new CloudHealthcare.Builder(HTTP_TRANSPORT, JSON_FACTORY, requestInitializer)
        .setApplicationName("your-application-name")
        .build();
  }
}

Node.js

const {google} = require('googleapis');
const healthcare = google.healthcare('v1beta1');

async function listDicomStores() {
  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 parent = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}`;
  const request = {parent};

  const dicomStores = await healthcare.projects.locations.datasets.dicomStores.list(
    request
  );
  console.log(dicomStores.data);
}

listDicomStores();

Python

def list_dicom_stores(
        service_account_json,
        project_id,
        cloud_region,
        dataset_id):
    """Lists the DICOM stores in the given dataset."""
    client = get_client(service_account_json)
    dicom_store_parent = 'projects/{}/locations/{}/datasets/{}'.format(
        project_id, cloud_region, dataset_id)

    dicom_stores = client.projects().locations().datasets().dicomStores().list(
        parent=dicom_store_parent).execute().get('dicomStores', [])

    for dicom_store in dicom_stores:
        print('DICOM store: {}\n'
              'Notification config: {}'.format(
                  dicom_store.get('name'),
                  dicom_store.get('notificationConfig'),
              ))

    return dicom_stores

Deleting a DICOM store

The following samples show how to delete a DICOM store.

Console

To delete a data store:
  1. In the GCP Console, go to the Datasets page.

    Go to the Datasets page

  2. Open the dataset by clicking the dataset ID.
  3. Select the data store that you want to delete and then click Delete.
  4. To confirm, type the data store name and then click Delete.

gcloud

To delete a DICOM store, run the gcloud beta healthcare dicom-stores delete command:

  1. Run the delete command.
gcloud beta healthcare dicom-stores delete DICOM_STORE_ID \
  --dataset=DATASET_ID \
  --location=REGION 
  
  1. To confirm, type Y.

If the request is successful, the command prompt displays the following response:

Deleted dicomStore [DICOM_STORE_ID].

API

To delete a DICOM store, use the projects.locations.datasets.dicomStores.delete method.

curl command

To delete a DICOM store, make a DELETE request and specify the following information:

  • The name of the parent dataset
  • The name of the DICOM store to delete
  • An access token

The following sample shows a DELETE request using curl.

curl -X DELETE \
     -H "Authorization: Bearer "$(gcloud auth print-access-token) \
     "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID"

If the request is successful, the server returns a 200 OK HTTP status code and the empty response body in JSON format:

200 OK
{}

PowerShell

To delete a DICOM store, make a DELETE request and specify the following information:

  • The name of the parent dataset
  • The name of the DICOM store to delete
  • An access token

The following sample shows a DELETE request using Windows PowerShell.

$cred = gcloud auth print-access-token
$headers = @{ Authorization = "Bearer $cred" }

Invoke-WebRequest `
  -Method Delete `
  -Headers $headers `
  -Uri "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID" | Select-Object -Expand Content

If the request is successful, the server returns a 200 OK HTTP status code and the empty response body in JSON format:

200 OK
{}

Go

import (
	"context"
	"fmt"
	"io"

	healthcare "google.golang.org/api/healthcare/v1beta1"
)

// deleteDICOMStore deletes an DICOM store.
func deleteDICOMStore(w io.Writer, projectID, location, datasetID, dicomStoreID string) error {
	ctx := context.Background()

	healthcareService, err := healthcare.NewService(ctx)
	if err != nil {
		return fmt.Errorf("healthcare.NewService: %v", err)
	}

	storesService := healthcareService.Projects.Locations.Datasets.DicomStores

	name := fmt.Sprintf("projects/%s/locations/%s/datasets/%s/dicomStores/%s", projectID, location, datasetID, dicomStoreID)
	if _, err := storesService.Delete(name).Do(); err != nil {
		return fmt.Errorf("Delete: %v", err)
	}

	fmt.Fprintf(w, "Deleted DICOM store: %q\n", name)
	return nil
}

Java

import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
import com.google.api.client.http.HttpHeaders;
import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.services.healthcare.v1beta1.CloudHealthcare;
import com.google.api.services.healthcare.v1beta1.CloudHealthcare.Projects.Locations.Datasets.DicomStores;
import com.google.api.services.healthcare.v1beta1.CloudHealthcareScopes;
import java.io.IOException;
import java.util.Collections;

public class DicomStoreDelete {
  private static final String DICOM_NAME = "projects/%s/locations/%s/datasets/%s/dicomStores/%s";
  private static final JsonFactory JSON_FACTORY = new JacksonFactory();
  private static final NetHttpTransport HTTP_TRANSPORT = new NetHttpTransport();

  public static void deleteDicomStore(String dicomStoreName) throws IOException {
    // String dicomStoreName =
    //    String.format(
    //        DICOM_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-dicom-id");

    // Initialize the client, which will be used to interact with the service.
    CloudHealthcare client = createClient();

    // Create request and configure any parameters.
    DicomStores.Delete request =
        client.projects().locations().datasets().dicomStores().delete(dicomStoreName);

    // Execute the request and process the results.
    request.execute();
    System.out.println("DICOM store deleted.");
  }

  private static CloudHealthcare createClient() throws IOException {
    // Use Application Default Credentials (ADC) to authenticate the requests
    // For more information see https://cloud.google.com/docs/authentication/production
    GoogleCredential credential =
        GoogleCredential.getApplicationDefault(HTTP_TRANSPORT, JSON_FACTORY)
            .createScoped(Collections.singleton(CloudHealthcareScopes.CLOUD_PLATFORM));

    // Create a HttpRequestInitializer, which will provide a baseline configuration to all requests.
    HttpRequestInitializer requestInitializer =
        request -> {
          credential.initialize(request);
          request.setHeaders(new HttpHeaders().set("X-GFE-SSL", "yes"));
          request.setConnectTimeout(60000); // 1 minute connect timeout
          request.setReadTimeout(60000); // 1 minute read timeout
        };

    // Build the client for interacting with the service.
    return new CloudHealthcare.Builder(HTTP_TRANSPORT, JSON_FACTORY, requestInitializer)
        .setApplicationName("your-application-name")
        .build();
  }
}

Node.js

const {google} = require('googleapis');
const healthcare = google.healthcare('v1beta1');

async function deleteDicomStore() {
  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 dicomStoreId = 'my-dicom-store';
  const name = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/dicomStores/${dicomStoreId}`;
  const request = {name};

  await healthcare.projects.locations.datasets.dicomStores.delete(request);
  console.log(`Deleted DICOM store: ${dicomStoreId}`);
}

deleteDicomStore();

Python

def delete_dicom_store(
        service_account_json,
        project_id,
        cloud_region,
        dataset_id,
        dicom_store_id):
    """Deletes the specified DICOM store."""
    client = get_client(service_account_json)
    dicom_store_parent = 'projects/{}/locations/{}/datasets/{}'.format(
        project_id, cloud_region, dataset_id)
    dicom_store_name = '{}/dicomStores/{}'.format(
        dicom_store_parent, dicom_store_id)

    request = client.projects().locations().datasets(
    ).dicomStores().delete(name=dicom_store_name)

    try:
        response = request.execute()
        print('Deleted DICOM store: {}'.format(dicom_store_id))
        return response
    except HttpError as e:
        print('Error, DICOM store not deleted: {}'.format(e))
        return ""

What's next

Was this page helpful? Let us know how we did:

Send feedback about...

Cloud Healthcare API