# HG changeset patch # User Sebastien Jodogne # Date 1733230324 -3600 # Node ID 9b039f4b1421fa28bab8757dfb5cddfc43f22321 # Parent cdb8b2a3aad5dc3c7f65e58a2b63e910a546633c refactoring diff -r cdb8b2a3aad5 -r 9b039f4b1421 OrthancServer/Sources/Database/FindRequest.cpp --- a/OrthancServer/Sources/Database/FindRequest.cpp Sat Nov 30 21:57:48 2024 +0100 +++ b/OrthancServer/Sources/Database/FindRequest.cpp Tue Dec 03 13:52:04 2024 +0100 @@ -290,4 +290,53 @@ !GetLabels().empty() || !GetOrdering().empty()); } + + + bool FindRequest::IsTrivialFind(std::string& publicId /* out */) const + { + if (HasConstraints()) + { + return false; + } + else if (GetLevel() == ResourceType_Patient && + GetOrthancIdentifiers().HasPatientId() && + !GetOrthancIdentifiers().HasStudyId() && + !GetOrthancIdentifiers().HasSeriesId() && + !GetOrthancIdentifiers().HasInstanceId()) + { + publicId = GetOrthancIdentifiers().GetPatientId(); + return true; + } + else if (GetLevel() == ResourceType_Study && + !GetOrthancIdentifiers().HasPatientId() && + GetOrthancIdentifiers().HasStudyId() && + !GetOrthancIdentifiers().HasSeriesId() && + !GetOrthancIdentifiers().HasInstanceId()) + { + publicId = GetOrthancIdentifiers().GetStudyId(); + return true; + } + else if (GetLevel() == ResourceType_Series && + !GetOrthancIdentifiers().HasPatientId() && + !GetOrthancIdentifiers().HasStudyId() && + GetOrthancIdentifiers().HasSeriesId() && + !GetOrthancIdentifiers().HasInstanceId()) + { + publicId = GetOrthancIdentifiers().GetSeriesId(); + return true; + } + else if (GetLevel() == ResourceType_Instance && + !GetOrthancIdentifiers().HasPatientId() && + !GetOrthancIdentifiers().HasStudyId() && + !GetOrthancIdentifiers().HasSeriesId() && + GetOrthancIdentifiers().HasInstanceId()) + { + publicId = GetOrthancIdentifiers().GetInstanceId(); + return true; + } + else + { + return false; + } + } } diff -r cdb8b2a3aad5 -r 9b039f4b1421 OrthancServer/Sources/Database/FindRequest.h --- a/OrthancServer/Sources/Database/FindRequest.h Sat Nov 30 21:57:48 2024 +0100 +++ b/OrthancServer/Sources/Database/FindRequest.h Tue Dec 03 13:52:04 2024 +0100 @@ -448,5 +448,7 @@ bool IsRetrieveOneInstanceMetadataAndAttachments() const; bool HasConstraints() const; + + bool IsTrivialFind(std::string& publicId /* out */) const; }; } diff -r cdb8b2a3aad5 -r 9b039f4b1421 OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp --- a/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp Sat Nov 30 21:57:48 2024 +0100 +++ b/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp Tue Dec 03 13:52:04 2024 +0100 @@ -3281,45 +3281,11 @@ **/ std::list identifiers; - if (!request.HasConstraints() && - request.GetLevel() == ResourceType_Patient && - request.GetOrthancIdentifiers().HasPatientId() && - !request.GetOrthancIdentifiers().HasStudyId() && - !request.GetOrthancIdentifiers().HasSeriesId() && - !request.GetOrthancIdentifiers().HasInstanceId()) - { - // This is a trivial case for which no transaction is needed - identifiers.push_back(request.GetOrthancIdentifiers().GetPatientId()); - } - else if (!request.HasConstraints() && - request.GetLevel() == ResourceType_Study && - !request.GetOrthancIdentifiers().HasPatientId() && - request.GetOrthancIdentifiers().HasStudyId() && - !request.GetOrthancIdentifiers().HasSeriesId() && - !request.GetOrthancIdentifiers().HasInstanceId()) + std::string publicId; + if (request.IsTrivialFind(publicId)) { // This is a trivial case for which no transaction is needed - identifiers.push_back(request.GetOrthancIdentifiers().GetStudyId()); - } - else if (!request.HasConstraints() && - request.GetLevel() == ResourceType_Series && - !request.GetOrthancIdentifiers().HasPatientId() && - !request.GetOrthancIdentifiers().HasStudyId() && - request.GetOrthancIdentifiers().HasSeriesId() && - !request.GetOrthancIdentifiers().HasInstanceId()) - { - // This is a trivial case for which no transaction is needed - identifiers.push_back(request.GetOrthancIdentifiers().GetSeriesId()); - } - else if (!request.HasConstraints() && - request.GetLevel() == ResourceType_Instance && - !request.GetOrthancIdentifiers().HasPatientId() && - !request.GetOrthancIdentifiers().HasStudyId() && - !request.GetOrthancIdentifiers().HasSeriesId() && - request.GetOrthancIdentifiers().HasInstanceId()) - { - // This is a trivial case for which no transaction is needed - identifiers.push_back(request.GetOrthancIdentifiers().GetInstanceId()); + identifiers.push_back(publicId); } else {