This page explains how to create, edit, view, list, and delete datasets. Before you use this page, familiarize yourself with the Cloud Healthcare API Data model.
Creating a dataset
Creating a dataset is the first step in using most of the features in the Cloud Healthcare API. After creating a dataset, you can create data stores that hold electronic health records, medical imaging data, user consents, and more.
The following examples show how to create a dataset.
Console
- In the Google Cloud console, go to the Datasets page.
- Click Create dataset.
-
In the Name field, enter an identifier for the dataset. The dataset ID must have the following:
- A unique ID in its location
- A Unicode string from 1-256 characters consisting of the following:
- Numbers
- Letters
- Underscores
- Dashes
- Periods
-
In the Location type section, choose one of the following types of locations:
- Region: the dataset permanently resides within one Google Cloud region. After selecting, type or select the location in the Region field.
- Multi-region: the dataset permanently resides within one location that spans multiple Google Cloud regions. After selecting, type or select the multi-region location in the Multi-region field.
The new dataset appears in the list of datasets.
gcloud CLI
To create a dataset, run the
gcloud healthcare datasets create
command:
- The DATASET_ID must be unique within the region. It can be any Unicode string of 1 to 256 characters consisting of numbers, letters, underscores, dashes, and periods.
- The region can be
us-central1
,us-west1
,us-west2
,us-west3
,us-east1
,us-east4
,europe-west2
,europe-west3
,europe-west4
,europe-west6
,northamerica-northeast1
,southamerica-east1
,asia-east1
,asia-east2
,asia-northeast1
,asia-northeast2
asia-northeast3
,asia-south1
,asia-southeast1
,asia-southeast2
,australia-southeast1
, orus
. To use the default region for the project, omit the--location
option.
gcloud healthcare datasets create DATASET_ID \ --location=LOCATION
The command line displays the operation ID and, after the operation completes, a confirmation that the dataset was created:
Create request issued for: [DATASET_ID] Waiting for operation [projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID] to complete...done. Created dataset [DATASET_ID].
To view more details about the operation, run the gcloud healthcare operations describe
command, providing the OPERATION_ID from the response:
gcloud healthcare operations describe OPERATION_ID \ --dataset=DATASET_ID
The response includes done: true
:
done: true metadata: '@type': type.googleapis.com/google.cloud.healthcare.v1.OperationMetadata apiMethodName: google.cloud.healthcare.v1.dataset.DatasetService.CreateDataset createTime: 'CREATE_TIME' endTime: 'END_TIME' name: projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID response: '@type': type.googleapis.com/google.cloud.healthcare.v1.dataset.Dataset name: projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID
REST
To create a dataset, use the projects.locations.datasets.create
method.
Create the dataset.
Before using any of the request data, make the following replacements:
- PROJECT_ID: the ID of your Google Cloud project
- LOCATION: the location of the dataset. Use
us-central1
,us-west1
,us-west2
,us-west3
,us-east1
,us-east4
,europe-west2
,europe-west3
,europe-west4
,europe-west6
,northamerica-northeast1
,southamerica-east1
,asia-east1
,asia-east2
,asia-northeast1
,asia-northeast2
asia-northeast3
,asia-south1
,asia-southeast1
,asia-southeast2
,australia-southeast1
, orus
. - DATASET_ID:
an identifier for the dataset. The dataset ID must have the following:
- A unique ID in its location
- A Unicode string of 1-256 characters consisting of the following:
- Numbers
- Letters
- Underscores
- Dashes
- Periods
To send your request, choose one of these options:
curl
Execute the following command:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d "" \
"https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets?datasetId=DATASET_ID"PowerShell
Execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets?datasetId=DATASET_ID" | Select-Object -Expand ContentAPI Explorer
Open the method reference page. The API Explorer panel opens on the right side of the page. You can interact with this tool to send requests. Complete any required fields and click Execute.
Use the
projects.locations.datasets.operations.get
method to get the status of the long-running operation.Before using any of the request data, make the following replacements:
- PROJECT_ID: the ID of your Google Cloud project
- LOCATION: the dataset location
- DATASET_ID: the ID of the dataset being created
- OPERATION_ID: the ID of the long-running operation
To send your request, choose one of these options:
curl
Execute the following command:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID"PowerShell
Execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID" | Select-Object -Expand ContentAPI Explorer
Open the method reference page. The API Explorer panel opens on the right side of the page. You can interact with this tool to send requests. Complete any required fields and click Execute.
"done": true
, which indicates that the dataset was successfully created.
Go
Java
Node.js
Python
Editing a dataset
The following examples show how to edit an existing dataset.
Console
Google Cloud console does not support editing a healthcare dataset. Instead,
use curl
, Windows PowerShell, or your preferred language.
gcloud CLI
To edit a dataset, run the
gcloud healthcare datasets update
command, specifying the new time zone. For example, you can set the time zone
to "Canada/Eastern".
gcloud healthcare datasets update DATASET_ID \ --location=LOCATION \ --time-zone=TIME_ZONE
If the request is successful, the command prompt displays the operation and dataset details:
Updated dataset [DATASET_ID]. name: projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID timeZone: TIME_ZONE
REST
To edit a dataset, use the projects.locations.datasets.patch
method.
Before using any of the request data, make the following replacements:
- PROJECT_ID: the ID of your Google Cloud project
- LOCATION: the dataset location
- DATASET_ID: the dataset ID
- TIME_ZONE: a supported time zone, such as
UTC
Request JSON body:
{ "timeZone": "TIME_ZONE" }
To send your request, choose one of these options:
curl
Save the request body in a file called request.json
.
Run the following command in the terminal to create or overwrite
this file in the current directory:
cat > request.json << 'EOF' { "timeZone": "TIME_ZONE" } EOF
Then execute the following command to send your REST request:
curl -X PATCH \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID?updateMask=timeZone"
PowerShell
Save the request body in a file called request.json
.
Run the following command in the terminal to create or overwrite
this file in the current directory:
@' { "timeZone": "TIME_ZONE" } '@ | Out-File -FilePath request.json -Encoding utf8
Then execute the following command to send your REST request:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method PATCH `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID?updateMask=timeZone" | Select-Object -Expand Content
API Explorer
Copy the request body and open the method reference page. The API Explorer panel opens on the right side of the page. You can interact with this tool to send requests. Paste the request body in this tool, complete any other required fields, and click Execute.
You should receive a JSON response similar to the following:
Go
Java
Node.js
Python
Getting dataset details
The following examples show how to get details about a dataset.
Console
To view the data stores in a dataset:
- In the Google Cloud console, go to the Datasets page.
- Select the dataset containing the data store you want to view.
gcloud CLI
To view details about a dataset, run the
gcloud healthcare datasets describe
command:
gcloud healthcare datasets describe DATASET_ID \ --location=LOCATION
If the request is successful, the command prompt displays the dataset details:
name: projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID timeZone: TIME_ZONE
REST
To get details about a dataset, use the projects.locations.datasets.get
method.
Before using any of the request data, make the following replacements:
- PROJECT_ID: the ID of your Google Cloud project
- LOCATION: the dataset location
- DATASET_ID: the dataset ID
To send your request, choose one of these options:
curl
Execute the following command:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID"
PowerShell
Execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID" | Select-Object -Expand Content
API Explorer
Open the method reference page. The API Explorer panel opens on the right side of the page. You can interact with this tool to send requests. Complete any required fields and click Execute.
You should receive a JSON response similar to the following:
Go
Java
Node.js
Python
The following samples show how to list the datasets in your project.
Console
To list the datasets in your project, in the Google Cloud console, go to the Healthcare Datasets page.
gcloud CLI
To list the datasets in your project, run the
gcloud healthcare datasets list
command:
gcloud healthcare datasets list
If the request is successful, the command prompt lists the datasets:
ID LOCATION TIMEZONE DATASET_ID LOCATION TIME_ZONE
REST
To list the datasets in your project, use the projects.locations.datasets.list
method.
Before using any of the request data, make the following replacements:
- PROJECT_ID: the ID of your Google Cloud project
- LOCATION: the dataset location
To send your request, choose one of these options:
curl
Execute the following command:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets"
PowerShell
Execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets" | Select-Object -Expand Content
API Explorer
Open the method reference page. The API Explorer panel opens on the right side of the page. You can interact with this tool to send requests. Complete any required fields and click Execute.
You should receive a JSON response similar to the following:
Go
Java
Node.js
Python
Deleting a dataset
The following examples show how to delete a dataset.
Console
To delete a dataset:
- In the Google Cloud console, go to the Datasets page.
- Select the dataset that you want to delete and then click Delete.
- To confirm, type the dataset identifier and then click Delete.
gcloud CLI
To delete a dataset, run the
gcloud healthcare datasets delete
command:
Run the
delete
command:gcloud healthcare datasets delete DATASET_ID \ --location=LOCATION
To confirm, type Y.
If the request is successful, the command prompt displays:
Deleted dataset [DATASET_ID]
REST
To delete a dataset, use the projects.locations.datasets.delete
method.
Before using any of the request data, make the following replacements:
- PROJECT_ID: the ID of your Google Cloud project
- LOCATION: the dataset location
- DATASET_ID: the dataset ID
To send your request, choose one of these options:
curl
Execute the following command:
curl -X DELETE \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID"
PowerShell
Execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method DELETE `
-Headers $headers `
-Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID" | Select-Object -Expand Content
API Explorer
Open the method reference page. The API Explorer panel opens on the right side of the page. You can interact with this tool to send requests. Complete any required fields and click Execute.
You should receive a JSON response similar to the following:
Go
Java
Node.js
Python
What's next
- De-identify sensitive data
- Create and manage DICOM stores
- Create and manage FHIR stores
- Create and manage HL7v2 stores