changeset 1819:84f0a118a72c worklists

new URI: /modalities/{id}/find-worklist
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 24 Nov 2015 17:20:23 +0100
parents 1065401501fb
children 2d8191b13567 87a3a8c04d8a
files OrthancServer/OrthancRestApi/OrthancRestModalities.cpp
diffstat 1 files changed, 28 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp	Tue Nov 24 16:48:23 2015 +0100
+++ b/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp	Tue Nov 24 17:20:23 2015 +0100
@@ -865,6 +865,32 @@
   }
 
 
+  static void DicomFindWorklist(RestApiPostCall& call)
+  {
+    ServerContext& context = OrthancRestApi::GetContext(call);
+
+    Json::Value json;
+    if (call.ParseJsonRequest(json))
+    {
+      const std::string& localAet = context.GetDefaultLocalApplicationEntityTitle();
+      RemoteModalityParameters remote = Configuration::GetModalityUsingSymbolicName(call.GetUriComponent("id", ""));
+
+      std::auto_ptr<ParsedDicomFile> query(ParsedDicomFile::CreateFromJson(json, static_cast<DicomFromJsonFlags>(0)));
+
+      DicomFindAnswers answers;
+
+      {
+        ReusableDicomUserConnection::Locker locker(context.GetReusableDicomUserConnection(), localAet, remote);
+        locker.GetConnection().FindWorklist(answers, *query);
+      }
+
+      Json::Value result;
+      answers.ToJson(result, true);
+      call.GetOutput().AnswerJson(result);
+    }
+  }
+
+
   void OrthancRestApi::RegisterModalities()
   {
     Register("/modalities", ListModalities);
@@ -898,5 +924,7 @@
     Register("/peers/{id}", UpdatePeer);
     Register("/peers/{id}", DeletePeer);
     Register("/peers/{id}/store", PeerStore);
+
+    Register("/modalities/{id}/find-worklist", DicomFindWorklist);
   }
 }