changeset 57:55539d564f4f

added support for /dicom-web/series? & /dicom-web/instances?
author Alain Mazy <am@osimis.io>
date Wed, 09 Nov 2022 15:40:35 +0100
parents c02f0646297d
children ad279c70c22d
files Plugin/AssociativeArray.h Plugin/DefaultAuthorizationParser.cpp Plugin/DefaultAuthorizationParser.h Plugin/Plugin.cpp
diffstat 4 files changed, 23 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/Plugin/AssociativeArray.h	Tue Nov 08 16:10:22 2022 +0100
+++ b/Plugin/AssociativeArray.h	Wed Nov 09 15:40:35 2022 +0100
@@ -41,5 +41,10 @@
     
     bool GetValue(std::string& value,
                   const std::string& key) const;
+
+    const std::map<std::string, std::string>& GetMap() const
+    {
+      return map_;
+    }
   };
 }
--- a/Plugin/DefaultAuthorizationParser.cpp	Tue Nov 08 16:10:22 2022 +0100
+++ b/Plugin/DefaultAuthorizationParser.cpp	Wed Nov 09 15:40:35 2022 +0100
@@ -49,8 +49,8 @@
     dicomWebInstances_ = boost::regex(
       "^" + tmp + "/studies/([.0-9]+)/series/([.0-9]+)/instances/([.0-9]+)(|/|/frames/.*)$");
 
-    dicomWebQidoRsFindStudies_ = boost::regex(
-      "^" + tmp + "/studies\?(.*)$");
+    dicomWebQidoRsFind_ = boost::regex(
+      "^" + tmp + "/(studies|series|instances)\?(.*)$");
   }
 
 
@@ -132,13 +132,23 @@
       AddOrthancInstance(target, what[2]);
       return true;
     }
-    else if (boost::regex_match(uri, what, dicomWebQidoRsFindStudies_))
+    else if (boost::regex_match(uri, what, dicomWebQidoRsFind_))
     {
-      std::string studyInstanceUid;
+      std::string studyInstanceUid, seriesInstanceUid, sopInstanceUid;
 
       studyInstanceUid = Orthanc::HttpToolbox::GetArgument(getArguments, "0020000D", "");
+      seriesInstanceUid = Orthanc::HttpToolbox::GetArgument(getArguments, "0020000E", "");
+      sopInstanceUid = Orthanc::HttpToolbox::GetArgument(getArguments, "00080018", "");
 
-      if (!studyInstanceUid.empty())
+      if (!sopInstanceUid.empty() && !seriesInstanceUid.empty() && !studyInstanceUid.empty())
+      {
+        AddDicomInstance(target, studyInstanceUid, seriesInstanceUid, sopInstanceUid);
+      }
+      else if (!seriesInstanceUid.empty() && !studyInstanceUid.empty())
+      {
+        AddDicomSeries(target, studyInstanceUid, seriesInstanceUid);
+      }
+      else if (!studyInstanceUid.empty())
       {
         AddDicomStudy(target, studyInstanceUid);
       }
--- a/Plugin/DefaultAuthorizationParser.h	Tue Nov 08 16:10:22 2022 +0100
+++ b/Plugin/DefaultAuthorizationParser.h	Wed Nov 09 15:40:35 2022 +0100
@@ -35,7 +35,7 @@
     boost::regex dicomWebStudies_;
     boost::regex dicomWebSeries_;
     boost::regex dicomWebInstances_;
-    boost::regex dicomWebQidoRsFindStudies_;
+    boost::regex dicomWebQidoRsFind_;
 
     boost::regex osimisViewerSeries_;
     boost::regex osimisViewerImages_;
--- a/Plugin/Plugin.cpp	Tue Nov 08 16:10:22 2022 +0100
+++ b/Plugin/Plugin.cpp	Wed Nov 09 15:40:35 2022 +0100
@@ -73,13 +73,9 @@
     {
       // Parse the resources that are accessed through this URI
       OrthancPlugins::IAuthorizationParser::AccessedResources accesses;
-      std::map<std::string, std::string> getArguments;
-      for (uint32_t i = 0; i < getArgumentsCount; i++)
-      {
-        getArguments[getArgumentsKeys[i]] = getArgumentsValues[i];
-      }
+      OrthancPlugins::AssociativeArray getArguments(getArgumentsCount, getArgumentsKeys, getArgumentsValues, true);
 
-      if (!authorizationParser_->Parse(accesses, uri, getArguments))
+      if (!authorizationParser_->Parse(accesses, uri, getArguments.GetMap()))
       {
         return 0;  // Unable to parse this URI
       }
@@ -109,9 +105,6 @@
             OrthancPlugins::AssociativeArray headers
               (headersCount, headersKeys, headersValues, false);
 
-            OrthancPlugins::AssociativeArray getArguments
-              (getArgumentsCount, getArgumentsKeys, getArgumentsValues, true);
-
             // Loop over all the authorization tokens stored in the HTTP
             // headers, until finding one that is granted
             for (std::list<OrthancPlugins::Token>::const_iterator