@@ -152,6 +152,41 @@ def dicomweb_retrieve_study(
152
152
# [END healthcare_dicomweb_retrieve_study]
153
153
154
154
155
+ # [START healthcare_dicomweb_search_studies]
156
+ def dicomweb_search_studies (
157
+ service_account_json ,
158
+ base_url ,
159
+ project_id ,
160
+ cloud_region ,
161
+ dataset_id ,
162
+ dicom_store_id ):
163
+ """Handles the GET requests specified in the DICOMweb standard."""
164
+ url = '{}/projects/{}/locations/{}' .format (base_url ,
165
+ project_id , cloud_region )
166
+
167
+ dicomweb_path = '{}/datasets/{}/dicomStores/{}/dicomWeb/studies' .format (
168
+ url , dataset_id , dicom_store_id )
169
+
170
+ # Refine your search by appending DICOM tags to the
171
+ # request in the form of query parameters. This sample
172
+ # searches for studies containing a patient's name.
173
+ params = {'PatientName' : 'Sally Zhang' }
174
+
175
+ session = get_session (service_account_json )
176
+
177
+ response = session .get (dicomweb_path , params = params )
178
+
179
+ response .raise_for_status ()
180
+
181
+ patients = response .json ()
182
+
183
+ print ('Patients found matching query:' )
184
+ print (json .dumps (patients , indent = 2 ))
185
+
186
+ return patients
187
+ # [END healthcare_dicomweb_search_studies]
188
+
189
+
155
190
# [START healthcare_dicomweb_retrieve_instance]
156
191
def dicomweb_retrieve_instance (
157
192
service_account_json ,
@@ -342,6 +377,9 @@ def parse_command_line_args():
342
377
command .add_parser (
343
378
'dicomweb-retrieve-study' ,
344
379
help = dicomweb_retrieve_study .__doc__ )
380
+ command .add_parser (
381
+ 'dicomweb-search-studies' ,
382
+ help = dicomweb_search_studies .__doc__ )
345
383
command .add_parser (
346
384
'dicomweb-retrieve-instance' ,
347
385
help = dicomweb_retrieve_instance .__doc__ )
@@ -403,6 +441,15 @@ def run_command(args):
403
441
args .series_uid ,
404
442
args .instance_uid )
405
443
444
+ elif args .command == 'dicomweb-search-studies' :
445
+ dicomweb_search_studies (
446
+ args .service_account_json ,
447
+ args .base_url ,
448
+ args .project_id ,
449
+ args .cloud_region ,
450
+ args .dataset_id ,
451
+ args .dicom_store_id )
452
+
406
453
elif args .command == 'dicomweb-retrieve-rendered' :
407
454
dicomweb_retrieve_rendered (
408
455
args .service_account_json ,
0 commit comments