Delete FHIR store
Stay organized with collections
Save and categorize content based on your preferences.
Delete a FHIR store.
Explore further
For detailed documentation that includes this code sample, see the following:
Code sample
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],[],[[["\u003cp\u003eThis document provides code samples in Go, Java, Node.js, and Python demonstrating how to delete a FHIR store within the Google Cloud Healthcare API.\u003c/p\u003e\n"],["\u003cp\u003eEach code sample guides users to set up the environment by using the Cloud Healthcare API quickstart and setting up Application Default Credentials for authentication.\u003c/p\u003e\n"],["\u003cp\u003eThe code snippets illustrate how to use the respective language's API client to make a \u003ccode\u003edelete\u003c/code\u003e request to the FHIR stores resource, referencing the project, location, dataset, and FHIR store ID.\u003c/p\u003e\n"],["\u003cp\u003eThe document refers users to further resources such as detailed documentation on creating and managing FHIR stores, the API reference documentation for each language, and the Google Cloud sample browser for more examples.\u003c/p\u003e\n"],["\u003cp\u003eTo successfully use the code samples to delete a FHIR store users will have to replace placeholder values with their own project ID, location, dataset ID, and FHIR store ID.\u003c/p\u003e\n"]]],[],null,["# Delete FHIR store\n\nDelete a FHIR store.\n\nExplore further\n---------------\n\n\nFor detailed documentation that includes this code sample, see the following:\n\n- [Creating and managing FHIR stores](/healthcare-api/docs/how-tos/fhir)\n\nCode sample\n-----------\n\n### Go\n\n\nBefore trying this sample, follow the Go setup instructions in the\n[Cloud Healthcare API quickstart using\nclient libraries](https://cloud.google.com/healthcare-api/docs/store-healthcare-data-client-library).\n\n\nFor more information, see the\n[Cloud Healthcare API Go API\nreference documentation](https://pkg.go.dev/google.golang.org/api/healthcare/v1).\n\n\nTo authenticate to Cloud Healthcare API, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n import (\n \t\"context\"\n \t\"fmt\"\n \t\"io\"\n\n \thealthcare \"google.golang.org/api/healthcare/v1\"\n )\n\n // deleteFHIRStore deletes an FHIR store.\n func deleteFHIRStore(w io.Writer, projectID, location, datasetID, fhirStoreID string) error {\n \tctx := context.Background()\n\n \thealthcareService, err := healthcare.NewService(ctx)\n \tif err != nil {\n \t\treturn fmt.Errorf(\"healthcare.NewService: %w\", err)\n \t}\n\n \tstoresService := healthcareService.Projects.Locations.Datasets.FhirStores\n\n \tname := fmt.Sprintf(\"projects/%s/locations/%s/datasets/%s/fhirStores/%s\", projectID, location, datasetID, fhirStoreID)\n\n \tif _, err := storesService.Delete(name).Do(); err != nil {\n \t\treturn fmt.Errorf(\"Delete: %w\", err)\n \t}\n\n \tfmt.Fprintf(w, \"Deleted FHIR store: %q\\n\", fhirStoreID)\n \treturn nil\n }\n\n### Java\n\n\nBefore trying this sample, follow the Java setup instructions in the\n[Cloud Healthcare API quickstart using\nclient libraries](https://cloud.google.com/healthcare-api/docs/store-healthcare-data-client-library).\n\n\nFor more information, see the\n[Cloud Healthcare API Java API\nreference documentation](https://googleapis.dev/java/google-api-services-healthcare/latest/index.html).\n\n\nTo authenticate to Cloud Healthcare API, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n import com.google.api.client.http.https://cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.HttpRequestInitializer.html;\n import com.google.api.client.http.javanet.https://cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.http.javanet.NetHttpTransport.html;\n import com.google.api.client.json.https://cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.json.JsonFactory.html;\n import com.google.api.client.json.gson.https://cloud.google.com/java/docs/reference/google-http-client/latest/com.google.api.client.json.gson.GsonFactory.html;\n import com.google.api.services.healthcare.v1.CloudHealthcare;\n import com.google.api.services.healthcare.v1.CloudHealthcare.Projects.Locations.Datasets.FhirStores;\n import com.google.api.services.healthcare.v1.CloudHealthcareScopes;\n import com.google.auth.http.https://cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.http.HttpCredentialsAdapter.html;\n import com.google.auth.oauth2.https://cloud.google.com/java/docs/reference/google-auth-library/latest/com.google.auth.oauth2.GoogleCredentials.html;\n import java.io.IOException;\n import java.util.Collections;\n\n public class FhirStoreDelete {\n private static final String FHIR_NAME = \"projects/%s/locations/%s/datasets/%s/fhirStores/%s\";\n private static final JsonFactory JSON_FACTORY = new GsonFactory();\n private static final NetHttpTransport HTTP_TRANSPORT = new NetHttpTransport();\n\n public static void fhirStoreDelete(String fhirStoreName) throws IOException {\n // String fhirStoreName =\n // String.format(\n // FHIR_NAME, \"your-project-id\", \"your-region-id\", \"your-dataset-id\", \"your-fhir-id\");\n\n // Initialize the client, which will be used to interact with the service.\n CloudHealthcare client = createClient();\n\n // Create request and configure any parameters.\n FhirStores.Delete request =\n client.projects().locations().datasets().fhirStores().delete(fhirStoreName);\n\n // Execute the request and process the results.\n request.execute();\n System.out.println(\"FHIR store deleted.\");\n }\n\n private static CloudHealthcare createClient() throws IOException {\n // Use Application Default Credentials (ADC) to authenticate the requests\n // For more information see https://cloud.google.com/docs/authentication/production\n GoogleCredentials credential =\n GoogleCredentials.getApplicationDefault()\n .createScoped(Collections.singleton(CloudHealthcareScopes.CLOUD_PLATFORM));\n\n // Create a HttpRequestInitializer, which will provide a baseline configuration to all requests.\n HttpRequestInitializer requestInitializer =\n request -\u003e {\n new HttpCredentialsAdapter(credential).initialize(request);\n request.setConnectTimeout(60000); // 1 minute connect timeout\n request.setReadTimeout(60000); // 1 minute read timeout\n };\n\n // Build the client for interacting with the service.\n return new CloudHealthcare.Builder(HTTP_TRANSPORT, JSON_FACTORY, requestInitializer)\n .setApplicationName(\"your-application-name\")\n .build();\n }\n }\n\n### Node.js\n\n\nBefore trying this sample, follow the Node.js setup instructions in the\n[Cloud Healthcare API quickstart using\nclient libraries](https://cloud.google.com/healthcare-api/docs/store-healthcare-data-client-library).\n\n\nFor more information, see the\n[Cloud Healthcare API Node.js API\nreference documentation](https://github.com/googleapis/google-api-nodejs-client/blob/main/src/apis/healthcare/README.md).\n\n\nTo authenticate to Cloud Healthcare API, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n const google = require('@googleapis/healthcare');\n const healthcare = google.healthcare({\n version: 'v1',\n auth: new google.auth.GoogleAuth({\n scopes: ['https://www.googleapis.com/auth/cloud-platform'],\n }),\n });\n\n const deleteFhirStore = async () =\u003e {\n // TODO(developer): uncomment these lines before running the sample\n // const cloudRegion = 'us-central1';\n // const projectId = 'adjective-noun-123';\n // const datasetId = 'my-dataset';\n // const fhirStoreId = 'my-fhir-store';\n const name = `projects/${projectId}/locations/${cloudRegion}/datasets/${datasetId}/fhirStores/${fhirStoreId}`;\n const request = {name};\n\n await healthcare.projects.locations.datasets.fhirStores.delete(request);\n console.log(`Deleted FHIR store: ${fhirStoreId}`);\n };\n\n deleteFhirStore();\n\n### Python\n\n\nBefore trying this sample, follow the Python setup instructions in the\n[Cloud Healthcare API quickstart using\nclient libraries](https://cloud.google.com/healthcare-api/docs/store-healthcare-data-client-library).\n\n\nFor more information, see the\n[Cloud Healthcare API Python API\nreference documentation](https://googleapis.github.io/google-api-python-client/docs/dyn/healthcare_v1).\n\n\nTo authenticate to Cloud Healthcare API, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n def delete_fhir_store(project_id, location, dataset_id, fhir_store_id):\n \"\"\"Deletes the specified FHIR store.\n\n See https://github.com/GoogleCloudPlatform/python-docs-samples/tree/main/healthcare/api-client/v1/fhir\n before running the sample.\"\"\"\n # Imports the Google API Discovery Service.\n from googleapiclient import discovery\n\n api_version = \"v1\"\n service_name = \"healthcare\"\n # Returns an authorized API client by discovering the Healthcare API\n # and using GOOGLE_APPLICATION_CREDENTIALS environment variable.\n client = discovery.build(service_name, api_version)\n\n # TODO(developer): Uncomment these lines and replace with your values.\n # project_id = 'my-project' # replace with your GCP project ID\n # location = 'us-central1' # replace with the parent dataset's location\n # dataset_id = 'my-dataset' # replace with the FHIR store's parent dataset\n # fhir_store_id = 'my-fhir-store' # replace with the FHIR store's ID\n fhir_store_parent = \"projects/{}/locations/{}/datasets/{}\".format(\n project_id, location, dataset_id\n )\n fhir_store_name = f\"{fhir_store_parent}/fhirStores/{fhir_store_id}\"\n\n request = (\n client.projects()\n .locations()\n .datasets()\n .fhirStores()\n .delete(name=fhir_store_name)\n )\n\n response = request.execute()\n print(f\"Deleted FHIR store: {fhir_store_id}\")\n\n return response\n\nWhat's next\n-----------\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=healthcare)."]]