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 create a Cloud Pub/Sub topic for the data store, type the topic name.
  8. Click Create.
The new data store appears in the list.

gcloud

The following sample works with the v1alpha2 version of the Cloud Healthcare API.

To create a DICOM store in the dataset, run the gcloud alpha 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.

The following sample shows how to create a DICOM store.

gcloud alpha healthcare dicom-stores create DICOM_STORE_ID \
  --dataset=DATASET_ID \
  --location=REGION \
  [--pubsub-topic=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 provide the name of the parent dataset, the name of the DICOM store, and an access token. The following sample shows a POST request using curl. Set a name for the DICOM store in the DICOM_STORE_ID variable. 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.

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 provide the name of the parent dataset, the name of the DICOM store, and an access token. The following sample shows a POST request using Windows PowerShell. Set a name for the DICOM store in the DICOM_STORE_ID variable. 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.

$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.HealthcareQuickstart;
import com.google.api.services.healthcare.v1beta1.CloudHealthcare;
import com.google.api.services.healthcare.v1beta1.model.DicomStore;
import com.google.gson.Gson;

import java.io.IOException;

public class DicomStoreCreate {
  private static final Gson GSON = new Gson();

  public static void createDicomStore(
      String projectId,
      String cloudRegion,
      String datasetId,
      String dicomStoreId) throws IOException {
    String parentName = String.format(
        "projects/%s/locations/%s/datasets/%s",
        projectId,
        cloudRegion,
        datasetId);
    DicomStore dicomStore = new DicomStore();
    CloudHealthcare.Projects.Locations.Datasets.DicomStores.Create createRequest =
        HealthcareQuickstart.getCloudHealthcareClient()
            .projects()
            .locations()
            .datasets()
            .dicomStores()
            .create(parentName, dicomStore);
    createRequest.setDicomStoreId(dicomStoreId);

    dicomStore = createRequest.execute();

    System.out.println("Created Dicom store: " + GSON.toJson(dicomStore));
  }
}

Node.js

function createDicomStore(
  client,
  projectId,
  cloudRegion,
  datasetId,
  dicomStoreId
) {
  // Client retrieved in callback
  // getClient(serviceAccountJson, function(cb) {...});
  // const cloudRegion = 'us-central1';
  // const projectId = 'adjective-noun-123';
  // const datasetId = 'my-dataset';
  // const dicomStoreId = 'my-dicom-store';
  const parentName = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}`;

  const request = {parent: parentName, dicomStoreId: dicomStoreId};

  client.projects.locations.datasets.dicomStores
    .create(request)
    .then(() => {
      console.log(`Created DICOM store: ${dicomStoreId}`);
    })
    .catch(err => {
      console.error(err);
    });
}

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 edit the Cloud Pub/Sub topic to which the Cloud Healthcare API sends notifications of DICOM store changes.

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. Instead, use curl, PowerShell, or your preferred language.

gcloud

The following sample works with the v1alpha2 version of the Cloud Healthcare API.

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

The following sample shows how to update the Cloud Pub/Sub topic for the DICOM store.

gcloud alpha healthcare dicom-stores update DICOM_STORE_ID \
  --dataset=DATASET_ID \
  --location=REGION \
  --pubsub-topic=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: 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 provide the name of the parent dataset, the name of the DICOM store, the metadata to update, an update mask, and 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'
      }
    }" \
    "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID?updateMask=notificationConfig"

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"
  }
}

PowerShell

To edit a DICOM store, make a PATCH request and provide the name of the parent dataset, the name of the DICOM store, the metadata to update, an update mask, and 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'
      }
  }" `
  -Uri "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID?updateMask=notificationConfig" | 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"
  }
}

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.HealthcareQuickstart;
import com.google.api.services.healthcare.v1beta1.model.DicomStore;
import com.google.api.services.healthcare.v1beta1.model.NotificationConfig;
import com.google.gson.Gson;

import java.io.IOException;

public class DicomStorePatch {
  private static final Gson GSON = new Gson();

  public static void patchDicomStore(String dicomStoreName, String pubsubTopic) throws IOException {
    DicomStore patched = HealthcareQuickstart.getCloudHealthcareClient()
        .projects()
        .locations()
        .datasets()
        .dicomStores()
        .get(dicomStoreName)
        .execute();
    NotificationConfig notificationConfig = new NotificationConfig();
    notificationConfig.setPubsubTopic(pubsubTopic);
    patched.setNotificationConfig(notificationConfig);
    DicomStore response = HealthcareQuickstart.getCloudHealthcareClient()
        .projects()
        .locations()
        .datasets()
        .dicomStores()
        .patch(dicomStoreName, patched)
        .setUpdateMask("notificationConfig")
        .execute();
    System.out.println("Patched Dicom store: " + GSON.toJson(response));
  }
}

Node.js

function patchDicomStore(
  client,
  projectId,
  cloudRegion,
  datasetId,
  dicomStoreId,
  pubsubTopic
) {
  // Client retrieved in callback
  // getClient(serviceAccountJson, function(cb) {...});
  // const cloudRegion = 'us-central1';
  // const projectId = 'adjective-noun-123';
  // const datasetId = 'my-dataset';
  // const dicomStoreId = 'my-dicom-store';
  // const pubsubTopic = 'my-topic'
  const dicomStoreName = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/dicomStores/${dicomStoreId}`;

  const request = {
    name: dicomStoreName,
    updateMask: 'notificationConfig',
    resource: {
      notificationConfig: {
        pubsubTopic: `projects/${projectId}/locations/${cloudRegion}/topics/${pubsubTopic}`,
      },
    },
  };

  client.projects.locations.datasets.dicomStores
    .patch(request)
    .then(results => {
      console.log(
        'Patched DICOM store with Cloud Pub/Sub topic',
        results['data']['notificationConfig']['pubsubTopic']
      );
    })
    .catch(err => {
      console.error(err);
    });
}

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

The following sample works with the v1alpha2 version of the Cloud Healthcare API.

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

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

gcloud alpha 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 provide the name of the parent dataset, the name of the DICOM store, and 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 provide the name of the parent dataset, the name of the DICOM store, and 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.HealthcareQuickstart;
import com.google.api.services.healthcare.v1beta1.model.DicomStore;
import com.google.gson.Gson;

import java.io.IOException;

public class DicomStoreGet {
  private static final Gson GSON = new Gson();

  public static void getDicomStore(String dicomStoreName) throws IOException {
    DicomStore dicomStore = HealthcareQuickstart.getCloudHealthcareClient()
        .projects()
        .locations()
        .datasets()
        .dicomStores()
        .get(dicomStoreName)
        .execute();
    System.out.println("Retrieved Dicom store: " + GSON.toJson(dicomStore));
  }
}

Node.js

function getDicomStore(
  client,
  projectId,
  cloudRegion,
  datasetId,
  dicomStoreId
) {
  // Client retrieved in callback
  // getClient(serviceAccountJson, function(cb) {...});
  // const cloudRegion = 'us-central1';
  // const projectId = 'adjective-noun-123';
  // const datasetId = 'my-dataset';
  // const dicomStoreId = 'my-dicom-store';
  const dicomStoreName = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/dicomStores/${dicomStoreId}`;

  const request = {name: dicomStoreName};

  client.projects.locations.datasets.dicomStores
    .get(request)
    .then(results => {
      console.log('Got DICOM store:\n', results['data']);
    })
    .catch(err => {
      console.error(err);
    });
}

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

The following sample works with the v1alpha2 version of the Cloud Healthcare API.

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

gcloud alpha healthcare dicom-store list --dataset=DATASET_ID

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

ID              LOCATION     REF_INT  RES_VER  UPDATE_CREATE  TOPIC
DICOM_STORE_ID  REGION

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 provide the name of the dataset and 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 provide the name of the dataset and 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.HealthcareQuickstart;
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.List;

public class DicomStoreList {
  public static void listDicomStores(String projectId, String cloudRegion, String datasetId) throws IOException {
    String parentName = String.format(
        "projects/%s/locations/%s/datasets/%s",
        projectId,
        cloudRegion,
        datasetId);
    ListDicomStoresResponse response = HealthcareQuickstart.getCloudHealthcareClient()
        .projects()
        .locations()
        .datasets()
        .dicomStores()
        .list(parentName)
        .execute();
    List<DicomStore> dicomStores = response.getDicomStores();
    if (dicomStores == null) {
      System.out.println("Retrieved 0 Dicom stores");
      return;
    }
    System.out.println("Retrieved " + dicomStores.size() + " Dicom stores");
    for (int i = 0; i < dicomStores.size(); i++) {
      System.out.println("  - " + dicomStores.get(i).getName());
    }
  }
}

Node.js

function listDicomStores(client, projectId, cloudRegion, datasetId) {
  // Client retrieved in callback
  // getClient(serviceAccountJson, function(cb) {...});
  // const cloudRegion = 'us-central1';
  // const projectId = 'adjective-noun-123';
  // const datasetId = 'my-dataset';
  const parentName = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}`;

  const request = {parent: parentName};

  client.projects.locations.datasets.dicomStores
    .list(request)
    .then(results => {
      console.log('DICOM stores:\n', results['data']['dicomStores']);
    })
    .catch(err => {
      console.error(err);
    });
}

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

The following sample works with the v1alpha2 version of the Cloud Healthcare API.

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

  1. Run the delete command.
    gcloud alpha healthcare dicom-store delete DICOM_STORE_ID \
      --dataset=DATASET_ID \
      --location=REGION
  2. 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 provide the name of the parent dataset, the name of the DICOM store, and 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 provide the name of the parent dataset, the name of the DICOM store, and 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.HealthcareQuickstart;

import java.io.IOException;

public class DicomStoreDelete {
  public static void deleteDicomStore(String dicomStoreName) throws IOException {
    HealthcareQuickstart.getCloudHealthcareClient()
        .projects()
        .locations()
        .datasets()
        .dicomStores()
        .delete(dicomStoreName)
        .execute();
  }
}

Node.js

function deleteDicomStore(
  client,
  projectId,
  cloudRegion,
  datasetId,
  dicomStoreId
) {
  // Client retrieved in callback
  // getClient(serviceAccountJson, function(cb) {...});
  // const cloudRegion = 'us-central1';
  // const projectId = 'adjective-noun-123';
  // const datasetId = 'my-dataset';
  // const dicomStoreId = 'my-dicom-store';
  const dicomStoreName = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/dicomStores/${dicomStoreId}`;

  const request = {name: dicomStoreName};

  client.projects.locations.datasets.dicomStores
    .delete(request)
    .then(() => {
      console.log(`Deleted DICOM store: ${dicomStoreId}`);
    })
    .catch(err => {
      console.error(err);
    });
}

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