Mercurial > hg > orthanc
annotate OrthancServer/Resources/Samples/Lua/AutoroutingModification.lua @ 4615:b91ed9e7f43c db-changes
minor api improvements in OrthancCDatabasePlugin.h
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 14 Apr 2021 11:20:05 +0200 |
parents | d25f4c0fa160 |
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 |