changeset 2634:442e7ef5cc41

merge
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 25 May 2018 18:54:11 +0200
parents 40c7926b75f8 (current diff) 3603a2e14592 (diff)
children 33c0b4da8cb2 5094369664f0
files
diffstat 4 files changed, 73 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Fri May 25 18:53:47 2018 +0200
+++ b/NEWS	Fri May 25 18:54:11 2018 +0200
@@ -9,11 +9,19 @@
 REST API
 --------
 
-* ".../tags" URI was returning only the first value of DicomTags containing 
-  multiple numerical value.  It now returns all values in a string separated
-  by \\ (i.e.: "1\\2\\3").  Note that, for data already in Orthanc, you'll need
-  to reconstruct the data by sending a POST request to the ".../reconstruct" URI.
-  This change triggered an update of ORTHANC_API_VERSION from 1.0 to 1.1
+* New option "?short" to list DICOM tags using their hexadecimal ID in:
+  - "/instances/.../tags?short"
+  - "/instances/.../header?short"
+  - "/{patients|studies|series}/.../instances-tags?short"
+  - "/{patients|studies|series}/.../shared-tags?short"
+  - "/{patients|studies|series|instances}/.../module?short"
+  - "/studies/.../module-patient?short"
+* "/instances/.../tags" URI was returning only the first value of
+  DicomTags containing multiple numerical value.  It now returns all
+  values in a string separated by \\ (i.e.: "1\\2\\3").  Note that,
+  for data already in Orthanc, you'll need to reconstruct the data by
+  sending a POST request to the ".../reconstruct" URI.  This change
+  triggered an update of ORTHANC_API_VERSION from 1.0 to 1.1
 
 Maintenance
 -----------
--- a/OrthancServer/OrthancRestApi/OrthancRestResources.cpp	Fri May 25 18:53:47 2018 +0200
+++ b/OrthancServer/OrthancRestApi/OrthancRestResources.cpp	Fri May 25 18:54:11 2018 +0200
@@ -50,12 +50,12 @@
 {
   static void AnswerDicomAsJson(RestApiCall& call,
                                 const Json::Value& dicom,
-                                bool simplify)
+                                DicomToJsonFormat mode)
   {
-    if (simplify)
+    if (mode != DicomToJsonFormat_Full)
     {
       Json::Value simplified;
-      ServerToolbox::SimplifyTags(simplified, dicom, DicomToJsonFormat_Human);
+      ServerToolbox::SimplifyTags(simplified, dicom, mode);
       call.GetOutput().AnswerJson(simplified);
     }
     else
@@ -65,6 +65,30 @@
   }
 
 
+  static DicomToJsonFormat GetDicomFormat(const RestApiGetCall& call)
+  {
+    if (call.HasArgument("simplify"))
+    {
+      return DicomToJsonFormat_Human;
+    }
+    else if (call.HasArgument("short"))
+    {
+      return DicomToJsonFormat_Short;
+    }
+    else
+    {
+      return DicomToJsonFormat_Full;
+    }
+  }
+
+
+  static void AnswerDicomAsJson(RestApiGetCall& call,
+                                const Json::Value& dicom)
+  {
+    AnswerDicomAsJson(call, dicom, GetDicomFormat(call));
+  }
+
+
   static void ParseSetOfTags(std::set<DicomTag>& target,
                              const RestApiGetCall& call,
                              const std::string& argument)
@@ -236,7 +260,7 @@
   }
 
 
-  template <bool simplify>
+  template <DicomToJsonFormat format>
   static void GetInstanceTags(RestApiGetCall& call)
   {
     ServerContext& context = OrthancRestApi::GetContext(call);
@@ -246,18 +270,18 @@
     std::set<DicomTag> ignoreTagLength;
     ParseSetOfTags(ignoreTagLength, call, "ignore-length");
     
-    if (simplify ||
+    if (format != DicomToJsonFormat_Full ||
         !ignoreTagLength.empty())
     {
       Json::Value full;
       context.ReadDicomAsJson(full, publicId, ignoreTagLength);
-      AnswerDicomAsJson(call, full, simplify);
+      AnswerDicomAsJson(call, full, format);
     }
     else
     {
       // This path allows to avoid the JSON decoding if no
-      // simplification is asked, or if no "ignore-length" argument is
-      // present
+      // simplification is asked, and if no "ignore-length" argument
+      // is present
       std::string full;
       context.ReadDicomAsJson(full, publicId);
       call.GetOutput().AnswerBuffer(full, "application/json");
@@ -267,15 +291,22 @@
 
   static void GetInstanceTagsBis(RestApiGetCall& call)
   {
-    bool simplify = call.HasArgument("simplify");
-
-    if (simplify)
+    switch (GetDicomFormat(call))
     {
-      GetInstanceTags<true>(call);
-    }
-    else
-    {
-      GetInstanceTags<false>(call);
+      case DicomToJsonFormat_Human:
+        GetInstanceTags<DicomToJsonFormat_Human>(call);
+        break;
+
+      case DicomToJsonFormat_Short:
+        GetInstanceTags<DicomToJsonFormat_Short>(call);
+        break;
+
+      case DicomToJsonFormat_Full:
+        GetInstanceTags<DicomToJsonFormat_Full>(call);
+        break;
+
+      default:
+        throw OrthancException(ErrorCode_InternalError);
     }
   }
 
@@ -1044,13 +1075,12 @@
   {
     ServerContext& context = OrthancRestApi::GetContext(call);
     std::string publicId = call.GetUriComponent("id", "");
-    bool simplify = call.HasArgument("simplify");
 
     Json::Value sharedTags;
     if (ExtractSharedTags(sharedTags, context, publicId))
     {
       // Success: Send the value of the shared tags
-      AnswerDicomAsJson(call, sharedTags, simplify);
+      AnswerDicomAsJson(call, sharedTags);
     }
   }
 
@@ -1071,7 +1101,6 @@
 
     ServerContext& context = OrthancRestApi::GetContext(call);
     std::string publicId = call.GetUriComponent("id", "");
-    bool simplify = call.HasArgument("simplify");
 
     std::set<DicomTag> ignoreTagLength;
     ParseSetOfTags(ignoreTagLength, call, "ignore-length");
@@ -1111,7 +1140,7 @@
       }      
     }
 
-    AnswerDicomAsJson(call, result, simplify);
+    AnswerDicomAsJson(call, result);
   }
     
 
@@ -1306,7 +1335,7 @@
   {
     ServerContext& context = OrthancRestApi::GetContext(call);
     std::string publicId = call.GetUriComponent("id", "");
-    bool simplify = call.HasArgument("simplify");
+    DicomToJsonFormat format = GetDicomFormat(call);
 
     std::set<DicomTag> ignoreTagLength;
     ParseSetOfTags(ignoreTagLength, call, "ignore-length");
@@ -1325,10 +1354,10 @@
       Json::Value full;
       context.ReadDicomAsJson(full, *it, ignoreTagLength);
 
-      if (simplify)
+      if (format != DicomToJsonFormat_Full)
       {
         Json::Value simplified;
-        ServerToolbox::SimplifyTags(simplified, full, DicomToJsonFormat_Human);
+        ServerToolbox::SimplifyTags(simplified, full, format);
         result[*it] = simplified;
       }
       else
@@ -1409,7 +1438,6 @@
     ServerContext& context = OrthancRestApi::GetContext(call);
 
     std::string publicId = call.GetUriComponent("id", "");
-    bool simplify = call.HasArgument("simplify");
 
     std::string dicomContent;
     context.ReadDicom(dicomContent, publicId);
@@ -1422,7 +1450,7 @@
     Json::Value header;
     dicom.HeaderToJson(header, DicomToJsonFormat_Full);
 
-    AnswerDicomAsJson(call, header, simplify);
+    AnswerDicomAsJson(call, header);
   }
 
 
@@ -1495,7 +1523,7 @@
     Register("/instances/{id}/file", GetInstanceFile);
     Register("/instances/{id}/export", ExportInstanceFile);
     Register("/instances/{id}/tags", GetInstanceTagsBis);
-    Register("/instances/{id}/simplified-tags", GetInstanceTags<true>);
+    Register("/instances/{id}/simplified-tags", GetInstanceTags<DicomToJsonFormat_Human>);
     Register("/instances/{id}/frames", ListFrames);
 
     Register("/instances/{id}/frames/{frame}/preview", GetImage<ImageExtractionMode_Preview>);
--- a/Plugins/Include/orthanc/OrthancCPlugin.h	Fri May 25 18:53:47 2018 +0200
+++ b/Plugins/Include/orthanc/OrthancCPlugin.h	Fri May 25 18:54:11 2018 +0200
@@ -54,7 +54,7 @@
  * @defgroup Callbacks Callbacks
  * @brief Functions to register and manage callbacks by the plugins.
  *
- * @defgroup DicomCallbaks DicomCallbaks
+ * @defgroup DicomCallbacks DicomCallbacks
  * @brief Functions to register and manage DICOM callbacks (worklists, C-Find, C-MOVE).
  *
  * @defgroup Orthanc Orthanc
--- a/README	Fri May 25 18:53:47 2018 +0200
+++ b/README	Fri May 25 18:54:11 2018 +0200
@@ -52,8 +52,11 @@
   title="The {O}rthanc Ecosystem for Medical Imaging",
   journal="Journal of Digital Imaging",
   year="2018",
-  month="May",
-  day="03",
+  month="Jun",
+  day="01",
+  volume="31",
+  number="3",
+  pages="341--352",
   issn="1618-727X",
   doi="10.1007/s10278-018-0082-y",
   url="https://doi.org/10.1007/s10278-018-0082-y"