changeset 4011:914b15dedae3

fix for non private sequence tags in C-Find
author Alain Mazy <alain@mazy.be>
date Mon, 08 Jun 2020 16:04:29 +0200
parents 884b55ce01f6
children dc6e7c7372ae
files Core/DicomParsing/ParsedDicomFile.cpp OrthancServer/OrthancFindRequestHandler.cpp OrthancServer/OrthancInitialization.cpp
diffstat 3 files changed, 20 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/Core/DicomParsing/ParsedDicomFile.cpp	Sat Jun 06 14:50:21 2020 +0200
+++ b/Core/DicomParsing/ParsedDicomFile.cpp	Mon Jun 08 16:04:29 2020 +0200
@@ -657,6 +657,12 @@
   void ParsedDicomFile::ReplacePlainString(const DicomTag& tag,
                                            const std::string& utf8Value)
   {
+//    if (tag.GetElement() == 4257 && tag.GetGroup() == 1031)
+//    {
+//      Replace(tag, utf8Value, false, DicomReplaceMode_InsertIfAbsent,
+//              "99CZM_CapeCod_OctGeneral");
+//    }
+//    else
     if (tag.IsPrivate())
     {
       throw OrthancException(ErrorCode_InternalError,
--- a/OrthancServer/OrthancFindRequestHandler.cpp	Sat Jun 06 14:50:21 2020 +0200
+++ b/OrthancServer/OrthancFindRequestHandler.cpp	Mon Jun 08 16:04:29 2020 +0200
@@ -303,7 +303,7 @@
                         const DicomArray& query,
                         const std::list<DicomTag>& sequencesToReturn,
                         const DicomMap* counters,
-                        const std::string& privateCreator)
+                        const std::string& defaultPrivateCreator)
   {
     DicomMap match;
 
@@ -373,7 +373,7 @@
     else
     {
       ParsedDicomFile dicom(result, GetDefaultDicomEncoding(),
-                            true /* be permissive, cf. issue #136 */, privateCreator);
+                            true /* be permissive, cf. issue #136 */, defaultPrivateCreator);
 
       for (std::list<DicomTag>::const_iterator tag = sequencesToReturn.begin();
            tag != sequencesToReturn.end(); ++tag)
@@ -396,7 +396,14 @@
             content.append(item);
           }
 
-          dicom.Replace(*tag, content, false, DicomReplaceMode_InsertIfAbsent, privateCreator);
+          if (tag->IsPrivate())
+          {
+            dicom.Replace(*tag, content, false, DicomReplaceMode_InsertIfAbsent, defaultPrivateCreator); // TODO: instead of taking the default private creator, we should get the private createor of the current "group"
+          }
+          else
+          {
+            dicom.Replace(*tag, content, false, DicomReplaceMode_InsertIfAbsent, "" /* no private creator */);
+          }
         }
       }
 
@@ -485,7 +492,7 @@
     const DicomMap&             query_;
     DicomArray                  queryAsArray_;
     const std::list<DicomTag>&  sequencesToReturn_;
-    std::string                 privateCreator_;
+    std::string                 defaultPrivateCreator_;
 
   public:
     LookupVisitor(DicomFindAnswers&  answers,
@@ -504,7 +511,7 @@
 
       {
         OrthancConfiguration::ReaderLock lock;
-        privateCreator_ = lock.GetConfiguration().GetDefaultPrivateCreator();
+        defaultPrivateCreator_ = lock.GetConfiguration().GetDefaultPrivateCreator();
       }
     }
 
@@ -547,7 +554,7 @@
       std::unique_ptr<DicomMap> counters(ComputeCounters(context_, instanceId, level_, query_));
 
       AddAnswer(answers_, mainDicomTags, dicomAsJson,
-                queryAsArray_, sequencesToReturn_, counters.get(), privateCreator_);
+                queryAsArray_, sequencesToReturn_, counters.get(), defaultPrivateCreator_);
     }
   };
 
--- a/OrthancServer/OrthancInitialization.cpp	Sat Jun 06 14:50:21 2020 +0200
+++ b/OrthancServer/OrthancInitialization.cpp	Mon Jun 08 16:04:29 2020 +0200
@@ -162,7 +162,7 @@
           (content.size() >= 4 && content[3].type() != Json::intValue) ||
           (content.size() >= 5 && content[4].type() != Json::stringValue))
       {
-        throw OrthancException(ErrorCode_BadFileFormat);
+        throw OrthancException(ErrorCode_BadFileFormat, "The definition of the '" + tags[i] + "' dictionary entry is invalid.");
       }
 
       DicomTag tag(FromDcmtkBridge::ParseTag(tags[i]));