comparison Resources/Samples/Lua/ModifyInstanceWithSequence.lua.orig @ 2249:38c7bf2e10f6

updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
author Alain Mazy <alain@mazy.be>
date Mon, 16 Jan 2017 13:55:54 +0100
parents
children
comparison
equal deleted inserted replaced
2248:69b0f4e8a49b 2249:38c7bf2e10f6
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, true))
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