# HG changeset patch # User Sebastien Jodogne # Date 1404921088 -7200 # Node ID 23590917e83e47584e50d2d259430d4869708580 # Parent 160dfe770618be8da8f1876d0b553f1b0ba554f8 lua samples diff -r 160dfe770618 -r 23590917e83e Resources/Samples/Lua/Autorouting.lua --- a/Resources/Samples/Lua/Autorouting.lua Wed Jul 09 17:05:00 2014 +0200 +++ b/Resources/Samples/Lua/Autorouting.lua Wed Jul 09 17:51:28 2014 +0200 @@ -1,23 +1,3 @@ function OnStoredInstance(instanceId, tags, metadata) - --PrintRecursive(tags) - --PrintRecursive(metadata) - --print(metadata['RemoteAET']) - - if (metadata['ModifiedFrom'] == nil and - metadata['AnonymizedFrom'] == nil) then - local patientName = string.lower(tags['PatientName']) - if string.find(patientName, 'david') ~= nil then - --Delete(SendToModality(instanceId, 'sample')) - --Delete(SendToPeer(instanceId, 'peer')) - local replace = {} - replace['StationName'] = 'My Medical Device' - - local remove = { 'MilitaryRank' } - - Delete(SendToModality(ModifyInstance(instanceId, replace, remove, true), 'sample')) - Delete(instanceId) - else - Delete(instanceId) - end - end + Delete(SendToModality(instanceId, 'sample')) end diff -r 160dfe770618 -r 23590917e83e Resources/Samples/Lua/AutoroutingConditional.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Resources/Samples/Lua/AutoroutingConditional.lua Wed Jul 09 17:51:28 2014 +0200 @@ -0,0 +1,13 @@ +function OnStoredInstance(instanceId, tags, metadata) + -- 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 diff -r 160dfe770618 -r 23590917e83e Resources/Samples/Lua/AutoroutingModification.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Resources/Samples/Lua/AutoroutingModification.lua Wed Jul 09 17:51:28 2014 +0200 @@ -0,0 +1,20 @@ +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' + + -- 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), 'sample')) + + -- Delete the original instance + Delete(instanceId) + end +end