Configuring Cloud Pub/Sub notifications

You can receive notifications when clinical events occur in Cloud Healthcare API data stores using Cloud Pub/Sub. These notifications inform you when:

  • A DICOM instance is stored in a DICOM store
  • A FHIR resource is created, updated, or deleted in a FHIR store
  • An HL7v2 message is ingested or created in an HL7v2 store

When one of these events occurs, the Cloud Healthcare API publishes a message to a named Cloud Pub/Sub resource called a topic. The message can then be received by applications subscribed to the topic.

For an overview of using Cloud Pub/Sub notifications with the Cloud Healthcare API, see Cloud Pub/Sub notifications.

Prerequisites

Before using this feature, complete the following sections:

Enable the Cloud Pub/Sub API

Click the button below to enable the Cloud Pub/Sub API:

Enable the API

Configure Cloud Pub/Sub permissions

To allow messages to be published from the Cloud Healthcare API to Cloud Pub/Sub, you must add the pubsub.publisher role to your project's Cloud Healthcare Service Agent service account. See DICOM, FHIR, and HL7v2 store Cloud Pub/Sub permissions for how to do so.

Create a Cloud Pub/Sub topic

For each data store for which you'd like to receive notifications, you must configure a Cloud Pub/Sub topic. Individual data stores can have their own Cloud Pub/Sub topic, or multiple data stores can share the same topic. You can create a topic using either the Google Cloud Platform Console or the gcloud command-line tool.

When you create a topic (or refer to it in a data store's configuration), you need to use a qualified URI in the following format:

projects/PROJECT_ID/topics/TOPIC_NAME

where PROJECT_ID is your Google Cloud Platform project ID and TOPIC_NAME is the name of the topic.

To create a topic:

Console

  1. Go to the Cloud Pub/Sub Topics page in the GCP Console.

    Go to the Cloud Pub/Sub topics page

  2. Click Create Topic.

  3. Enter a topic name with the URI:

    projects/PROJECT_ID/topics/TOPIC_NAME

    where PROJECT_ID is your GCP project ID.

  4. Click Create.

gcloud

To create a topic, run the gcloud pubsub topics create command:

gcloud pubsub topics create projects/PROJECT_ID/topics/TOPIC_NAME

If the request is successful, the command returns the following output:

Created topic [projects/PROJECT_ID/topics/TOPIC_NAME].

Create a Cloud Pub/Sub subscription

To receive messages published to a topic, you need to create a Cloud Pub/Sub subscription. Every Cloud Pub/Sub topic should have at least one Cloud Pub/Sub subscription.

The subscription connects the topic to a subscriber application that receives and processes messages published to the topic.

Subscriptions can be configured to use a push model or a pull model.

To create a subscription:

Console

  1. Go to the Cloud Pub/Sub Topics page in the GCP Console.

    Go to the Cloud Pub/Sub topics page

  2. Click your project's topic.

  3. Click Create Subscription.

  4. Enter a subscription name:

    projects/PROJECT_ID/subscriptions/SUBSCRIPTION_NAME

    Leave Delivery Type set to Pull.

  5. Click Create.

gcloud

To create a topic, run the gcloud pubsub subscriptions create command:

gcloud pubsub subscriptions create SUBSCRIPTION_NAME --topic=TOPIC_NAME

If the request is successful, the command returns the following output:

Created subscription [projects/PROJECT_ID/subscriptions/TOPIC_NAME].

DICOM instances

The DicomStore resource contains a notificationConfig object where you can specify a Cloud Pub/Sub topic.

Whenever a DICOM instance is stored in a DICOM store, even if the DICOM instance already exists, the Cloud Healthcare API publishes a message to the DICOM store's Cloud Pub/Sub topic.

The following diagram shows the flow of notifications that occur when a DICOM instance is stored:

dicom_pubsub

  1. A dicomStores.dicomWeb.studies.storeInstances request is made to store a DICOM instance.
  2. The DICOM store receives the instance, then creates and sends a message to its Cloud Pub/Sub topic.
  3. Cloud Pub/Sub forwards the message to the topic's subscriptions.
  4. The subscribers receive a notification, in the form of a Cloud Pub/Sub message, from their subscription. Each subscription can have one or more subscribers for increase parallelism.

Complete the following steps to view a notification for a stored DICOM instance:

  1. Create or edit a DICOM store and configure it with a Cloud Pub/Sub topic.
  2. Add the required pubsub.publisher role to your project's service account.
  3. Store an instance in the DICOM store. This triggers the Cloud Healthcare API to publish a message to the configured Cloud Pub/Sub topic.
  4. Run the gcloud pubsub subscriptions pull command to view the message published to the Cloud Pub/Sub topic:

    gcloud pubsub subscriptions pull --auto-ack projects/PROJECT_ID/subscriptions/PUBSUB_SUBSCRIPTION
    

    The command returns the following output about the DICOM instance that was stored:

    ┌----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------┐
    |                                                                          DATA                                                                           |    MESSAGE_ID   | ATTRIBUTES |
    ├---------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------|------------|
    | projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/dicomStores/DICOM_STORE_ID/dicomWeb/studies/STUDY_UID/series/SERIES_UID/instances/INSTANCE_UID | 123456789012345 |            |
    └----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------┘
    

FHIR resources

The FhirStore resource contains a notificationConfig object where you can specify a Cloud Pub/Sub topic.

Whenever a FHIR resource is created, updated, or deleted in a FHIR store, the Cloud Healthcare API publishes a message to the FHIR store's Cloud Pub/Sub topic.

The following diagram shows the flow of notifications that occur when a FHIR resource is created, updated, or deleted:

fhir_pubsub

  1. A fhirStores.fhir.update API request is made to edit a FHIR resource.
  2. The FHIR store containing the resource creates and sends a Cloud Pub/Sub message to the store's Cloud Pub/Sub topic.
  3. Cloud Pub/Sub forwards the message to the topic's subscriptions.
  4. The subscribers receive a notification, in the form of a Cloud Pub/Sub message, from their subscription. Each subscription can have one or more subscribers for increase parallelism.

Complete the following steps to view a notification for a created FHIR resource:

  1. Create or edit a FHIR store and configure it with a Cloud Pub/Sub topic.
  2. Add the required pubsub.publisher role to your project's service account.
  3. Create a FHIR resource in the FHIR store. This triggers the Cloud Healthcare API to publish a message to the configured Cloud Pub/Sub topic.
  4. Run the gcloud pubsub subscriptions pull command to view the message published to the Cloud Pub/Sub topic:

    gcloud pubsub subscriptions pull --auto-ack projects/PROJECT_ID/subscriptions/PUBSUB_SUBSCRIPTION
    

    The command returns the following output about the created FHIR resource:

    ┌----------------------------------------------------------------------------------------------------------------|-----------------|-----------------------┐
    |                                                      DATA                                                      |    MESSAGE_ID   |       ATTRIBUTES      |
    ├----------------------------------------------------------------------------------------------------------------|-----------------|-----------------------|
    | projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/resources/Patient/PATIENT_ID | 123456789012345 | action=CreateResource |
    |                                                                                                                |                 | resourceType=Patient  |
    └----------------------------------------------------------------------------------------------------------------|-----------------|-----------------------┘
    

HL7v2 messages

The Hl7V2Store resource contains a notificationConfig object where you can specify a Cloud Pub/Sub topic.

Whenever an HL7v2 message is ingested or created in an HL7v2 store, the Cloud Healthcare API publishes a message to the HL7v2 store's Cloud Pub/Sub topic.

The following diagram shows the flow of notifications that occur when an HL7v2 message is ingested or created:

hl7v2_pubsub

  1. The Cloud Healthcare API ingests an HL7v2 message from a care system.
  2. The message is stored in an HL7v2 store.
  3. The HL7v2 store creates and sends a Cloud Pub/Sub message to the store's Cloud Pub/Sub topic.
  4. Cloud Pub/Sub forwards the Cloud Pub/Sub message to the topic's subscriptions.
  5. The subscribers receive a notification, in the form of a Cloud Pub/Sub message, from their subscription. Each subscription can have one or more subscribers for increase parallelism.

Complete the following steps to view a notification for an ingested HL7v2 message:

  1. Create or edit an HL7v2 store and configure it with a Cloud Pub/Sub topic.
  2. Add the required pubsub.publisher role to your project's service account.
  3. Ingest an HL7v2 message into the HL7v2 store. This triggers the Cloud Healthcare API to publish a message to the configured Cloud Pub/Sub topic.
  4. Run the gcloud pubsub subscriptions pull command to view the message published to the Cloud Pub/Sub topic:

    gcloud pubsub subscriptions pull --auto-ack projects/PROJECT_ID/subscriptions/PUBSUB_SUBSCRIPTION
    

    The command returns the following output about the ingested HL7v2 message:

    ┌--------------------------------------------------------------------------------------------------------------------|-----------------|---------------┐
    |                                                                 DATA                                               |    MESSAGE_ID   |   ATTRIBUTES  |
    ├--------------------------------------------------------------------------------------------------------------------|-----------------|---------------|
    | projects/PROJECT_ID/locations/us-central1/datasets/DATASET_ID/hl7V2Stores/HL7V2_STORE_ID/messages/HL7V2_MESSAGE_ID | 123456789012345 | msgType=TYPE  |
    └--------------------------------------------------------------------------------------------------------------------|-----------------|---------------┘
    

What's next

Learn how to configure a Cloud Pub/Sub topic in:

หน้านี้มีประโยชน์ไหม โปรดแสดงความคิดเห็น