Stream DICOM metadata to BigQuery

This page describes how to configure a DICOM store to exportDICOM instance metadata to a BigQuery table whenever one of thefollowing occurs:

Streaming DICOM metadata to a BigQuery table synchronizes the tablewith your DICOM data so you can run complex queries on the latest version ofyour DICOM store.

Before you begin

Before you configure your DICOM store, complete the following

Set BigQuery permissions

Before streaming DICOM metadata to BigQuery, you must grantthe required permissions to theCloud Healthcare Service Agentservice account. For more information, seeDICOM store BigQuery permissions.

Learn to export DICOM metadata to BigQuery

Before configuring streaming, understand how toexport DICOM metadata to BigQuery.

Configure the DICOM store

To enable streaming to BigQuery, configure theStreamConfigobject in your DICOM store. In theStreamConfig object, set theBigQueryDestinationobject to a fully qualified BigQuery table URI as a DICOMinstance metadata destination.

You can specify up to five BigQuery destinations ascomma-separated JSON objects.

Deleting DICOM instances in a DICOM store doesn't delete the BigQueryrows containing the metadata for those instances.

Console

To update a DICOM store to enable BigQuery streaming, complete the following steps:

  1. In the Google Cloud console, go to theDatasets page.
    Go to Datasets
  2. Select the dataset containing the DICOM store you want to edit.
  3. Select the DICOM store for which you are adding a streaming configuration.
  4. In theOverview tab of theData store details page, clickAdd new streaming configuration.
  5. In theNew streaming configuration field, clickBrowse.
    1. In theSelect table pane, select a BigQuery table.
    2. ClickSelect.
  6. ClickDone.

REST

The following samples show how to update a DICOM store to enable BigQuerystreaming. In these samples, the DICOM store and the BigQuerytable are in the same project. To exportDICOM metadata to another project, seeExporting DICOM metadata to a different project.

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 DICOM store's parent dataset
  • DICOM_STORE_ID: the DICOM store ID
  • BIGQUERY_DATASET_ID: the name of an existing BigQuery dataset
  • BIGQUERY_TABLE_ID: a unique name for a table in the BigQuery dataset. SeeTable naming for naming requirements. The BigQuery dataset must exist, but the Cloud Healthcare API can update an existing table or create a new one.

Request JSON body:

{  'streamConfigs': [{     'bigqueryDestination': {      'tableUri': 'bq://PROJECT_ID.BIGQUERY_DATASET_ID.BIGQUERY_TABLE_ID'     }  }]}

To send your request, choose one of these options:

curl

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login , or by usingCloud Shell, which automatically logs you into thegcloud CLI . You can check the currently active account by runninggcloud auth list.

Save the request body in a file namedrequest.json. Run the following command in the terminal to create or overwrite this file in the current directory:

cat > request.json<< 'EOF'{  'streamConfigs': [{     'bigqueryDestination': {      'tableUri': 'bq://PROJECT_ID.BIGQUERY_DATASET_ID.BIGQUERY_TABLE_ID'     }  }]}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/dicomStores/DICOM_STORE_ID?updateMask=streamConfigs"

PowerShell

Note: The following command assumes that you have logged in to thegcloud CLI with your user account by runninggcloud init orgcloud auth login . You can check the currently active account by runninggcloud auth list.

Save the request body in a file namedrequest.json. Run the following command in the terminal to create or overwrite this file in the current directory:

@'{  'streamConfigs': [{     'bigqueryDestination': {      'tableUri': 'bq://PROJECT_ID.BIGQUERY_DATASET_ID.BIGQUERY_TABLE_ID'     }  }]}'@  | 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/dicomStores/DICOM_STORE_ID?updateMask=streamConfigs" | Select-Object -Expand Content

APIs Explorer

Copy the request body and open themethod reference page. The APIs 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 clickExecute.

You should receive a JSON response similar to the following:

Response

{  "name": "projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID",  "streamConfigs": [    {      "bigqueryDestination": {        "tableUri": "bq://PROJECT_ID.BIGQUERY_DATASET_ID.BIGQUERY_TABLE_ID"      }    }  ]}

Deletion metadata

In previous Cloud Healthcare API versions, DICOM instance metadata was onlyexported to BigQuery when a DICOM instance was inserted into a DICOMstore. When writing metadata for deletions was added,two new columns, namedType andLastUpdated, were added to the generatedtable containing the DICOM metadata.

Any metadata in the table that existed before the introduction of deletionmetadata has aNULL value for these columns. ANULL is the lowest value andappears last when sorting by descending order.

Generated BigQuery view

When you insert or delete a DICOM instance in a DICOM store, the configuredBigQuery table is updated.

If aview of the table doesn't exist,the view is created. Otherwise, the view is updated.

Limitations and additional behavior

Some DICOM tags might be missing from the exported metadata. If so, the missingtags are added to a separate column namedDroppedTags.TagName in thedestination BigQuery table.

Tags will be missing for one of the following reasons:

  • The DICOM tag is an unsupported VR listed inExcluded VRs.
  • The DICOM tag approximately exceeds 1 MB.
  • The number of columns in the destination BigQuery table exceeds themaximum number of columns.When exporting DICOM metadata to a BigQuery table exceeds thecolumn limit, DICOM tags that don't match an existing column are added totheDroppedTags.Name column. If theDroppedTags column can't be added,the DICOM tags are dropped without a notification and a warning log isgenerated. For more information, seeTroubleshooting DICOM streaming requests for viewing logs.

Incorporate deletion metadata into an existing table

Thegenerated view's behaviour depends on whether its basetable contains metadata added before thedeletion metadatafeature was introduced.

Suppose a BigQuery table contains DICOM metadata from beforedeletion metadata was supported, and then the following occurs:

  1. You insert a DICOM instance into a DICOM store.
  2. You delete the DICOM instance from the DICOM store.
  3. You edit the tags of the original DICOM instance, and insert the modifiedDICOM instance into the DICOM store.

Because the BigQuery table contained the original metadata beforedeletion metadata was supported, the original DICOM instance and its editedversion have the same studies, series, and instanceunique identifiers (UID). The generated view might containeither the original DICOM instance or the most recent DICOM instance. WithouttheLastUpdated column, the view can't identify which DICOM instance is newer.

To ensure you're querying the most recent DICOM instance metadata, do one of thefollowing:

  • Query the base table instead of the view. Ensure the query searches for the updated tags in the edited DICOM instance.
  • Delete the existing table containing DICOM metadata, and then recreate itbyexporting the DICOM metadata to BigQuery manually.The recreated table contains theLastUpdated column.

    This option removes historical streaming metadata, but ensures that the tablecontains theLastUpdated column with valid values.

Troubleshoot DICOM streaming requests

If errors occur during a DICOM export metadata to BigQueryrequest, the errors are logged toCloud Logging. For moreinformation, seeViewing error logs in Cloud Logging.

To filter streaming DICOM metadata error logs in the Google Cloud console, complete the following steps:

  1. Go to theLogs explorer page.

    Go to Logs explorer

  2. In theQuery field, enter the following query:

    logName="healthcare.googleapis.com%2Fdicom_stream"
  3. ClickRun query.

    Any error logs are displayed in theQuery results section.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-18 UTC.