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

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

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.

That would be really nice!
That way you do not have to make/compile a new Orthanc version for every “non conforming” DICOM modality.

I found Marc’s idea so nice that I have immediately implemented it:
https://bitbucket.org/sjodogne/orthanc/commits/512b6e76f5311cfbd71c6d3ceb50671f1ffb5b74

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

Excellent !!!

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 ?

Great :wink:

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

Done, but I don’t see on the log any reference as the script been executed when the query come into the Orthan server

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.

[…]
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 = ?

[…]

What is the exact content of:
/home/orthanc/scripts/filterAEMED.lua

?

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

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.

EUREKA!!!

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

Awesome!, just Awesome man! …

Thankssssssssssssssssssssss!

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)