diff OrthancServer/ServerContext.cpp @ 1757:98abb8d7f905 db-changes

ServerContext::Apply lookup
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 28 Oct 2015 12:29:12 +0100
parents 06addfcd1d4c
children 318c2e83c2bd
line wrap: on
line diff
--- a/OrthancServer/ServerContext.cpp	Wed Oct 28 12:14:06 2015 +0100
+++ b/OrthancServer/ServerContext.cpp	Wed Oct 28 12:29:12 2015 +0100
@@ -543,4 +543,37 @@
     return false;
 #endif
   }
+
+
+  bool ServerContext::Apply(std::vector<std::string>& result,
+                            const ::Orthanc::LookupResource& lookup,
+                            size_t maxResults)
+  {
+    std::vector<std::string> resources, instances;
+    GetIndex().FindCandidates(resources, instances, lookup);
+
+    assert(resources.size() == instances.size());
+
+    for (size_t i = 0; i < instances.size(); i++)
+    {
+      Json::Value dicom;
+      ReadJson(dicom, instances[i]);
+      
+      if (lookup.IsMatch(dicom))
+      {
+        if (maxResults != 0 &&
+            result.size() >= maxResults)
+        {
+          return false;  // too many results
+        }
+        else
+        {
+          result.push_back(resources[i]);
+        }
+      }
+    }
+
+    return true;  // finished
+  }
+
 }