diff Framework/Plugins/DatabaseBackendAdapterV4.cpp @ 403:91124cc8a8c7 db-protobuf

database plugins are informed about the identifier tags
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 11 Apr 2023 11:10:19 +0200
parents 82921a29349a
children 7c1fe5d6c12c ecd0b719cff5
line wrap: on
line diff
--- a/Framework/Plugins/DatabaseBackendAdapterV4.cpp	Sat Apr 08 10:26:03 2023 +0200
+++ b/Framework/Plugins/DatabaseBackendAdapterV4.cpp	Tue Apr 11 11:10:19 2023 +0200
@@ -90,6 +90,28 @@
   }
 
 
+  static Orthanc::ResourceType Convert2(Orthanc::DatabasePluginMessages::ResourceType resourceType)
+  {
+    switch (resourceType)
+    {
+      case Orthanc::DatabasePluginMessages::RESOURCE_PATIENT:
+        return Orthanc::ResourceType_Patient;
+
+      case Orthanc::DatabasePluginMessages::RESOURCE_STUDY:
+        return Orthanc::ResourceType_Study;
+
+      case Orthanc::DatabasePluginMessages::RESOURCE_SERIES:
+        return Orthanc::ResourceType_Series;
+
+      case Orthanc::DatabasePluginMessages::RESOURCE_INSTANCE:
+        return Orthanc::ResourceType_Instance;
+
+      default:
+        throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
+    }
+  }
+
+
   class Output : public IDatabaseBackendOutput
   {
   private:
@@ -414,7 +436,24 @@
 
       case Orthanc::DatabasePluginMessages::OPERATION_OPEN:
       {
-        pool.OpenConnections();
+        std::list<IdentifierTag> identifierTags;
+
+        if (request.open().identifier_tags().empty())
+        {
+          throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError,
+                                          "No identifier tag was provided by the Orthanc core");
+        }
+
+        for (int i = 0; i < request.open().identifier_tags().size(); i++)
+        {
+          const Orthanc::DatabasePluginMessages::Open_Request_IdentifierTag& tag = request.open().identifier_tags(i);
+          identifierTags.push_back(IdentifierTag(Convert2(tag.level()),
+                                                 Orthanc::DicomTag(tag.group(), tag.element()),
+                                                 tag.name()));
+        }
+          
+        pool.OpenConnections(true, identifierTags);
+        
         break;
       }