changeset 4950:3778a0433dd3 more-tags

new field 'MainDicomTags' in the /system response
author Alain Mazy <am@osimis.io>
date Mon, 21 Mar 2022 15:19:42 +0100
parents f377d5643538
children e1495a34cd39 c68265bf1f94
files NEWS OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp
diffstat 4 files changed, 37 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Thu Mar 17 17:03:59 2022 +0100
+++ b/NEWS	Mon Mar 21 15:19:42 2022 +0100
@@ -32,7 +32,7 @@
   - /studies, /studies/../series, /studies/../instances
   - /series, /series/../instances
   - /instances
-
+* new field "MainDicomTags" in the /system route response
 
 
 Documentation
--- a/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp	Thu Mar 17 17:03:59 2022 +0100
+++ b/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp	Mon Mar 21 15:19:42 2022 +0100
@@ -1323,6 +1323,16 @@
     Toolbox::JoinStrings(output, values, ";");
   }
 
+  void FromDcmtkBridge::FormatListOfTags(Json::Value& output, const std::set<DicomTag>& tags)
+  {
+    output = Json::arrayValue;
+    for (std::set<DicomTag>::const_iterator it = tags.begin();
+         it != tags.end(); it++)
+    {
+      output.append(it->Format());
+    }
+  }
+
   // parses a list like "0010,0010;PatientBirthDate;0020,0020"
   void FromDcmtkBridge::ParseListOfTags(std::set<DicomTag>& result, const std::string& source)
   {
--- a/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h	Thu Mar 17 17:03:59 2022 +0100
+++ b/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h	Mon Mar 21 15:19:42 2022 +0100
@@ -182,6 +182,8 @@
 
     static void FormatListOfTags(std::string& output, const std::set<DicomTag>& tags);
 
+    static void FormatListOfTags(Json::Value& output, const std::set<DicomTag>& tags);
+
     static bool HasTag(const DicomMap& fields,
                        const std::string& tagName);
 
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp	Thu Mar 17 17:03:59 2022 +0100
+++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp	Mon Mar 21 15:19:42 2022 +0100
@@ -47,7 +47,24 @@
   {
     call.GetOutput().Redirect("app/images/favicon.ico");
   }
- 
+
+  static void GetMainDicomTagsConfiguration(Json::Value& result)
+  {
+      Json::Value v;
+      
+      FromDcmtkBridge::FormatListOfTags(v, DicomMap::GetMainDicomTags(ResourceType_Patient));
+      result["Patient"] = v;
+
+      FromDcmtkBridge::FormatListOfTags(v, DicomMap::GetMainDicomTags(ResourceType_Study));
+      result["Study"] = v;
+
+      FromDcmtkBridge::FormatListOfTags(v, DicomMap::GetMainDicomTags(ResourceType_Series));
+      result["Series"] = v;
+
+      FromDcmtkBridge::FormatListOfTags(v, DicomMap::GetMainDicomTags(ResourceType_Instance));
+      result["Instance"] = v;
+  }
+
   static void GetSystemInformation(RestApiGetCall& call)
   {
     static const char* const API_VERSION = "ApiVersion";
@@ -62,6 +79,7 @@
     static const char* const PLUGINS_ENABLED = "PluginsEnabled";
     static const char* const STORAGE_AREA_PLUGIN = "StorageAreaPlugin";
     static const char* const VERSION = "Version";
+    static const char* const MAIN_DICOM_TAGS = "MainDicomTags";
     
     if (call.IsDocumentation())
     {
@@ -88,6 +106,8 @@
                         "Whether Orthanc was built with support for plugins")
         .SetAnswerField(CHECK_REVISIONS, RestApiCallDocumentation::Type_Boolean,
                         "Whether Orthanc handle revisions of metadata and attachments to deal with multiple writers (new in Orthanc 1.9.2)")
+        .SetAnswerField(MAIN_DICOM_TAGS, RestApiCallDocumentation::Type_JsonObject,
+                        "The list of MainDicomTags saved in DB for each resource level (new in Orthanc 1.11.0)")
         .SetHttpGetSample("https://demo.orthanc-server.com/system", true);
       return;
     }
@@ -132,6 +152,9 @@
     result[PLUGINS_ENABLED] = false;
 #endif
 
+    result[MAIN_DICOM_TAGS] = Json::objectValue;
+    GetMainDicomTagsConfiguration(result[MAIN_DICOM_TAGS]);
+
     call.GetOutput().AnswerJson(result);
   }