annotate Resources/Samples/Lua/ModifyInstanceWithSequence.lua @ 3827:638906dcfe32 transcoding

integration mainline->transcoding
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 10 Apr 2020 16:18:17 +0200
parents 38c7bf2e10f6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1699
8ca0e89798b2 "/modify" can insert/modify sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 -- Answer to:
8ca0e89798b2 "/modify" can insert/modify sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 -- https://groups.google.com/d/msg/orthanc-users/0ymHe1cDBCQ/YfD0NoOTn0wJ
8ca0e89798b2 "/modify" can insert/modify sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 -- Applicable starting with Orthanc 0.9.5
8ca0e89798b2 "/modify" can insert/modify sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4
8ca0e89798b2 "/modify" can insert/modify sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 function OnStoredInstance(instanceId, tags, metadata, origin)
8ca0e89798b2 "/modify" can insert/modify sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 -- Do not modify twice the same file
8ca0e89798b2 "/modify" can insert/modify sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 if origin['RequestOrigin'] ~= 'Lua' then
8ca0e89798b2 "/modify" can insert/modify sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 local replace = {}
8ca0e89798b2 "/modify" can insert/modify sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 replace['0010,1002'] = {}
8ca0e89798b2 "/modify" can insert/modify sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 replace['0010,1002'][1] = {}
8ca0e89798b2 "/modify" can insert/modify sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 replace['0010,1002'][1]['PatientID'] = 'Hello'
8ca0e89798b2 "/modify" can insert/modify sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 replace['0010,1002'][2] = {}
8ca0e89798b2 "/modify" can insert/modify sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 replace['0010,1002'][2]['PatientID'] = 'World'
8ca0e89798b2 "/modify" can insert/modify sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14
8ca0e89798b2 "/modify" can insert/modify sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 local request = {}
8ca0e89798b2 "/modify" can insert/modify sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 request['Replace'] = replace
8ca0e89798b2 "/modify" can insert/modify sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17
8ca0e89798b2 "/modify" can insert/modify sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 -- Create the modified instance
8ca0e89798b2 "/modify" can insert/modify sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 local modified = RestApiPost('/instances/' .. instanceId .. '/modify',
2249
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents: 1699
diff changeset
20 DumpJson(request, true))
1699
8ca0e89798b2 "/modify" can insert/modify sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
8ca0e89798b2 "/modify" can insert/modify sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 -- Upload the modified instance to the Orthanc store
8ca0e89798b2 "/modify" can insert/modify sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 RestApiPost('/instances/', modified)
8ca0e89798b2 "/modify" can insert/modify sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
8ca0e89798b2 "/modify" can insert/modify sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 -- Delete the original instance
8ca0e89798b2 "/modify" can insert/modify sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 RestApiDelete('/instances/' .. instanceId)
8ca0e89798b2 "/modify" can insert/modify sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 end
8ca0e89798b2 "/modify" can insert/modify sequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 end