annotate Resources/Samples/Lua/OnStableStudy.lua.orig @ 2249:38c7bf2e10f6

updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
author Alain Mazy <alain@mazy.be>
date Mon, 16 Jan 2017 13:55:54 +0100
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2249
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
1 function Initialize()
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
2 print('Number of stored studies at initialization: ' ..
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
3 table.getn(ParseJson(RestApiGet('/studies'))))
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
4 end
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
5
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
6
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
7 function Finalize()
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
8 print('Number of stored studies at finalization: ' ..
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
9 table.getn(ParseJson(RestApiGet('/studies'))))
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
10 end
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
11
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
12
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
13 function OnStoredInstance(instanceId, tags, metadata)
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
14 patient = ParseJson(RestApiGet('/instances/' .. instanceId .. '/patient'))
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
15 print('Received an instance for patient: ' ..
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
16 patient['MainDicomTags']['PatientID'] .. ' - ' ..
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
17 patient['MainDicomTags']['PatientName'])
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
18 end
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
19
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
20
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
21 function OnStableStudy(studyId, tags, metadata)
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
22 if (metadata['ModifiedFrom'] == nil and
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
23 metadata['AnonymizedFrom'] == nil) then
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
24
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
25 print('This study is now stable: ' .. studyId)
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
26
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
27 -- The tags to be replaced
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
28 local replace = {}
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
29 replace['StudyDescription'] = 'Modified study'
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
30 replace['StationName'] = 'My Medical Device'
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
31 replace['0031-1020'] = 'Some private tag'
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
32
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
33 -- The tags to be removed
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
34 local remove = { 'MilitaryRank' }
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
35
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
36 -- The modification command
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
37 local command = {}
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
38 command['Remove'] = remove
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
39 command['Replace'] = replace
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
40
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
41 -- Modify the entire study in one single call
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
42 local m = RestApiPost('/studies/' .. studyId .. '/modify',
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
43 DumpJson(command, true))
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
44 print('Modified study: ' .. m)
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
45 end
38c7bf2e10f6 updated samples to set keepStrings=ture when calling DumpJson() to access the Orthanc API
Alain Mazy <alain@mazy.be>
parents:
diff changeset
46 end