Mercurial > hg > orthanc
comparison Resources/Samples/Lua/OnStableStudy.lua @ 1457:6a9daad345c1
OnStableStudy.lua sample
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 02 Jul 2015 15:45:15 +0200 |
parents | |
children | 1d109322f5d3 |
comparison
equal
deleted
inserted
replaced
1456:68827c07e683 | 1457:6a9daad345c1 |
---|---|
1 function Initialize() | |
2 print('Number of stored studies at initialization: ' .. | |
3 table.getn(ParseJson(RestApiGet('/studies')))) | |
4 end | |
5 | |
6 | |
7 function Finalize() | |
8 print('Number of stored studies at finalization: ' .. | |
9 table.getn(ParseJson(RestApiGet('/studies')))) | |
10 end | |
11 | |
12 | |
13 function OnStoredInstance(instanceId, tags, metadata) | |
14 patient = ParseJson(RestApiGet('/instances/' .. instanceId .. '/patient')) | |
15 print('Received an instance for patient: ' .. | |
16 patient['MainDicomTags']['PatientID'] .. ' - ' .. | |
17 patient['MainDicomTags']['PatientName']) | |
18 end | |
19 | |
20 | |
21 function OnStableStudy(studyId, tags, metadata) | |
22 if (metadata['ModifiedFrom'] == nil and | |
23 metadata['AnonymizedFrom'] == nil) then | |
24 | |
25 print('This study is now stable: ' .. studyId) | |
26 | |
27 -- The tags to be replaced | |
28 local replace = {} | |
29 replace['StudyDescription'] = 'Modified study' | |
30 replace['StationName'] = 'My Medical Device' | |
31 replace['0031-1020'] = 'Some private tag' | |
32 | |
33 -- The tags to be removed | |
34 local remove = { 'MilitaryRank' } | |
35 | |
36 -- The modification command | |
37 local command = {} | |
38 command['Remove'] = remove | |
39 command['Replace'] = replace | |
40 | |
41 -- Modify the instance, send it, then delete the modified instance | |
42 local m = RestApiPost('/studies/' .. studyId .. '/modify', | |
43 DumpJson(command)) | |
44 print('Modified study: ' .. m) | |
45 end | |
46 end |