Quickstart using curl or Windows PowerShell

This page shows you how to create a dataset and a DICOM, FHIR, or HL7v2 store using the Cloud Healthcare API with curl and Windows PowerShell.

Before you begin

  1. Accede a tu Cuenta de Google.

    Si todavía no tienes una cuenta, regístrate para obtener una nueva.

  2. En GCP Console, en la página de selección de proyecto, selecciona o crea un proyecto de GCP.

    Ir a la página de selección de proyecto

  3. Comprueba que la facturación esté habilitada en tu proyecto.

    Descubre cómo puedes habilitar la facturación

  4. Configurar la autenticación
    1. En GCP Console, ve a la página Crear clave de la cuenta de servicio.

      Ir a la página Crear clave de la cuenta de servicio
    2. En la lista Cuenta de servicio, selecciona Cuenta de servicio nueva.
    3. Ingresa un nombre en el campo Nombre de cuenta de servicio.
    4. En la lista Función, selecciona Proyecto > Propietario.

      Nota: El campo Función autoriza tu cuenta de servicio para acceder a los recursos. Puedes ver y cambiar este campo luego con GCP Console. Si desarrollas una app de producción, especifica permisos más detallados que Proyecto > Propietario. Para obtener más información, consulta Cómo otorgar funciones a las cuentas de servicio.
    5. Haz clic en Crear. Se descargará un archivo JSON a tu computadora que contiene tus descargas de claves.
  5. Configura la variable de entorno GOOGLE_APPLICATION_CREDENTIALS con la ruta de acceso al archivo JSON que contiene la clave de tu cuenta de servicio. Esta variable solo se aplica a tu sesión actual de shell. Por lo tanto, si abres una sesión nueva, deberás volver a configurar la variable.

  6. Habilita lasCloud Healthcare APIAPInecesarias.

    Habilita lasAPI

  7. Instala e inicializa el SDK de Cloud.

Tip: Need a command prompt? You can use the Google Cloud Shell. The Google Cloud Shell is a command line environment that already includes the Google Cloud SDK, so you don't need to install it. (The Google Cloud SDK also comes preinstalled on Google Compute Engine Virtual Machines.)

Create a dataset

Datasets are the basic containers that hold healthcare data in Google Cloud.

Tip: You can edit placeholder values in requests, denoted by the VARIABLES syntax, directly in this page.

curl command

To create a dataset, make a POST request, providing the name of the dataset and an access token. The following sample shows a POST request using curl.

When setting the LOCATION variable, use us-central1, us-west2, europe-west2, europe-west4, northamerica-northeast1, asia-northeast1, asia-southeast1, or us.

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/LOCATION/datasets?datasetId=DATASET_ID"

If the request is successful, the server returns a 200 OK HTTP status code and the response in JSON format. The response contains an identifier for a long-running operation. Long-running operations are returned when method calls might take a substantial amount of time to complete.

200 OK
{
  "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID",
}

The response contains an operation name. To track the status of the operation, you can use the Operation get method:

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

If the request is successful, the server returns a 200 OK HTTP status code and a response with the status of the operation in JSON format. You can tell that the operation finished when the response contains "done": true.

200 OK
{
  "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.healthcare.v1beta1.OperationMetadata",
    "apiMethodName": "google.cloud.healthcare.v1beta1.dataset.DatasetService.CreateDataset",
    "createTime": "2018-01-01T00:00:00+00:00",
    "endTime": "2018-01-01T00:00:00+00:00"
  },
  "done": true,
  "response": {
    "@type": "type.googleapis.com/google.cloud.healthcare.v1beta1.dataset.Dataset",
    "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID"
  }
}

PowerShell

To create a dataset, make a POST request, providing the name of the dataset and an access token. The following sample shows a POST request using Windows PowerShell.

When setting the LOCATION variable, use us-central1, us-west2, europe-west2, europe-west4, northamerica-northeast1, asia-northeast1, asia-southeast1, or us.

$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/LOCATION/datasets?datasetId=DATASET_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. The response contains an identifier for a long-running operation. Long-running operations are returned when method calls might take a substantial amount of time to complete.

200 OK
{
  "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID",
}

The response contains an operation name. To track the status of the operation, you can use the Operation get method:

$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/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID" | Select-Object -Expand Content

If the request is successful, the server returns a 200 OK HTTP status code and a response with the status of the operation in JSON format. You can tell that the operation finished when the response contains "done": true.

200 OK
{
  "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.healthcare.v1beta1.OperationMetadata",
    "apiMethodName": "google.cloud.healthcare.v1beta1.dataset.DatasetService.CreateDataset",
    "createTime": "2018-01-01T00:00:00+00:00",
    "endTime": "2018-01-01T00:00:00+00:00"
  },
  "done": true,
  "response": {
    "@type": "type.googleapis.com/google.cloud.healthcare.v1beta1.dataset.Dataset",
    "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID"
  }
}

Get dataset details

You can view details about the dataset and verify that it was created.

curl command

To get details about 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/LOCATION/datasets/DATASET_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/LOCATION/datasets/DATASET_ID"
  "timeZone": "UTC"
}

PowerShell

To get details about 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.

$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/LOCATION/datasets/DATASET_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/LOCATION/datasets/DATASET_ID"
  "timeZone": "UTC"
}

Create and manage DICOM, FHIR, and HL7v2 stores

To complete this quickstart, expand the relevant section:

Clean up

To avoid incurring charges to your Google Cloud account for the resources used in this tutorial, you can clean up the resources you created on Google Cloud. If you created a new project for this tutorial, follow the steps in Delete the project. Otherwise, follow the steps in Delete the dataset.

Delete the project

  1. En GCP Console, dirígete a la página Administrar recursos.

    Ir a la página Administración de recursos

  2. En la lista de proyectos, selecciona el proyecto que deseas borrar y haz clic en Borrar .
  3. En el cuadro de diálogo, escribe el ID del proyecto y, luego, haz clic en Cerrar para borrar el proyecto.

Delete the dataset

If you no longer need the dataset created in this quickstart, you can delete it. Deleting a dataset permanently deletes the dataset and any FHIR, HL7v2, or DICOM stores it contains.

curl command

To delete a dataset, make a DELETE request, providing the name of the dataset 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/LOCATION/datasets/DATASET_ID"

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

200 OK
{}

PowerShell

To delete a dataset, make a DELETE request, providing the name of the dataset 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/LOCATION/datasets/DATASET_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
{}

What's next

¿Te ha resultado útil esta página? Enviar comentarios:

Enviar comentarios sobre...

Cloud Healthcare API