Auto routing with OnStableStudy

Hello,
I’ve been using Orthanc as an auto-router to cloud storage as well as a local back-up for 4 years now. I would like to be able to route the incoming studies in one block instead of instance-by-instance. I have been trying to convert my existing auto-route Lua using onStableStudy instead of onStoredInstance but have not been successful. Also, I use the origin parameter for parsing certain studies and see that it isn’t listed as a parameter in the onStoredInstance documentation (at least that I can find).

here is my current auto-routing code, if it helps:

function OnStoredInstance(instanceId, tags, metadata, origin)

– Extract the value of the “PatientName” DICOM tag

local patientName= string.lower(tags[‘PatientName’])

–Do not send out exams received from MIM (192.168.6.41)
if origin[‘RemoteIp’] ~= ‘192.168.6.41’ then
print(‘onStoredInstance function has been called’)
SendToModality(instanceId, ‘03-MIMCLOUD’)
print(patientName…’ image sent to Mim’)
SendToModality(instanceId, ‘08-RADIUS’)
print(patientName…’ image sent to Radius’)
SendToModality(instanceId, ‘09-MIM-CD’)
print(patientName…’ image sent to Front Desk Archive’)
end

–Only route CT SCANS to MEDICVISION
if origin[‘RemoteIp’] == ‘192.168.6.10’ then
print(‘CT scan found’)
SendToModality(instanceId, ‘13-MEDICVISION’)
print(‘CT image sent to MEDICVISION’)
end

Thanks for any help!
Jason McDonald

print(‘SendToModality has been executed’)
end

Hi,

I think there’s no origin at the study level because multiple instances from the same study could originate from multiple sources (i.e a few series from the modality and a few series from the radiology workstation).

I would advise you to define a new metadata “my-origin”.
In the OnStoredInstance, get the origin of the instance and attach it as the “my-origin” of the study.
In the OnStableStudy, read the “my-origin” metadata from the study to perform your auto-routing.

Best,

Alain

I was about to ask how to get the origin from OnStableStudy. I think this is the way to do it. Do you have a sample code doing this?
Also when you say “In the OnStoredInstance, get the origin of the instance and attach it as the “my-origin” of the study.” this will insert the origin in the study for each dicom received. I think will be wise, if you know the whole study is received from one modality, to do this operation one time, at first dicom received from the study.
I need to know the origin of a study as I will do some processing on the study data then I need to know where to send back the results.