Periodically performing Query/Retrieve over dicom protocol

I am new to orthanc but we are finding it very useful for our lab. Thank you for such a nice piece of software tool! We have hosted a central Orthanc server and we can pull/push from multiple scanners in the lab over dicom protocol (over local LAN). OE2 interface is working great to allow researchers to quickly pull and check/download exams from scanners.

Now, we want to go one step further: We have been looking for way to automatically & periodically query scanner for recent exams and retrieve new exams over dicom protocol (or dicomweb). Basically, we want to automate the manual Query/Retrieve on orthanc. This way orthanc server will have the latest exams, and folks do not have to manually remember to pull/push.

I think custom plugin is the solution and I have been going over the python plugins page. I see the task scheduling example. However, I can not figure out how to query/retrieve from external DicomModalities using orthanc library (i.e after import orthanc). I guess I can use orthanc.RestApiPost & orthanc.RestApiGet with REST-based Query/Retrieve. Although this feel little bit indirect.

Can someone please point us to the right direction? Thanks!

You are in the right direction… e.g:

r = orthanc.RestApiPost(f"/modalities/xxx/query", {"Level": "Study", "Query": {"StudyDate": "20241118"}})
pprint.pprint(r)  # and here you go ...