I need to ensure that whenever a user makes a POST request to /tools/find, the results are automatically filtered based on matching the user who initiated the request with the a metadata called “username” at the study level.
I tried using IncomingHttpRequestFilter to intercept /tools/find, but it didn’t work because IncomingHttpRequestFilter can only return true or false, which isn’t sufficient for this task.
Instead, I created a Lua function that calls the /tools/find endpoint and applies a query to filter the results based on the metadata. However, I’m facing a challenge: I cannot retrieve the username of the user who calls this function.
Do you have any ideas on how to achieve this? Your help would be greatly appreciated!
tools/find route is internal Orthanc implementation. I do not think you can overwrite that route, except that you change the source code and recompile it. Another way is to develop another route and wrap it around the /tools/find then you can filter what ever you want. But I am not sure it’s suitable for your usecase
Hey Ben,
Thank you for pointing me in the right direction as usual! Your advice helped, and I successfully implemented a callback for /tools/find.
I noticed that ordering and filtering based on metadata were not available in my setup. To address this, I upgraded Orthanc by changing the base image to FROM jodogne/orthanc:1.12.6.
Unfortunately, after upgrading, the plugin fails to load with the following error:
“E0222 19:11:17.798813 MAIN SharedLibrary.cpp:99] dlopen(/usr/local/share/orthanc/plugins/libOrthancPython.so) failed: Error libpython3.7m.so.1.0: cannot open shared object file: No such file or directory”
It seems the plugin is looking for libpython3.7m.so.1.0, which is missing in the updated image.
Note that, if you are using PostgreSQL, you need to switch to orthancteam/orthanc:25.1.1 since the jodogne/orthanc images are still using an older version of the PG plugin.
If you want to use python, you need to use either the jodogne/orthanc-python image or orthancteam/orthanc images.
Many thanks, @alainmazy and @benjamin.golinvaux (the best team ever)!
Apologies for not being available to provide feedback in the past days.
I will try again today and keep you posted.