1st grade question

I have been using Orthanc for a while now… I love the product. Now I would like to start using the Curl command to query and delete multiple studies based on a range of date of service so I could clear up the database. I’m using Windows and Postgresql.
Can some one guide me where to download CURL and from where do I execute it ? CMD line ? Powershell Also where is the output of Curl goes ? If I query a date range I would like to be able to batch run and delete all of the studies

Thank You for your help…
Tom

We are in the same boat, Tom.

Curl is included in Windows 10, but you can download it. Just Google search it and you will find it.

I am finding that Powershell/Command line gets a little tricky once you start adding quotes. It’s been a long time since I’ve done scripting, in a modern OS, so I am still learning how to escape all that stuff.
I have found it useful to issue basic queries in command line or powershell, edit the list and paste it into a new curl command in Ubuntu. You can run the Linux subsystem under Windows 10 and install Ubuntu as a “virtual machine” of sorts.
Most of the curl examples you’ll find in the Orthanc Book online is based on Linux which handles the quotations differently than Windows. So I find a combination of the two works for me while I’m trying to figure out how to script things properly.

For example, if I want to send a block of patients (or studies) to a remote modality, I can query either the entire DB, or a date range using windows command line and then append " > c:\directory\filename.txt" to the end of the command and get the output in a text file. I can edit the results of that and manipulate that into a curl command for Linux that has multiple UID’s.

EG:
RUN IN COMMAND LINE
curl.exe --user username:password http://localhost:8042/patients > c:\curl\output\patients.txt

Then I go to the text file, manipulate the output (remove the spaces and line breaks) and make a new command that I paste into an Ubuntu command line.

RUN IN UBUNTU:
curl -X POST -u username:password http://localhost:8042/modalities/MODALITYNAME/store -d ‘[“c4d4d00a-8dd087cb-432a37de-68550505-d0d63070”,“96ad7dff-f8713642-ac0f060a-de40f60e-97b4c705”,“aac7f73f-fcb922ef-b950c4c1-ee1d512e-e2aeb5ae”,“3a8aafa6-3c461989-fe620e53-86c8b34a-6090a875”,“94c7e2bf-23dce14c-8920c4cb-4c93cccc-53f754db”,“12a24226-56314ea4-09b01751-ba21bc33-b00146e7”]’

You can also download the Orthanc Tools java tool and it works well for deleting multiple studies based on a date range, modality type, etc. Google search “Orthanc Tools java” and you’ll find it. Make sure you have JRE installed and then the java executable will run.

I’m working a migration project between two different PACS systems on two different networks and using Orthanc to facilitate the migration. I just found this product a couple weeks ago myself and it’s working great so far, except for a couple things I’m trying to nail down. Anyway, for the time being, while I am on a hard deadline time crunch and am trying to learn how to write modern script in a modern OS (I haven’t written anything since the old VB4.0 days - I’m THAT old), a combination of those three things is working for me for mass moving/deleting/etc.

I still have a lot of questions myself, but maybe this will get you started since we appear to be in the same boat…

Also…you will get the curl results on the screen if you don’t append the " > c:\directory\filename.txt" to the command… just fyi

Note that, on Windows, you can now install WSL (Windows Subsystem for Linux), then in a cmd prompt, just type “bash” and you now have a Linux shell and use the Linux curl command … I do it a lot for simple curl command.

If you really want to make more complex scripting, I would advise using an http client in python or whatever higher level language than bash/powershell … but it’s just my opinion.

As a complement to the previous answers: You can easily create a Python script to remove studies using their “StudyDate” DICOM tag.

This amounts to combining the two following sample scripts that are part of the Orthanc source distribution:
https://bitbucket.org/sjodogne/orthanc/src/default/Resources/Samples/Python/DeleteAllStudies.py
https://bitbucket.org/sjodogne/orthanc/src/default/Resources/Samples/Python/ArchiveStudiesInTimeRange.py

Sébastien-