Auto-Routing lua script

2,707 views
Skip to first unread message

vijendr...@gmail.com

unread,
Jul 7, 2015, 9:22:28 AM7/7/15
to orthan...@googlegroups.com
Hi,

Sorry for the beginner question. I am new to lua. I am trying to auto-route the files received to other modality server running on the same server.

This is how I have defined in config file.

"isiri" :[ "ISIRI", "localhost", 3020]

"LuaScripts" : ["/home/radio/auto_routing.lua"],

This is the content of my auto_routing.lua file.

function OnStoredInstance(instanceId, tags, metadata)
Delete(SendToModality(instanceId, 'isiri'))
end


I have installed lua on my ubuntu machine. Also I can forward/send to "isiri" from web interface. But automatically it is not happening. Can you please suggest, if I have missed something.

Thanks

Emsy Chan

unread,
Jul 7, 2015, 8:30:27 PM7/7/15
to orthan...@googlegroups.com, vijendr...@gmail.com
Hi,

I only know some basic Lua scripting for Orthanc, but your syntax looks correct.

Have you checked that the function is actually being called? Easiest way is to add a print and check the Orthanc output.

function OnStoredInstance(instanceId, tags, metadata)
   print('onStoredInstance function has been called')
   Delete(SendToModality(instanceId, 'isiri'))
   print('SendToModality has been executed')
end

Regards,
Em

vijendr...@gmail.com

unread,
Jul 8, 2015, 2:41:19 AM7/8/15
to orthan...@googlegroups.com, vijendr...@gmail.com
Thanks. I have checked logs in /var/log/orthanc folder.

3 files are created for today's date. And on log.INFO file it shows lua script is installed like below.

W0708 05:10:05.787369 5748 main.cpp:338] Installing the Lua scripts from: /home/radiology/auto_routing.lua

And on log.ERROR following error is recorded.

Log line format: [IWEF]mmdd hh:mm:ss.uuuuuu threadid file:line] msg
E0708 05:27:51.112529 5759 MongooseServer.cpp:711] MongooseServer Exception [Internal error]

This could be the reason for auto route failure. Please suggest.

Emsy Chan

unread,
Jul 8, 2015, 3:31:57 AM7/8/15
to orthan...@googlegroups.com, vijendr...@gmail.com
Hi,

If I read correctly, MongooseServer is the HTTP server part of Orthanc. Line 711 corresponds to a 404 error. I'm not a C programmer, but I don't think that auto-routing is going to call the HTTP server.

Your config uses the directory of "radio" whereas the output is "radiology". Is this significant?

Experimented with your script, and my Orthanc outputs this:
W0708 15:27:11.755973  8008 main.cpp:362] Installing the Lua scripts from: .\./auto_routing.lua
W0708 15:27:11.755973  8008 ServerIndex.cpp:1326] No limit on the number of stored patients
W0708 15:27:11.755973  8008 ServerIndex.cpp:1343] No limit on the size of the storage area
W0708 15:27:11.755973  8008 MongooseServer.cpp:921] HTTP keep alive is disabled
W0708 15:27:11.755973  8008 OrthancInitialization.cpp:776] Storage directory: ".\OrthancStorage"
W0708 15:27:11.771595  8008 main.cpp:519] HTTP server listening on port: 8042
W0708 15:27:11.818461  8008 main.cpp:529] DICOM server listening on port: 4242
W0708 15:27:11.818461  8008 main.cpp:536] Orthanc has started
W0708 15:27:22.878767 11032 LuaContext.cpp:89] Lua says: onStoredInstance function has been called
W0708 15:27:22.878767 11032 LuaContext.cpp:89] Lua says: SendToModality has been executed

I have no problems using the script as is. Auto-routing is successful.

Can you confirm whether Orthanc outputs the last 2 lines (Lua says: ***) as above?

vijendr...@gmail.com

unread,
Jul 8, 2015, 3:42:05 AM7/8/15
to orthan...@googlegroups.com, vijendr...@gmail.com
Thanks for the help. Sorry, that is changed to radiology. Here is the content of log.INFO file.

Log line format: [IWEF]mmdd hh:mm:ss.uuuuuu threadid file:line] msg

W0708 05:10:05.781128 5748 OrthancInitialization.cpp:62] Using the configuration from: /etc/orthanc/orthanc.json
W0708 05:10:05.787314 5748 main.cpp:327] Storage directory: "/var/lib/orthanc/db-v3"
W0708 05:10:05.787338 5748 main.cpp:328] Index directory: "/var/lib/orthanc/db-v3"
W0708 05:10:05.787351 5748 ServerContext.cpp:76] Disk compression is disabled


W0708 05:10:05.787369 5748 main.cpp:338] Installing the Lua scripts from: /home/radiology/auto_routing.lua

W0708 05:10:05.787451 5748 ServerIndex.cpp:1034] No limit on the number of stored patients
W0708 05:10:05.787549 5748 ServerIndex.cpp:1051] No limit on the size of the storage area
W0708 05:10:05.787816 5748 main.cpp:400] DICOM server listening on port: 4242
W0708 05:10:05.787843 5748 main.cpp:401] HTTP server listening on port: 8042
W0708 05:10:05.792481 5763 DicomServer.cpp:86] Loading the external DICOM dictionary "/usr/share/libdcmtk2/dicom.dic"
W0708 05:10:05.808430 5763 DicomServer.cpp:86] Loading the external DICOM dictionary "/usr/share/libdcmtk2/private.dic"
W0708 05:10:05.842730 5748 main.cpp:415] Orthanc has started


E0708 05:27:51.112529 5759 MongooseServer.cpp:711] MongooseServer Exception [Internal error]

--------------------------

It is not logging below lines.

print('onStoredInstance function has been called')

Emsy Chan

unread,
Jul 8, 2015, 3:59:25 AM7/8/15
to orthan...@googlegroups.com, vijendr...@gmail.com
Are you using Orthanc Explorer to upload the DICOM file or are you sending it to Orthanc from another node?

If you are uploading through Orthanc Explorer, there may be a possibility that the 404 error is encountered. In that case, you may want to try sending the DICOM file from another node.

vijendr...@gmail.com

unread,
Jul 8, 2015, 8:40:21 AM7/8/15
to orthan...@googlegroups.com, vijendr...@gmail.com
Thanks for those insights. I have tried from both Orthanc Explorer and a local Ruby based dicom client. Files are successfully arrived in orthanc and I can view them from explorer. Also It seems any lua script is not being executed inside orthanc. I have tried just logging the string, like below.

function OnStoredInstance(instanceId, tags, metadata)


print('onStoredInstance function has been called')

end

But no log/warning files inside /var/log/orthanc folder recorded this string. I am running orthanc on a ubuntu machine. I have installed lua and confirmed it works using lua interactive console like below

lua
Lua 5.2.3 Copyright (C) 1994-2013 Lua.org, PUC-Rio


> print('onStoredInstance function has been called')

onStoredInstance function has been called
>

Do I have to do any thing else in orthanc side? I have attached orthanc config file for reference.

Thanks for helping.

orthanc.json

Emsy Chan

unread,
Jul 8, 2015, 8:00:02 PM7/8/15
to orthan...@googlegroups.com, vijendr...@gmail.com
Hi again!

As far as I know, Lua script support in embedded into Orthanc. You don't need to install Lua separately. (At least, I didn't have to in my Windows version.)

Sorry, at the moment, I'm stumped. The Lua script is correct and your Orthanc configuration looks right (I assume that you've changed "isis" in the example above to "teleradiology" based on your config, right?). 

I also can't think of any reason for MongooseServer to fail when receiving an instance.

My last ideas (which don't make much sense) would be that something went wrong with the build or perhaps the other Lua installation is interfering with Orthanc.

You'll probably need help from somebody with Linux experience or wait till Sebastien comes back.

Regards,
Em

vijendr...@gmail.com

unread,
Jul 24, 2015, 12:39:49 AM7/24/15
to Orthanc Users, eml...@yahoo.com
It works fine now. I have removed the version installed by Ubuntu software manager (apt-get) and installed the latest version from source. Guess the Orthanc version was the problem.
Reply all
Reply to author
Forward
0 new messages