Changing the Filename when downloading a Study/Series

To make it easier for the user to identify the downloaded files i’m hoping to change the filename generated by orthanc’s rest api when calling, for example orthanc/studies/ccc04d8a-95705811-090c9e02-383f26a4-f674d803/archive, i’d like the name to use PatientName, StudyDate and AccessionNumber so that the name would be, “Name - Date -” instead of the default “”

How hard would that be? Any tips?

I figured i will probably need to mess with either(or both), OrthancRestArchive.cpp or ArchiveJob.cpp but i’m having a hard time knowing where/how to start since i have no idea of how to actually debug those files since they do not appear under Orthanc’s Solution in Visual Studio, they seem to added as an external reference…


This can be implemented as an Orthanc plugin:

The plugin would:

  1. Call “OrthancPluginRegisterRestCallback()” to overwrite the default behavior of URI “/studies/{id}/archive”.
  2. Download the archive using the core implementation of Orthanc by calling “OrthancPluginRestApiPost()” on “/studies/{id}/archive”.
  3. Retrieve the PatientName, StudyDate and AccessionNumber by calling “OrthancPluginRestApiGet()” on URI “/studies/{id}”, in order to compute the filename.
  4. Set the HTTP header “Content-Disposition” with “OrthancPluginSetHttpHeader()” using the computed filename:
  5. Send the archive with “OrthancPluginAnswerBuffer()”.