Mercurial > hg > orthanc
annotate Resources/Samples/Lua/AutoroutingModification.lua @ 3812:abd3a1d114c0 transcoding
transcoding to 1.2.840.10008.1.2.4.51
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 07 Apr 2020 13:54:57 +0200 |
parents | bfdf24883ff3 |
children |
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 | 5 |
6 -- The tags to be replaced | |
7 local replace = {} | |
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 | 10 |
11 -- The tags to be removed | |
12 local remove = { 'MilitaryRank' } | |
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 | 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 | 30 end |
31 end |