comparison Resources/Samples/Lua/ModifyInstanceWithSequence.lua @ 1699:8ca0e89798b2

"/modify" can insert/modify sequences
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 09 Oct 2015 13:31:22 +0200
parents
children 38c7bf2e10f6
comparison
equal deleted inserted replaced
1698:d78b87f93bcf 1699:8ca0e89798b2
1 -- Answer to:
2 -- https://groups.google.com/d/msg/orthanc-users/0ymHe1cDBCQ/YfD0NoOTn0wJ
3 -- Applicable starting with Orthanc 0.9.5
4
5 function OnStoredInstance(instanceId, tags, metadata, origin)
6 -- Do not modify twice the same file
7 if origin['RequestOrigin'] ~= 'Lua' then
8 local replace = {}
9 replace['0010,1002'] = {}
10 replace['0010,1002'][1] = {}
11 replace['0010,1002'][1]['PatientID'] = 'Hello'
12 replace['0010,1002'][2] = {}
13 replace['0010,1002'][2]['PatientID'] = 'World'
14
15 local request = {}
16 request['Replace'] = replace
17
18 -- Create the modified instance
19 local modified = RestApiPost('/instances/' .. instanceId .. '/modify',
20 DumpJson(request))
21
22 -- Upload the modified instance to the Orthanc store
23 RestApiPost('/instances/', modified)
24
25 -- Delete the original instance
26 RestApiDelete('/instances/' .. instanceId)
27 end
28 end