diff OrthancServer/OrthancRestApi/OrthancRestResources.cpp @ 1718:2b812969e136 db-changes

getting rid of an IDatabaseWrapper::LookupIdentifier flavor
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 20 Oct 2015 10:11:22 +0200
parents b80e76dd1d56
children 3b1f7e706d38
line wrap: on
line diff
--- a/OrthancServer/OrthancRestApi/OrthancRestResources.cpp	Mon Oct 19 17:45:34 2015 +0200
+++ b/OrthancServer/OrthancRestApi/OrthancRestResources.cpp	Tue Oct 20 10:11:22 2015 +0200
@@ -879,20 +879,32 @@
   }
 
 
+  static void AccumulateLookupResults(ServerIndex::LookupResults& result,
+                                      ServerIndex& index,
+                                      const DicomTag& tag,
+                                      const std::string& value)
+  {
+    ServerIndex::LookupResults tmp;
+    index.LookupIdentifier(tmp, tag, value);
+    result.insert(result.end(), tmp.begin(), tmp.end());
+  }
+
+
   static void Lookup(RestApiPostCall& call)
   {
-    typedef std::list< std::pair<ResourceType, std::string> >  Resources;
-
     std::string tag;
     call.BodyToString(tag);
-    Resources resources;
-
-    OrthancRestApi::GetIndex(call).LookupIdentifier(resources, tag);
 
-    Json::Value result = Json::arrayValue;
-    
-    for (Resources::const_iterator it = resources.begin();
-         it != resources.end(); ++it)
+    ServerIndex::LookupResults resources;
+    ServerIndex& index = OrthancRestApi::GetIndex(call);
+    AccumulateLookupResults(resources, index, DICOM_TAG_PATIENT_ID, tag);
+    AccumulateLookupResults(resources, index, DICOM_TAG_STUDY_INSTANCE_UID, tag);
+    AccumulateLookupResults(resources, index, DICOM_TAG_SERIES_INSTANCE_UID, tag);
+    AccumulateLookupResults(resources, index, DICOM_TAG_SOP_INSTANCE_UID, tag);
+
+    Json::Value result = Json::arrayValue;    
+    for (ServerIndex::LookupResults::const_iterator 
+           it = resources.begin(); it != resources.end(); ++it)
     {     
       ResourceType type = it->first;
       const std::string& id = it->second;