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