Auto-routing copy instead of delete

I am looking for a way to setup an existing Orthanc instance to auto-route incoming Dicom studies from modalities connected to it, based on “institutionName”, for example, and COPY, not delete the studies to other modalities connected to it.

I have the example from docs:

function OnStoredInstance(instanceId, tags, metadata) – Extract the value of the “PatientName” DICOM tag local patientName = string.lower(tags[‘PatientName’]) if string.find(patientName, ‘david’) ~= nil then – Only route patients whose name contains “David” Delete(SendToModality(instanceId, ‘sample’)) else – Delete the patients that are not called “David” Delete(instanceId) end end

But it extracts the patient name, not the institute name, has only one condition (I want it to decide to what modality to send the study to) and it also, it deletes the study from the server as it routes it to other modality.

Any scripting help would be much appreciated.

Hi,

Don’t hesitate to experiment lua scripting by yourself. The sample script you provided only requires minimal modifications.

function OnStoredInstance(instanceId, tags, metadata)
– Extract the value of the “PatientName” DICOM tag
local patientName = string.lower(tags[‘PatientName’])
if string.find(patientName, ‘david’) ~= nil then
– Only route patients whose name contains “David”
Delete(SendToModality(instanceId, ‘sample’))
else
– Delete the patients that are not called “David”
Delete(instanceId)
end
end

function OnStoredInstance(instanceId, tags, metadata)
– Extract the value of the “PatientName” DICOM tag
local institution = string.lower(tags[‘InstitutionName’])
if string.find(institution, ‘AAA’) ~= nil then
– Route instances for institution AAA
SendToModality(instanceId, ‘modality-a’)
elseif string.find(institution, ‘BBB’) ~= nil then
– Route instances for institution BBB
SendToModality(instanceId, ‘modality-b’)
else
– do nothing
end
end

Disclaimer: not tested

HTH

Alain.

Hello,

After experimenting and trying several different tags, it looks like the command :

SendToModality(instanceId, ‘modality-b’)

Is not sending anything to the modality.

I guess the format should be

COPY(SendToModality(instanceId, ‘modality-b’))

or something else - I do not know what should be the command instead of the originally provided “DELTE” example.

There’s no need for anything like “Copy”. I would advise you to add print statements in order to make sure that your script follows the expected path.

alain.