comparison Resources/Samples/Lua/Autorouting.lua @ 1007:871c49c9b11d lua-scripting

lua routing is working
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 08 Jul 2014 17:35:00 +0200
parents 649d47854314
children 187ed107a59f
comparison
equal deleted inserted replaced
1006:649d47854314 1007:871c49c9b11d
1 function OnStoredInstance(instance, tags, metadata) 1 function _InitializeJob()
2 _job = {}
3 end
4
5 function _AccessJob()
6 return _job
7 end
8
9 function SendToModality(instanceId, modality)
10 if instanceId == nil then
11 error('Cannot send an nonexistent instance')
12 end
13
14 table.insert(_job, {
15 operation = 'store-scu',
16 instance = instanceId,
17 modality = modality
18 })
19 return instanceId
20 end
21
22 function SendToPeer(instanceId, peer)
23 if instanceId == nil then
24 error('Cannot send an nonexistent instance')
25 end
26
27 table.insert(_job, {
28 operation = 'store-peer',
29 instance = instanceId,
30 peer = peer
31 })
32 return instanceId
33 end
34
35 function Delete(instanceId)
36 if instanceId == nil then
37 error('Cannot delete an nonexistent instance')
38 end
39
40 table.insert(_job, {
41 operation = 'delete',
42 instance = instanceId
43 })
44 return nil -- Forbid chaining
45 end
46
47 function Modify(instanceId, replacements, removals, removePrivateTags)
48 if instanceId == nil then
49 error('Cannot modify an nonexistent instance')
50 end
51
52 if instanceId == '' then
53 error('Cannot modify twice an instance');
54 end
55
56 table.insert(_job, {
57 operation = 'modify',
58 instance = instanceId,
59 replacements = replacements,
60 removals = removals,
61 removePrivateTags = removePrivateTags
62 })
63 return '' -- Chain with another operation
64 end
65
66
67 function OnStoredInstance(instanceId, tags, metadata)
2 --PrintRecursive(tags) 68 --PrintRecursive(tags)
3 PrintRecursive(metadata) 69 --PrintRecursive(metadata)
4 print(metadata['RemoteAET']) 70 --print(metadata['RemoteAET'])
5 return { 71
6 { "store", instance, "pacs" }, 72 if true then
7 { "delete", instance } 73 local patientName = string.lower(tags['PatientName'])
8 } 74 if string.find(patientName, 'david') ~= nil then
75 --Delete(SendToModality(instanceId, 'sample'))
76 --Delete(SendToPeer(instanceId, 'peer'))
77 Delete(SendToModality(Modify(instanceId, { PatientName = 'Hello^World' }), 'sample'))
78 else
79 Delete(instanceId)
80 end
81 end
9 end 82 end