view OrthancServer/Resources/Samples/Lua/AutoroutingConditional.lua @ 5223:a47b24f231d0

Fix Housekeeper plugin infinite loop if Orthanc is empty
author Alain Mazy <am@osimis.io>
date Mon, 03 Apr 2023 15:13:58 +0200
parents d25f4c0fa160
children
line wrap: on
line source

function OnStoredInstance(instanceId, tags, metadata, origin)
   -- The "origin" is only available since Orthanc 0.9.4
   PrintRecursive(origin)

   -- Extract the value of the "PatientName" DICOM tag
   local patientName = string.lower(tags['PatientName'])

   if string.find(patientName, 'david') ~= nil then
      -- Only send patients whose name contains "David"
      Delete(SendToModality(instanceId, 'sample'))

   else
      -- Delete the patients that are not called "David"
      Delete(instanceId)
   end
end