changeset 16:04fa104ab63b

lua
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 19 Jun 2015 08:34:24 +0200
parents 2e5dbbbe3889
children 7c8500991a12
files Database/Lua/Autorouting.lua Database/Lua/AutoroutingConditional.lua Database/Lua/AutoroutingModification.lua
diffstat 3 files changed, 43 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Database/Lua/Autorouting.lua	Fri Jun 19 08:34:24 2015 +0200
@@ -0,0 +1,3 @@
+function OnStoredInstance(instanceId, tags, metadata)
+   Delete(SendToModality(instanceId, 'orthanctest'))
+end
--- /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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Database/Lua/AutoroutingModification.lua	Fri Jun 19 08:34:24 2015 +0200
@@ -0,0 +1,21 @@
+function OnStoredInstance(instanceId, tags, metadata)
+   -- Ignore the instances that result from a modification to avoid
+   -- infinite loops
+   if (metadata['ModifiedFrom'] == nil and
+       metadata['AnonymizedFrom'] == nil) then
+
+      -- The tags to be replaced
+      local replace = {}
+      replace['StationName'] = 'My Medical Device'
+      replace['0031-1020'] = 'Some private tag'
+
+      -- The tags to be removed
+      local remove = { 'MilitaryRank' }
+
+      -- Modify the instance, send it, then delete the modified instance
+      Delete(SendToModality(ModifyInstance(instanceId, replace, remove, true), 'orthanctest'))
+
+      -- Delete the original instance
+      Delete(instanceId)
+   end
+end