This page explains how to create, update, patch, view, and delete FHIR resources.
A FHIR resource can contain data about a patient, a device, an observation, and more. For a full list of FHIR resources, see the FHIR Resource Index (DSTU2, or R4).
The curl
and Windows PowerShell samples in this page work with an R4 FHIR store,
and are not guaranteed to work if you're using a DSTU2 or STU3 FHIR store.
If you're using a DSTU2 or STU3 FHIR store, consult the official FHIR
documentation at https://www.hl7.org/fhir/
for information on how to convert the samples to the FHIR version you're using.
The Go, Java, Node.js, and Python samples work with an STU3 FHIR store.
Creating a FHIR resource
Before you can create FHIR resources, you need to create a FHIR store.
The curl
, Windows PowerShell, and Python samples show how to create the
following FHIR resources:
- A Patient (DSTU2, STU3, and R4) resource
- An Encounter (DSTU2, STU3, and R4) resource for the Patient
- An Observation (DSTU2, STU3, and R4) resource for the Encounter
The samples for all other languages show how to create a generic FHIR resource.
For more information, see
projects.locations.datasets.fhirStores.fhir.create
.
The following curl
and Windows PowerShell samples work with R4 FHIR stores. The Go, Java, Node.js, and Python samples work with STU3 FHIR stores.
curl
To create a Patient resource, make a POST
request and specify the following
information:
- The name of the parent dataset
- The name of the FHIR store
- A blob of data containing information about the patient
- The type of resource
- An access token
The following sample shows how to send a POST
request using curl
to
create a Patient resource:
curl -X POST \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ -H "Content-Type: application/fhir+json; charset=utf-8" \ --data "{ \"name\": [ { \"use\": \"official\", \"family\": \"Smith\", \"given\": [ \"Darcy\" ] } ], \"gender\": \"female\", \"birthDate\": \"1970-01-01\", \"resourceType\": \"Patient\" }" \ "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient"
If the request is successful, the server returns a response similar to the following sample in JSON format:
{ "birthDate": "1970-01-01", "gender": "female", "id": "PATIENT_ID", "meta": { "lastUpdated": "2020-01-01T00:00:00+00:00", "versionId": "VERSION_ID" }, "name": [ { "family": "Smith", "given": [ "Darcy" ], "use": "official" } ], "resourceType": "Patient" }
PowerShell
To create a Patient resource, make a POST
request and specify the following
information:
- The name of the parent dataset
- The name of the FHIR store
- A blob of data containing information about the patient
- The type of resource
- An access token
The following sample shows how to send a POST
request using Windows
PowerShell to create a Patient resource:
$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } $patient = '{ "name": [ { "use": "official", "family": "Smith", "given": [ "Darcy" ] } ], "gender": "female", "birthDate": "1970-01-01", "resourceType": "Patient" }' Invoke-RestMethod ` -Method Post ` -Headers $headers ` -ContentType: "application/fhir+json; charset=utf-8" ` -Body $patient ` -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient" | ConvertTo-Json
If the request is successful, the server returns a response similar to the following sample in JSON format:
{ "birthDate": "1970-01-01", "gender": "female", "id": "PATIENT_ID", "meta": { "lastUpdated": "2020-01-01T00:00:00+00:00", "versionId": "VERSION_ID" }, "name": [ { "family": "Smith", "given": [ "Darcy" ], "use": "official" } ], "resourceType": "Patient" }
Go
Java
Node.js
Python
The following curl
and Windows PowerShell samples work with R4 FHIR stores. The Python sample works with STU3 FHIR stores.
curl
After creating the Patient resource, create an Encounter resource to describe an interaction between the patient and a practitioner.
The following sample shows how to send a POST
request using curl
to create
an Encounter resource.
In the PATIENT_ID field, substitute the ID from the response returned by the server when you created the Patient.
curl -X POST \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ -H "Content-Type: application/fhir+json; charset=utf-8" \ --data "{ \"status\": \"finished\", \"class\": { \"system\": \"http://hl7.org/fhir/v3/ActCode\", \"code\": \"IMP\", \"display\": \"inpatient encounter\" }, \"reasonCode\": [ { \"text\": \"The patient had an abnormal heart rate. She was concerned about this.\" } ], \"subject\": { \"reference\": \"Patient/PATIENT_ID\" }, \"resourceType\": \"Encounter\" }" \ "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Encounter"
If the request is successful, the server returns a response similar to the following sample in JSON format.
{ "class": { "code": "IMP", "display": "inpatient encounter", "system": "http://hl7.org/fhir/v3/ActCode" }, "id": "ENCOUNTER_ID", "meta": { "lastUpdated": "2020-01-01T00:00:00+00:00", "versionId": "VERSION_ID" }, "reasonCode": [ { "text": "The patient had an abnormal heart rate. She was concerned about this." } ], "resourceType": "Encounter", "status": "finished", "subject": { "reference": "Patient/PATIENT_ID" } }
PowerShell
After creating the Patient resource, create an Encounter resource to describe
an interaction between the patient and a practitioner. The following sample
shows how to send a POST
request using Windows PowerShell to create an
Encounter resource.
In the PATIENT_ID field, substitute the ID from the response returned by the server when you created the Patient.
$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } $encounter = '{ "status": "finished", "class": { "system": "http://hl7.org/fhir/v3/ActCode", "code": "IMP", "display": "inpatient encounter" }, "reasonCode": [ { "text": "The patient had an abnormal heart rate. She was concerned about this." } ], "subject": { "reference": "Patient/PATIENT_ID" }, "resourceType": "Encounter" }' Invoke-RestMethod ` -Method Post ` -Headers $headers ` -ContentType: "application/fhir+json; charset=utf-8" ` -Body $encounter ` -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Encounter" | ConvertTo-Json
If the request is successful, the server returns a response similar to the following sample in JSON format.
{ "class": { "code": "IMP", "display": "inpatient encounter", "system": "http://hl7.org/fhir/v3/ActCode" }, "id": "ENCOUNTER_ID", "meta": { "lastUpdated": "2020-01-01T00:00:00+00:00", "versionId": "VERSION_ID" }, "reasonCode": [ { "text": "The patient had an abnormal heart rate. She was concerned about this." } ], "resourceType": "Encounter", "status": "finished", "subject": { "reference": "Patient/PATIENT_ID" } }
Python
The following curl
and Windows PowerShell samples work with R4 FHIR stores. The Python sample works with STU3 FHIR stores.
curl
After creating the Encounter resource, create an Observation about the
encounter. The Observation provides a measurement of the patient's heart rate in
beats per minute (BPM). The following sample shows how to send a POST
request using curl
to create an Observation resource:
- Enter a value in the BPM_VALUE field.
- In the PATIENT_ID field, substitute the ID from the response returned by the server when you created the Patient.
- In the ENCOUNTER_ID field, substitute the ID from the response returned by the server when you created the Encounter.
curl -X POST \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ -H "Content-Type: application/fhir+json; charset=utf-8" \ --data "{ \"resourceType\": \"Observation\", \"status\": \"final\", \"subject\": { \"reference\": \"Patient/PATIENT_ID\" }, \"effectiveDateTime\": \"2020-01-01T00:00:00+00:00\", \"code\": { \"coding\": [ { \"system\": \"http://loinc.org\", \"code\": \"8867-4\", \"display\": \"Heart rate\" } ] }, \"valueQuantity\": { \"value\": BPM_VALUE, \"unit\": \"bpm\" }, \"encounter\": { \"reference\": \"Encounter/ENCOUNTER_ID\" } }" \ "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Observation"
If the request is successful, the server returns a response similar to the following sample in JSON format:
{ "code": { "coding": [ { "code": "8867-4", "display": "Heart rate", "system": "http://loinc.org" } ] }, "encounter": { "reference": "Encounter/ENCOUNTER_ID" }, "effectiveDateTime": "2020-01-01T00:00:00+00:00", "id": "OBSERVATION_ID", "meta": { "lastUpdated": "2020-01-01T00:00:00+00:00", "versionId": "VERSION_ID" }, "resourceType": "Observation", "status": "final", "subject": { "reference": "Patient/PATIENT_ID" }, "valueQuantity": { "unit": "bpm", "value": BPM_VALUE } }
PowerShell
After creating the Encounter resource, create an Observation about the
encounter. The Observation provides a measurement of the patient's heartbeats
per minute (BPM). The following sample shows how to send a POST
request
using Windows PowerShell to create an Observation resource:
- Enter a value in the BPM_VALUE field.
- In the PATIENT_ID field, substitute the ID from the response returned by the server when you created the Patient.
- In the ENCOUNTER_ID field, substitute the ID from the response returned by the server when you created the Encounter.
$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } $observation = '{ "resourceType": "Observation", "status": "final", "subject": { "reference": "Patient/PATIENT_ID" }, "effectiveDateTime": "2020-01-01T00:00:00+00:00", "code": { "coding": [ { "system": "http://loinc.org", "code": "8867-4", "display": "Heart rate" } ] }, "valueQuantity": { "value": BPM_VALUE, "unit": "bpm" }, "encounter": { "reference": "Encounter/ENCOUNTER_ID" } }' Invoke-RestMethod ` -Method Post ` -Headers $headers ` -ContentType: "application/fhir+json; charset=utf-8" ` -Body $observation ` -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Observation" | ConvertTo-Json
If the request is successful, the server returns a response similar to the following sample in JSON format:
{ "code": { "coding": [ { "code": "8867-4", "display": "Heart rate", "system": "http://loinc.org" } ] }, "encounter": { "reference": "Encounter/ENCOUNTER_ID" }, "effectiveDateTime": "2020-01-01T00:00:00+00:00", "id": "OBSERVATION_ID", "meta": { "lastUpdated": "2020-01-01T00:00:00+00:00", "versionId": "VERSION_ID" }, "resourceType": "Observation", "status": "final", "subject": { "reference": "Patient/PATIENT_ID" }, "valueQuantity": { "unit": "bpm", "value": BPM_VALUE } }
Python
Updating a FHIR resource
The following samples show how to call the
projects.locations.datasets.fhirStores.fhir.update
method to update a FHIR resource. The method implements the FHIR standard
update interaction
(DSTU2,
STU3,
and R4).
When you update a resource, you update the entire contents of the resource. This is in contrast to patching a resource, which updates only part of a resource.
If the FHIR store has
enableUpdateCreate
set, the request is treated as an upsert (update or insert) that updates the
resource if it exists or inserts it using the ID specified the request if
it does not exist.
The request body must contain a JSON-encoded FHIR resource and the request
headers must contain Content-Type: application/fhir+json
. The resource must
contain an id
element having an identical value to the ID in the REST path of
the request.
The following curl
and Windows PowerShell samples work with R4 FHIR stores. The Go, Java, Node.js, and Python samples work with STU3 FHIR stores.
curl
To update a FHIR resource, make a PUT
request and specify the following
information:
- The name of the parent dataset
- The name of the FHIR store
- The type of resource
- The resource ID
- An access token
The following sample shows how to send a PUT
request using curl
to edit an
Observation resource. The Observation provides a measurement of a patient's
heartbeats per minute (BPM).
curl -X PUT \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ -H "Content-Type: application/fhir+json; charset=utf-8" \ --data '{ "code": { "coding": [ { "code": "8867-4", "display": "Heart rate", "system": "http://loinc.org" } ] }, "effectiveDateTime": "2020-01-01T00:00:00+00:00", "id": "OBSERVATION_ID", "resourceType": "Observation", "status": "final", "subject": { "reference": "Patient/PATIENT_ID" }, "valueQuantity": { "unit": "bpm", "value": BPM_VALUE } }' \ "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Observation/OBSERVATION_ID"
If the request is successful, the server returns a response similar to the following sample in JSON format:
{ "code": { "coding": [ { "code": "8867-4", "display": "Heart rate", "system": "http://loinc.org" } ] }, "effectiveDateTime": "2020-01-01T00:00:00+00:00", "id": "OBSERVATION_ID", "meta": { "lastUpdated": "2020-01-01T00:00:00+00:00", "versionId": "VERSION_ID" }, "resourceType": "Observation", "status": "final", "subject": { "reference": "Patient/PATIENT_ID" }, "valueQuantity": { "unit": "bpm", "value": BPM_VALUE } }
PowerShell
To update a FHIR resource, make a PUT
request and specify the following
information:
- The name of the parent dataset
- The name of the FHIR store
- The type of resource
- The resource ID
- An access token
The following sample shows how to send a PUT
request using Windows PowerShell
to edit an Observation resource. The Observation provides a measurement of a
patient's heartbeats per minute (BPM).
$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } $observation = '{ "code": { "coding": [ { "code": "8867-4", "display": "Heart rate", "system": "http://loinc.org" } ] }, "effectiveDateTime": "2020-01-01T00:00:00+00:00", "id": "OBSERVATION_ID", "resourceType": "Observation", "status": "final", "subject": { "reference": "Patient/PATIENT_ID" }, "valueQuantity": { "unit": "bpm", "value": BPM_VALUE } }' Invoke-RestMethod ` -Method Put ` -Headers $headers ` -ContentType: "application/fhir+json; charset=utf-8" ` -Body $observation ` -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Observation/OBSERVATION_ID" | ConvertTo-Json
If the request is successful, the server returns a response similar to the following sample in JSON format:
{ "code": { "coding": [ { "code": "8867-4", "display": "Heart rate", "system": "http://loinc.org" } ] }, "effectiveDateTime": "2020-01-01T00:00:00+00:00", "id": "OBSERVATION_ID", "meta": { "lastUpdated": "2020-01-01T00:00:00+00:00", "versionId": "VERSION_ID" }, "resourceType": "Observation", "status": "final", "subject": { "reference": "Patient/PATIENT_ID" }, "valueQuantity": { "unit": "bpm", "value": BPM_VALUE } }
Go
Node.js
Python
Conditionally updating a FHIR resource
The following samples show how to call the
projects.locations.datasets.fhirStores.fhir.conditionalUpdate
method to update a FHIR resource that matches a search
query, rather than identifying the resource by its ID. The method implements the
FHIR standard conditional update interaction
(DSTU2,
STU3,
and R4).
A conditional update can be applied to only one resource at a time.
The response returned from the server depends on how many matches occur based on the search criteria:
- One match: The resource is successfully updated or an error is returned.
- More than one match: The request
returns a
412 Precondition Failed
error. - Zero matches with an
id
: If the search criteria identify zero matches, the supplied resource body contains anid
, and the FHIR store hasenableUpdateCreate
set, the resource is created with a server-assigned ID similar to if the resource was created usingprojects.locations.datasets.fhirStores.fhir.create
. Theid
is ignored. - Zero matches without an
id
: If the search criteria identify zero matches and the supplied resource body does not contain anid
, the resource is created with a server-assigned ID similar to if the resource was created usingprojects.locations.datasets.fhirStores.fhir.create
.
The request body must contain a JSON-encoded FHIR resource and the request
headers must contain Content-Type: application/fhir+json
.
The following curl
and Windows PowerShell samples work with R4 FHIR stores. The Go and Python samples work with STU3 FHIR stores.
curl
To update a FHIR resource that matches a search query, make a PUT
request
and specify the following information:
- The name of the parent dataset
- The name of the FHIR store
- The type of resource you're searching for
- A query string containing the information you're searching for
- An access token
The following sample shows how to send a PUT
request using curl
to edit an
Observation resource using the Observation's identifier
(ABC-12345
in my-code-system
). The Observation provides a measurement of a
patient's heartbeats per minute (BPM).
curl -X PUT \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ -H "Content-Type: application/fhir+json; charset=utf-8" \ --data '{ "effectiveDateTime": "2020-01-01T00:00:00+00:00", "resourceType": "Observation", "identifier": [ { "system": "my-code-system", "value": "ABC-12345" } ], "status": "final", "subject": { "reference": "Patient/PATIENT_ID" }, "valueQuantity": { "unit": "bpm", "value": BPM_VALUE } }' \ "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Observation?identifier=my-code-system|ABC-12345"
If the request is successful, the server returns a response similar to the following sample in JSON format:
{ "effectiveDateTime": "2020-01-01T00:00:00+00:00", "id": "OBSERVATION_ID", "meta": { "lastUpdated": "2020-01-01T00:00:00+00:00", "versionId": "VERSION_ID" }, "resourceType": "Observation", "identifier": [ { "system": "my-code-system", "value": "ABC-12345" } ], "status": "final", "subject": { "reference": "Patient/PATIENT_ID" }, "valueQuantity": { "unit": "bpm", "value": BPM_VALUE } }
PowerShell
To update a FHIR resource that matches a search query, make a PUT
request
and specify the following information:
- The name of the parent dataset
- The name of the FHIR store
- The type of resource you're searching for
- A query string containing the information you're searching for
- An access token
The following sample shows how to send a PUT
request using Windows PowerShell
to edit an Observation resource using the Observation's identifier
(ABC-12345
in my-code-system
). The Observation provides a measurement of a
patient's heartbeats per minute (BPM).
$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } $observation = '{ "effectiveDateTime": "2020-01-01T00:00:00+00:00", "resourceType": "Observation", "identifier": [ { "system": "my-code-system", "value": "ABC-12345" } ], "status": "final", "subject": { "reference": "Patient/PATIENT_ID" }, "valueQuantity": { "unit": "bpm", "value": BPM_VALUE } }' Invoke-RestMethod ` -Method Put ` -Headers $headers ` -ContentType: "application/fhir+json; charset=utf-8" ` -Body $observation ` -Uri "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Observation?identifier=my-code-system|ABC-12345" | ConvertTo-Json
If the request is successful, the server returns a response similar to the following sample in JSON format:
{ "effectiveDateTime": "2020-01-01T00:00:00+00:00", "id": "OBSERVATION_ID", "meta": { "lastUpdated": "2020-01-01T00:00:00+00:00", "versionId": "VERSION_ID" }, "resourceType": "Observation", "identifier": [ { "system": "my-code-system", "value": "ABC-12345" } ], "status": "final", "subject": { "reference": "Patient/PATIENT_ID" }, "valueQuantity": { "unit": "bpm", "value": BPM_VALUE } }
Go
Python
Patching a FHIR resource
The following samples show how to call the
projects.locations.datasets.fhirStores.fhir.patch
method to patch a FHIR resource. The method implements the FHIR standard patch
interaction
(DSTU2,
STU3,
and R4).
When you patch a resource, you update part of the resource by applying the operations specified in a JSON Patch document.
The request must contain a JSON patch document, and the request headers must
contain Content-Type: application/json-patch+json
.
The following curl
and Windows PowerShell samples work with R4 FHIR stores. The Go, Java, Node.js, and Python samples work with STU3 FHIR stores.
curl
To patch a FHIR resource, make a PATCH
request and specify the following
information:
- The name of the parent dataset
- The name of the FHIR store
- The type of resource
- The resource ID
- An access token
The following sample shows how to send a PATCH
request using curl
to edit an
Observation resource. The Observation of a patient's heartbeats per minute (BPM)
is updated using the replace
patch operation.
curl -X PATCH \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ -H "Content-Type: application/json-patch+json" \ --data '[ { "op": "replace", "path": "/valueQuantity/value", "value": BPM_VALUE } ]' \ "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Observation/OBSERVATION_ID"
If the request is successful, the server returns a response similar to the following sample in JSON format:
{ "effectiveDateTime": "2020-01-01T00:00:00+00:00", "id": "OBSERVATION_ID", "meta": { "lastUpdated": "2020-01-01T00:00:00+00:00", "versionId": "VERSION_ID" }, "resourceType": "Observation", "status": "final", "subject": { "reference": "Patient/PATIENT_ID" }, "valueQuantity": { "unit": "bpm", "value": BPM_VALUE } }
PowerShell
To patch a FHIR resource, make a PATCH
request and specify the following information:
- The name of the parent dataset
- The name of the FHIR store
- The type of resource
- The resource ID
- An access token
The following sample shows how
to send a PATCH
request using Windows PowerShell to edit an Observation
resource. The Observation of a patient's heartbeats per minute (BPM) is
updated using the replace
patch operation.
$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } $patch = '[ { "op": "replace", "path": "/valueQuantity/value", "value": BPM_VALUE } ]' Invoke-RestMethod ` -Method Patch ` -Headers $headers ` -ContentType: "application/json-patch+json" ` -Body $patch ` -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Observation/OBSERVATION_ID" | ConvertTo-Json
If the request is successful, the server returns a response similar to the following sample in JSON format:
{ "effectiveDateTime": "2020-01-01T00:00:00+00:00", "id": "OBSERVATION_ID", "meta": { "lastUpdated": "2020-01-01T00:00:00+00:00", "versionId": "VERSION_ID" }, "resourceType": "Observation", "status": "final", "subject": { "reference": "Patient/PATIENT_ID" }, "valueQuantity": { "unit": "bpm", "value": BPM_VALUE } }
Go
Java
Node.js
Python
Conditionally patching a FHIR resource
The following samples show how to call the
projects.locations.datasets.fhirStores.fhir.conditionalPatch
method to patch a FHIR resource that matches a search query, rather than
identifying the resource by its ID. The method implements the FHIR standard
conditional patch interaction
(DSTU2,
STU3,
and R4).
A conditional patch can be applied to only one resource at
a time. If the search criteria identify more than one match, the request
returns a 412 Precondition Failed
error.
The following curl
and Windows PowerShell samples work with R4 FHIR stores. The Go and Python samples work with STU3 FHIR stores.
curl
To patch a FHIR resource that matches a search query, make a PATCH
request
and specify the following information:
- The name of the parent dataset
- The name of the FHIR store
- The type of resource you're searching for
- A query string containing the information you're searching for
- An access token
The following sample shows how to send a PATCH
request using curl
to edit an Observation if the identifier of the Observation is
ABC-12345
in my-code-system
.
The Observation of a patient's heartbeats per minute (BPM) is
updated using the replace
patch operation.
curl -X PATCH \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ -H "Content-Type: application/json-patch+json" \ --data '[ { "op": "replace", "path": "/valueQuantity/value", "value": BPM_VALUE } ]' \ "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Observation?identifier=my-code-system|ABC-12345"
If the request is successful, the server returns a response similar to the following sample in JSON format:
{ "effectiveDateTime": "2020-01-01T00:00:00+00:00", "id": "OBSERVATION_ID", "meta": { "lastUpdated": "2020-01-01T00:00:00+00:00", "versionId": "VERSION_ID" }, "resourceType": "Observation", "status": "final", "subject": { "reference": "Patient/PATIENT_ID" }, "valueQuantity": { "unit": "bpm", "value": BPM_VALUE } }
PowerShell
To patch a FHIR resource that matches a search query, make a PATCH
request
and specify the following information:
- The name of the parent dataset
- The name of the FHIR store
- The type of resource you're searching for
- A query string containing the information you're searching for
- An access token
The following sample shows how to send a PATCH
request using Windows PowerShell
to edit an Observation if the identifier of the Observation is
ABC-12345
in my-code-system
.
The Observation of a patient's heartbeats per minute (BPM) is
updated using the replace
patch operation.
$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } $patch = '[ { "op": "replace", "path": "/valueQuantity/value", "value": BPM_VALUE } ]' Invoke-RestMethod ` -Method Patch ` -Headers $headers ` -ContentType: "application/json-patch+json" ` -Body $patch ` -Uri "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Observation?identifier=my-code-system|ABC-12345" | ConvertTo-Json
If the request is successful, the server returns a response similar to the following sample in JSON format:
{ "effectiveDateTime": "2020-01-01T00:00:00+00:00", "id": "OBSERVATION_ID", "meta": { "lastUpdated": "2020-01-01T00:00:00+00:00", "versionId": "VERSION_ID" }, "resourceType": "Observation", "status": "final", "subject": { "reference": "Patient/PATIENT_ID" }, "valueQuantity": { "unit": "bpm", "value": BPM_VALUE } }
Go
Python
Getting a FHIR resource
The following samples show how to get the contents of a FHIR resource. For more
information, see
projects.locations.datasets.fhirStores.fhir.read
.
Console
To get the contents of a FHIR resource, follow these steps:
In the Cloud Console, go to the FHIR viewer page.
In the FHIR Store drop-down list, select a dataset, and then select a FHIR store in the dataset.
To filter the list of resource types, search for the resource types that you want to display:
Click the Resource Type field.
In the Properties drop-down list that appears, select Resource Type.
Enter a resource type.
To search for another resource type, select OR from the Operators drop-down list that appears, and then enter another resource type.
In the list of resource types, select the resource type for the resource that you want to get the contents of.
In the table of resources that appears, select or search for a resource.
API
The following curl
and Windows PowerShell samples work with R4 FHIR stores. The Go, Java, Node.js, and Python samples work with STU3 FHIR stores.
curl
To get the contents of a FHIR resource, make a GET
request and specify the
following information:
- The name of the parent dataset
- The name of the FHIR store
- The resource type and ID
- An access token
The following sample shows a GET
request using curl
on the Observation
created in the previous section.
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/Observation/RESOURCE_ID"
If the request is successful, the server returns a response similar to the following sample in JSON format:
{ "encounter": { "reference": "Encounter/ENCOUNTER_ID" }, "effectiveDateTime": "2020-01-01T00:00:00+00:00", "id": "OBSERVATION_ID", "meta": { "lastUpdated": "2020-01-01T00:00:00+00:00", "versionId": "VERSION_ID" }, "resourceType": "Observation", "status": "final", "subject": { "reference": "Patient/PATIENT_ID" }, "valueQuantity": { "unit": "bpm", "value": BPM_VALUE } }
PowerShell
To get the contents of a FHIR resource, make a GET
request and specify the
following information:
- The name of the parent dataset
- The name of the FHIR store
- The resource type and ID
- An access token
The following sample shows a GET
request using Windows PowerShell on the
Observation created in the previous section.
$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/Observation/RESOURCE_ID" | ConvertTo-Json
If the request is successful, the server returns a response similar to the following sample in JSON format:
{ "encounter": { "reference": "Encounter/ENCOUNTER_ID" }, "effectiveDateTime": "2020-01-01T00:00:00+00:00", "id": "OBSERVATION_ID", "meta": { "lastUpdated": "2020-01-01T00:00:00+00:00", "versionId": "VERSION_ID" }, "resourceType": "Observation", "status": "final", "subject": { "reference": "Patient/PATIENT_ID" }, "valueQuantity": { "unit": "bpm", "value": BPM_VALUE } }
Go
Java
Node.js
Python
Getting all patient compartment resources
The following samples show how to get all resources associated with a
particular patient compartment
(DSTU2,
STU3,
and R4).
For more information, see
projects.locations.datasets.fhirStores.fhir.Patient-everything
.
The following curl
and Windows PowerShell samples work with R4 FHIR stores. The Go, Java, Node.js, and Python samples work with STU3 FHIR stores.
curl
To get the resources in a patient compartment, make a GET
request and
specify the following information:
- The name of the parent dataset
- The name of the FHIR store
- The patient's ID
- An access token
The following sample shows a GET
request using 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/PATIENT_ID/\$everything"
If the request is successful, the server returns a response similar to the following sample in JSON format:
{ "entry": [ { "resource": { "birthDate": "1970-01-01", "gender": "female", "id": "PATIENT_ID", "name": [ { "family": "Smith", "given": [ "Darcy" ], "use": "official" } ], "resourceType": "Patient" } }, { "resource": { "class": { "code": "IMP", "display": "inpatient encounter", "system": "http://hl7.org/fhir/v3/ActCode" }, "id": "ENCOUNTER_ID", "reasonCode": [ { "text": "The patient had an abnormal heart rate. She was concerned about this." } ], "resourceType": "Encounter", "status": "finished", "subject": { "reference": "Patient/PATIENT_ID" } } }, { "resource": { "encounter": { "reference": "Encounter/ENCOUNTER_ID" }, "effectiveDateTime": "2020-01-01T00:00:00+00:00", "id": "OBSERVATION_ID", "resourceType": "Observation", "status": "final", "subject": { "reference": "Patient/PATIENT_ID" }, "valueQuantity": { "unit": "bpm", "value": BPM_VALUE } } } ], "resourceType": "Bundle", "type": "searchset" }
PowerShell
To get the resources in a patient compartment, make a GET
request and
specify the following information:
- The name of the parent dataset
- The name of the FHIR store
- The patient's ID
- An access token
The following sample shows a GET
request using Windows 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/Patient/RESOURCE_ID/$everything' | ConvertTo-Json
If the request is successful, the server returns a response similar to the following sample in JSON format:
{ "entry": [ { "resource": { "birthDate": "1970-01-01", "gender": "female", "id": "PATIENT_ID", "name": [ { "family": "Smith", "given": [ "Darcy" ], "use": "official" } ], "resourceType": "Patient" } }, { "resource": { "class": { "code": "IMP", "display": "inpatient encounter", "system": "http://hl7.org/fhir/v3/ActCode" }, "id": "ENCOUNTER_ID", "reasonCode": [ { "text": "The patient had an abnormal heart rate. She was concerned about this." } ], "resourceType": "Encounter", "status": "finished", "subject": { "reference": "Patient/PATIENT_ID" } } }, { "resource": { "encounter": { "reference": "Encounter/ENCOUNTER_ID" }, "effectiveDateTime": "2020-01-01T00:00:00+00:00", "id": "OBSERVATION_ID", "resourceType": "Observation", "status": "final", "subject": { "reference": "Patient/PATIENT_ID" }, "valueQuantity": { "unit": "bpm", "value": BPM_VALUE } } } ], "resourceType": "Bundle", "type": "searchset" }
Go
Java
Node.js
Python
Getting patient compartment resources filtered by type or date
The following samples show how to get all resources associated with a
particular
patient compartment (R4)
filtered by a list of types and since a specified date and time.
For more information, see
projects.locations.datasets.fhirStores.fhir.Patient-everything
.
The following curl
and Windows PowerShell samples work with R4 FHIR stores.
curl
To get the resources in a patient compartment of a specified type and since
a specified date, make a GET
request and specify the following information:
- The name of the parent dataset
- The name of the FHIR store
- The patient's ID
- A query string containing a comma-separated resource type list and starting date
- An access token
The following sample shows a GET
request using 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/PATIENT_ID/\$everything?_type=RESOURCE_TYPES&_since=DATE"
If the request is successful, the server returns any resources that match the specified criteria in JSON format.
PowerShell
To get the resources in a patient compartment of a specified type and since
a specified date, make a GET
request and specify the following information:
- The name of the parent dataset
- The name of the FHIR store
- The patient's ID
- A query string containing a comma-separated resource type list and starting date
- An access token
The following sample shows a GET
request using Windows 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/Patient/RESOURCE_ID/$everything?_type=RESOURCE_TYPES&_since=DATE' | ConvertTo-Json
If the request is successful, the server returns any resources that match the specified criteria in JSON format.
Listing FHIR resource versions
The following samples show how to list all historical versions of a FHIR
resource. For more information, see
projects.locations.datasets.fhirStores.fhir.history
.
The samples use the resources created in Creating a FHIR resource and show how to list the versions of an Observation resource.
The following curl
and Windows PowerShell samples work with R4 FHIR stores. The Go, Java, Node.js, and Python samples work with STU3 FHIR stores.
curl
The following sample shows how to list all versions of an Observation resource. The Observation has been updated one time after its original creation to change the patient's heartbeats per minute (BPM).
To list all versions of a FHIR resource, including the current version and any
deleted versions, make a GET
request and specify the following information:
- The name of the parent dataset
- The name of the FHIR store
- The resource type and ID
- An access token
The following sample shows a GET
request using 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/RESOURCE_TYPE/RESOURCE_ID/_history"
If the request is successful, the server returns the response in JSON format. In this example, it returns two versions of the Observation. In the first version, the patient's heart rate was 75 BPM. In the second version, the patient's heart rate was 85 BPM.
{ "entry": [ { "resource": { "effectiveDateTime": "2020-01-01T00:00:00+00:00", "id": "OBSERVATION_ID", "meta": { "lastUpdated": "2020-01-02T00:00:00+00:00", "versionId": "MTU0MTE5MDk5Mzk2ODcyODAwMA" }, "resourceType": "Observation", "status": "final", "subject": { "reference": "Patient/PATIENT_ID" }, "valueQuantity": { "unit": "bpm", "value": 85 } } }, { "resource": { "encounter": { "reference": "Encounter/ENCOUNTER_ID" }, "effectiveDateTime": "2020-01-01T00:00:00+00:00", "id": "OBSERVATION_ID", "meta": { "lastUpdated": "2020-01-01T00:00:00+00:00", "versionId": "MTU0MTE5MDg4MTY0MzQ3MjAwMA" }, "resourceType": "Observation", "status": "final", "subject": { "reference": "Patient/PATIENT_ID" }, "valueQuantity": { "unit": "bpm", "value": 75 } } } ], "resourceType": "Bundle", "type": "history" }
PowerShell
The following sample shows how to list all versions of an Observation resource. The Observation has been updated one time after its original creation to change the patient's heartbeats per minute (BPM).
To list all versions of a FHIR resource, including the current version and any
deleted versions, make a GET
request and specify the following information:
- The name of the parent dataset
- The name of the FHIR store
- The resource type and ID
- An access token
The following sample shows a GET
request using Windows 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/RESOURCE_ID/_history" | Select-Object -Expand Content
If the request is successful, the server returns the response in JSON format. In this example, it returns two versions of the Observation. In the first version, the patient's heart rate was 75 BPM. In the second version, the patient's heart rate was 85 BPM.
{ "entry": [ { "resource": { "effectiveDateTime": "2020-01-01T00:00:00+00:00", "id": "OBSERVATION_ID", "meta": { "lastUpdated": "2020-01-02T00:00:00+00:00", "versionId": "MTU0MTE5MDk5Mzk2ODcyODAwMA" }, "resourceType": "Observation", "status": "final", "subject": { "reference": "Patient/PATIENT_ID" }, "valueQuantity": { "unit": "bpm", "value": 85 } } }, { "resource": { "encounter": { "reference": "Encounter/ENCOUNTER_ID" }, "effectiveDateTime": "2020-01-01T00:00:00+00:00", "id": "OBSERVATION_ID", "meta": { "lastUpdated": "2020-01-01T00:00:00+00:00", "versionId": "MTU0MTE5MDg4MTY0MzQ3MjAwMA" }, "resourceType": "Observation", "status": "final", "subject": { "reference": "Patient/PATIENT_ID" }, "valueQuantity": { "unit": "bpm", "value": 75 } } } ], "resourceType": "Bundle", "type": "history" }
Go
Java
Node.js
Python
Retrieving a FHIR resource version
The following samples show how to retrieve a specific version of a resource.
For more information, see
projects.locations.datasets.fhirStores.fhir.vread
.
The version IDs for the Observation resource from Listing FHIR resource versions are highlighted below:
{ "entry": [ { "resource": { "effectiveDateTime": "2020-01-01T00:00:00+00:00", "id": "OBSERVATION_ID", "meta": { "lastUpdated": "2020-01-02T00:00:00+00:00", "versionId": "MTU0MTE5MDk5Mzk2ODcyODAwMA" }, ... { "resource": { "encounter": { "reference": "Encounter/ENCOUNTER_ID" }, "effectiveDateTime": "2020-01-01T00:00:00+00:00", "id": "OBSERVATION_ID", "meta": { "lastUpdated": "2020-01-01T00:00:00+00:00", "versionId": "MTU0MTE5MDg4MTY0MzQ3MjAwMA" }, ... }
The following samples use the resources created in Creating a FHIR resource and show how to view an Observation resource.
The following curl
and Windows PowerShell samples work with R4 FHIR stores. The Go, Node.js, and Python samples work with STU3 FHIR stores.
curl
To get a specific version of a FHIR resource, make a GET
request and
specify the following information:
- The name of the parent dataset
- The name of the FHIR store
- The resource type and ID
- The resource version
- An access token
The following sample shows a GET
request using 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/RESOURCE_TYPE/RESOURCE_ID/_history/RESOURCE_VERSION"
If the request is successful, the server returns the response in JSON format. In this example, the first version of the Observation, where the patient's heart rate was 75 BPM, is returned.
{ "encounter": { "reference": "Encounter/ENCOUNTER_ID" }, "effectiveDateTime": "2020-01-01T00:00:00+00:00", "id": "OBSERVATION_ID", "meta": { "lastUpdated": "2020-01-01T00:00:00+00:00", "versionId": "MTU0MTE5MDg4MTY0MzQ3MjAwMA" }, "resourceType": "Observation", "status": "final", "subject": { "reference": "Patient/PATIENT_ID" }, "valueQuantity": { "unit": "bpm", "value": 75 } }
PowerShell
To get a specific version of a FHIR resource, make a GET
request and
specify the following information:
- The name of the parent dataset
- The name of the FHIR store
- The resource type and ID
- The resource version
- An access token
The following sample shows a GET
request using curl
.
$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/RESOURCE_ID/RESOURCE_VERSION/_history" | Select-Object -Expand Content
If the request is successful, the server returns the response in JSON format. In this example, the first version of the Observation, where the patient's heart rate was 75 BPM, is returned.
{ "encounter": { "reference": "Encounter/ENCOUNTER_ID" }, "effectiveDateTime": "2020-01-01T00:00:00+00:00", "id": "OBSERVATION_ID", "meta": { "lastUpdated": "2020-01-01T00:00:00+00:00", "versionId": "MTU0MTE5MDg4MTY0MzQ3MjAwMA" }, "resourceType": "Observation", "status": "final", "subject": { "reference": "Patient/PATIENT_ID" }, "valueQuantity": { "unit": "bpm", "value": 75 } }
Go
Node.js
Python
Deleting a FHIR resource
The following samples show how to call the
projects.locations.datasets.fhirStores.fhir.delete
method to delete a FHIR resource.
Regardless of whether the operation succeeds or fails, the server returns a
200 OK
HTTP status code. To check that the resource was successfully
deleted, search for or get
the resource and see if it exists.
The following curl
and Windows PowerShell samples work with R4 FHIR stores. The Go, Java, Node.js, and Python samples work with STU3 FHIR stores.
curl
To delete a FHIR resource, make a DELETE
request and specify the following
information:
- The name of the parent dataset
- The name of the FHIR store
- An access token
The following sample shows a DELETE
request using 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/fhirStores/FHIR_STORE_ID/fhir/RESOURCE_TYPE/RESOURCE_ID"
If the request is successful, the server returns the empty response body in JSON format:
{}
PowerShell
To delete a FHIR resource, make a DELETE
request and specify the following
information:
- The name of the parent dataset
- The name of the FHIR store
- The resource type and ID
- An access token
The following sample shows a DELETE
request using Windows 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/fhirStores/FHIR_STORE_ID/fhir/RESOURCE_TYPE/RESOURCE_ID" | Select-Object -Expand Content
If the request is successful, the server returns the empty response body in JSON format:
{}
Go
Java
Node.js
Python
Conditionally deleting a FHIR resource
The following samples show how to call the
projects.locations.datasets.fhirStores.fhir.conditionalDelete
method to delete a FHIR resource that matches a search query, rather than identifying the resource by its ID.
Unlike conditionally patching or conditionally updating a resource, the conditional delete method can apply to multiple resources if multiple matches are returned from the search criteria.
Regardless of whether the operation succeeds or fails, the server returns a
200 OK
HTTP status code. To make sure that the resource was successfully
deleted, search for or get
the resource and see if it exists.
The following curl
and Windows PowerShell samples work with R4 FHIR stores. The Go and Python samples work with STU3 FHIR stores.
curl
To delete FHIR resources that match a search query, make a DELETE
request
and specify the following information:
- The name of the parent dataset
- The name of the FHIR store
- The type of resource you're searching for
- A query string containing the information you're searching for
- An access token
The following sample shows a DELETE
request using curl
to delete all
Observations with a status
of cancelled
(STU3
and R4).
curl -X DELETE \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Observation?status=cancelled"
If the request is successful, the server returns the empty response body in JSON format:
{}
PowerShell
To delete FHIR resources that match a search query, make a DELETE
request
and specify the following information:
- The name of the parent dataset
- The name of the FHIR store
- The type of resource you're searching for
- A query string containing the information you're searching for
- An access token
The following sample shows a DELETE
request using Windows PowerShell
to delete all Observations with a status
of cancelled
(STU3
and R4).
$cred = gcloud auth application-default 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/fhirStores/FHIR_STORE_ID/fhir/Observation?status=cancelled" | Select-Object -Expand Content
If the request is successful, the server returns the empty response body in JSON format:
{}
Go
Python
Deleting historical versions of a FHIR resource
The following samples show how to delete all historical versions of a FHIR
resource. For more information, see
projects.locations.datasets.fhirStores.fhir.Resource-purge
.
Calling the projects.locations.datasets.fhirStores.fhir.Resource-purge
method is limited to users (callers) with the
roles/healthcare.fhirStoreAdmin
role; users with the roles/healthcare.fhirResourceEditor
role cannot
call the method. To permit a caller to delete historical versions of a FHIR
resource, either:
- Make sure that the caller has the
roles/healthcare.fhirStoreAdmin
role. - Create a custom IAM role
with the
healthcare.fhirResources.purge
permission and assign the role to the caller.
The samples use the resources created in Creating a FHIR resource and show how to delete the historical versions of an Observation resource.
The following curl
and Windows PowerShell samples work with R4 FHIR stores. The Go, Java, Node.js, and Python samples work with STU3 FHIR stores.
curl
To delete all historical versions of a FHIR resource, make a DELETE
request
and specify the following information:
- The name of the parent dataset
- The name of the FHIR store
- The resource type and ID
- An access token
The following sample shows a DELETE
request using curl
.
curl -X DELETE \ -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \ -H "Content-Type: application/fhir+json; charset=utf-8" \ "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/RESOURCE_TYPE/RESOURCE_ID/$purge"
If the request is successful, the server returns the empty response body in JSON format:
{}
PowerShell
To delete all historical versions of a FHIR resource, make a DELETE
request
and specify the following information:
- The name of the parent dataset
- The name of the FHIR store
- The resource type and ID
- An access token
The following sample shows a DELETE
request using Windows PowerShell.
$cred = gcloud auth application-default print-access-token $headers = @{ Authorization = "Bearer $cred" } Invoke-RestMethod ` -Method Delete ` -Headers $headers ` -ContentType: "application/fhir+json; charset=utf-8" ` -Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/RESOURCE_TYPE/RESOURCE_ID/$purge" | ConvertTo-Json
If the request is successful, the server returns the empty response body in JSON format:
{}