# HG changeset patch # User Sebastien Jodogne # Date 1435844715 -7200 # Node ID 6a9daad345c10933b66cc9bc1e027a82b04196ca # Parent 68827c07e6830a0c470ce4ab947bfd845f7e703f OnStableStudy.lua sample diff -r 68827c07e683 -r 6a9daad345c1 Resources/Samples/Lua/OnStableStudy.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Resources/Samples/Lua/OnStableStudy.lua Thu Jul 02 15:45:15 2015 +0200 @@ -0,0 +1,46 @@ +function Initialize() + print('Number of stored studies at initialization: ' .. + table.getn(ParseJson(RestApiGet('/studies')))) +end + + +function Finalize() + print('Number of stored studies at finalization: ' .. + table.getn(ParseJson(RestApiGet('/studies')))) +end + + +function OnStoredInstance(instanceId, tags, metadata) + patient = ParseJson(RestApiGet('/instances/' .. instanceId .. '/patient')) + print('Received an instance for patient: ' .. + patient['MainDicomTags']['PatientID'] .. ' - ' .. + patient['MainDicomTags']['PatientName']) +end + + +function OnStableStudy(studyId, tags, metadata) + if (metadata['ModifiedFrom'] == nil and + metadata['AnonymizedFrom'] == nil) then + + print('This study is now stable: ' .. studyId) + + -- The tags to be replaced + local replace = {} + replace['StudyDescription'] = 'Modified study' + replace['StationName'] = 'My Medical Device' + replace['0031-1020'] = 'Some private tag' + + -- The tags to be removed + local remove = { 'MilitaryRank' } + + -- The modification command + local command = {} + command['Remove'] = remove + command['Replace'] = replace + + -- Modify the instance, send it, then delete the modified instance + local m = RestApiPost('/studies/' .. studyId .. '/modify', + DumpJson(command)) + print('Modified study: ' .. m) + end +end