C-MOVE from Lua script

Hi all,
I’m trying to start a C-MOVE using the restAPI. Specifically using the

`
/queries/{id}/answers/{index}/retrieve

`
endpoint.

This works beautifully when I make a POST request to this endpoint from anywhere but not in a lua script on the Orthanc server, specfically in the

`
function IncomingFindRequestFilter(query, origin)

`

using this call:

`
RestApiPost(queryPath … ‘/answers/0/retrieve’, “ORTHANC”)

`

wherequeryPath = "/queries/MY_ID_FROM_PREVIOUS_QUERY"

The PACS server sure enough receives the C-MOVE request and tries to send it to Orthanc, but Orthanc (and the lua script just hangs for 15 seconds, and the script continues and no studies are stored.

I suspect it is because Orthanc is already busy running this lua script, so it doesn’t have a free thread for handling the incoming DICOM data.

Any ideas are greatly appreciated.

Context: I’m using Orthanc as a WADO proxy between the OHIF Viewer (https://github.com/OHIF/Viewers) and our local PACS server. The OHIF viewer only speaks WADO/DicomWeb for retrieving images, and out PACS server only speaks DIMSE. So I use Orthanc to handle incoming WADO requests from OHIF and reroute them via DIMSE to our PACS server.
It works great for C-FIND requests, because the response from the PACS server is returned directly in the lua script, but the C-MOVE is another story.

If I can get this to work it will be great way of adding full-fledged DIMSE support to the OHIF viewer. Gotta love Orthanc :slight_smile:

Kind regards,
Emil Johansen
Denmark

Hi Emil,

Indeed, there’s a mutex protecting against concurrent access to the Lua engine therefore you should always avoid lengthy operations inside a Lua script. In your case, when Orthanc receives the first instance through the C-Move, it tries to enter the OnInstanceStored Lua callback which is not possible since you’re already inside a Lua script.

The solution to this is to write a C++ plugin. I remember we started to work on that a few months ago but finally did never complete the job. Our ‘work in progress’ is available in this fork of the DicomWeb plugin: https://bitbucket.org/osimis/orthanc-dicomweb-proxy/commits/all. If you’re interested in finishing the job, you’re welcome … We never actually finished that feature because, anyway, in that particular project, we needed other authentication features that were not generic at all and we ended up writing the proxy in python.