I’d like the ability to automatically inject private DICOM tags into received instances. The private tags will be pre-defined in the orthanc config files (the private tags will have static values).
As of now, I’m doing this via lua/python plugin by intercepting the OnStoredInstance
hook. However, it uses multiple REST calls overwrite the metadata.
Here’s my code:
function OnStoredInstance(instanceId, tags, metadata, origin)
if origin['RequestOrigin'] ~= 'Lua' then
local replace = {}
replace["00xx,00xx"] = "some data"
replace["Private_Tag_Defined_In_Dictionary"] = "more data"
replace["SOPInstanceUID"] = tags["SOPInstanceUID"]
local remove = {}
local command = {}
command['Replace'] = replace
command['Remove'] = remove
command["Force"] = true
local modifiedFile = RestApiPost('/instances/' .. instanceId .. '/modify', DumpJson(command, true))
local uploadResponse = ParseJson(RestApiPost('/instances/', modifiedFile)) ['ID']
if (uploadResponse["Status"] == 'AlreadyStored') then
print("Are you sure you've enabled 'OverwriteInstances' option ?")
end
if (uploadResponse["ID"] ~= instanceId) then
print("modified instance and original instance don't have the same Orthanc IDs !")
end
print('replaced Private Tag in instance ' .. instanceId)
end
end
I’d like to know if this can be done in the core DICOM server. Ideally, the tags would be injected upon receiving images.