# HG changeset patch # User Alain Mazy # Date 1768319033 -3600 # Node ID 72aca3bddaf76aa8b06f4195be5748747bd05203 # Parent da36804105e3a1fea409fdac0c17bfc2cd1ce024 fix LookupIdentifierExact to differentiate e.g '1234' and '_1234' diff -r da36804105e3 -r 72aca3bddaf7 NEWS --- a/NEWS Mon Jan 12 18:46:50 2026 +0100 +++ b/NEWS Tue Jan 13 16:43:53 2026 +0100 @@ -14,7 +14,6 @@ * Fixed a security issue where one could hijack HTTP headers in the response through the `filename` argument of "/.../file" or "/.../archive" routes. - Maintenance ----------- @@ -22,6 +21,8 @@ applied to C-FIND (bug introduced in 1.12.5). * Allow executing multiple "/queries/../answers/../retrieve" in parallel https://discourse.orthanc-server.org/t/synchronous-jobs-limited-to-one-at-a-time/6365 +* Fix /tools/lookup and OrthancPluginLookupPatient that were considering '1234', '_1234' and '%1234' + as the same PatientID. * Upgraded dependencies for static builds: - boost 1.89.0 - dcmtk 3.7.0 diff -r da36804105e3 -r 72aca3bddaf7 OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp --- a/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp Mon Jan 12 18:46:50 2026 +0100 +++ b/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp Tue Jan 13 16:43:53 2026 +0100 @@ -1210,10 +1210,19 @@ FindRequest request(level); - DicomTagConstraint c(tag, ConstraintType_Equal, value, true, true); - - bool isIdentical; // unused - request.GetDicomTagConstraints().AddConstraint(c.ConvertToDatabaseConstraint(isIdentical, level, DicomTagType_Identifier)); + DicomTagConstraint c(tag, ConstraintType_Equal, value, false /* case sensitivity */, true /* mandatory */); + + bool isIdentical; + + std::unique_ptr dbConstraint(c.ConvertToDatabaseConstraint(isIdentical, level, DicomTagType_Identifier)); // first try to look in the identifier table (that is faster !) + + if (!isIdentical) // if an exact match can not be ensured because some values contained characters that are removed from the DicomIdentifier table during normalization, + // search in the MainDicomTags table instead. + { + dbConstraint.reset(c.ConvertToDatabaseConstraint(isIdentical, level, DicomTagType_Main)); + } + + request.GetDicomTagConstraints().AddConstraint(dbConstraint.release()); FindResponse response; ExecuteFind(response, request);