Hi all, Please, help me to write a script, probably there is some kind of error. forwarding works but no replacing.
this script was not written by me, please answer in more detail. Thanks.
`
function OnStoredInstance(instanceId, tags, metadata, origin)
– Ignore the instances that result from the present Lua script to
– avoid infinite loops
if origin[‘RequestOrigin’] ~= ‘Lua’ then
– The tags to be replaced
local replace = {}
replace[‘InstitutionName’] = ‘XXX’
replace[‘RetrieveAETitle’] = ‘ORTHANC-XXX’
– The tags to be removed
local remove = { ‘MilitaryRank’ }
– Modify the instance
local command = {}
command[‘Replace’] = replace
command[‘Remove’] = remove
local modifiedFile = RestApiPost(‘/instances/’ … instanceId … ‘/modify’, DumpJson(command, true))
– Upload the modified instance to the Orthanc database so that
– it can be sent by Orthanc to other modalities
local modifiedId = ParseJson(RestApiPost(‘/instances/’, modifiedFile)) [‘ID’]
– Send the modified instance to another modality
RestApiPost(‘/modalities/dcm4chee/store’, modifiedId)
– Delete the original instances
RestApiDelete(‘/instances/’ … instanceId)
end
end
`