changeset 2289:89d17c72287b

Modality worklist: added logs to display the number of files parsed and number of matches
author Alain Mazy <alain@mazy.be>
date Fri, 23 Jun 2017 16:43:29 +0200
parents c6772af6dea3
children 4d500a555aad
files Plugins/Samples/ModalityWorklists/Plugin.cpp
diffstat 1 files changed, 24 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/Plugins/Samples/ModalityWorklists/Plugin.cpp	Fri Jun 23 10:51:44 2017 +0200
+++ b/Plugins/Samples/ModalityWorklists/Plugin.cpp	Fri Jun 23 16:43:29 2017 +0200
@@ -8,7 +8,7 @@
  * modify it under the terms of the GNU General Public License as
  * published by the Free Software Foundation, either version 3 of the
  * License, or (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@@ -35,7 +35,7 @@
 /**
  * This is the main function for matching a DICOM worklist against a query.
  **/
-static void  MatchWorklist(OrthancPluginWorklistAnswers*      answers,
+static bool MatchWorklist(OrthancPluginWorklistAnswers*      answers,
                            const OrthancPluginWorklistQuery*  query,
                            const OrthancPlugins::FindMatcher& matcher,
                            const std::string& path)
@@ -54,7 +54,11 @@
       OrthancPlugins::LogError(context_, "Error while adding an answer to a worklist request");
       ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(code);
     }
+
+    return true;
   }
+
+  return false;
 }
 
 
@@ -67,10 +71,10 @@
 
   // Convert the DICOM as JSON, and dump it to the user in "--verbose" mode
   Json::Value json;
-  dicom.DicomToJson(json, OrthancPluginDicomToJsonFormat_Short, 
+  dicom.DicomToJson(json, OrthancPluginDicomToJsonFormat_Short,
                     static_cast<OrthancPluginDicomToJsonFlags>(0), 0);
-  
-  OrthancPlugins::LogInfo(context_, "Received worklist query from remote modality " + 
+
+  OrthancPlugins::LogInfo(context_, "Received worklist query from remote modality " +
                           std::string(issuerAet) + ":\n" + json.toStyledString());
 
   if (!filterIssuerAet_)
@@ -140,10 +144,12 @@
     std::auto_ptr<OrthancPlugins::FindMatcher> matcher(CreateMatcher(query, issuerAet));
 
     // Loop over the regular files in the database folder
-    namespace fs = boost::filesystem;  
+    namespace fs = boost::filesystem;
 
     fs::path source(folder_);
     fs::directory_iterator end;
+    int parsedFilesCount = 0;
+    int matchedWorklistCount = 0;
 
     try
     {
@@ -159,11 +165,21 @@
 
           if (extension == ".wl")
           {
+            parsedFilesCount++;
             // We found a worklist (i.e. a DICOM find with extension ".wl"), match it against the query
-            MatchWorklist(answers, query, *matcher, it->path().string());
+            if (MatchWorklist(answers, query, *matcher, it->path().string()))
+            {
+              OrthancPlugins::LogInfo(context_, "Worklist matched: " + it->path().string());
+              matchedWorklistCount++;
+            }
           }
         }
       }
+
+      std::ostringstream message;
+      message << "Worklist C-Find: parsed " << parsedFilesCount << " files, found " << matchedWorklistCount << " match(es)";
+      OrthancPlugins::LogInfo(context_, message.str());
+
     }
     catch (fs::filesystem_error&)
     {
@@ -192,7 +208,7 @@
     /* Check the version of the Orthanc core */
     if (OrthancPluginCheckVersion(c) == 0)
     {
-      OrthancPlugins::ReportMinimalOrthancVersion(context_, 
+      OrthancPlugins::ReportMinimalOrthancVersion(context_,
                                                   ORTHANC_PLUGINS_MINIMAL_MAJOR_NUMBER,
                                                   ORTHANC_PLUGINS_MINIMAL_MINOR_NUMBER,
                                                   ORTHANC_PLUGINS_MINIMAL_REVISION_NUMBER);