annotate Resources/Samples/Lua/AutoroutingModification.lua @ 4077:ae7ebd5b0443

fix signature of OrthancPluginSendMultipartItem[2]()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 22 Jun 2020 15:09:40 +0200
parents bfdf24883ff3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2033
bfdf24883ff3 more generic AutoroutingModification.lua sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1307
diff changeset
1 function OnStoredInstance(instanceId, tags, metadata, origin)
bfdf24883ff3 more generic AutoroutingModification.lua sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1307
diff changeset
2 -- Ignore the instances that result from the present Lua script to
bfdf24883ff3 more generic AutoroutingModification.lua sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1307
diff changeset
3 -- avoid infinite loops
bfdf24883ff3 more generic AutoroutingModification.lua sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1307
diff changeset
4 if origin['RequestOrigin'] ~= 'Lua' then
1011
23590917e83e lua samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5
23590917e83e lua samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 -- The tags to be replaced
23590917e83e lua samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 local replace = {}
23590917e83e lua samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 replace['StationName'] = 'My Medical Device'
1307
f796207e3df1 Fix replacement and insertion of private DICOM tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1011
diff changeset
9 replace['0031-1020'] = 'Some private tag'
1011
23590917e83e lua samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10
23590917e83e lua samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 -- The tags to be removed
23590917e83e lua samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 local remove = { 'MilitaryRank' }
23590917e83e lua samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13
2033
bfdf24883ff3 more generic AutoroutingModification.lua sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1307
diff changeset
14 -- Modify the instance
bfdf24883ff3 more generic AutoroutingModification.lua sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1307
diff changeset
15 local command = {}
bfdf24883ff3 more generic AutoroutingModification.lua sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1307
diff changeset
16 command['Replace'] = replace
bfdf24883ff3 more generic AutoroutingModification.lua sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1307
diff changeset
17 command['Remove'] = remove
bfdf24883ff3 more generic AutoroutingModification.lua sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1307
diff changeset
18 local modifiedFile = RestApiPost('/instances/' .. instanceId .. '/modify', DumpJson(command, true))
1011
23590917e83e lua samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19
2033
bfdf24883ff3 more generic AutoroutingModification.lua sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1307
diff changeset
20 -- Upload the modified instance to the Orthanc database so that
bfdf24883ff3 more generic AutoroutingModification.lua sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1307
diff changeset
21 -- it can be sent by Orthanc to other modalities
bfdf24883ff3 more generic AutoroutingModification.lua sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1307
diff changeset
22 local modifiedId = ParseJson(RestApiPost('/instances/', modifiedFile)) ['ID']
bfdf24883ff3 more generic AutoroutingModification.lua sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1307
diff changeset
23
bfdf24883ff3 more generic AutoroutingModification.lua sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1307
diff changeset
24 -- Send the modified instance to another modality
bfdf24883ff3 more generic AutoroutingModification.lua sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1307
diff changeset
25 RestApiPost('/modalities/sample/store', modifiedId)
bfdf24883ff3 more generic AutoroutingModification.lua sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1307
diff changeset
26
bfdf24883ff3 more generic AutoroutingModification.lua sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1307
diff changeset
27 -- Delete the original and the modified instances
bfdf24883ff3 more generic AutoroutingModification.lua sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1307
diff changeset
28 RestApiDelete('/instances/' .. instanceId)
bfdf24883ff3 more generic AutoroutingModification.lua sample
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1307
diff changeset
29 RestApiDelete('/instances/' .. modifiedId)
1011
23590917e83e lua samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 end
23590917e83e lua samples
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 end