How to debug OnStoredInstance Lua script?

Hi all,

I’m trying to write a Lua script that will allow me to route only the series that are marked “ORIGINAL” in the 0008,008 Image Type tag.

So far I have this:

`

function OnStoredInstance(instanceId, tags, metadata)
– Extract the value of the “ImageType” DICOM tag
local imageType = string.lower(tags[‘ImageType’])

if string.find(imageType, ‘ORIGINAL’) ~= nil then
– Only send instances whose imageType contains “ORIGINAL”
SendToModality(instanceId, ‘OsiriX’)

else
– Delete the instances that are not original
Delete(instanceId)
end
end

`

However, all instances are being deleted! How can I gain some more visibility on what the script is doing (why it’s not matching anything) ?

Thanks!

Simon

OOPS Sorry. I figured it out. I was matching for ‘ORIGINAL’ when I should have been matching for ‘original’, since I am lowercase-ing the tag.