Quickstart using curl or Windows PowerShell

This page shows you how to use the Cloud Healthcare API with curl or Windows PowerShell to complete the following tasks:

  1. Create a Cloud Healthcare API dataset.
  2. Create one of the following data stores inside the dataset:
    • Digital Imaging and Communications in Medicine (DICOM) store
    • Fast Healthcare Interoperability Resources (FHIR) store
    • Health Level Seven International Version 2 (HL7v2) store
  3. Store and inspect a particular type of medical data in the DICOM, FHIR, or HL7v2 store.

If you are only interested in working with one type of data store, you can skip directly to that section of the quickstart after completing the steps in Before you begin and Create a dataset.

Before you begin

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud Console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  3. Make sure that billing is enabled for your Cloud project. Learn how to confirm that billing is enabled for your project.

  4. Enable the Cloud Healthcare API.

    Enable the API

  5. Install and initialize the Cloud SDK.
  6. Use the gcloud command-line tool to test your authentication environment. Check that the following command outputs a text string without errors:
    gcloud auth application-default print-access-token

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 contain data stores, and data stores contain healthcare data. To use the Cloud Healthcare API, you must create at least one dataset.

To create a dataset, use the datasets.create method:

curl

curl -X POST \
    --data "" \
    -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
    -H "Content-Type: application/json; charset=utf-8" \
    "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets?datasetId=DATASET_ID"

Replace the following:

  • PROJECT_ID: the ID of your project
  • LOCATION: the location of the dataset. Use us-central1, us-west2, us-east4, europe-west2, europe-west3, europe-west4, europe-west6, northamerica-northeast1, southamerica-east1, asia-east2, asia-northeast1, asia-northeast3, asia-south1, asia-southeast1, australia-southeast1, or us.
  • 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

If the request is successful, the server returns 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.

{
  "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, use the operations.get method:

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

Replace the following:

  • PROJECT_ID: the ID of your project
  • LOCATION: the dataset location
  • DATASET_ID: the dataset ID
  • OPERATION_ID: the ID returned from the long-running operation

The output is the following. The operation finishes when the response contains "done": true.

{
  "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.healthcare.v1.OperationMetadata",
    "apiMethodName": "google.cloud.healthcare.v1.dataset.DatasetService.CreateDataset",
    "createTime": "CREATE_TIME",
    "endTime": "END_TIME",
    "logsUrl": "https://console.cloud.google.com/logs/viewer/CLOUD_LOGGING_URL"
  },
  "done": true,
  "response": {
    "@type": "type.googleapis.com/google.cloud.healthcare.v1.dataset.Dataset",
    "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID"
  }
}

PowerShell

$cred = gcloud auth application-default print-access-token
$headers = @{ Authorization = "Bearer $cred" }

Invoke-WebRequest `
  -Method Post `
  -Headers $headers `
  -ContentType: "application/json; charset=utf-8" `
  -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets?datasetId=DATASET_ID" | Select-Object -Expand Content

Replace the following:

  • PROJECT_ID: the ID of your project
  • LOCATION: the dataset location
  • DATASET_ID: the dataset ID

If the request is successful, the server returns 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.

{
  "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, use the operations.get method:

$cred = gcloud auth application-default 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 Content

Replace the following:

  • PROJECT_ID: the ID of your project
  • LOCATION: the dataset location
  • DATASET_ID: the dataset ID
  • OPERATION_ID: the ID returned from the long-running operation

The output is the following. The operation finishes when the response contains "done": true.

{
  "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.healthcare.v1.OperationMetadata",
    "apiMethodName": "google.cloud.healthcare.v1.dataset.DatasetService.CreateDataset",
    "createTime": "CREATE_TIME",
    "endTime": "END_TIME",
    "logsUrl": "https://console.cloud.google.com/logs/viewer/CLOUD_LOGGING_URL"
  },
  "done": true,
  "response": {
    "@type": "type.googleapis.com/google.cloud.healthcare.v1.dataset.Dataset",
    "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID"
  }
}

To complete this quickstart, choose from one of the following sections:

Store and view a DICOM instance

This section shows how to complete the following tasks:

  1. Create a DICOM store.
  2. Store a DICOM instance in the DICOM store.
  3. View the DICOM instance's metadata.

The Cloud Healthcare API implements the DICOMweb standard to store and access medical imaging data.

Create a DICOM store

DICOM stores exist inside datasets and hold DICOM instances. Create a DICOM store using the projects.locations.datasets.dicomStores.create method:

curl

curl -X POST \
    --data "" \
    -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
    -H "Content-Type: application/json; charset=utf-8" \
    "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/dicomStores?dicomStoreId=DICOM_STORE_ID"

Replace the following:

  • PROJECT_ID: the ID of your project
  • LOCATION: the dataset location
  • DATASET_ID: the dataset ID
  • DICOM_STORE_ID: an identifier for the DICOM store. The DICOM store ID must have the following:
    • A unique ID in its dataset
    • A Unicode string of 1-256 characters consisting of the following:
      • Numbers
      • Letters
      • Underscores
      • Dashes
      • Periods

The output is the following:

{
  "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID"
}

PowerShell

$cred = gcloud auth application-default print-access-token
$headers = @{ Authorization = "Bearer $cred" }

Invoke-WebRequest `
  -Method Post `
  -Headers $headers `
  -ContentType: "application/json; charset=utf-8" `
  -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/dicomStores?dicomStoreId=DICOM_STORE_ID" | Select-Object -Expand Content

Replace the following:

  • PROJECT_ID: the ID of your project
  • LOCATION: the dataset location
  • DATASET_ID: the dataset ID
  • DICOM_STORE_ID: an identifier for the DICOM store. The DICOM store ID must have the following:
    • A unique ID in its dataset
    • A Unicode string of 1-256 characters consisting of the following:
      • Numbers
      • Letters
      • Underscores
      • Dashes
      • Periods

The output is the following:

{
  "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID"
}

Store a DICOM instance

  1. Download the sample DICOM instance file to your machine. The file contains a de-identified patient X-ray.

  2. Store the DICOM instance in the DICOM store. This quickstart assumes that you are running the command from the same directory where the DICOM instance is saved.

    curl

    curl -X POST \
        -H "Content-Type: application/dicom" \
        -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
        --data-binary @dicom_00000001_000.dcm \
        https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID/dicomWeb/studies
    

    Replace the following:

    • PROJECT_ID: the ID of your project
    • LOCATION: the dataset location
    • DATASET_ID: the dataset ID
    • DICOM_STORE_ID: the DICOM store ID

    The output is the following in XML format:

    <NativeDicomModel>
      <DicomAttribute tag="00081190" vr="UR" keyword="RetrieveURL">
        <Value number="1">https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID/dicomWeb/studies/1.3.6.1.4.1.11129.5.5.111396399361969898205364400549799252857604</Value>
      </DicomAttribute>
      <DicomAttribute tag="00081199" vr="SQ" keyword="ReferencedSOPSequence">
        <Item number="1">
          <DicomAttribute tag="00081150" vr="UI" keyword="ReferencedSOPClassUID">
            <Value number="1">1.2.840.10008.5.1.4.1.1.7</Value>
          </DicomAttribute>
          <DicomAttribute tag="00081155" vr="UI" keyword="ReferencedSOPInstanceUID">
            <Value number="1">1.3.6.1.4.1.11129.5.5.153751009835107614666834563294684339746480</Value>
          </DicomAttribute>
          <DicomAttribute tag="00081190" vr="UR" keyword="RetrieveURL">
            <Value number="1">https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID/dicomWeb/studies/1.3.6.1.4.1.11129.5.5.111396399361969898205364400549799252857604/series/1.3.6.1.4.1.11129.5.5.195628213694300498946760767481291263511724/instances/1.3.6.1.4.1.11129.5.5.153751009835107614666834563294684339746480</Value>
          </DicomAttribute>
        </Item>
      </DicomAttribute>
    </NativeDicomModel>
    

    PowerShell

    $cred = gcloud auth application-default print-access-token
    $headers = @{ Authorization = "Bearer $cred" }
    
    Invoke-WebRequest `
      -Method Post `
      -Headers $headers `
      -ContentType: "application/dicom" `
      -InFile dicom_00000001_000.dcm `
      -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID/dicomWeb/studies" | Select-Object -Expand Content
    

    Replace the following:

    • PROJECT_ID: the ID of your project
    • LOCATION: the dataset location
    • DATASET_ID: the dataset ID
    • DICOM_STORE_ID: the DICOM store ID

    The output is the following in XML format:

    <NativeDicomModel>
      <DicomAttribute tag="00081190" vr="UR" keyword="RetrieveURL">
        <Value number="1">https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID/dicomWeb/studies/1.3.6.1.4.1.11129.5.5.111396399361969898205364400549799252857604</Value>
      </DicomAttribute>
      <DicomAttribute tag="00081199" vr="SQ" keyword="ReferencedSOPSequence">
        <Item number="1">
          <DicomAttribute tag="00081150" vr="UI" keyword="ReferencedSOPClassUID">
            <Value number="1">1.2.840.10008.5.1.4.1.1.7</Value>
          </DicomAttribute>
          <DicomAttribute tag="00081155" vr="UI" keyword="ReferencedSOPInstanceUID">
            <Value number="1">1.3.6.1.4.1.11129.5.5.153751009835107614666834563294684339746480</Value>
          </DicomAttribute>
          <DicomAttribute tag="00081190" vr="UR" keyword="RetrieveURL">
            <Value number="1">https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID/dicomWeb/studies/1.3.6.1.4.1.11129.5.5.111396399361969898205364400549799252857604/series/1.3.6.1.4.1.11129.5.5.195628213694300498946760767481291263511724/instances/1.3.6.1.4.1.11129.5.5.153751009835107614666834563294684339746480</Value>
          </DicomAttribute>
        </Item>
      </DicomAttribute>
    </NativeDicomModel>
    

View DICOM instance metadata

Search for instances in the DICOM store to view the metadata for the instance you stored:

curl

curl -X GET \
     -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
     "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID/dicomWeb/instances"

Replace the following:

  • PROJECT_ID: the ID of your project
  • LOCATION: the dataset location
  • DATASET_ID: the dataset ID
  • DICOM_STORE_ID: the DICOM store ID

The output is the following:

[
  {
    "00080016": {
      "vr": "UI",
      "Value": [
        "1.2.840.10008.5.1.4.1.1.7"
      ]
    },
    "00080018": {
      "vr": "UI",
      "Value": [
        "1.3.6.1.4.1.11129.5.5.153751009835107614666834563294684339746480"
      ]
    },
    "00080060": {
      "vr": "CS",
      "Value": [
        "DX"
      ]
    },
    "00100020": {
      "vr": "LO",
      "Value": [
        "1"
      ]
    },
    "00100040": {
      "vr": "CS",
      "Value": [
        "M"
      ]
    },
    "0020000D": {
      "vr": "UI",
      "Value": [
        "1.3.6.1.4.1.11129.5.5.111396399361969898205364400549799252857604"
      ]
    },
    "0020000E": {
      "vr": "UI",
      "Value": [
        "1.3.6.1.4.1.11129.5.5.195628213694300498946760767481291263511724"
      ]
    },
    "00280010": {
      "vr": "US",
      "Value": [
        1024
      ]
    },
    "00280011": {
      "vr": "US",
      "Value": [
        1024
      ]
    },
    "00280100": {
      "vr": "US",
      "Value": [
        8
      ]
    }
  }
]

PowerShell

$cred = gcloud auth application-default print-access-token
$headers = @{ Authorization = "Bearer $cred" }

Invoke-RestMethod `
  -Method Get `
  -Headers $headers `
  -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID/dicomWeb/instances"

Replace the following:

  • PROJECT_ID: the ID of your project
  • LOCATION: the dataset location
  • DATASET_ID: the dataset ID
  • DICOM_STORE_ID: the DICOM store ID

The output is the following:

[
  {
    "00080016": {
      "vr": "UI",
      "Value": [
        "1.2.840.10008.5.1.4.1.1.7"
      ]
    },
    "00080018": {
      "vr": "UI",
      "Value": [
        "1.3.6.1.4.1.11129.5.5.153751009835107614666834563294684339746480"
      ]
    },
    "00080060": {
      "vr": "CS",
      "Value": [
        "DX"
      ]
    },
    "00100020": {
      "vr": "LO",
      "Value": [
        "1"
      ]
    },
    "00100040": {
      "vr": "CS",
      "Value": [
        "M"
      ]
    },
    "0020000D": {
      "vr": "UI",
      "Value": [
        "1.3.6.1.4.1.11129.5.5.111396399361969898205364400549799252857604"
      ]
    },
    "0020000E": {
      "vr": "UI",
      "Value": [
        "1.3.6.1.4.1.11129.5.5.195628213694300498946760767481291263511724"
      ]
    },
    "00280010": {
      "vr": "US",
      "Value": [
        1024
      ]
    },
    "00280011": {
      "vr": "US",
      "Value": [
        1024
      ]
    },
    "00280100": {
      "vr": "US",
      "Value": [
        8
      ]
    }
  }
]

Now that you've stored and viewed a DICOM instance in the Cloud Healthcare API, continue to What's next for information on next steps.

Store and view FHIR resources

This section shows how to complete the following tasks:

  1. Create a FHIR store.
  2. Store a FHIR resource in the FHIR store.
  3. View the FHIR resource's data.

The Cloud Healthcare API implements the FHIR specification standard to store and access FHIR data.

Create a FHIR store

FHIR stores exist inside datasets and hold FHIR resources. Create a FHIR store using the projects.locations.datasets.fhirStores.create method:

curl

curl -X POST \
    -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
    -H "Content-Type: application/json; charset=utf-8" \
    --data "{
      'version': 'R4'
    }" "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores?fhirStoreId=FHIR_STORE_ID"

Replace the following:

  • PROJECT_ID: the ID of your project
  • LOCATION: the dataset location
  • DATASET_ID: the dataset ID
  • FHIR_STORE_ID: an identifier for the FHIR store. The FHIR store ID must have the following:
    • A unique ID in its dataset
    • A Unicode string of 1-256 characters consisting of the following:
      • Numbers
      • Letters
      • Underscores
      • Dashes
      • Periods

The output is the following:

{
  "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID",
  "version": "R4"
}

PowerShell

$cred = gcloud auth application-default print-access-token
$headers = @{ Authorization = "Bearer $cred" }

Invoke-WebRequest `
  -Method Post `
  -Headers $headers `
  -ContentType: "application/json; charset=utf-8" `
  -Body "{
      'version': 'R4'
  }" `
  -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores?fhirStoreId=FHIR_STORE_ID" | Select-Object -Expand Content

Replace the following:

  • PROJECT_ID: the ID of your project
  • LOCATION: the dataset location
  • DATASET_ID: the dataset ID
  • FHIR_STORE_ID: an identifier for the FHIR store. The FHIR store ID must have the following:
    • A unique ID in its dataset
    • A Unicode string of 1-256 characters consisting of the following:
      • Numbers
      • Letters
      • Underscores
      • Dashes
      • Periods

The output is the following:

{
  "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID",
  "version": "R4"
}

Store a FHIR resource

  1. Save the sample JSON FHIR resource file. The file contains basic data for a Patient resource.

  2. Run the following command to store the Patient resource in the FHIR store you created. This quickstart assumes that you are running the command from the same directory where the Patient resource is saved.

    curl

    curl -X POST \
        -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
        -H "Content-Type: application/fhir+json; charset=utf-8" \
        --data @Patient.json \
        "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient"
    

    Replace the following:

    • PROJECT_ID: the ID of your project
    • LOCATION: the dataset location
    • DATASET_ID: the dataset ID
    • FHIR_STORE_ID: the FHIR store ID

    The output is the following:

    {
      "birthDate": "1970-01-01",
      "gender": "female",
      "id": "PATIENT_ID",
      "meta": {
        "lastUpdated": "LAST_UPDATED",
        "versionId": "VERSION_ID"
      },
      "name": [
        {
          "family": "Smith",
          "given": [
            "Darcy"
          ],
          "use": "official"
        }
      ],
      "resourceType": "Patient"
    }
    

    PowerShell

    $cred = gcloud auth application-default print-access-token
    $headers = @{ Authorization = "Bearer $cred" }
    
    Invoke-WebRequest `
      -Method Post `
      -Headers $headers `
      -ContentType: "application/dicom" `
      -InFile Patient.json `
      -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient" | Select-Object -Expand Content
    

    Replace the following:

    • PROJECT_ID: the ID of your project
    • LOCATION: the dataset location
    • DATASET_ID: the dataset ID
    • FHIR_STORE_ID: the FHIR store ID

    The output is the following:

    {
      "birthDate": "1970-01-01",
      "gender": "female",
      "id": "PATIENT_ID",
      "meta": {
        "lastUpdated": "LAST_UPDATED",
        "versionId": "VERSION_ID"
      },
      "name": [
        {
          "family": "Smith",
          "given": [
            "Darcy"
          ],
          "use": "official"
        }
      ],
      "resourceType": "Patient"
    }
    

View FHIR resource contents

Search for the resource in your FHIR store to view information about the patient. The following samples show how to search for all patients with the last name "Smith".

curl

curl -X GET \
     -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
     "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient?family:exact=Smith"

Replace the following:

  • PROJECT_ID: the ID of your project
  • LOCATION: the dataset location
  • DATASET_ID: the dataset ID
  • FHIR_STORE_ID: the FHIR store ID

If the request is successful, the server returns the response as a FHIR Bundle in JSON format. The Bundle.type is searchset and the search results are entries in the Bundle.entry array. In this example, the request returns a single Patient resource including the data inside that resource:

{
  "entry": [
    {
      "fullUrl": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/PATIENT_ID",
      "resource": {
        "birthDate": "1970-01-01",
        "gender": "female",
        "id": "PATIENT_ID",
        "meta": {
          "lastUpdated": "LAST_UPDATED",
          "versionId": "VERSION_ID"
        },
        "name": [
          {
            "family": "Smith",
            "given": [
              "Darcy"
            ],
            "use": "official"
          }
        ],
        "resourceType": "Patient"
      },
      "search": {
        "mode": "match"
      }
    }
  ],
  "link": [
    {
      "url": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/?family%3Aexact=Smith"
    }
  ],
  "resourceType": "Bundle",
  "total": 1,
  "type": "searchset"
}

PowerShell

$cred = gcloud auth application-default print-access-token
$headers = @{ Authorization = "Bearer $cred" }

Invoke-RestMethod `
  -Method Get `
  -Headers $headers `
  -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/RESOURCE_TYPE?family:exact=Smith" | ConvertTo-Json

Replace the following:

  • PROJECT_ID: the ID of your project
  • LOCATION: the dataset location
  • DATASET_ID: the dataset ID
  • FHIR_STORE_ID: the FHIR store ID

If the request is successful, the server returns the response as a FHIR Bundle in JSON format. The Bundle.type is searchset and the search results are entries in the Bundle.entry array. In this example, the request returns a single Patient resource including the data inside that resource:

{
  "entry": [
    {
      "fullUrl": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/PATIENT_ID",
      "resource": {
        "birthDate": "1970-01-01",
        "gender": "female",
        "id": "PATIENT_ID",
        "meta": {
          "lastUpdated": "LAST_UPDATED",
          "versionId": "VERSION_ID"
        },
        "name": [
          {
            "family": "Smith",
            "given": [
              "Darcy"
            ],
            "use": "official"
          }
        ],
        "resourceType": "Patient"
      },
      "search": {
        "mode": "match"
      }
    }
  ],
  "link": [
    {
      "url": "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/?family%3Aexact=Smith"
    }
  ],
  "resourceType": "Bundle",
  "total": 1,
  "type": "searchset"
}

Now that you've stored and viewed a FHIR resource in the Cloud Healthcare API, continue to What's next for information on next steps.

Store and view an HL7v2 message

This section shows how to complete the following tasks:

  1. Create an HL7v2 store.
  2. Store an HL7v2 message in the HL7v2 store.
  3. View the HL7v2 message's data.

The HL7v2 implementation in the Cloud Healthcare API aligns with the HL7v2 standard.

Create an HL7v2 store

HL7v2 stores exist inside datasets and hold HL7v2 messages. Create an HL7v2 store using the projects.locations.datasets.hl7V2Stores.create method:

curl

curl -X POST \
    --data "" \
    -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
    -H "Content-Type: application/json; charset=utf-8" \
    "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores?hl7V2StoreId=HL7V2_STORE_ID"

Replace the following:

  • PROJECT_ID: the ID of your project
  • LOCATION: the dataset location
  • DATASET_ID: the dataset ID
  • HL7V2_STORE_ID: an identifier for the HL7v2 store. The HL7v2 store ID must have the following:
    • A unique ID in its dataset
    • A Unicode string of 1-256 characters consisting of the following:
      • Numbers
      • Letters
      • Underscores
      • Dashes
      • Periods

The output is the following:

{
  "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID"
}

PowerShell

$cred = gcloud auth application-default print-access-token
$headers = @{ Authorization = "Bearer $cred" }

Invoke-WebRequest `
  -Method Post `
  -Headers $headers `
  -ContentType: "application/json; charset=utf-8" `
  -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores?hl7V2StoreId=HL7V2_STORE_ID" | Select-Object -Expand Content

Replace the following:

  • PROJECT_ID: the ID of your project
  • LOCATION: the dataset location
  • DATASET_ID: the dataset ID
  • HL7V2_STORE_ID: an identifier for the HL7v2 store. The HL7v2 store ID must have the following:
    • A unique ID in its dataset
    • A Unicode string of 1-256 characters consisting of the following:
      • Numbers
      • Letters
      • Underscores
      • Dashes
      • Periods

The output is the following:

{
  "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID"
}

Create an HL7v2 message

  1. Download the sample HL7v2 message file to your machine. The message contains the following basic information, where it is base-64 encoded in the data field of the sample file:

    MSH|^~\&|A|SEND_FACILITY|A|A|20180101000000||TYPE^A|20180101000000|T|0.0|||AA||00|ASCII
    EVN|A00|20180101040000
    PID||14^111^^^^MRN|11111111^^^^MRN~1111111111^^^^ORGNMBR
    
  2. There are two methods to store an HL7v2 message: creation and ingestion. See Overview of creating and ingesting HL7v2 messages for more information. In this sample, you store the HL7v2 message using the create method, because the ingest method typically consumes an HL7v2 message that comes from a care center.

    Run the following command to store the HL7v2 message in the HL7v2 store you created. This quickstart assumes that you are running the command from the same directory where the HL7v2 message file is saved.

    curl

    curl -X POST \
         -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
         -H "Content-Type: application/json; charset=utf-8" \
         --data-binary @hl7v2-sample.json \
         "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages"
    

    Replace the following:

    • PROJECT_ID: the ID of your project
    • LOCATION: the dataset location
    • DATASET_ID: the dataset ID
    • HL7V2_STORE_ID: the HL7v2 store ID

    The output is the following:

    {
      "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages/MESSAGE_ID",
      "data": "TVNIfF5+XCZ8QXxTRU5EX0ZBQ0lMSVRZfEF8QXwyMDE4MDEwMTAwMDAwMHx8VFlQRV5BfDIwMTgwMTAxMDAwMDAwfFR8MC4wfHx8QUF8fDAwfEFTQ0lJDUVWTnxBMDB8MjAxODAxMDEwNDAwMDANUElEfHwxNAExMTFeXl5eTVJOfDExMTExMTExXl5eXk1STn4xMTExMTExMTExXl5eXk9SR05NQlI=",
      "sendFacility": "SEND_FACILITY",
      "sendTime": "2018-01-01T00:00:00Z",
      "messageType": "TYPE",
      "createTime": "CREATE_TIME",
      "patientIds": [
        {
          "value": "14\u0001111",
          "type": "MRN"
        },
        {
          "value": "11111111",
          "type": "MRN"
        },
        {
          "value": "1111111111",
          "type": "ORGNMBR"
        }
      ]
    }
    

    PowerShell

    $cred = gcloud auth application-default print-access-token
    $headers = @{ Authorization = "Bearer $cred" }
    
    Invoke-WebRequest `
      -Method Post `
      -Headers $headers `
      -ContentType: "application/json; charset=utf-8" `
      -InFile hl7v2-sample.json `
      -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages" | Select-Object -Expand Content
    

    Replace the following:

    • PROJECT_ID: the ID of your project
    • LOCATION: the dataset location
    • DATASET_ID: the dataset ID
    • HL7V2_STORE_ID: the HL7v2 store ID

    The output is the following:

    {
      "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages/MESSAGE_ID",
      "data": "TVNIfF5+XCZ8QXxTRU5EX0ZBQ0lMSVRZfEF8QXwyMDE4MDEwMTAwMDAwMHx8VFlQRV5BfDIwMTgwMTAxMDAwMDAwfFR8MC4wfHx8QUF8fDAwfEFTQ0lJDUVWTnxBMDB8MjAxODAxMDEwNDAwMDANUElEfHwxNAExMTFeXl5eTVJOfDExMTExMTExXl5eXk1STn4xMTExMTExMTExXl5eXk9SR05NQlI=",
      "sendFacility": "SEND_FACILITY",
      "sendTime": "2018-01-01T00:00:00Z",
      "messageType": "TYPE",
      "createTime": "CREATE_TIME",
      "patientIds": [
        {
          "value": "14\u0001111",
          "type": "MRN"
        },
        {
          "value": "11111111",
          "type": "MRN"
        },
        {
          "value": "1111111111",
          "type": "ORGNMBR"
        }
      ]
    }
    

View HL7v2 message contents

Using the MESSAGE_ID from the response you received when you created the message, run the following command to view the message's details:

curl

curl -X GET \
     -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
     "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages/MESSAGE_ID"

Replace the following:

  • PROJECT_ID: the ID of your project
  • LOCATION: the dataset location
  • DATASET_ID: the dataset ID
  • HL7V2_STORE_ID: the HL7v2 store ID
  • MESSAGE_ID: the message ID

The output is the following:

{
  "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages/MESSAGE_ID",
  "data": "TVNIfF5+XCZ8QXxTRU5EX0ZBQ0lMSVRZfEF8QXwyMDE4MDEwMTAwMDAwMHx8VFlQRV5BfDIwMTgwMTAxMDAwMDAwfFR8MC4wfHx8QUF8fDAwfEFTQ0lJDUVWTnxBMDB8MjAxODAxMDEwNDAwMDANUElEfHwxNAExMTFeXl5eTVJOfDExMTExMTExXl5eXk1STn4xMTExMTExMTExXl5eXk9SR05NQlI=",
  "sendFacility": "SEND_FACILITY",
  "sendTime": "2018-01-01T00:00:00Z",
  "messageType": "TYPE",
  "createTime": "CREATE_TIME",
  "patientIds": [
    {
      "value": "14\u0001111",
      "type": "MRN"
    },
    {
      "value": "11111111",
      "type": "MRN"
    },
    {
      "value": "1111111111",
      "type": "ORGNMBR"
    }
  ],
  "parsedData": {
    "segments": [
      {
        "segmentId": "MSH",
        "fields": {
          "5": "A",
          "8.1": "TYPE",
          "6": "20180101000000",
          "8.2": "A",
          "3": "SEND_FACILITY",
          "4": "A",
          "11": "0.0",
          "10": "T",
          "1": "^~\\&",
          "17": "ASCII",
          "2": "A",
          "0": "MSH",
          "14": "AA",
          "9": "20180101000000",
          "16": "00"
        }
      },
      {
        "segmentId": "EVN",
        "fields": {
          "2": "20180101040000",
          "0": "EVN",
          "1": "A00"
        }
      },
      {
        "segmentId": "PID",
        "fields": {
          "3[0].5": "MRN",
          "3[1].1": "1111111111",
          "3[1].5": "ORGNMBR",
          "0": "PID",
          "2.1": "14\u0001111",
          "2.5": "MRN",
          "3[0].1": "11111111"
        }
      }
    ]
  }
}

PowerShell

$cred = gcloud auth application-default 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/hl7V2Stores/HL7V2_STORE_ID/messages/MESSAGE_ID" | Select-Object -Expand Content

Replace the following:

  • PROJECT_ID: the ID of your project
  • LOCATION: the dataset location
  • DATASET_ID: the dataset ID
  • HL7V2_STORE_ID: the HL7v2 store ID
  • MESSAGE_ID: the message ID

The output is the following:

{
  "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages/MESSAGE_ID",
  "data": "TVNIfF5+XCZ8QXxTRU5EX0ZBQ0lMSVRZfEF8QXwyMDE4MDEwMTAwMDAwMHx8VFlQRV5BfDIwMTgwMTAxMDAwMDAwfFR8MC4wfHx8QUF8fDAwfEFTQ0lJDUVWTnxBMDB8MjAxODAxMDEwNDAwMDANUElEfHwxNAExMTFeXl5eTVJOfDExMTExMTExXl5eXk1STn4xMTExMTExMTExXl5eXk9SR05NQlI=",
  "sendFacility": "SEND_FACILITY",
  "sendTime": "2018-01-01T00:00:00Z",
  "messageType": "TYPE",
  "createTime": "CREATE_TIME",
  "patientIds": [
    {
      "value": "14\u0001111",
      "type": "MRN"
    },
    {
      "value": "11111111",
      "type": "MRN"
    },
    {
      "value": "1111111111",
      "type": "ORGNMBR"
    }
  ],
  "parsedData": {
    "segments": [
      {
        "segmentId": "MSH",
        "fields": {
          "5": "A",
          "8.1": "TYPE",
          "6": "20180101000000",
          "8.2": "A",
          "3": "SEND_FACILITY",
          "4": "A",
          "11": "0.0",
          "10": "T",
          "1": "^~\\&",
          "17": "ASCII",
          "2": "A",
          "0": "MSH",
          "14": "AA",
          "9": "20180101000000",
          "16": "00"
        }
      },
      {
        "segmentId": "EVN",
        "fields": {
          "2": "20180101040000",
          "0": "EVN",
          "1": "A00"
        }
      },
      {
        "segmentId": "PID",
        "fields": {
          "3[0].5": "MRN",
          "3[1].1": "1111111111",
          "3[1].5": "ORGNMBR",
          "0": "PID",
          "2.1": "14\u0001111",
          "2.5": "MRN",
          "3[0].1": "11111111"
        }
      }
    ]
  }
}

Now that you've stored and viewed an HL7v2 message in the Cloud Healthcare API, continue to What's next for information on next steps.

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. In the Cloud Console, go to the Manage resources page.

    Go to Manage resources

  2. In the project list, select the project that you want to delete, and then click Delete.
  3. In the dialog, type the project ID, and then click Shut down to delete the project.

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

curl -X DELETE \
     -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
     "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID"

Replace the following:

  • PROJECT_ID: the ID of your project
  • LOCATION: the dataset location
  • DATASET_ID: the dataset ID

The output is the following:

{}

PowerShell

$cred = gcloud auth application-default 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

Replace the following:

  • PROJECT_ID: the ID of your project
  • LOCATION: the dataset location
  • DATASET_ID: the dataset ID

The output is the following:

{}

How did it go?

What's next

See the following sections for general information on the Cloud Healthcare API and how to perform tasks using the Cloud Console and the gcloud command-line tool:

DICOM

Continue to the DICOM guide to review topics such as:

See the DICOM conformance statement for information on how the Cloud Healthcare API implements the DICOMweb standard.

FHIR

Continue to the FHIR guide to review topics such as:

See the FHIR conformance statement for information on how the Cloud Healthcare API implements the FHIR standard.

HL7v2

Continue to the HL7v2 guide to review topics such as: