Filter some params of a C-FIND on the Orthanc side

443 views
Skip to first unread message

Raúl Alexis Betancor Santana

unread,
Dec 10, 2015, 3:06:56 PM12/10/15
to orthan...@googlegroups.com


I need to filter one param of a C-FIND query that a DICOM client sends.

Thats because a very good Dicom Client that wants to use on the hospital, but it supposed to only work with 'their' PACS, making some test, I have seen that the only diference beetween what they send and a 'normal' C-FIND, it's that they add to the query this:

OrthancFindRequestHandler.cpp:214]   (5555,0010)  PrivateCreator = AETMED RETRIEVE INFO

Is there any way to tell Orthanc to ignore that Param ?

Best regards

Marc Delpont

unread,
Dec 11, 2015, 8:15:39 AM12/11/15
to Orthanc Users
Why not a Lua function for debuging, filtering and/or tuning a received C-FIND query before applying it ?
It could be applied to both Q/R and Worklist C-FIND queries.

Robert van Ommen

unread,
Dec 11, 2015, 8:31:11 AM12/11/15
to Orthanc Users
That would be really nice!
That way you do not have to make/compile a new Orthanc version for every "non conforming" DICOM modality.

Sébastien Jodogne

unread,
Dec 11, 2015, 10:43:56 AM12/11/15
to Orthanc Users
I found Marc's idea so nice that I have immediately implemented it:

Here is a sample Lua script that would solve Raúl's issue:

function IncomingFindRequestFilter(source, origin)
   PrintRecursive(source)
   PrintRecursive(origin)
   local v = source
   v['5555,0010'] = nil
   return v
end

Marc Delpont

unread,
Dec 11, 2015, 12:29:13 PM12/11/15
to Orthanc Users
Excellent !!!

Raúl Alexis Betancor Santana

unread,
Dec 11, 2015, 12:30:02 PM12/11/15
to orthan...@googlegroups.com
Thats fantastic!! ... I'm testing it ...

I have never used lua scripts before, did I need to setup any option, more than declaring the script on the orthanc.json file ?

Sébastien Jodogne

unread,
Dec 11, 2015, 12:35:46 PM12/11/15
to Orthanc Users
Great ;)

You only have to declare the path to the Lua script in the section "LuaScripts" of the configuration file.

Raúl Alexis Betancor Santana

unread,
Dec 11, 2015, 12:38:27 PM12/11/15
to orthan...@googlegroups.com
Done, but I don't see on the log any reference as the script been executed when the query come into the Orthan server

Sébastien Jodogne

unread,
Dec 11, 2015, 12:41:27 PM12/11/15
to Orthanc Users
It should, because of the PrintRecursive() that will write to the log.

Are you sure the "LuaScripts" section is properly configured? You should see a line "Installing the Lua scripts from..." in the log.

Raúl Alexis Betancor Santana

unread,
Dec 11, 2015, 12:44:30 PM12/11/15
to orthan...@googlegroups.com
[...]
main.cpp:598] Installing the Lua scripts from: /home/orthanc/scripts/filterAEMED.lua
[...]

But when the query comes ... anything printed ...

[...]
I1211 18:30:28.050170 main.cpp:120] No limit on the number of C-FIND results at the Patient, Study and Series levels
I1211 18:30:28.050223 main.cpp:130] No limit on the number of C-FIND results at the Instance level
I1211 18:30:28.087647 OrthancFindRequestHandler.cpp:208] DICOM C-Find request at level: Study
I1211 18:30:28.087720 OrthancFindRequestHandler.cpp:214]   (0008,0020)  StudyDate =
I1211 18:30:28.087807 OrthancFindRequestHandler.cpp:214]   (0008,0030)  StudyTime =
I1211 18:30:28.087882 OrthancFindRequestHandler.cpp:214]   (0008,0050)  AccessionNumber =
I1211 18:30:28.087959 OrthancFindRequestHandler.cpp:214]   (0008,0052)  QueryRetrieveLevel = STUDY
I1211 18:30:28.088039 OrthancFindRequestHandler.cpp:214]   (0008,0056)  InstanceAvailability =
I1211 18:30:28.088115 OrthancFindRequestHandler.cpp:214]   (0008,0061)  ModalitiesInStudy =
I1211 18:30:28.088190 OrthancFindRequestHandler.cpp:214]   (0008,0090)  ReferringPhysicianName =
I1211 18:30:28.088266 OrthancFindRequestHandler.cpp:214]   (0008,1030)  StudyDescription =
I1211 18:30:28.088339 OrthancFindRequestHandler.cpp:214]   (0010,0010)  PatientName =
I1211 18:30:28.088412 OrthancFindRequestHandler.cpp:214]   (0010,0020)  PatientID =
I1211 18:30:28.088487 OrthancFindRequestHandler.cpp:214]   (0010,0030)  PatientBirthDate =
I1211 18:30:28.088566 OrthancFindRequestHandler.cpp:214]   (0010,0040)  PatientSex =
I1211 18:30:28.088639 OrthancFindRequestHandler.cpp:214]   (0020,000d)  StudyInstanceUID =
I1211 18:30:28.088714 OrthancFindRequestHandler.cpp:214]   (0020,0010)  StudyID =
I1211 18:30:28.088790 OrthancFindRequestHandler.cpp:214]   (0020,1206)  NumberOfStudyRelatedSeries =
I1211 18:30:28.088865 OrthancFindRequestHandler.cpp:214]   (0020,1208)  NumberOfStudyRelatedInstances =
I1211 18:30:28.088947 OrthancFindRequestHandler.cpp:214]   (5555,0010)  PrivateCreator = AETMED RETRIEVE INFO
T1211 18:30:28.089229 Statement.cpp:144] SQLite::Statement::Step SELECT internalId FROM Resources WHERE resourceType=?
T1211 18:30:28.089335 Statement.cpp:144] SQLite::Statement::Step SELECT internalId FROM Resources WHERE resourceType=?
T1211 18:30:28.089469 Statement.cpp:144] SQLite::Statement::Step SELECT resourceType FROM Resources WHERE internalId=?
T1211 18:30:28.089665 Statement.cpp:144] SQLite::Statement::Step SELECT a.internalId FROM Resources AS a, Resources AS b  WHERE a.parentId = b.internalId AND b.internalId = ?
[...]

Sébastien Jodogne

unread,
Dec 11, 2015, 12:47:25 PM12/11/15
to Orthanc Users
What is the exact content of:
/home/orthanc/scripts/filterAEMED.lua

?

Raúl Alexis Betancor Santana

unread,
Dec 11, 2015, 12:48:00 PM12/11/15
to orthan...@googlegroups.com
function IncomingFindRequestFilter(source, origin)
   PrintRecursive(source)
   PrintRecursive(origin)
   local v = source
   v['5555,0010'] = nil
   return v
end

Sébastien Jodogne

unread,
Dec 11, 2015, 12:53:57 PM12/11/15
to Orthanc Users
Here is what I get in the log by copy/pasting your script:

I1211 18:52:15.373115 CommandDispatcher.cpp:491] Association Received from AET ORTHANCTEST on IP 127.0.0.1
I1211 18:52:15.373607 CommandDispatcher.cpp:689] Association Acknowledged (Max Send PDV: 16372)
I1211 18:52:15.374139 main.cpp:120] No limit on the number of C-FIND results at the Patient, Study and Series levels
I1211 18:52:15.374190 main.cpp:130] No limit on the number of C-FIND results at the Instance level
W1211 18:52:15.374629 LuaContext.cpp:103] Lua says: table
W1211 18:52:15.374715 LuaContext.cpp:103] Lua says:     [0010,0020], string, 
W1211 18:52:15.374745 LuaContext.cpp:103] Lua says:     [0008,0052], string, PATIENT
W1211 18:52:15.374788 LuaContext.cpp:103] Lua says: table
W1211 18:52:15.374852 LuaContext.cpp:103] Lua says:     [CalledAet], string, ORTHANC
W1211 18:52:15.374927 LuaContext.cpp:103] Lua says:     [RemoteIp], string, 127.0.0.1
W1211 18:52:15.374997 LuaContext.cpp:103] Lua says:     [RemoteAet], string, ORTHANCTEST
I1211 18:52:15.375110 OrthancFindRequestHandler.cpp:289] DICOM C-Find request at level: Patient
I1211 18:52:15.375189 OrthancFindRequestHandler.cpp:295]   (0008,0052)  QueryRetrieveLevel = PATIENT
I1211 18:52:15.375254 OrthancFindRequestHandler.cpp:295]   (0010,0020)  PatientID = 
I1211 18:52:15.392323 OrthancFindRequestHandler.cpp:388] Number of matching resources: 3
I1211 18:52:15.393621 CommandDispatcher.cpp:860] DUL Peer Requested Release
I1211 18:52:15.393725 CommandDispatcher.cpp:867] Association Release


After issuing the following command:

# findscu -P -aet ORTHANCTEST -aec ORTHANC localhost 4000 -k 0008,0052=PATIENT -k 0010,0020


I highly suspect that you are not running the latest version of the mainline Orthanc. Please be sure to pull, update to the mainline branch, and to rebuild.

Raúl Alexis Betancor Santana

unread,
Dec 11, 2015, 1:10:25 PM12/11/15
to orthan...@googlegroups.com
EUREKA!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Now an artificially closed Dicom Viewer, could be used with Orthan as PACS!!! ..

Awesome!, just Awesome man! ..

Thankssssssssssssssssssssss!

2015-12-11 18:00 GMT+00:00 Raúl Alexis Betancor Santana <rbet...@gmail.com>:
Jeje ..., ok ... that explains the lack of logs .. XDD

2015-12-11 17:57 GMT+00:00 Sébastien Jodogne <s.jo...@gmail.com>:
I pushed the change only 2 hours ago :)

So, this feature is only in the mainline and you will have to clone from BitBucket:




On Fri, Dec 11, 2015 at 6:56 PM, Raúl Alexis Betancor Santana <rbet...@gmail.com> wrote:
W1211 18:56:55.113220 main.cpp:1129] Orthanc version: 0.9.6

From .tar.gz as yesterday ... build as 

cmake .. -DCMAKE_BUILD_TYPE=Debug -DALLOW_DOWNLOADS=ON -DSTATIC_BUILD=ON

Nikos Kakouros

unread,
Jan 21, 2017, 5:50:48 PM1/21/17
to Orthanc Users
What's this awesome closed DICOM viewer? Still trying to decide what to deploy and would like to try it (even if it takes installing the lua script)
Reply all
Reply to author
Forward
0 new messages