@@ -223,7 +223,7 @@ def list_fhir_stores(project_id, location, dataset_id):
223223
224224
225225# [START healthcare_patch_fhir_store]
226- def patch_fhir_store (project_id , location , dataset_id , fhir_store_id ):
226+ def patch_fhir_store (project_id , location , dataset_id , fhir_store_id , pubsub_topic ):
227227 """Updates the FHIR store.
228228
229229 See https://github.com/GoogleCloudPlatform/python-docs-samples/tree/main/healthcare/api-client/v1/fhir
@@ -242,24 +242,28 @@ def patch_fhir_store(project_id, location, dataset_id, fhir_store_id):
242242 # location = 'us-central1' # replace with the dataset's location
243243 # dataset_id = 'my-dataset' # replace with your dataset ID
244244 # fhir_store_id = 'my-fhir-store' # replace with the FHIR store's ID
245+ # pubsub_topic = 'projects/{project_id}/topics/{topic_id}' # replace with your Pub/Sub topic
245246 fhir_store_parent = "projects/{}/locations/{}/datasets/{}" .format (
246247 project_id , location , dataset_id
247248 )
248249 fhir_store_name = f"{ fhir_store_parent } /fhirStores/{ fhir_store_id } "
249250
250- # TODO(developer): Replace with the full URI of an existing Pub/Sub topic
251- patch = {"notificationConfig" : None }
251+ patch = {
252+ "notificationConfigs" : [{"pubsubTopic" : pubsub_topic }] if pubsub_topic else []
253+ }
252254
253255 request = (
254256 client .projects ()
255257 .locations ()
256258 .datasets ()
257259 .fhirStores ()
258- .patch (name = fhir_store_name , updateMask = "notificationConfig " , body = patch )
260+ .patch (name = fhir_store_name , updateMask = "notificationConfigs " , body = patch )
259261 )
260262
261263 response = request .execute ()
262- print (f"Patched FHIR store { fhir_store_id } with Cloud Pub/Sub topic: None" )
264+ print (
265+ f"Patched FHIR store { fhir_store_id } with Cloud Pub/Sub topic: { pubsub_topic or 'None' } "
266+ )
263267
264268 return response
265269
0 commit comments