We need to find a way to track which user uploaded a study in Orthanc. Since Orthanc allows multiple users to upload DICOM studies, we want to determine if there is an API or any other way that can help retrieve this information.
You can define private DICOM tags in your receiving+forwarding orthanc instance. The private tags can be injected by server-side Lua or Python scripts.
Hello,
For each DICOM instance stored into Orthanc through the REST API, Orthanc automatically records the username associated with the HTTP basic access authentication as the HttpUsername
metadata.
For instance:
$ curl -u user:password http://localhost:8042/instances --data-binary @sample.dcm
$ curl http://localhost:8042/instances/19816330-cb02e1cf-df3a8fe8-bf510623-ccefe9f5/metadata/HttpUsername
user
If the DICOM files are received by a more complex mechanism than the plain REST API, you’ll have to implement a plugin (e.g. in Python) that records the username as a custom metadata, depending on the origin of the request. Metadata allows you not to modify the actual DICOM file, which is desirable in most scenarios.
Regards,
Sébastien-
Thank you, @masroor .
I am new in the world of orthanc, i like the idea that you are suggesting. However, i am slightly confused. How can I run my custom script/plugin when any DICOM image uploaded to orthanc. How can read the user name who is trying to upload or send DICOM?
I mean, is there any event that I can subscribe to run the plugin? I see you are mentioning about receiving+forwarding orthanc instance. Can you please help me understand more.
Thank you @jodogne . I am able to get the HttpUsername via API. Appreciate the response.
In my scenario, the data is going to come in complex mechanism. On what event I can invoke plugin, so I can attach the custom tags to the incoming data. Also I should be able to read http headers in that event, so I can see what host it is coming from. I want to attach custom metadata as the username, who send this data.
Is this possible. I am new in the world of Orthanc. Your guidance is appreciated.
You can for instance extend the built-in REST API of Orthanc using Python.
You can access the HTTP headers in the callbacks registered using orthanc.RegisterRestCallback()
. It is up to your reverse proxy or application to properly fill the necessary HTTP headers.
As explained above, don’t “attach tags” but use metadata.
Thanks @jodogne . I am able get headers via below method,
def OnInstances(output, uri, **request):
pprint.pprint(request[‘headers’][‘authorization’])