diff Database/Lua/AutoroutingConditional.lua @ 16:04fa104ab63b

lua
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 19 Jun 2015 08:34:24 +0200
parents
children 525a2f57ec94
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Database/Lua/AutoroutingConditional.lua	Fri Jun 19 08:34:24 2015 +0200
@@ -0,0 +1,19 @@
+function OnStoredInstance(instanceId, tags, metadata, remoteAet, calledAet)
+   -- The "remoteAet" and "calledAet" arguments are only available
+   -- since Orthanc 0.8.6
+   if remoteAet ~=nil and calledAet ~= nil then
+      print ("Source AET: " .. remoteAet .. " => Called AET: " .. calledAet)
+   end
+
+   -- Extract the value of the "PatientName" DICOM tag
+   local patientName = string.lower(tags['PatientName'])
+
+   if string.find(patientName, 'knee') ~= nil then
+      -- Only send patients whose name contains "Knee"
+      Delete(SendToModality(instanceId, 'orthanctest'))
+
+   else
+      -- Delete the patients that are not called "Knee"
+      Delete(instanceId)
+   end
+end