Delete all Pictures at once

Hello,

I’m using Orthanc 1.4.0.1
an I’m searching for simple way to delete all Pictrues at once without clicking for each patient “Delete this patient”.

Is there a solution?

Hi!

I might be mistaken but I believe there isn’t a 1-click nuke button. You can, as you said, delete patients.

However, such feature can be implemented through scripting and the Rest API. A Lua callback would call “/patients” and iterate through its contents. It would then delete each one in succession, doing programmatically what we otherwise would have to do manually.

Personally and because we’re working with dockers and developing a plugin ourselves, I ended coding a “dirty” shell script. It stops all containers and “rm -rf” all volumes, then restart everything.

HTH

I’ve taken the liberty to write such a script for you. I can’t however test it now since I’m on a bus ride to work. So please do consider it a sample.

Thank you for your support!

I installed the script via Configuration file as script.lua;
First, Orthanc didn’t start anymore., so I modified it a little bit:

function IncomingHttpRequestFilter(method, uri, ip, username, httpHeaders)

– Only allow DELETE

if method == ‘DELETE’ and uri == ‘/nuke’
then
getResult = RestApiGet( ‘/patients’, true )
patients = ParseJson( getResult )

for i, patientId in ipairs( patients ) do
RestApiDelete( ‘/patients/’ … patientId )
end
return true
else
return true
end
end

Test with Delphi REST-Debugger for method “DELETE” gives the answer:
{
“HttpError”:“Not Found”,
“HttpStatus”:404,
“Message”:“Unknown resource”,
“Method”:“DELETE”,
“OrthancError”:“Unknown resource”,
“OrthancStatus”:17,
“Uri”:“/nuke/patients”
}

Looks like we’re one level too deep in /nuke/patients instead of /patients,
so I tried

getResult = RestApiGet( ‘/patients’, true ), but without change. The answer remains at “Unkown resource”, Uri /nuke/patients

Any suggestions?

The 404 is expected since this URLs doesn’t actually exist. I failed to find a Lua counterpart to C’s callback registration. But it should work nonetheless, that is, if you had patients they’d be deleted even with the 404.

To get it to production quality, we’d have to register the URL so Orthanc doesn’t yield a 404.

Long story made short: that was a Lua hack because of my lack of knowledge with Lua scripting.

In my test system I have 3 patients, which still remain after trying this hack.

Until today, Lua was unknown for me.

In short:

I’m missing something like /patients/all in REST API for method DELETE

Just added a sample Python script to this end:
https://bitbucket.org/sjodogne/orthanc/src/default/Resources/Samples/Python/DeleteAllStudies.py

Remarkable, how easy it is in Python.
Thank you!