diff OrthancServer/OrthancRestApi/OrthancRestModalities.cpp @ 2948:d2e548e643af

New options to URI "/queries/.../answers": "?expand" and "?limit"
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 29 Nov 2018 20:36:31 +0100
parents f395460af74d
children bbfd95a0c429
line wrap: on
line diff
--- a/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp	Thu Nov 29 18:40:51 2018 +0100
+++ b/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp	Thu Nov 29 20:36:31 2018 +0100
@@ -498,13 +498,30 @@
 
   static void ListQueryAnswers(RestApiGetCall& call)
   {
+    const bool expand = call.HasArgument("expand");
+    const bool simplify = call.HasArgument("simplify");
+    
     QueryAccessor query(call);
     size_t count = query.GetHandler().GetAnswersCount();
 
     Json::Value result = Json::arrayValue;
     for (size_t i = 0; i < count; i++)
     {
-      result.append(boost::lexical_cast<std::string>(i));
+      if (expand)
+      {
+        // New in Orthanc 1.4.3
+        DicomMap value;
+        query.GetHandler().GetAnswer(value, i);
+        
+        Json::Value json = Json::objectValue;
+        FromDcmtkBridge::ToJson(json, value, simplify);
+
+        result.append(json);
+      }
+      else
+      {
+        result.append(boost::lexical_cast<std::string>(i));
+      }
     }
 
     call.GetOutput().AnswerJson(result);