changeset 4145:c5cdb6dc6865

New config option "Worklist.LimitAnswers" for the sample modality worklist plugin
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 17 Aug 2020 14:48:11 +0200
parents be88fe7e4670
children 1fbe54808853
files NEWS OrthancServer/Plugins/Samples/ModalityWorklists/Plugin.cpp OrthancServer/Plugins/Samples/ServeFolders/Plugin.cpp
diffstat 3 files changed, 18 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Fri Aug 14 08:26:07 2020 +0200
+++ b/NEWS	Mon Aug 17 14:48:11 2020 +0200
@@ -4,6 +4,7 @@
 * Add missing tag "Retrieve AE Title (0008,0054)" in C-FIND SCP responses
 * Fix DICOM SCP filters if some query tag has more than 256 characters
 * "/series/.../ordered-slices" supports spaces in Image Position/Orientation Patient tags
+* New config option "Worklist.LimitAnswers" for the sample modality worklist plugin
 
 
 Version 1.7.2 (2020-07-08)
--- a/OrthancServer/Plugins/Samples/ModalityWorklists/Plugin.cpp	Fri Aug 14 08:26:07 2020 +0200
+++ b/OrthancServer/Plugins/Samples/ModalityWorklists/Plugin.cpp	Mon Aug 17 14:48:11 2020 +0200
@@ -31,6 +31,7 @@
 
 static std::string folder_;
 static bool filterIssuerAet_ = false;
+static unsigned int limitAnswers_ = 0;
 
 /**
  * This is the main function for matching a DICOM worklist against a query.
@@ -150,8 +151,8 @@
 
     fs::path source(folder_);
     fs::directory_iterator end;
-    int parsedFilesCount = 0;
-    int matchedWorklistCount = 0;
+    unsigned int parsedFilesCount = 0;
+    unsigned int matchedWorklistCount = 0;
 
     try
     {
@@ -171,6 +172,16 @@
             // We found a worklist (i.e. a DICOM find with extension ".wl"), match it against the query
             if (MatchWorklist(answers, query, *matcher, it->path().string()))
             {
+              if (limitAnswers_ != 0 &&
+                  matchedWorklistCount >= limitAnswers_)
+              {
+                // Too many answers are to be returned wrt. the
+                // "LimitAnswers" configuration parameter. Mark the
+                // C-FIND result as incomplete.
+                OrthancPluginWorklistMarkIncomplete(OrthancPlugins::GetGlobalContext(), answers);
+                return OrthancPluginErrorCode_Success;
+              }
+              
               OrthancPlugins::LogInfo("Worklist matched: " + it->path().string());
               matchedWorklistCount++;
             }
@@ -179,9 +190,9 @@
       }
 
       std::ostringstream message;
-      message << "Worklist C-Find: parsed " << parsedFilesCount << " files, found " << matchedWorklistCount << " match(es)";
+      message << "Worklist C-Find: parsed " << parsedFilesCount
+              << " files, found " << matchedWorklistCount << " match(es)";
       OrthancPlugins::LogInfo(message.str());
-
     }
     catch (fs::filesystem_error&)
     {
@@ -189,9 +200,6 @@
       return OrthancPluginErrorCode_DirectoryExpected;
     }
 
-    // Uncomment the following line if too many answers are to be returned
-    // OrthancPluginMarkWorklistAnswersIncomplete(OrthancPlugins::GetGlobalContext(), answers);
-
     return OrthancPluginErrorCode_Success;
   }
   catch (OrthancPlugins::PluginException& e)
@@ -239,6 +247,7 @@
       }
 
       filterIssuerAet_ = worklists.GetBooleanValue("FilterIssuerAet", false);
+      limitAnswers_ = worklists.GetUnsignedIntegerValue("LimitAnswers", 0);
     }
     else
     {
--- a/OrthancServer/Plugins/Samples/ServeFolders/Plugin.cpp	Fri Aug 14 08:26:07 2020 +0200
+++ b/OrthancServer/Plugins/Samples/ServeFolders/Plugin.cpp	Mon Aug 17 14:48:11 2020 +0200
@@ -70,6 +70,7 @@
   extensions_["wasm"] = "application/wasm";
   extensions_["woff"] = "application/x-font-woff";
   extensions_["xml"]  = "application/xml";
+  extensions_["pdf"]  = "application/pdf";
 }