@@ -202,15 +202,15 @@ def patch_fhir_store(
202
202
# [END healthcare_patch_fhir_store]
203
203
204
204
205
- # [START healthcare_export_fhir_resource ]
206
- def export_fhir_resource (
205
+ # [START healthcare_export_fhir_store_gcs ]
206
+ def export_fhir_store_gcs (
207
207
service_account_json ,
208
208
api_key ,
209
209
project_id ,
210
210
cloud_region ,
211
211
dataset_id ,
212
212
fhir_store_id ,
213
- uri_prefix ):
213
+ gcs_uri ):
214
214
"""Export resources to a Google Cloud Storage bucket by copying
215
215
them from the FHIR store."""
216
216
client = get_client (service_account_json , api_key )
@@ -220,12 +220,9 @@ def export_fhir_resource(
220
220
fhir_store_parent , fhir_store_id )
221
221
222
222
body = {
223
- "outputConfig " :
223
+ "gcsDestinationLocation " :
224
224
{
225
- "gcsDestination" :
226
- {
227
- "uriPrefix" : 'gs://{}' .format (uri_prefix )
228
- }
225
+ "gcsUri" : 'gs://{}' .format (gcs_uri )
229
226
}
230
227
}
231
228
@@ -234,23 +231,23 @@ def export_fhir_resource(
234
231
235
232
try :
236
233
response = request .execute ()
237
- print ('Exported FHIR resources to bucket: gs://{}' .format (uri_prefix ))
234
+ print ('Exported FHIR resources to bucket: gs://{}' .format (gcs_uri ))
238
235
return response
239
236
except HttpError as e :
240
237
print ('Error, FHIR resources not exported: {}' .format (e ))
241
238
return ""
242
- # [END healthcare_export_fhir_resource ]
239
+ # [END healthcare_export_fhir_store_gcs ]
243
240
244
241
245
- # [START healthcare_import_fhir_resource ]
246
- def import_fhir_resource (
242
+ # [START healthcare_import_fhir_store ]
243
+ def import_fhir_store (
247
244
service_account_json ,
248
245
api_key ,
249
246
project_id ,
250
247
cloud_region ,
251
248
dataset_id ,
252
249
fhir_store_id ,
253
- content_uri ):
250
+ gcs_uri ):
254
251
"""Import resources into the FHIR store by copying them from the
255
252
specified source.
256
253
"""
@@ -261,12 +258,13 @@ def import_fhir_resource(
261
258
fhir_store_parent , fhir_store_id )
262
259
263
260
body = {
264
- "inputConfig " :
261
+ "gcsSourceLocation " :
265
262
{
266
- "gcsSource" :
267
- {
268
- "contentUri" : 'gs://{}' .format (content_uri )
269
- }
263
+ "gcsUri" : 'gs://{}' .format (gcs_uri )
264
+ },
265
+ "gcsErrorLocation" :
266
+ {
267
+ "gcsUri" : 'gs://{}/errors' .format (gcs_uri )
270
268
}
271
269
}
272
270
@@ -277,12 +275,12 @@ def import_fhir_resource(
277
275
278
276
try :
279
277
response = request .execute ()
280
- print ('Imported FHIR resources: {}' .format (content_uri ))
278
+ print ('Imported FHIR resources: {}' .format (gcs_uri ))
281
279
return response
282
280
except HttpError as e :
283
281
print ('Error, FHIR resources not imported: {}' .format (e ))
284
282
return ""
285
- # [END healthcare_import_fhir_resource ]
283
+ # [END healthcare_import_fhir_store ]
286
284
287
285
288
286
def parse_command_line_args ():
@@ -329,16 +327,11 @@ def parse_command_line_args():
329
327
'are published' )
330
328
331
329
parser .add_argument (
332
- '--uri_prefix' ,
333
- default = None ,
334
- help = 'URI for a Google Cloud Storage directory to which result files'
335
- 'should be written (e.g., "bucket-id/path/to/destination/dir").' )
336
-
337
- parser .add_argument (
338
- '--content_uri' ,
330
+ '--gcs_uri' ,
339
331
default = None ,
340
332
help = 'URI for a Google Cloud Storage directory from which files'
341
- 'should be imported (e.g., "bucket-id/path/to/destination/dir").' )
333
+ 'should be import or to which result files'
334
+ 'should be written (e.g., "bucket-id/path/to/destination/dir").' )
342
335
343
336
command = parser .add_subparsers (dest = 'command' )
344
337
@@ -348,11 +341,11 @@ def parse_command_line_args():
348
341
command .add_parser ('list-fhir-stores' , help = list_fhir_stores .__doc__ )
349
342
command .add_parser ('patch-fhir-store' , help = patch_fhir_store .__doc__ )
350
343
command .add_parser (
351
- 'export -fhir-resource ' ,
352
- help = import_fhir_resource .__doc__ )
344
+ 'import -fhir-store ' ,
345
+ help = import_fhir_store .__doc__ )
353
346
command .add_parser (
354
- 'import -fhir-resource ' ,
355
- help = export_fhir_resource .__doc__ )
347
+ 'export -fhir-store-gcs ' ,
348
+ help = export_fhir_store_gcs .__doc__ )
356
349
357
350
return parser .parse_args ()
358
351
@@ -409,25 +402,25 @@ def run_command(args):
409
402
args .fhir_store_id ,
410
403
args .pubsub_topic )
411
404
412
- elif args .command == 'export-fhir-resource ' :
413
- patch_fhir_store (
405
+ elif args .command == 'export-fhir-store-gcs ' :
406
+ export_fhir_store_gcs (
414
407
args .service_account_json ,
415
408
args .api_key ,
416
409
args .project_id ,
417
410
args .cloud_region ,
418
411
args .dataset_id ,
419
412
args .fhir_store_id ,
420
- args .uri_prefix )
413
+ args .gcs_uri )
421
414
422
- elif args .command == 'import-fhir-resource ' :
423
- patch_fhir_store (
415
+ elif args .command == 'import-fhir-store ' :
416
+ import_fhir_store (
424
417
args .service_account_json ,
425
418
args .api_key ,
426
419
args .project_id ,
427
420
args .cloud_region ,
428
421
args .dataset_id ,
429
422
args .fhir_store_id ,
430
- args .content_uri )
423
+ args .gcs_uri )
431
424
432
425
433
426
def main ():
0 commit comments