# HG changeset patch # User Sebastien Jodogne # Date 1445355598 -7200 # Node ID 54d78925cbb6b8544efed41d44d1e2f79c7e6775 # Parent 4941494b5dd816ec1613d65906d89a7bac3b7f8e notes diff -r 4941494b5dd8 -r 54d78925cbb6 OrthancServer/DatabaseWrapper.cpp --- 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(GlobalProperty_DatabaseSchemaVersion) + ";"); db_.CommitTransaction(); version_ = 6; - } + } } diff -r 4941494b5dd8 -r 54d78925cbb6 OrthancServer/DatabaseWrapper.h --- 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& target, + const DicomTag& tag, + const std::string& value) + { + base_.LookupIdentifierWildcard(target, tag, value); + } + virtual void GetAllMetadata(std::map& target, int64_t id); diff -r 4941494b5dd8 -r 54d78925cbb6 OrthancServer/DatabaseWrapperBase.cpp --- 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& target, + const DicomTag& tag, + const std::string& value) + { + // TODO + throw OrthancException(ErrorCode_NotImplemented); + } } diff -r 4941494b5dd8 -r 54d78925cbb6 OrthancServer/DatabaseWrapperBase.h --- 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& target, + const DicomTag& tag, + const std::string& value); }; } diff -r 4941494b5dd8 -r 54d78925cbb6 OrthancServer/IDatabaseWrapper.h --- 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& target, + const DicomTag& tag, + const std::string& value) = 0; + virtual bool LookupMetadata(std::string& target, int64_t id, MetadataType type) = 0; diff -r 4941494b5dd8 -r 54d78925cbb6 OrthancServer/ServerToolbox.cpp --- 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); diff -r 4941494b5dd8 -r 54d78925cbb6 OrthancServer/ServerToolbox.h --- 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); } } diff -r 4941494b5dd8 -r 54d78925cbb6 Plugins/Engine/OrthancPluginDatabase.cpp --- 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& target, + const DicomTag& tag, + const std::string& value) + { + // TODO + throw OrthancException(ErrorCode_NotImplemented); + } + + bool OrthancPluginDatabase::LookupMetadata(std::string& target, int64_t id, MetadataType type) diff -r 4941494b5dd8 -r 54d78925cbb6 Plugins/Engine/OrthancPluginDatabase.h --- 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& target, + const DicomTag& tag, + const std::string& value); + virtual bool LookupMetadata(std::string& target, int64_t id, MetadataType type); diff -r 4941494b5dd8 -r 54d78925cbb6 Resources/Configuration.json --- 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 }