Mercurial > hg > orthanc
diff OrthancServer/Resources/Samples/Lua/ModifyInstanceWithSequence.lua @ 4044:d25f4c0fa160 framework
splitting code into OrthancFramework and OrthancServer
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 10 Jun 2020 20:30:34 +0200 |
parents | Resources/Samples/Lua/ModifyInstanceWithSequence.lua@38c7bf2e10f6 |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OrthancServer/Resources/Samples/Lua/ModifyInstanceWithSequence.lua Wed Jun 10 20:30:34 2020 +0200 @@ -0,0 +1,28 @@ +-- Answer to: +-- https://groups.google.com/d/msg/orthanc-users/0ymHe1cDBCQ/YfD0NoOTn0wJ +-- Applicable starting with Orthanc 0.9.5 + +function OnStoredInstance(instanceId, tags, metadata, origin) + -- Do not modify twice the same file + if origin['RequestOrigin'] ~= 'Lua' then + local replace = {} + replace['0010,1002'] = {} + replace['0010,1002'][1] = {} + replace['0010,1002'][1]['PatientID'] = 'Hello' + replace['0010,1002'][2] = {} + replace['0010,1002'][2]['PatientID'] = 'World' + + local request = {} + request['Replace'] = replace + + -- Create the modified instance + local modified = RestApiPost('/instances/' .. instanceId .. '/modify', + DumpJson(request, true)) + + -- Upload the modified instance to the Orthanc store + RestApiPost('/instances/', modified) + + -- Delete the original instance + RestApiDelete('/instances/' .. instanceId) + end +end