Mercurial > hg > orthanc
changeset 1166:a921e3b5e763
bulk tags retrieval
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 19 Sep 2014 10:17:50 +0200 |
parents | 0561f2087cc9 |
children | 33ba03f2e0a7 6467a3fa72a2 |
files | NEWS OrthancServer/OrthancRestApi/OrthancRestResources.cpp |
diffstat | 2 files changed, 42 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/NEWS Thu Sep 18 17:48:55 2014 +0200 +++ b/NEWS Fri Sep 19 10:17:50 2014 +0200 @@ -1,6 +1,8 @@ Pending changes in the mainline =============================== +* "/instances-tags" to get the tags of all the child instances of a + patient/study/series with a single REST call (bulk tags retrieval) * Configuration/Lua to select the accepted C-Store SCP transfer syntaxes * Fix reporting of errors in Orthanc Explorer when sending images to peers/modalities * Installation of plugin SDK in CMake
--- a/OrthancServer/OrthancRestApi/OrthancRestResources.cpp Thu Sep 18 17:48:55 2014 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestResources.cpp Fri Sep 19 10:17:50 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); } }