changeset 1049:bd2cb95003da

C-Echo SCU in the REST API
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 22 Jul 2014 16:49:34 +0200
parents 648bf1457113
children 64f1842aae2e
files NEWS OrthancServer/OrthancRestApi/OrthancRestModalities.cpp
diffstat 2 files changed, 24 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Fri Jul 18 17:18:33 2014 +0200
+++ b/NEWS	Tue Jul 22 16:49:34 2014 +0200
@@ -4,6 +4,7 @@
 * Lookup for DICOM UIDs in the plugin SDK
 * Plugins have access to the HTTP headers and can answer with HTTP status codes
 * On-the-fly conversion of JSON to XML according to the HTTP Accept header
+* C-Echo SCU in the REST API
 
 
 Version 0.8.0 (2014/07/10)
--- a/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp	Fri Jul 18 17:18:33 2014 +0200
+++ b/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp	Tue Jul 22 16:49:34 2014 +0200
@@ -68,6 +68,27 @@
     return true;
   }
 
+
+  static void DicomEcho(RestApiPostCall& call)
+  {
+    ServerContext& context = OrthancRestApi::GetContext(call);
+
+    RemoteModalityParameters remote = Configuration::GetModalityUsingSymbolicName(call.GetUriComponent("id", ""));
+    ReusableDicomUserConnection::Locker locker(context.GetReusableDicomUserConnection(), remote);
+
+    try
+    {
+      if (locker.GetConnection().Echo())
+      {
+        call.GetOutput().AnswerBuffer("{}", "application/json");
+      }
+    }
+    catch (OrthancException&)
+    {
+    }
+  }
+
+
   static void DicomFindPatient(RestApiPostCall& call)
   {
     ServerContext& context = OrthancRestApi::GetContext(call);
@@ -438,6 +459,7 @@
     if (IsExistingModality(modalities, id))
     {
       Json::Value result = Json::arrayValue;
+      result.append("echo");
       result.append("find-patient");
       result.append("find-study");
       result.append("find-series");
@@ -497,6 +519,7 @@
     Register("/modalities/{id}", ListModalityOperations);
     Register("/modalities/{id}", UpdateModality);
     Register("/modalities/{id}", DeleteModality);
+    Register("/modalities/{id}/echo", DicomEcho);
     Register("/modalities/{id}/find-patient", DicomFindPatient);
     Register("/modalities/{id}/find-study", DicomFindStudy);
     Register("/modalities/{id}/find-series", DicomFindSeries);