Creating and managing FHIR stores

This page explains how to create, edit, view, and delete Fast Healthcare Interoperability Resources (FHIR) stores.

Creating a FHIR store

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

The following samples show how to create a FHIR store.

Console

To create a FHIR store:

  1. In the Cloud Console, go to the Datasets page.

    Go to the Datasets page

  2. Open the dataset where you want to create a FHIR 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 FHIR as the data store type.
  6. Click Create.
  7. If you want to configure a Pub/Sub topic for the data store, type the topic name. When specifying a 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 FHIR store in the dataset, run the gcloud beta healthcare fhir-stores create command.

  • The FHIR 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 Pub/Sub topic of FHIR store changes, specify an existing Pub/Sub topic name using the --pubsub-topic argument.
When specifying a 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 FHIR store.

gcloud beta healthcare fhir-stores create FHIR_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 fhirStore [FHIR_STORE_ID].

API

To create a FHIR store, use the projects.locations.datasets.fhirStores.create method.

curl command

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

  • The name of the parent dataset
  • The name of the FHIR store
  • An access token
  • A name for the FHIR store. The FHIR store name 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.

The following sample shows a POST request using curl.

You can optionally configure an existing Pub/Sub topic to which the Cloud Healthcare API sends notifications of FHIR store changes. See Editing a FHIR store for information on how to configure the Pub/Sub topic.

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/fhirStores?fhirStoreId=FHIR_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/fhirStores/FHIR_STORE_ID"
}

PowerShell

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

  • The name of the parent dataset
  • A name for the FHIR store. The FHIR store name 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

The following sample shows a POST request using Windows PowerShell.

You can optionally configure an existing Pub/Sub topic to which the Cloud Healthcare API sends notifications of FHIR store changes. See Editing a FHIR store for information on how to configure the Pub/Sub topic.

$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/fhirStores?fhirStoreId=FHIR_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/fhirStores/FHIR_STORE_ID"
}

Go

import (
	"context"
	"fmt"
	"io"

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

// createFHIRStore creates an FHIR store.
func createFHIRStore(w io.Writer, projectID, location, datasetID, fhirStoreID 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.FhirStores

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

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

	fmt.Fprintf(w, "Created FHIR 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.FhirStores;
import com.google.api.services.healthcare.v1beta1.CloudHealthcareScopes;
import com.google.api.services.healthcare.v1beta1.model.FhirStore;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public class FhirStoreCreate {
  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 fhirStoreCreate(String datasetName, String fhirStoreId) throws IOException {
    // String datasetName =
    //     String.format(DATASET_NAME, "your-project-id", "your-region-id", "your-dataset-id");
    // String fhirStoreId = "your-fhir-id"

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

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

    // Create request and configure any parameters.
    FhirStores.Create request =
        client
            .projects()
            .locations()
            .datasets()
            .fhirStores()
            .create(datasetName, content)
            .setFhirStoreId(fhirStoreId);

    // Execute the request and process the results.
    FhirStore response = request.execute();
    System.out.println("FHIR 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');

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

  await healthcare.projects.locations.datasets.fhirStores.create(request);
  console.log(`Created FHIR store: ${fhirStoreId}`);
};

createFhirStore();

Python

def create_fhir_store(
        service_account_json,
        project_id,
        cloud_region,
        dataset_id,
        fhir_store_id):
    """Creates a new FHIR store within the parent dataset."""
    client = get_client(service_account_json)
    fhir_store_parent = 'projects/{}/locations/{}/datasets/{}'.format(
        project_id, cloud_region, dataset_id)

    body = {}

    request = client.projects().locations().datasets().fhirStores().create(
        parent=fhir_store_parent, body=body, fhirStoreId=fhir_store_id)

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

Editing a FHIR store

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

  • Edit the Pub/Sub topic to which the Cloud Healthcare API sends notifications of FHIR store changes.
  • Edit the labels. Labels are key-value pairs that help you organize your Google Cloud resources.
When specifying a 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 Pub/Sub permissions.

Console

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

gcloud

To update the FHIR store, run the gcloud beta healthcare fhir-stores update command.

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

gcloud beta healthcare fhir-stores update FHIR_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 FHIR store details including the new topic name:

Updated fhirStore [FHIR_STORE_ID].
name: projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/fhir-stores/FHIR_STORE_ID
notificationConfig:
pubsubTopic: projects/PROJECT_ID/topics/PUBSUB_TOPIC

API

To edit a FHIR store, use the projects.locations.datasets.fhirStores.patch method.

curl command

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

  • The name of the parent dataset
  • The name of the FHIR store
  • The metadata to update
  • 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/fhirStores/FHIR_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/fhirStores/FHIR_STORE_ID",
  "notificationConfig": {
    "pubsubTopic": "projects/PROJECT_ID/topics/PUBSUB_TOPIC"
  },
  'labels': {
    'KEY1':'VALUE1','KEY2':'VALUE2'
  }
}

PowerShell

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

  • The name of the parent dataset
  • The name of the FHIR store
  • The metadata to update
  • 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/fhirStores/FHIR_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/fhirStores/FHIR_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"
)

// patchFHIRStore updates (patches) a FHIR store by updating its Pub/sub topic name.
func patchFHIRStore(w io.Writer, projectID, location, datasetID, fhirStoreID, 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.FhirStores

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

	if _, err := storesService.Patch(name, &healthcare.FhirStore{
		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 FHIR 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.FhirStores;
import com.google.api.services.healthcare.v1beta1.CloudHealthcareScopes;
import com.google.api.services.healthcare.v1beta1.model.FhirStore;
import com.google.api.services.healthcare.v1beta1.model.NotificationConfig;
import java.io.IOException;
import java.util.Collections;

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

  public static void fhirStorePatch(String dicomStoreName, String pubsubTopic) throws IOException {
    // String fhirStoreName =
    //    String.format(
    //        FHIR_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-fhir-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 FHIR store.
    FhirStores.Get getRequest =
        client.projects().locations().datasets().fhirStores().get(dicomStoreName);
    FhirStore store = getRequest.execute();

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

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

    // Execute the request and process the results.
    store = request.execute();
    System.out.println("Fhir 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');

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

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

patchFhirStore();

Python

def patch_fhir_store(
        service_account_json,
        project_id,
        cloud_region,
        dataset_id,
        fhir_store_id):
    """Updates the FHIR store."""
    client = get_client(service_account_json)
    fhir_store_parent = 'projects/{}/locations/{}/datasets/{}'.format(
        project_id, cloud_region, dataset_id)
    fhir_store_name = '{}/fhirStores/{}'.format(
        fhir_store_parent, fhir_store_id)

    patch = {
        'notificationConfig': None}

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

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

Getting FHIR store details

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

Console

To view a FHIR store's details:

  1. In the Cloud Console, go to the Datasets page.

    Go to the Datasets page

  2. Click the ID of the dataset that contains the FHIR store.
  3. Click the name of the FHIR store.

Note: Cloud Console does not display the Pub/Sub topic to which the Healthcare API sends notifications.

gcloud

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

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

gcloud beta healthcare fhir-stores describe FHIR_STORE_ID \
  --dataset=DATASET_ID \
  --location=REGION 

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

name: projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/fhir-stores/FHIR_STORE_ID

API

To get details about a FHIR store, use the projects.locations.datasets.fhirStores.get method.

curl command

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

  • The name of the parent dataset
  • The name of the FHIR 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/fhirStores/FHIR_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/fhirStores/FHIR_STORE_ID"
}

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

PowerShell

To get details about a FHIR store, make a GET request and specify the following information: * The name of the parent dataset * The name of the FHIR 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/fhirStores/FHIR_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/fhirStores/FHIR_STORE_ID"
}

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

Go

import (
	"context"
	"fmt"
	"io"

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

// getFHIRStore gets an FHIR store.
func getFHIRStore(w io.Writer, projectID, location, datasetID, fhirStoreID 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.FhirStores

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

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

	fmt.Fprintf(w, "Got FHIR store: %q\n", store.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.FhirStores;
import com.google.api.services.healthcare.v1beta1.CloudHealthcareScopes;
import com.google.api.services.healthcare.v1beta1.model.FhirStore;
import java.io.IOException;
import java.util.Collections;

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

  public static void fhirStoreGet(String fhirStoreName) throws IOException {
    // String fhirStoreName =
    //    String.format(
    //        FHIR_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-fhir-id");

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

    // Create request and configure any parameters.
    FhirStores.Get request =
        client.projects().locations().datasets().fhirStores().get(fhirStoreName);

    // Execute the request and process the results.
    FhirStore store = request.execute();
    System.out.println("FHIR 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');

const getFhirStore = async () => {
  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 fhirStoreId = 'my-fhir-store';
  const name = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/fhirStores/${fhirStoreId}`;
  const request = {name};

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

getFhirStore();

Python

def get_fhir_store(
        service_account_json,
        project_id,
        cloud_region,
        dataset_id,
        fhir_store_id):
    """Gets the specified FHIR store."""
    client = get_client(service_account_json)
    fhir_store_parent = 'projects/{}/locations/{}/datasets/{}'.format(
        project_id, cloud_region, dataset_id)
    fhir_store_name = '{}/fhirStores/{}'.format(
        fhir_store_parent, fhir_store_id)

    fhir_stores = client.projects().locations().datasets().fhirStores()
    fhir_store = fhir_stores.get(name=fhir_store_name).execute()

    print('Name: {}'.format(fhir_store.get('name')))
    print('Enable update/create: {}'.format(fhir_store.get(
        'enableUpdateCreate')))
    print('Notification config:')
    if fhir_store.get('notificationConfig') is not None:
        notification_config = fhir_store.get('notificationConfig')
        print('\tCloud Pub/Sub topic: {}'.format(
            notification_config.get('pubsubTopic')))
    print('Disable referential integrity: {}'.format(
        fhir_store.get('disableReferentialIntegrity')))

    return fhir_store

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

Console

To view the data stores in a dataset:

  1. In the Cloud 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 FHIR stores in a dataset, run the gcloud beta healthcare fhir-stores list command.

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

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

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

API

To list the FHIR stores in a dataset, use the projects.locations.datasets.fhirStores.list method.

curl command

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

  • The name of the 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/fhirStores"

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

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

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

PowerShell

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

  • The name of the 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/fhirStores" | 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
{
  "fhirStores": [
    {
      "name": "projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID"
    },
    {
      ...
    }
  ]
}

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

Go

import (
	"context"
	"fmt"
	"io"

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

// listFHIRStores prints a list of FHIR stores to w.
func listFHIRStores(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.FhirStores

	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, "FHIR stores:")
	for _, s := range resp.FhirStores {
		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.FhirStores;
import com.google.api.services.healthcare.v1beta1.CloudHealthcareScopes;
import com.google.api.services.healthcare.v1beta1.model.FhirStore;
import com.google.api.services.healthcare.v1beta1.model.ListFhirStoresResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

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

  public static void fhirStoreList(String fhirStoreName) throws IOException {
    // String fhirStoreName =
    //    String.format(
    //        FHIR_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-fhir-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<FhirStore> stores = new ArrayList<>();
    do {
      // Create request and configure any parameters.
      FhirStores.List request =
          client
              .projects()
              .locations()
              .datasets()
              .fhirStores()
              .list(fhirStoreName)
              .setPageSize(100) // Specify pageSize up to 1000
              .setPageToken(pageToken);

      // Execute response and collect results.
      ListFhirStoresResponse response = request.execute();
      stores.addAll(response.getFhirStores());

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

    // Print results.
    System.out.printf("Retrieved %s Fhir stores: \n", stores.size());
    for (FhirStore 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');

const listFhirStores = async () => {
  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 fhirStores = await healthcare.projects.locations.datasets.fhirStores.list(
    request
  );
  console.log(fhirStores.data);
};

listFhirStores();

Python

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

    fhir_stores = client.projects().locations().datasets().fhirStores().list(
        parent=fhir_store_parent).execute().get('fhirStores', [])

    for fhir_store in fhir_stores:
        print('FHIR store: {}\n'
              'Enable update/create: {}\n'
              'Notification config: {}\n'
              'Disable referential integrity: {}'.format(
                  fhir_store.get('name'),
                  fhir_store.get('enableUpdateCreate'),
                  fhir_store.get('notificationConfig'),
                  fhir_store.get('disableReferentialIntegrity')
              ))

    return fhir_stores

Getting the capabilities statement for a FHIR store

The following samples show how to get the capabilities statement for a FHIR store. The information in the capabilities statement reflects the settings in the FHIR store. For example, if FhirStore.enableUpdateCreate is set to true, then this will be reflected in the capabilities statement's CapabilityStatement.rest.resource.updateCreate field.

The following table shows the Cloud Healthcare API method for getting the capabilities statement for a FHIR store and its equivalent FHIR specification interaction:

Cloud Healthcare API method FHIR specification interaction
projects.locations.datasets.fhirStores.fhir.capabilities capabilities

Console

Cloud Console does not support getting the capabilities statement. Instead, use curl, Windows PowerShell, or your preferred language.

gcloud

The gcloud tool does not support getting the capabilities statement. Instead, use curl, Windows PowerShell, or your preferred language.

API

To get the capabilities statement for a FHIR store, use the projects.locations.datasets.fhirStores.fhir.capabilities method.

curl command

To get the capabilities statement for a FHIR store, make a GET request and specify the following information:

  • The name of the dataset
  • The name of the FHIR 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/fhirStores/FHIR_STORE_ID/fhir/metadata"

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

200 OK
{
  "acceptUnknown": "both",
  "date": "2018-01-01",
  "description": "FHIR capability statement for the FHIR store specified by the request.",
  "experimental": true,
  "fhirVersion": "3.0.1",
  "format": [
    "json"
  ],
  "id": "FHIR_STORE_ID",
  "kind": "instance",
  "patchFormat": [
    "application/json-patch+json"
  ],
  "publisher": "Google",
  "resourceType": "CapabilityStatement",
  ...
  "status": "draft",
  "url": "projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID",
  "version": "20180101"
}

PowerShell

To get the capabilities statement for a FHIR store, make a GET request and specify the following information:

  • The name of the dataset
  • The name of the FHIR 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/fhirStores/FHIR_STORE_ID/fhir/metadata" | ConvertTo-Json

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

200 OK
{
  "acceptUnknown": "both",
  "date": "2018-01-01",
  "description": "FHIR capability statement for the FHIR store specified by the request.",
  "experimental": true,
  "fhirVersion": "3.0.1",
  "format": [
    "json"
  ],
  "id": "FHIR_STORE_ID",
  "kind": "instance",
  "patchFormat": [
    "application/json-patch+json"
  ],
  "publisher": "Google",
  "resourceType": "CapabilityStatement",
  ...
  "status": "draft",
  "url": "projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID",
  "version": "20180101"
}

Go

import (
	"context"
	"fmt"
	"io"
	"io/ioutil"

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

// getFHIRMetadata gets FHIR store metadata.
func getFHIRMetadata(w io.Writer, projectID, location, datasetID, fhirStoreID string) error {
	ctx := context.Background()

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

	fhirService := healthcareService.Projects.Locations.Datasets.FhirStores.Fhir

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

	resp, err := fhirService.Capabilities(name).Do()
	if err != nil {
		return fmt.Errorf("Capabilities: %v", err)
	}

	defer resp.Body.Close()

	respBytes, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return fmt.Errorf("could not read response: %v", err)
	}

	if resp.StatusCode > 299 {
		return fmt.Errorf("Capabilities: status %d %s: %s", resp.StatusCode, resp.Status, respBytes)
	}
	fmt.Fprintf(w, "%s", respBytes)
	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.FhirStores.Fhir.Capabilities;
import com.google.api.services.healthcare.v1beta1.CloudHealthcareScopes;
import com.google.api.services.healthcare.v1beta1.model.HttpBody;

import java.io.IOException;
import java.util.Collections;

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

  public static void fhirResourceGetMetadata(String resourceName) throws IOException {
    // String resourceName =
    //    String.format(
    //        FHIR_NAME, "project-id", "region-id", "dataset-id", "store-id", "fhir-id");

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

    // Create request and configure any parameters.
    Capabilities request =
        client.projects().locations().datasets().fhirStores().fhir().capabilities(resourceName);

    // Execute the request and process the results.
    HttpBody response = request.execute();
    System.out.println("FHIR resource metadata retrieved: " + 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');

const getFhirStoreCapabilities = async () => {
  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 fhirStoreId = 'my-fhir-store';
  const name = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/fhirStores/${fhirStoreId}/fhir/metadata`;
  const request = {name};

  const fhirStore = await healthcare.projects.locations.datasets.fhirStores.get(
    request
  );
  console.log(JSON.stringify(fhirStore.data, null, 2));
};

getFhirStoreCapabilities();

Python

def get_metadata(
        service_account_json,
        base_url,
        project_id,
        cloud_region,
        dataset_id,
        fhir_store_id):
    """Gets the capabilities statement for a FHIR store."""
    url = '{}/projects/{}/locations/{}'.format(base_url,
                                               project_id, cloud_region)

    fhir_store_path = '{}/datasets/{}/fhirStores/{}/fhir/metadata'.format(
        url, dataset_id, fhir_store_id)

    # Make an authenticated API request
    session = get_session(service_account_json)

    response = session.get(fhir_store_path)
    response.raise_for_status()

    metadata = response.json()

    print(json.dumps(metadata, indent=2))

    return metadata

Deleting a FHIR store

The following samples show how to delete a FHIR store.

Console

To delete a data store:

  1. In the Cloud 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 FHIR store, run the gcloud beta healthcare fhir-stores delete command:

  1. Run the delete command.

    gcloud beta healthcare fhir-stores delete FHIR_STORE_ID \
    --dataset=DATASET_ID \
    --location=REGION 
    
  2. To confirm, type Y.

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

Deleted fhirStore [FHIR_STORE_ID].

API

To delete a FHIR store, use the projects.locations.datasets.fhirStores.delete method.

curl command

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

  • The name of the parent dataset
  • The name of the FHIR store
  • 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/fhirStores/FHIR_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 FHIR store, make a DELETE request and specify the following information:

  • The name of the parent dataset
  • The name of the FHIR store
  • 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/fhirStores/FHIR_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"
)

// deleteFHIRStore deletes an FHIR store.
func deleteFHIRStore(w io.Writer, projectID, location, datasetID, fhirStoreID 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.FhirStores

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

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

	fmt.Fprintf(w, "Deleted FHIR store: %q\n", fhirStoreID)
	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.FhirStores;
import com.google.api.services.healthcare.v1beta1.CloudHealthcareScopes;
import java.io.IOException;
import java.util.Collections;

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

  public static void fhirStoreDelete(String fhirStoreName) throws IOException {
    // String fhirStoreName =
    //    String.format(
    //        FHIR_NAME, "your-project-id", "your-region-id", "your-dataset-id", "your-fhir-id");

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

    // Create request and configure any parameters.
    FhirStores.Delete request =
        client.projects().locations().datasets().fhirStores().delete(fhirStoreName);

    // Execute the request and process the results.
    request.execute();
    System.out.println("FHIR 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');

const deleteFhirStore = async () => {
  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 fhirStoreId = 'my-fhir-store';
  const name = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/fhirStores/${fhirStoreId}`;
  const request = {name};

  await healthcare.projects.locations.datasets.fhirStores.delete(request);
  console.log(`Deleted FHIR store: ${fhirStoreId}`);
};

deleteFhirStore();

Python

def delete_fhir_store(
        service_account_json,
        project_id,
        cloud_region,
        dataset_id,
        fhir_store_id):
    """Deletes the specified FHIR store."""
    client = get_client(service_account_json)
    fhir_store_parent = 'projects/{}/locations/{}/datasets/{}'.format(
        project_id, cloud_region, dataset_id)
    fhir_store_name = '{}/fhirStores/{}'.format(
        fhir_store_parent, fhir_store_id)

    request = client.projects().locations().datasets(
    ).fhirStores().delete(name=fhir_store_name)

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

What's next

Learn how to create and work with FHIR resources.

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

Send feedback about...

Cloud Healthcare API