Mercurial > hg > orthanc
comparison Resources/Samples/Lua/ModifyInstanceWithSequence.lua @ 1701:4aaaecae5803 db-changes
integration mainline->db-changes
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 12 Oct 2015 14:47:58 +0200 |
parents | 8ca0e89798b2 |
children | 38c7bf2e10f6 |
comparison
equal
deleted
inserted
replaced
1683:21d31da73374 | 1701:4aaaecae5803 |
---|---|
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 |