diff OrthancServer/Sources/Database/Compatibility/GenericFind.cpp @ 5615:a10978a5e65c find-refactoring

expansion of single resources using ResourceFinder
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 09 May 2024 12:24:29 +0200
parents 4640b7ae9a11
children 1e92fb051fd7
line wrap: on
line diff
--- a/OrthancServer/Sources/Database/Compatibility/GenericFind.cpp	Thu May 09 11:59:56 2024 +0200
+++ b/OrthancServer/Sources/Database/Compatibility/GenericFind.cpp	Thu May 09 12:24:29 2024 +0200
@@ -32,17 +32,22 @@
 {
   namespace Compatibility
   {
+    static bool IsRequestWithoutContraint(const FindRequest& request)
+    {
+      return (request.GetDicomTagConstraintsCount() == 0 &&
+              request.GetMetadataConstraintsCount() == 0 &&
+              request.GetLabels().empty() &&
+              request.GetOrdering().empty());
+    }
+
     void GenericFind::ExecuteFind(std::list<std::string>& identifiers,
                                   const FindRequest& request)
     {
-      if (!request.GetOrthancIdentifiers().HasPatientId() &&
+      if (IsRequestWithoutContraint(request) &&
+          !request.GetOrthancIdentifiers().HasPatientId() &&
           !request.GetOrthancIdentifiers().HasStudyId() &&
           !request.GetOrthancIdentifiers().HasSeriesId() &&
-          !request.GetOrthancIdentifiers().HasInstanceId() &&
-          request.GetDicomTagConstraintsCount() == 0 &&
-          request.GetMetadataConstraintsCount() == 0 &&
-          request.GetLabels().empty() &&
-          request.GetOrdering().empty())
+          !request.GetOrthancIdentifiers().HasInstanceId())
       {
         if (request.HasLimits())
         {
@@ -53,6 +58,38 @@
           transaction_.GetAllPublicIds(identifiers, request.GetLevel());
         }
       }
+      else if (IsRequestWithoutContraint(request) &&
+               request.GetOrthancIdentifiers().HasPatientId() &&
+               !request.GetOrthancIdentifiers().HasStudyId() &&
+               !request.GetOrthancIdentifiers().HasSeriesId() &&
+               !request.GetOrthancIdentifiers().HasInstanceId())
+      {
+        identifiers.push_back(request.GetOrthancIdentifiers().GetPatientId());
+      }
+      else if (IsRequestWithoutContraint(request) &&
+               !request.GetOrthancIdentifiers().HasPatientId() &&
+               request.GetOrthancIdentifiers().HasStudyId() &&
+               !request.GetOrthancIdentifiers().HasSeriesId() &&
+               !request.GetOrthancIdentifiers().HasInstanceId())
+      {
+        identifiers.push_back(request.GetOrthancIdentifiers().GetStudyId());
+      }
+      else if (IsRequestWithoutContraint(request) &&
+               !request.GetOrthancIdentifiers().HasPatientId() &&
+               !request.GetOrthancIdentifiers().HasStudyId() &&
+               request.GetOrthancIdentifiers().HasSeriesId() &&
+               !request.GetOrthancIdentifiers().HasInstanceId())
+      {
+        identifiers.push_back(request.GetOrthancIdentifiers().GetSeriesId());
+      }
+      else if (IsRequestWithoutContraint(request) &&
+               !request.GetOrthancIdentifiers().HasPatientId() &&
+               !request.GetOrthancIdentifiers().HasStudyId() &&
+               !request.GetOrthancIdentifiers().HasSeriesId() &&
+               request.GetOrthancIdentifiers().HasInstanceId())
+      {
+        identifiers.push_back(request.GetOrthancIdentifiers().GetInstanceId());
+      }
       else
       {
         throw OrthancException(ErrorCode_NotImplemented);  // Not supported