diff OrthancServer/OrthancRestApi/OrthancRestResources.cpp @ 1172:059391d3f8df db-changes

integration mainline->db-changes
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 22 Sep 2014 13:44:08 +0200
parents 1ea4094d077c a921e3b5e763
children 09aa7c126be9
line wrap: on
line diff
--- a/OrthancServer/OrthancRestApi/OrthancRestResources.cpp	Wed Sep 17 13:25:37 2014 +0200
+++ b/OrthancServer/OrthancRestApi/OrthancRestResources.cpp	Mon Sep 22 13:44:08 2014 +0200
@@ -876,6 +876,42 @@
   }
 
 
+  static void GetChildInstancesTags(RestApiGetCall& call)
+  {
+    ServerContext& context = OrthancRestApi::GetContext(call);
+    std::string publicId = call.GetUriComponent("id", "");
+    bool simplify = call.HasArgument("simplify");
+
+    // Retrieve all the instances of this patient/study/series
+    typedef std::list<std::string> Instances;
+    Instances instances;
+
+    context.GetIndex().GetChildInstances(instances, publicId);  // (*)
+
+    Json::Value result = Json::arrayValue;
+
+    for (Instances::const_iterator it = instances.begin();
+         it != instances.end(); it++)
+    {
+      Json::Value full;
+      context.ReadJson(full, *it);
+
+      if (simplify)
+      {
+        Json::Value simplified;
+        SimplifyTags(simplified, full);
+        result.append(simplified);
+      }
+      else
+      {
+        result.append(full);
+      }
+    }
+    
+    call.GetOutput().AnswerJson(result);
+  }
+
+
 
   void OrthancRestApi::RegisterResources()
   {
@@ -954,6 +990,10 @@
     Register("/studies/{id}/instances", GetChildResources<ResourceType_Study, ResourceType_Instance>);
     Register("/series/{id}/instances", GetChildResources<ResourceType_Series, ResourceType_Instance>);
 
+    Register("/patients/{id}/instances-tags", GetChildInstancesTags);
+    Register("/studies/{id}/instances-tags", GetChildInstancesTags);
+    Register("/series/{id}/instances-tags", GetChildInstancesTags);
+
     Register("/instances/{id}/content/*", GetRawContent);
   }
 }