Problem with LUA Script

I am having issues with a lua script: https://gist.github.com/anonymous/39ba573eabbc5c5e885477704d55c8e8

Whenever a DX, XR, DR, SR, or CT is received, I want to send the images to a dosage monitor.

Here is my error in the log:

I0406 23:33:38.577649 ServerContext.cpp:260] New instance stored
I0406 23:33:38.577712 OrthancPlugins.cpp:942] Plugin making REST GET call on URI /instances/c69ca7b9-baca1d3f-2148747c-6629b43d-d4881972 (built-in API)
E0406 23:33:38.577956 LuaFunctionCall.cpp:107] [string “line”]:5: attempt to index global ‘dicom’ (a nil value)
E0406 23:33:38.578016 ServerContext.cpp:289] Error in the Lua callback while receiving an instance: Cannot execute a Lua command

Simply replace “tags” with “dicom” in the prototype of your function:

– if the modality type is DX, XR, DR, SR, or CT, then it forwards
– a copy of the study to Dose Monitor. US not needed.

function OnStoredInstance(instanceId, dicom, metadata)
if dicom.Modality == ‘DX’ then
SendToModality(instanceId, ‘DoseMon’)
elseif dicom.Modality == ‘XR’ then
SendToModality(instanceId, ‘DoseMon’)
elseif dicom.Modality == ‘DR’ then
SendToModality(instanceId, ‘DoseMon’)
elseif dicom.Modality == ‘CT’ then
SendToModality(instanceId, ‘DoseMon’)
elseif dicom.Modality == ‘SR’ then
SendToModality(instanceId, ‘DoseMon’)
end
end

Thank you, Sébastien, I will try this out!

This worked perfectly, thanks!