Skip to content
Reference

Google Cloud Healthcare FHIR adapter

Read and write FHIR R4 resources in a Google Cloud Healthcare API FHIR store from a workflow, with no stored key.

On this page

The Google Cloud Healthcare FHIR adapter (gcp-healthcare-fhir) reads and writes FHIR R4 resources in a FHIR store of the Google Cloud Healthcare API. Terraform can create the store in your own Google Cloud project, next to the engine. The engine signs in with its own Google identity, so no key is stored, and your team queries the same store directly with Google IAM.

flowchart LR
    subgraph YOURS["Your Google Cloud project"]
        direction TB
        ENG["MedHook engine\non private GKE"]
        FS[("Cloud Healthcare API\nR4 FHIR store")]
        ENG == "Workload Identity\nfhirResourceEditor on this store" ==> FS
    end
    TEAM["Your team and services"] -- "Google IAM\n(gcloud, curl, your apps)" --> FS

How it works

  • Sign-in. On GKE the token comes from the metadata server for the engine's Google service account (Workload Identity). There is no key to store or rotate. The token is cached and fetched again a minute before it expires, and once more after a 401. An engine outside GKE can use a stored service account key instead. With workload-identity a private CA (tlsCaPem) is refused: the requests carry the engine's own token, so they are verified against the system CAs only. A proxy still works. Only a service-account-key profile may set a CA.
  • The store. A profile names the store with four fields: project, location, dataset and FHIR store. The engine builds the base URL from them and checks each one. Every request, including a search's next-page link, has to stay inside that store.
  • Requests. Every request is the FHIR REST adapter's: read, search with paging, create, update, and transaction or batch Bundles posted to the store's base URL.
  • Retries. A 401, 403 or another 4xx fails the step without a retry: the store refused it and would refuse it again. A 408, 429 or 5xx is retried with the step's retry settings, and a 429's Retry-After is respected.

Turn it on

You need the engine on GKE, installed with the Terraform module (Install).

1. Set the variables

In terraform.tfvars:

hcl
fhir_store_enabled = true
# Optional:
# fhir_store_location       = ""           # empty = the engine's region
# fhir_store_dataset_id     = "medhook"
# fhir_store_id             = "medhook-r4"
# fhir_store_readers        = ["group:fhir-analysts@demohealth.example.test"]
# fhir_store_pubsub_enabled = false

2. Apply and deploy

bash
cd terraform/gke
terraform plan -out=fhir.tfplan
terraform apply fhir.tfplan

Then run your usual deploy, so the engine picks up the new chart value.

Terraform enables the Cloud Healthcare API and creates:

WhatSetting
Datasetfhir_store_dataset_id, in fhir_store_location (default: the engine's region)
FHIR storefhir_store_id, FHIR version R4, update-as-create on, referential integrity on
Engine accessroles/healthcare.fhirResourceEditor on this store only. No project-wide Healthcare role.
Readersroles/healthcare.fhirResourceReader on the store for each fhir_store_readers member
Encryption at restGoogle-managed keys, or your key when cmek_kms_key is set (keep the store in the key's region)
Deletionterraform destroy stops instead of deleting the store: it holds PHI

3. Check the FHIR store card

Open Adapters in the engine. The FHIR store card shows the store's name, whether it is reachable, the FHIR version it reports and its base URL. Without a store, the card says how to turn one on. An engine with the bundled Medplum and no managed store shows Medplum in the same card.

Use it in a workflow

The card has two buttons. Each saves an adapter profile for the store if this workspace has none, and opens a new draft workflow in the builder. Deploy it when it is ready.

  • Use as destination. An MLLP workflow: HL7v2 to FHIR R4, then a write to the store.
  • Use as source (polling). A polling workflow that runs once for each Patient created or changed in the store.

You can also create a profile with New connection: pick Google Cloud Healthcare FHIR. The settings are:

SettingRequiredDescription
projectYesGoogle Cloud project ID that holds the dataset
locationYesDataset location, such as us-central1
datasetYesHealthcare dataset ID
fhirStoreYesFHIR store ID
authTypeNoworkload-identity (default) or service-account-key
credentials.serviceAccountKeyNoService account JSON key, for service-account-key only. Encrypted at rest.
timeoutNoRequest timeout in milliseconds

Every action and setting is also in Adapter settings.

Write without duplicates

A create step can send a conditional create. Set ifNoneExist to identifier to search on the resource's first identifier, or to a search such as identifier=urn:demohealth:mrn|TP0001. If the store has a match, it returns that resource and stores nothing new, so a resent HL7 message does not create a second patient. A transaction Bundle can do the same per entry with request.ifNoneExist.

Start workflows from the store

A polling trigger reads the store on an interval. Search on _lastUpdated with the stored cursor, and sort by it:

json
{
  "type": "polling",
  "interval": 60000,
  "adapterProfileId": "<profile id>",
  "action": "search",
  "params": {
    "resourceType": "Patient",
    "searchParams": { "_lastUpdated": "gt{{cursor}}", "_sort": "_lastUpdated" }
  },
  "cursorField": "meta.lastUpdated",
  "startFrom": "now"
}

Each new or changed Patient runs once. The first poll leaves out the _lastUpdated filter, because there is no cursor yet. With startFrom: "now" it only records where the store is, and later changes run.

Start a workflow from each change

With fhir_store_pubsub_enabled, Terraform creates a Pub/Sub topic and the store publishes a message for every change. A Pub/Sub trigger on a subscription to that topic starts one run per change, with no polling: see FHIR store write → workflow. Your own services can subscribe to the same topic.

Query it directly with Google IAM

The store is a normal Cloud Healthcare API FHIR store in your project. Your analysts and services use it with their own Google identities and the API's own IAM roles. MedHook is not in the path.

Grant access with fhir_store_readers, or with your own IAM grants on the store. Then, signed in with gcloud:

bash
BASE=$(cd terraform/gke && terraform output -raw fhir_store_base_url)
TOKEN=$(gcloud auth print-access-token)

# Find the synthetic test patient a workflow wrote
curl -s -H "Authorization: Bearer ${TOKEN}" \
  "${BASE}/Patient?family=TESTPATIENT"

# Read one resource by id
curl -s -H "Authorization: Bearer ${TOKEN}" "${BASE}/Patient/<id>"

The base URL is on the healthcare.googleapis.com host, with the path /v1/projects/<project>/locations/<location>/datasets/<dataset>/fhirStores/<store>/fhir. Writing needs roles/healthcare.fhirResourceEditor:

bash
curl -s -X POST -H "Authorization: Bearer ${TOKEN}" \
  -H "Content-Type: application/fhir+json" \
  --data '{"resourceType":"Patient","identifier":[{"system":"urn:demohealth:mrn","value":"TP0001"}],"name":[{"family":"TESTPATIENT","given":["JANE"]}]}' \
  "${BASE}/Patient"

Compliance

  • BAA. The Cloud Healthcare API is covered by Google Cloud's Business Associate Agreement. Your organization signs the BAA with Google, and the store stays in your project and region.
  • Encryption. Data is encrypted at rest with Google-managed keys, or with your Cloud KMS key when cmek_kms_key is set. Requests use TLS.
  • Audit. Cloud Audit Logs record admin activity on the store. Turn on Data Access audit logs for the Cloud Healthcare API to also record reads and writes of FHIR resources.
  • Least privilege. The engine's service account has roles/healthcare.fhirResourceEditor on this store only, and no stored key.

Reference