Get all stored instances and bulk route

I am running a script that automatically modifies and routes incoming instances. When it works, no images are left on Orthanc. If the script fails for any reason, Lua stops and the instances stay on Orthanc (as the SendToModality followed by the Delete are the last steps).

For example, if the SendToModality command fails because the server is down, images get left on Orthanc unrouted.

I would like to run a basic Initialize() script that takes all those unrouted studies and sends them, modified or not, as the last catch-all. That way, if there are any problems, for any reason, this will eventually get the studies to the server. I am trying to avoid manually having to individually click on a study and Send to Modality, I want this done automatically. Then perhaps set a Windows Schedule to restart the service periodically (perhaps nightly) to trigger this periodically.

Lua is for basic use cases.

For more expressiveness and flexibility (such as what you describe), you should be using the Python plugin:
https://book.orthanc-server.com/plugins/python.html

For instance, check out “orthanc.ChangeType.ORTHANC_STARTED” to run some script at the Orthanc startup. The “threading.Timer()” class of Python could be used to periodically run a task.

Hello Ron,

You could also consider a python script beside Orthanc with an infinite loop trying to modify/forward all it finds in Orthanc, so that, if the destination server is down, the script will try again until the server is up again.

Best regards,

That answers my question and saved me a ton of time. Thanks.

I ultimately accomplished the job with a powershell script. It took me a few days to figure out the syntax, modifying Linux curl operations to Windows Invoke-WebRequest commands, but it only required a few lines of code. I set a Windows Task to trigger it every few hours.

No matter how careful I am with the lua script, we kept getting sent studies with data that somehow manages to confuse the script.

Thanks again