Behaviour of MaximumStorageSize

Hello,
we want to use Orthanc as a fallback server for when our Pacs is down.
So we don't need all of our data, just like the last 3 month.
Now i have a question about the setting MaximumStorageSize.
I read somewhere here that this function starts to delete studies with the oldest study date.
But we would prefer it to delete the first study that got into Orthanc.
Would it be possible to switch it to a FIFO system instead?

Hello,

This is explained in the documentation here:
http://book.orthanc-server.com/faq/features.html?highlight=recycling#recycling-protection

Oldest patients are deleted first according to their order of arrival in Orthanc.

However, even if you push a new study, this will not change the position of the patient in the recycling order which might be an issue for your use case. I have added an issue in Orthanc to fix that in a future release: https://bitbucket.org/sjodogne/orthanc/issues/58/patient-recycling-order-should-be-defined.

There’s a workaround however by implementing a lua script (http://book.orthanc-server.com/users/lua.html) which will protect and unprotect a patient each time a new study is received for this patient. This way, everytime a new study is received, the patient will be moved to the last position in the recycling order.

function OnStablePatient(patientId)
local protectedStatus = RestApiGet(‘patients/’ … patientId … ‘/protected’)

if protectedStatus == ‘1’ then
RestApiPut(‘/patients/’ … patientId … ‘/protected’, ‘0’)
RestApiPut(‘/patients/’ … patientId … ‘/protected’, ‘1’)
else
RestApiPut(‘/patients/’ … patientId … ‘/protected’, ‘1’)
RestApiPut(‘/patients/’ … patientId … ‘/protected’, ‘0’)
end
end

Thank you for your reply.
If the patient is already deleted by FIFO then it should work out of the box. :slight_smile:
Usually we get patient data from other hospitals with studies up to two years old from the patient via disc.(These data don’t merge with our pid, so it is handled like a new patient i guess)
We take those data and import it in our pacs for 3 month then delete it.
But in this 3 month doctors use those studies to compare it against new studies made by our modalities.
And if this is already a patient based FIFO it should work for us, because usually we import the data at maximum one week apart from new studies and this “more time” i can control roughly with the MaximumStorageSize.