changeset 1342:9ec7ac03152d

"?expand" flag for URIs "/patients", "/studies" and "/series"
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 03 Apr 2015 15:25:04 +0200
parents 479e31b13de5
children 72d1c2fc0edb
files NEWS OrthancServer/OrthancRestApi/OrthancRestResources.cpp
diffstat 2 files changed, 23 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Fri Apr 03 13:53:08 2015 +0200
+++ b/NEWS	Fri Apr 03 15:25:04 2015 +0200
@@ -1,6 +1,7 @@
 Pending changes in the mainline
 ===============================
 
+* "?expand" flag for URIs "/patients", "/studies" and "/series"
 * Support of FreeBSD
 * Prevent freeze on C-FIND if no DICOM tag is to be returned
 * Allow replacing PatientID/StudyInstanceUID/SeriesInstanceUID from Lua scripts
--- a/OrthancServer/OrthancRestApi/OrthancRestResources.cpp	Fri Apr 03 13:53:08 2015 +0200
+++ b/OrthancServer/OrthancRestApi/OrthancRestResources.cpp	Fri Apr 03 15:25:04 2015 +0200
@@ -45,9 +45,29 @@
   template <enum ResourceType resourceType>
   static void ListResources(RestApiGetCall& call)
   {
+    ServerIndex& index = OrthancRestApi::GetIndex(call);
+
     Json::Value result;
-    OrthancRestApi::GetIndex(call).GetAllUuids(result, resourceType);
-    call.GetOutput().AnswerJson(result);
+    index.GetAllUuids(result, resourceType);
+
+    if (call.HasArgument("expand"))
+    {
+      Json::Value expanded = Json::arrayValue;
+      for (Json::Value::ArrayIndex i = 0; i < result.size(); i++)
+      {
+        Json::Value item;
+        if (index.LookupResource(item, result[i].asString(), resourceType))
+        {
+          expanded.append(item);
+        }
+      }
+
+      call.GetOutput().AnswerJson(expanded);
+    }
+    else
+    {
+      call.GetOutput().AnswerJson(result);
+    }
   }
 
   template <enum ResourceType resourceType>