Question and Comment:
- One of the acquisition devices we have does not read StudyDescription from the MWL and the operator normally has to enter that manually, although ‘tags[‘RequestAttributesSequence’][1][‘RequestedProcedureDescription’]’ is set via the MWL. I wrote a first attempt at a Lua script (below) based on an example that seems to work, but there might be a better way and it needs some error checking etc. Basically want to populate [‘0008,1030’] with [‘RequestAttributesSequence’][1][‘RequestedProcedureDescription’] if it is present in an instance when it gets sent to a from a particular AET via DICOM. Might want to add some other similar items down the road. It seems to work, but I only want to do that if:
a. [‘0008,1030’] is not already set.
b. [‘RequestAttributesSequence’][1][‘RequestedProcedureDescription’] is set.
Probably simple to check for those conditions, but I an a novice with Lua scripting, and not clear to me that this is the best way to do that. Also, wondering about performance since it has to create a modified instance, store it, and then delete than old one, rather than just making the change before it is stored the first time. Is it possible to just edit / add a tag before storing it the first time ?
- Also, discovered an MWL plug-in on Github after connecting with the author:
Not sure if that is indexed on the Orthanc site somewhere. Since I am using Custom Docker images, I guess I’d have to compile that when I build the Docker Container, or rewrite it in Python with some modifiations, but could be useful because I’d like to implement MPPS also. Might actually be easier to write a Python script that as suggested here: https://groups.google.com/g/orthanc-users/c/Tec0xgD4s2c
Lua Script
function OnStoredInstance(instanceId, tags, metadata, origin)
– PrintRecursive(instanceId)
– PrintRecursive(tags)
– PrintRecursive(metadata)
– PrintRecursive(origin)
– Do not modify twice the same file
if origin.RequestOrigin == ‘DicomProtocol’ and origin.RemoteAet == ‘SOME_AET’ then
– Need a check here for [‘0008,1030’] not set and tags[‘RequestAttributesSequence’][1][‘RequestedProcedureDescription’] is set.
local replace = {}
replace[‘0008,1030’] = tags[‘RequestAttributesSequence’][1][‘RequestedProcedureDescription’]
local request = {}
request[‘Replace’] = replace
– Create the modified instance
local modified = RestApiPost(‘/instances/’ … instanceId … ‘/modify’,
DumpJson(request, true))
– Upload the modified instance to the Orthanc store
RestApiPost(‘/instances/’, modified)
– Delete the original instance
RestApiDelete(‘/instances/’ … instanceId)
end
end
end