comparison OrthancServer/Resources/Samples/Lua/OnStableStudy.lua @ 4044:d25f4c0fa160 framework

splitting code into OrthancFramework and OrthancServer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 10 Jun 2020 20:30:34 +0200
parents Resources/Samples/Lua/OnStableStudy.lua@38c7bf2e10f6
children
comparison
equal deleted inserted replaced
4043:6c6239aec462 4044:d25f4c0fa160
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 entire study in one single call
42 local m = RestApiPost('/studies/' .. studyId .. '/modify',
43 DumpJson(command, true))
44 print('Modified study: ' .. m)
45 end
46 end