This page explains how to create, update, patch, view, list, retrieve, 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 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
, 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 PowerShell samples work with R4 FHIR stores. The Go, Java, Node.js, and Python samples work with STU3 FHIR stores.
REST
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 FHIR store's parent dataset
- FHIR_STORE_ID: the FHIR store ID
Request JSON body:
{ "name": [ { "use": "official", "family": "Smith", "given": [ "Darcy" ] } ], "gender": "female", "birthDate": "1970-01-01", "resourceType": "Patient" }
To send your request, choose one of these options:
curl
Save the request body in a file called request.json
.
Run the following command in the terminal to create or overwrite
this file in the current directory:
cat > request.json << 'EOF' { "name": [ { "use": "official", "family": "Smith", "given": [ "Darcy" ] } ], "gender": "female", "birthDate": "1970-01-01", "resourceType": "Patient" } EOF
Then execute the following command to send your REST request:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/fhir+json" \
-d @request.json \
"https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient"
PowerShell
Save the request body in a file called request.json
.
Run the following command in the terminal to create or overwrite
this file in the current directory:
@' { "name": [ { "use": "official", "family": "Smith", "given": [ "Darcy" ] } ], "gender": "female", "birthDate": "1970-01-01", "resourceType": "Patient" } '@ | 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 POST `
-Headers $headers `
-ContentType: "application/fhir+json" `
-InFile request.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
You should receive a JSON response similar to the following:
Go
Java
Node.js
Python
After creating the Patient resource, create an Encounter resource to describe an interaction between the patient and a practitioner.
In the PATIENT_ID field, substitute the ID from the response returned by the server when you created the Patient resource.
The following curl
and PowerShell samples work with R4 FHIR stores. The Python sample works with STU3 FHIR stores.
REST
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 FHIR store's parent dataset
- FHIR_STORE_ID: the FHIR store ID
- PATIENT_ID: the response returned by the server when you created the Patient resource
Request JSON body:
{ "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" }
To send your request, choose one of these options:
curl
Save the request body in a file called request.json
.
Run the following command in the terminal to create or overwrite
this file in the current directory:
cat > request.json << 'EOF' { "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" } EOF
Then execute the following command to send your REST request:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/fhir+json" \
-d @request.json \
"https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Encounter"
PowerShell
Save the request body in a file called request.json
.
Run the following command in the terminal to create or overwrite
this file in the current directory:
@' { "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" } '@ | 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 POST `
-Headers $headers `
-ContentType: "application/fhir+json" `
-InFile request.json `
-Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Encounter" | Select-Object -Expand Content
You should receive a JSON response similar to the following:
Python
After creating the Encounter resource, create an Observation resource associated with the Encounter resource. The Observation resource provides a measurement of the patient's heart rate in beats per minute (BPM) (80
in bpm
).
The following curl
and PowerShell samples work with R4 FHIR stores. The Python sample works with STU3 FHIR stores.
REST
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 FHIR store's parent dataset
- FHIR_STORE_ID: the FHIR store ID
- PATIENT_ID: the ID in the response returned by the server when you created the Patient resource
- ENCOUNTER_ID: the ID in the response returned by the server when you created the Encounter resource
Request JSON body:
{ "resourceType": "Observation", "status": "final", "subject": { "reference": "Patient/PATIENT_ID" }, "effectiveDateTime": "2020-01-01T00:00:00+00:00", "identifier": [ { "system": "my-code-system", "value": "ABC-12345" } ], "code": { "coding": [ { "system": "http://loinc.org", "code": "8867-4", "display": "Heart rate" } ] }, "valueQuantity": { "value": 80, "unit": "bpm" }, "encounter": { "reference": "Encounter/ENCOUNTER_ID" } }
To send your request, choose one of these options:
curl
Save the request body in a file called request.json
.
Run the following command in the terminal to create or overwrite
this file in the current directory:
cat > request.json << 'EOF' { "resourceType": "Observation", "status": "final", "subject": { "reference": "Patient/PATIENT_ID" }, "effectiveDateTime": "2020-01-01T00:00:00+00:00", "identifier": [ { "system": "my-code-system", "value": "ABC-12345" } ], "code": { "coding": [ { "system": "http://loinc.org", "code": "8867-4", "display": "Heart rate" } ] }, "valueQuantity": { "value": 80, "unit": "bpm" }, "encounter": { "reference": "Encounter/ENCOUNTER_ID" } } EOF
Then execute the following command to send your REST request:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/fhir+json" \
-d @request.json \
"https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Observation"
PowerShell
Save the request body in a file called request.json
.
Run the following command in the terminal to create or overwrite
this file in the current directory:
@' { "resourceType": "Observation", "status": "final", "subject": { "reference": "Patient/PATIENT_ID" }, "effectiveDateTime": "2020-01-01T00:00:00+00:00", "identifier": [ { "system": "my-code-system", "value": "ABC-12345" } ], "code": { "coding": [ { "system": "http://loinc.org", "code": "8867-4", "display": "Heart rate" } ] }, "valueQuantity": { "value": 80, "unit": "bpm" }, "encounter": { "reference": "Encounter/ENCOUNTER_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 POST `
-Headers $headers `
-ContentType: "application/fhir+json" `
-InFile request.json `
-Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Observation" | Select-Object -Expand Content
You should receive a JSON response similar to the following:
Python
Updating a FHIR resource
The following samples show how to use 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 PowerShell samples work with R4 FHIR stores. The Go, Java, Node.js, and Python samples work with STU3 FHIR stores.
REST
The following samples show how to update the beats per minute (BPM) in an Observation resource.
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 FHIR store's parent dataset
- FHIR_STORE_ID: the FHIR store ID
- OBSERVATION_ID: the Observation resource ID
- PATIENT_ID: the Patient resource ID
- ENCOUNTER_ID: the Encounter resource ID
- BPM_VALUE: the beats per minute (BPM) value in the updated Observation resource
Request JSON body:
{ "resourceType": "Observation", "id": "OBSERVATION_ID", "status": "final", "subject": { "reference": "Patient/PATIENT_ID" }, "effectiveDateTime": "2020-01-01T00:00:00+00:00", "identifier": [ { "system": "my-code-system", "value": "ABC-12345" } ], "code": { "coding": [ { "system": "http://loinc.org", "code": "8867-4", "display": "Heart rate" } ] }, "valueQuantity": { "value": BPM_VALUE, "unit": "bpm" }, "encounter": { "reference": "Encounter/ENCOUNTER_ID" } }
To send your request, choose one of these options:
curl
Save the request body in a file called request.json
.
Run the following command in the terminal to create or overwrite
this file in the current directory:
cat > request.json << 'EOF' { "resourceType": "Observation", "id": "OBSERVATION_ID", "status": "final", "subject": { "reference": "Patient/PATIENT_ID" }, "effectiveDateTime": "2020-01-01T00:00:00+00:00", "identifier": [ { "system": "my-code-system", "value": "ABC-12345" } ], "code": { "coding": [ { "system": "http://loinc.org", "code": "8867-4", "display": "Heart rate" } ] }, "valueQuantity": { "value": BPM_VALUE, "unit": "bpm" }, "encounter": { "reference": "Encounter/ENCOUNTER_ID" } } EOF
Then execute the following command to send your REST request:
curl -X PUT \
-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/fhirStores/FHIR_STORE_ID/fhir/Observation/OBSERVATION_ID"
PowerShell
Save the request body in a file called request.json
.
Run the following command in the terminal to create or overwrite
this file in the current directory:
@' { "resourceType": "Observation", "id": "OBSERVATION_ID", "status": "final", "subject": { "reference": "Patient/PATIENT_ID" }, "effectiveDateTime": "2020-01-01T00:00:00+00:00", "identifier": [ { "system": "my-code-system", "value": "ABC-12345" } ], "code": { "coding": [ { "system": "http://loinc.org", "code": "8867-4", "display": "Heart rate" } ] }, "valueQuantity": { "value": BPM_VALUE, "unit": "bpm" }, "encounter": { "reference": "Encounter/ENCOUNTER_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 PUT `
-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/fhirStores/FHIR_STORE_ID/fhir/Observation/OBSERVATION_ID" | Select-Object -Expand Content
API Explorer
Copy the request body and open the method reference page. The API 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 click Execute.
You should receive a JSON response similar to the following:
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 PowerShell samples work with R4 FHIR stores. The Go and Python samples work with STU3 FHIR stores.
REST
The following sample shows how to send a PUT
request using curl
and
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).
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 FHIR store's parent dataset
- FHIR_STORE_ID: the FHIR store ID
- PATIENT_ID: the ID in the response returned by the server when you created the Patient resource
- BPM_VALUE: the beats per minute (BPM) value in the Observation resource
Request JSON body:
{ "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 } }
To send your request, choose one of these options:
curl
Save the request body in a file called request.json
.
Run the following command in the terminal to create or overwrite
this file in the current directory:
cat > request.json << 'EOF' { "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 } } EOF
Then execute the following command to send your REST request:
curl -X PUT \
-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/fhirStores/FHIR_STORE_ID/fhir/Observation?identifier=my-code-system|ABC-12345"
PowerShell
Save the request body in a file called request.json
.
Run the following command in the terminal to create or overwrite
this file in the current directory:
@' { "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 } } '@ | 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 PUT `
-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/fhirStores/FHIR_STORE_ID/fhir/Observation?identifier=my-code-system|ABC-12345" | Select-Object -Expand Content
API Explorer
Copy the request body and open the method reference page. The API 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 click Execute.
You should receive a JSON response similar to the following:
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 samples show how
to patch an Observation resource. The Observation of a patient's heartbeats per
minute (BPM) is updated using the replace
patch operation.
The following curl
and PowerShell samples work with R4 FHIR stores. The Go, Java, Node.js, and Python samples work with STU3 FHIR stores.
REST
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 FHIR store's parent dataset
- FHIR_STORE_ID: the FHIR store ID
- OBSERVATION_ID: the Observation resource ID
- BPM_VALUE: the beats per minute (BPM) value in the patched Observation resource
Request JSON body:
[ { "op": "replace", "path": "/valueQuantity/value", "value": BPM_VALUE } ]
To send your request, choose one of these options:
curl
Save the request body in a file called request.json
.
Run the following command in the terminal to create or overwrite
this file in the current directory:
cat > request.json << 'EOF' [ { "op": "replace", "path": "/valueQuantity/value", "value": BPM_VALUE } ] 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-patch+json" \
-d @request.json \
"https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Observation/OBSERVATION_ID"
PowerShell
Save the request body in a file called request.json
.
Run the following command in the terminal to create or overwrite
this file in the current directory:
@' [ { "op": "replace", "path": "/valueQuantity/value", "value": BPM_VALUE } ] '@ | 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-patch+json" `
-InFile request.json `
-Uri "https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Observation/OBSERVATION_ID" | Select-Object -Expand Content
You should receive a JSON response similar to the following:
Go
Java
Node.js
Python
Executing a PATCH
request in a FHIR bundle
You can a specify a PATCH
request in a FHIR bundle (FHIR R4 only).
Executing PATCH
request in a FHIR bundle allows you to patch many
FHIR resources at once, rather than having to make individual patch requests
for each FHIR resource.
To make a PATCH
request in a bundle, specify the following information in
a resource
object in the request:
- A
resourceType
field set toBinary
- A
contentType
field set toapplication/json-patch+json
- The patch body encoded in base64
Ensure that the resource
object looks like the following:
"resource": {
"resourceType": "Binary",
"contentType": "application/json-patch+json",
"data": "WyB7ICJvcCI6ICJyZXBsYWNlIiwgInBhdGgiOiAiL2JpcnRoRGF0ZSIsICJ2YWx1ZSI6ICIxOTkwLTAxLTAxIiB9IF0K"
}
The following shows the patch body that was encoded to base64 in the data
field:
[
{
"op": "replace",
"path": "/birthdate",
"value": "1990-01-01"
}
]
The following samples show how to use a PATCH
request in a bundle to patch
the Patient resource you created in
Creating a FHIR resource to have a birthDate
value of 1990-01-01
:
Before using any of the request data, make the following replacements:
- PROJECT_ID: your Google Cloud project ID
- LOCATION: the location of the parent dataset
- DATASET_ID: the FHIR store's parent dataset
- FHIR_STORE_ID: the FHIR store ID
- PATIENT_ID: the ID of an existing Patient resource
Request JSON body:
{ "type": "transaction", "resourceType": "Bundle", "entry": [ { "request": { "method": "PATCH", "url": "Patient/PATIENT_ID" }, "resource": { "resourceType": "Binary", "contentType": "application/json-patch+json", "data": "WyB7ICJvcCI6ICJyZXBsYWNlIiwgInBhdGgiOiAiL2JpcnRoRGF0ZSIsICJ2YWx1ZSI6ICIxOTkwLTAxLTAxIiB9IF0K" } } ] }
To send your request, choose one of these options:
curl
Save the request body in a file called request.json
.
Run the following command in the terminal to create or overwrite
this file in the current directory:
cat > request.json << 'EOF' { "type": "transaction", "resourceType": "Bundle", "entry": [ { "request": { "method": "PATCH", "url": "Patient/PATIENT_ID" }, "resource": { "resourceType": "Binary", "contentType": "application/json-patch+json", "data": "WyB7ICJvcCI6ICJyZXBsYWNlIiwgInBhdGgiOiAiL2JpcnRoRGF0ZSIsICJ2YWx1ZSI6ICIxOTkwLTAxLTAxIiB9IF0K" } } ] } EOF
Then execute the following command to send your REST request:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/fhir+json" \
-d @request.json \
"https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir"
PowerShell
Save the request body in a file called request.json
.
Run the following command in the terminal to create or overwrite
this file in the current directory:
@' { "type": "transaction", "resourceType": "Bundle", "entry": [ { "request": { "method": "PATCH", "url": "Patient/PATIENT_ID" }, "resource": { "resourceType": "Binary", "contentType": "application/json-patch+json", "data": "WyB7ICJvcCI6ICJyZXBsYWNlIiwgInBhdGgiOiAiL2JpcnRoRGF0ZSIsICJ2YWx1ZSI6ICIxOTkwLTAxLTAxIiB9IF0K" } } ] } '@ | 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 POST `
-Headers $headers `
-ContentType: "application/fhir+json" `
-InFile request.json `
-Uri "https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir" | Select-Object -Expand Content
You should receive a JSON response similar to the following:
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 PowerShell samples work with R4 FHIR stores. The Go and Python samples work with STU3 FHIR stores.
REST
The following sample shows how to send a PATCH
request using curl
and PowerShell
to edit an Observation resource if the identifier of the Observation resource is
ABC-12345 in my-code-system
.
The Observation of a patient's heartbeats per minute (BPM) is
updated using the replace
patch operation.
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 FHIR store's parent dataset
- FHIR_STORE_ID: the FHIR store ID
- BPM_VALUE: the beats per minute (BPM) value in the Observation resource
Request JSON body:
[ { "op": "replace", "path": "/valueQuantity/value", "value": BPM_VALUE } ]
To send your request, choose one of these options:
curl
Save the request body in a file called request.json
.
Run the following command in the terminal to create or overwrite
this file in the current directory:
cat > request.json << 'EOF' [ { "op": "replace", "path": "/valueQuantity/value", "value": BPM_VALUE } ] 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-patch+json" \
-d @request.json \
"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"
PowerShell
Save the request body in a file called request.json
.
Run the following command in the terminal to create or overwrite
this file in the current directory:
@' [ { "op": "replace", "path": "/valueQuantity/value", "value": BPM_VALUE } ] '@ | 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-patch+json" `
-InFile request.json `
-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" | Select-Object -Expand Content
API Explorer
Copy the request body and open the method reference page. The API 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 click Execute.
You should receive a JSON response similar to the following:
Go
Python
Getting a FHIR resource
The following samples show how to use the
projects.locations.datasets.fhirStores.fhir.read
method to get the contents of a FHIR resource.
The following curl
and PowerShell samples work with R4 FHIR stores.
The Go, Java, Node.js, and Python samples work with STU3 FHIR stores.
Console
To get the contents of a FHIR resource, follow these steps:
In the Google 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.
REST
The following samples show how to get the details of the Observation resource created in a previous section.
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 FHIR store's parent dataset
- FHIR_STORE_ID: the FHIR store ID
- OBSERVATION_ID: the Observation resource ID
To send your request, choose one of these options:
curl
Execute the following command:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Observation/OBSERVATION_ID"
PowerShell
Execute the following command:
$cred = gcloud auth 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/fhirStores/FHIR_STORE_ID/fhir/Observation/OBSERVATION_ID" | Select-Object -Expand Content
API Explorer
Open the method reference page. The API Explorer panel opens on the right side of the page. You can interact with this tool to send requests. Complete any required fields and click Execute.
You should receive a JSON response similar to the following:
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 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 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 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 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 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 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 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
Java
Node.js
Python
Deleting a FHIR resource
The following samples show how to call the
projects.locations.datasets.fhirStores.fhir.delete
method to delete an Observation 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 PowerShell samples work with R4 FHIR stores. The Go, Java, Node.js, and Python samples work with STU3 FHIR stores.
REST
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 FHIR store's parent dataset
- FHIR_STORE_ID: the FHIR store ID
- OBSERVATION_ID: the Observation resource ID
To send your request, choose one of these options:
curl
Execute the following command:
curl -X DELETE \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://healthcare.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Observation/OBSERVATION_ID"
PowerShell
Execute the following command:
$cred = gcloud auth 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/Observation/OBSERVATION_ID" | Select-Object -Expand Content
API Explorer
Open the method reference page. The API Explorer panel opens on the right side of the page. You can interact with this tool to send requests. Complete any required fields and click Execute.
You should receive a JSON response similar to the following:
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 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 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 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 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:
{}