changeset 5254:fafdb6179829 db-protobuf

inform database plugins about the identifier tags
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 11 Apr 2023 11:09:52 +0200
parents 1700fe5c9737
children f783b99e4738
files OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.cpp OrthancServer/Plugins/Include/orthanc/OrthancDatabasePlugin.proto
diffstat 2 files changed, 40 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.cpp	Sat Apr 08 11:44:05 2023 +0200
+++ b/OrthancServer/Plugins/Engine/OrthancPluginDatabaseV4.cpp	Tue Apr 11 11:09:52 2023 +0200
@@ -27,10 +27,12 @@
 #  error The plugin support is disabled
 #endif
 
+#include "../../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h"
 #include "../../../OrthancFramework/Sources/Logging.h"
 #include "../../../OrthancFramework/Sources/OrthancException.h"
 #include "../../Sources/Database/ResourcesContent.h"
 #include "../../Sources/Database/VoidDatabaseListener.h"
+#include "../../Sources/ServerToolbox.h"
 #include "PluginsEnumerations.h"
 
 #include "OrthancDatabasePlugin.pb.h"  // Auto-generated file
@@ -1275,6 +1277,31 @@
     definition_.finalize(definition_.backend);
   }
 
+
+  static void AddIdentifierTags(DatabasePluginMessages::Open::Request& request,
+                                ResourceType level)
+  {
+    const DicomTag* tags = NULL;
+    size_t size;
+
+    ServerToolbox::LoadIdentifiers(tags, size, level);
+
+    if (tags == NULL ||
+        size == 0)
+    {
+      throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
+    }
+
+    for (size_t i = 0; i < size; i++)
+    {
+      DatabasePluginMessages::Open_Request_IdentifierTag* tag = request.add_identifier_tags();
+      tag->set_level(Convert(level));
+      tag->set_group(tags[i].GetGroup());
+      tag->set_element(tags[i].GetElement());
+      tag->set_name(FromDcmtkBridge::GetTagName(tags[i], ""));
+    }
+  }
+
   
   void OrthancPluginDatabaseV4::Open()
   {
@@ -1285,6 +1312,11 @@
     
     {
       DatabasePluginMessages::DatabaseRequest request;
+      AddIdentifierTags(*request.mutable_open(), ResourceType_Patient);
+      AddIdentifierTags(*request.mutable_open(), ResourceType_Study);
+      AddIdentifierTags(*request.mutable_open(), ResourceType_Series);
+      AddIdentifierTags(*request.mutable_open(), ResourceType_Instance);
+
       DatabasePluginMessages::DatabaseResponse response;
       ExecuteDatabase(response, *this, DatabasePluginMessages::OPERATION_OPEN, request);
     }
@@ -1299,7 +1331,7 @@
       hasLabelsSupport_ = response.get_system_information().supports_labels();
     }
 
-    open_ = true;    
+    open_ = true;
   }
 
 
--- a/OrthancServer/Plugins/Include/orthanc/OrthancDatabasePlugin.proto	Sat Apr 08 11:44:05 2023 +0200
+++ b/OrthancServer/Plugins/Include/orthanc/OrthancDatabasePlugin.proto	Tue Apr 11 11:09:52 2023 +0200
@@ -141,6 +141,13 @@
 
 message Open {
   message Request {
+    message IdentifierTag {
+      ResourceType level = 1;
+      uint32 group = 2;
+      uint32 element = 3;
+      string name = 4;
+    }
+    repeated IdentifierTag identifier_tags = 1;
   }
   message Response {
   }