changeset 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 11f8d72f366f
children e6204cd21443
files NEWS OrthancServer/OrthancRestApi/OrthancRestModalities.cpp
diffstat 2 files changed, 20 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Thu Nov 29 18:40:51 2018 +0100
+++ b/NEWS	Thu Nov 29 20:36:31 2018 +0100
@@ -24,7 +24,8 @@
 * New URI: "/studies/.../merge" to merge a study
 * New URI: "/studies/.../split" to split a study
 * POST-ing a DICOM file to "/instances" also answers the patient/study/series ID
-* GET /modalities/... now returns a JSON object instead of a JSON array
+* GET "/modalities/..." now returns a JSON object instead of a JSON array
+* New options to URI "/queries/.../answers": "?expand" and "?limit"
 
 Maintenance
 -----------
--- 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);