@@ -173,6 +173,25 @@ def get_study(self, from_modality: str, dicom_id: str):
173173 from_modality = from_modality
174174 )
175175
176+ def get_study_async (self , from_modality : str , dicom_id : str ) -> Job :
177+ """
178+ retrieves a study from a remote modality (C-Get)
179+
180+ This call is asynchronous and returns a job.
181+
182+ :param from_modality: the modality alias configured in orthanc
183+ :param dicom_id: the StudyInstanceUid of the study to move
184+ """
185+ return Job .from_json (self ._api_client , self ._get (
186+ level = "Study" ,
187+ resource = {
188+ "StudyInstanceUID" : dicom_id
189+ },
190+ from_modality = from_modality ,
191+ asynchronous = True
192+ ))
193+
194+
176195 def get_series (self , from_modality : str , dicom_id : str , study_dicom_id : str ):
177196 """
178197 retrieves a series from a remote modality (C-Get)
@@ -232,6 +251,26 @@ def move_study(self, from_modality: str, dicom_id: str, to_modality_aet: str = N
232251 to_modality_aet = to_modality_aet
233252 )
234253
254+ def move_study_async (self , from_modality : str , dicom_id : str , to_modality_aet : str = None ) -> Job :
255+ """
256+ moves a study from a remote modality (C-Move) to a target modality (AET)
257+
258+ This call is asynchronous. It returns a job.
259+
260+ :param from_modality: the modality alias configured in orthanc
261+ :param dicom_id: the StudyInstanceUid of the study to move
262+ :param to_modality_aet: the AET of the target modality
263+ """
264+ return Job .from_json (self ._api_client , self ._move (
265+ level = "Study" ,
266+ resource = {
267+ "StudyInstanceUID" : dicom_id
268+ },
269+ from_modality = from_modality ,
270+ to_modality_aet = to_modality_aet ,
271+ asynchronous = True
272+ ))
273+
235274 def move_series (self , from_modality : str , dicom_id : str , study_dicom_id : str , to_modality_aet : str = None ):
236275 """
237276 moves a series from a remote modality (C-Move) to a target modality (AET)
@@ -276,30 +315,29 @@ def move_instance(self, from_modality: str, dicom_id: str, series_dicom_id: str,
276315 to_modality_aet = to_modality_aet
277316 )
278317
279- def _move (self , level : str , resource : object , from_modality : str , to_modality_aet : str = None ):
318+ def _move (self , level : str , resource : object , from_modality : str , to_modality_aet : str = None , asynchronous : bool = False ):
280319 """
281320 moves a study from a remote modality (C-Move) to a target modality (AET)
282321
283- this call is synchronous. It completes once the C-Move is complete.
284-
285322 :param from_modality: the modality alias configured in orthanc
286323 :param to_modality_aet: the AET of the target modality
287324 """
288325
289326 payload = {
290327 'Level' : level ,
291- 'Resources' : [resource ]
328+ 'Resources' : [resource ],
329+ 'Asynchronous' : asynchronous
292330 }
293331
294332 if to_modality_aet :
295333 payload ['TargetAet' ] = to_modality_aet
296334
297- self ._api_client .post (
335+ return self ._api_client .post (
298336 endpoint = f"{ self ._url_segment } /{ from_modality } /move" ,
299- json = payload )
337+ json = payload ). json ()
300338
301339
302- def _get (self , level : str , resource : object , from_modality : str ):
340+ def _get (self , level : str , resource : object , from_modality : str , asynchronous : bool = False ):
303341 """
304342 retrieves a study from a remote modality (C-Get)
305343
@@ -310,12 +348,13 @@ def _get(self, level: str, resource: object, from_modality: str):
310348
311349 payload = {
312350 'Level' : level ,
313- 'Resources' : [resource ]
351+ 'Resources' : [resource ],
352+ 'Asynchronous' : asynchronous
314353 }
315354
316- self ._api_client .post (
355+ return self ._api_client .post (
317356 endpoint = f"{ self ._url_segment } /{ from_modality } /get" ,
318- json = payload )
357+ json = payload ). json ()
319358
320359
321360 def query_studies (self , from_modality : str , query : object ) -> typing .List [RemoteModalityStudy ]:
0 commit comments