diff OrthancServer/Sources/OrthancFindRequestHandler.cpp @ 4143:1ec3e1e18f50

Add missing tag "Retrieve AE Title (0008,0054)" in C-FIND SCP responses
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 14 Aug 2020 08:19:02 +0200
parents c02a2d9efbc2
children 318c16cfccab
line wrap: on
line diff
--- a/OrthancServer/Sources/OrthancFindRequestHandler.cpp	Thu Aug 13 17:44:39 2020 +0200
+++ b/OrthancServer/Sources/OrthancFindRequestHandler.cpp	Fri Aug 14 08:19:02 2020 +0200
@@ -304,7 +304,8 @@
                         const std::list<DicomTag>& sequencesToReturn,
                         const DicomMap* counters,
                         const std::string& defaultPrivateCreator,
-                        const std::map<uint16_t, std::string>& privateCreators)
+                        const std::map<uint16_t, std::string>& privateCreators,
+                        const std::string& retrieveAet)
   {
     DicomMap match;
 
@@ -319,6 +320,13 @@
     
     DicomMap result;
 
+    /**
+     * Add the mandatory "Retrieve AE Title (0008,0054)" tag, which was missing in Orthanc <= 1.7.2.
+     * http://dicom.nema.org/medical/dicom/current/output/html/part04.html#sect_C.4.1.1.3.2
+     * https://groups.google.com/g/orthanc-users/c/-7zNTKR_PMU/m/kfjwzEVNAgAJ
+     **/
+    result.SetValue(DICOM_TAG_RETRIEVE_AE_TITLE, retrieveAet, false /* not binary */);
+
     for (size_t i = 0; i < query.GetSize(); i++)
     {
       if (query.GetElement(i).GetTag() == DICOM_TAG_QUERY_RETRIEVE_LEVEL)
@@ -504,6 +512,7 @@
     const std::list<DicomTag>&  sequencesToReturn_;
     std::string                 defaultPrivateCreator_;       // the private creator to use if the group is not defined in the query itself
     const std::map<uint16_t, std::string>& privateCreators_;  // the private creators defined in the query itself
+    std::string                 retrieveAet_;
 
   public:
     LookupVisitor(DicomFindAnswers&  answers,
@@ -525,6 +534,7 @@
       {
         OrthancConfiguration::ReaderLock lock;
         defaultPrivateCreator_ = lock.GetConfiguration().GetDefaultPrivateCreator();
+        retrieveAet_ = lock.GetConfiguration().GetOrthancAET();
       }
     }
 
@@ -566,8 +576,8 @@
     {
       std::unique_ptr<DicomMap> counters(ComputeCounters(context_, instanceId, level_, query_));
 
-      AddAnswer(answers_, mainDicomTags, dicomAsJson,
-                queryAsArray_, sequencesToReturn_, counters.get(), defaultPrivateCreator_, privateCreators_);
+      AddAnswer(answers_, mainDicomTags, dicomAsJson, queryAsArray_, sequencesToReturn_,
+                counters.get(), defaultPrivateCreator_, privateCreators_, retrieveAet_);
     }
   };