How to autodelete an old images?

Hello All!

I have a problem with autodelete old images from the base.

In the config-file of ORTHANC I integrate a function to load Lua script as follow:

function OnStablePatient(patientId, tags, metadata)
Delete(patientId)
end

In the config-file I have the follow instructions:

“MaximumStorageSize” : 100000,
“MaximumPatientCount” :750,
“StableAge” : 604800,

Is it right to create an autodelete function?

Error-dcm-autodelete.jpg

If you configure a MaximumPatientCount, you don’t have to delete the patient yourself ( https://book.orthanc-server.com/faq/features.html#recycling-protection)

In your case, I guess that the patient has already been deleted when you try to delete it in Lua.