How do I have the LUA script log the accession number?

We use a LUA routing script, and I’d like the log file to show the accession number instead of, or in addition to the InstanceID in the logs.

Current script:

function OnStoredInstance(instanceId, tags, metadata, origin)
print('*—Routing instanceId: ', instanceId)

Output:

Lua says: *—Routing instanceId: , 7bcafb85-f0c19996-0fc6a0eb-a43788cf-ed7e350a

Attempted script:

function OnStoredInstance(instanceId, tags, metadata, origin)
print('*—Routing instanceId: ', instanceId, Accession, AccessionNumber)

Output:

Lua says: *—Routing instanceId: , 7bcafb85-f0c19996-0fc6a0eb-a43788cf-ed7e350a, nil, nil

What do I need to change to make this work?

Thanks!

Hello. You can extract all DICOM tags from the tags object. For example:

tags[‘AccessionNumber’]

tags[‘PatientName’]
tags[‘StudyInstanceUID’]
PrintRecursive(tags)

A GET request like this to your Orthanc will show all possible instance tags.
$ORTHANC_ROOT/instances/1363a999-7fce2558-b793f56c-0c71584e-3b55edb2/tags?simplify
https://demo.orthanc-server.com/instances/1363a999-7fce2558-b793f56c-0c71584e-3b55edb2/tags?simplify

However, I recommend using Python scripts instead of Lua: https://book.orthanc-server.com/plugins/python.html

A quarta-feira, 4 de maio de 2022 à(s) 17:49:39 UTC+1, dustin...@gmail.com escreveu:

Excellent, thank you.

print('*—Routing instanceId: ', instanceId, tags[‘AccessionNumber’])

Worked!

This is just part of the auto-routing script we use. I’m not much of a programmer, it’s a tall order to change the language at this point.