diff OrthancServer/OrthancFindRequestHandler.cpp @ 1851:d364926389e0

OrthancFindRequestHandler::FilterQueryTag
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 01 Dec 2015 14:53:52 +0100
parents 30e97a1f4093
children b7d3d3b182cf
line wrap: on
line diff
--- a/OrthancServer/OrthancFindRequestHandler.cpp	Tue Dec 01 14:02:35 2015 +0100
+++ b/OrthancServer/OrthancFindRequestHandler.cpp	Tue Dec 01 14:53:52 2015 +0100
@@ -88,6 +88,16 @@
   }
 
 
+
+  bool OrthancFindRequestHandler::FilterQueryTag(std::string& value /* can be modified */,
+                                                 ResourceType level,
+                                                 const DicomTag& tag,
+                                                 ModalityManufacturer manufacturer)
+  {
+    return true;
+  }
+
+
   void OrthancFindRequestHandler::Handle(DicomFindAnswers& answers,
                                          const DicomMap& input,
                                          const std::string& remoteIp,
@@ -105,8 +115,6 @@
       throw OrthancException(ErrorCode_UnknownModality);
     }
 
-    // ModalityManufacturer manufacturer = modality.GetManufacturer();
-
     bool caseSensitivePN = Configuration::GetGlobalBoolParameter("CaseSensitivePN", false);
 
 
@@ -119,6 +127,7 @@
         levelTmp->IsNull() ||
         levelTmp->IsBinary())
     {
+      LOG(ERROR) << "C-FIND request without the tag 0008,0052 (QueryRetrieveLevel)";
       throw OrthancException(ErrorCode_BadRequest);
     }
 
@@ -171,17 +180,25 @@
         continue;
       }
 
-      ValueRepresentation vr = FromDcmtkBridge::GetValueRepresentation(tag);
+      if (FilterQueryTag(value, level, tag, modality.GetManufacturer()))
+      {
+        ValueRepresentation vr = FromDcmtkBridge::GetValueRepresentation(tag);
 
-      // DICOM specifies that searches must be case sensitive, except
-      // for tags with a PN value representation
-      bool sensitive = true;
-      if (vr == ValueRepresentation_PatientName)
+        // DICOM specifies that searches must be case sensitive, except
+        // for tags with a PN value representation
+        bool sensitive = true;
+        if (vr == ValueRepresentation_PatientName)
+        {
+          sensitive = caseSensitivePN;
+        }
+
+        finder.AddDicomConstraint(tag, value, sensitive);
+      }
+      else
       {
-        sensitive = caseSensitivePN;
+        LOG(INFO) << "Because of a patch for the manufacturer of the remote modality, " 
+                  << "ignoring constraint on tag (" << tag.Format() << ") " << FromDcmtkBridge::GetName(tag);
       }
-
-      finder.AddDicomConstraint(tag, value, sensitive);
     }