changeset 1851:d364926389e0

OrthancFindRequestHandler::FilterQueryTag
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 01 Dec 2015 14:53:52 +0100
parents 68854412c7bc
children efbc3afd6cd3
files OrthancServer/OrthancFindRequestHandler.cpp OrthancServer/OrthancFindRequestHandler.h OrthancServer/main.cpp
diffstat 3 files changed, 34 insertions(+), 11 deletions(-) [+]
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);
     }
 
 
--- a/OrthancServer/OrthancFindRequestHandler.h	Tue Dec 01 14:02:35 2015 +0100
+++ b/OrthancServer/OrthancFindRequestHandler.h	Tue Dec 01 14:53:52 2015 +0100
@@ -47,6 +47,11 @@
     bool HasReachedLimit(const DicomFindAnswers& answers,
                          ResourceType level) const;
 
+    bool FilterQueryTag(std::string& value /* can be modified */,
+                        ResourceType level,
+                        const DicomTag& tag,
+                        ModalityManufacturer manufacturer);
+
   public:
     OrthancFindRequestHandler(ServerContext& context) :
       context_(context), 
--- a/OrthancServer/main.cpp	Tue Dec 01 14:02:35 2015 +0100
+++ b/OrthancServer/main.cpp	Tue Dec 01 14:53:52 2015 +0100
@@ -748,7 +748,8 @@
   dicomServer.SetApplicationEntityFilter(dicomFilter);
 
   dicomServer.Start();
-  LOG(WARNING) << "DICOM server listening on port: " << dicomServer.GetPortNumber();
+  LOG(WARNING) << "DICOM server listening with AET " << dicomServer.GetApplicationEntityTitle() 
+               << " on port: " << dicomServer.GetPortNumber();
 
   bool restart;
   ErrorCode error = ErrorCode_Success;