changeset 1729:54d78925cbb6 db-changes

notes
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 20 Oct 2015 17:39:58 +0200
parents 4941494b5dd8
children b3de74dec2d5
files OrthancServer/DatabaseWrapper.cpp OrthancServer/DatabaseWrapper.h OrthancServer/DatabaseWrapperBase.cpp OrthancServer/DatabaseWrapperBase.h OrthancServer/IDatabaseWrapper.h OrthancServer/ServerToolbox.cpp OrthancServer/ServerToolbox.h Plugins/Engine/OrthancPluginDatabase.cpp Plugins/Engine/OrthancPluginDatabase.h Resources/Configuration.json
diffstat 10 files changed, 66 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/DatabaseWrapper.cpp	Tue Oct 20 15:03:52 2015 +0200
+++ b/OrthancServer/DatabaseWrapper.cpp	Tue Oct 20 17:39:58 2015 +0200
@@ -373,7 +373,7 @@
                   boost::lexical_cast<std::string>(GlobalProperty_DatabaseSchemaVersion) + ";");
       db_.CommitTransaction();
       version_ = 6;
-    }    
+    }
   }
 
 
--- a/OrthancServer/DatabaseWrapper.h	Tue Oct 20 15:03:52 2015 +0200
+++ b/OrthancServer/DatabaseWrapper.h	Tue Oct 20 17:39:58 2015 +0200
@@ -323,6 +323,13 @@
       base_.LookupIdentifierExact(target, level, tag, value);
     }
 
+    virtual void LookupIdentifierWildcard(std::list<int64_t>& target,
+                                          const DicomTag& tag,
+                                          const std::string& value)
+    {
+      base_.LookupIdentifierWildcard(target, tag, value);
+    }
+
     virtual void GetAllMetadata(std::map<MetadataType, std::string>& target,
                                 int64_t id);
 
--- a/OrthancServer/DatabaseWrapperBase.cpp	Tue Oct 20 15:03:52 2015 +0200
+++ b/OrthancServer/DatabaseWrapperBase.cpp	Tue Oct 20 17:39:58 2015 +0200
@@ -677,8 +677,8 @@
            (level == ResourceType_Instance && tag == DICOM_TAG_SOP_INSTANCE_UID));
     
     SQLite::Statement s(db_, SQLITE_FROM_HERE, 
-                        "SELECT d.id FROM DicomIdentifiers as d, Resources as r WHERE "
-                        "d.id = r.internalId AND r.resourceType=? AND d.tagGroup=? AND d.tagElement=? and d.value=?");
+                        "SELECT d.id FROM DicomIdentifiers AS d, Resources AS r WHERE "
+                        "d.id = r.internalId AND r.resourceType=? AND d.tagGroup=? AND d.tagElement=? AND d.value=?");
 
     s.BindInt(0, level);
     s.BindInt(1, tag.GetGroup());
@@ -692,4 +692,13 @@
       target.push_back(s.ColumnInt64(0));
     }
   }
+
+
+  void DatabaseWrapperBase::LookupIdentifierWildcard(std::list<int64_t>& target,
+                                                     const DicomTag& tag,
+                                                     const std::string& value)
+  {
+    // TODO
+    throw OrthancException(ErrorCode_NotImplemented);
+  }
 }
--- a/OrthancServer/DatabaseWrapperBase.h	Tue Oct 20 15:03:52 2015 +0200
+++ b/OrthancServer/DatabaseWrapperBase.h	Tue Oct 20 17:39:58 2015 +0200
@@ -194,6 +194,10 @@
                                ResourceType level,
                                const DicomTag& tag,
                                const std::string& value);
+
+    void LookupIdentifierWildcard(std::list<int64_t>& target,
+                                  const DicomTag& tag,
+                                  const std::string& value);
   };
 }
 
--- a/OrthancServer/IDatabaseWrapper.h	Tue Oct 20 15:03:52 2015 +0200
+++ b/OrthancServer/IDatabaseWrapper.h	Tue Oct 20 17:39:58 2015 +0200
@@ -151,6 +151,29 @@
                                        const DicomTag& tag,
                                        const std::string& value) = 0;
 
+    /**
+     * Primitive for wildcard matching, as defined in DICOM:
+     * http://dicom.nema.org/dicom/2013/output/chtml/part04/sect_C.2.html#sect_C.2.2.2.4
+     * 
+     * "Any occurrence of an "*" or a "?", then "*" shall match any
+     * sequence of characters (including a zero length value) and "?"
+     * shall match any single character. This matching is case
+     * sensitive, except for Attributes with an PN Value
+     * Representation (e.g., Patient Name (0010,0010))."
+     * 
+     * Pay attention to the fact that "*" (resp. "?") generally
+     * corresponds to "%" (resp. "_") in primitive LIKE of SQL. The
+     * values "%", "_", "\" should in the user request should
+     * respectively be escaped as "\%", "\_" and "\\".
+     * 
+     * This matching must be case sensitive: The special case of PN VR
+     * is taken into consideration by normalizing the query string in
+     * method "ServerIndex::LookupIdentifierWildcard()".
+     **/
+    virtual void LookupIdentifierWildcard(std::list<int64_t>& target,
+                                          const DicomTag& tag,
+                                          const std::string& value) = 0;
+
     virtual bool LookupMetadata(std::string& target,
                                 int64_t id,
                                 MetadataType type) = 0;
--- a/OrthancServer/ServerToolbox.cpp	Tue Oct 20 15:03:52 2015 +0200
+++ b/OrthancServer/ServerToolbox.cpp	Tue Oct 20 17:39:58 2015 +0200
@@ -190,7 +190,7 @@
             tag != DICOM_TAG_SOP_INSTANCE_UID &&
             tag != DICOM_TAG_ACCESSION_NUMBER)
         {
-          s = NormalizeIdentifierTag(s);
+          s = NormalizeTagForWildcard(s);
         }
 
         database.SetIdentifierTag(resource, tag, s);
@@ -355,7 +355,7 @@
     }
 
 
-    std::string NormalizeIdentifierTag(const std::string& value)
+    std::string NormalizeTagForWildcard(const std::string& value)
     {
       std::string s = Toolbox::ConvertToAscii(Toolbox::StripSpaces(value));
       Toolbox::ToUpperCase(s);
--- a/OrthancServer/ServerToolbox.h	Tue Oct 20 15:03:52 2015 +0200
+++ b/OrthancServer/ServerToolbox.h	Tue Oct 20 17:39:58 2015 +0200
@@ -60,6 +60,6 @@
                                   IStorageArea& storageArea,
                                   ResourceType level);
 
-    std::string NormalizeIdentifierTag(const std::string& value);
+    std::string NormalizeTagForWildcard(const std::string& value);
   }
 }
--- a/Plugins/Engine/OrthancPluginDatabase.cpp	Tue Oct 20 15:03:52 2015 +0200
+++ b/Plugins/Engine/OrthancPluginDatabase.cpp	Tue Oct 20 17:39:58 2015 +0200
@@ -646,6 +646,15 @@
   }
 
 
+  void OrthancPluginDatabase::LookupIdentifierWildcard(std::list<int64_t>& target,
+                                                       const DicomTag& tag,
+                                                       const std::string& value)
+  {
+    // TODO
+    throw OrthancException(ErrorCode_NotImplemented);
+  }
+
+
   bool OrthancPluginDatabase::LookupMetadata(std::string& target,
                                              int64_t id,
                                              MetadataType type)
--- a/Plugins/Engine/OrthancPluginDatabase.h	Tue Oct 20 15:03:52 2015 +0200
+++ b/Plugins/Engine/OrthancPluginDatabase.h	Tue Oct 20 17:39:58 2015 +0200
@@ -208,6 +208,10 @@
                                        const DicomTag& tag,
                                        const std::string& value);
 
+    virtual void LookupIdentifierWildcard(std::list<int64_t>& target,
+                                          const DicomTag& tag,
+                                          const std::string& value);
+
     virtual bool LookupMetadata(std::string& target,
                                 int64_t id,
                                 MetadataType type);
--- a/Resources/Configuration.json	Tue Oct 20 15:03:52 2015 +0200
+++ b/Resources/Configuration.json	Tue Oct 20 17:39:58 2015 +0200
@@ -258,8 +258,9 @@
   // deleted as new requests are issued.
   "QueryRetrieveSize" : 10,
 
-  // When handling a C-Find SCP request, setting this flag to "false"
-  // will enable case-insensitive match for PN value representation
-  // (such as PatientName). By default, the search is case-insensitive.
+  // When handling a C-Find SCP request, setting this flag to "true"
+  // will enable case-sensitive match for PN value representation
+  // (such as PatientName). By default, the search is
+  // case-insensitive, which does not follow the DICOM standard.
   "CaseSensitivePN" : false
 }