Mercurial > hg > orthanc
diff Plugins/Samples/ModalityWorklists/Plugin.cpp @ 2215:028214a95194
refactoring the worklist sample
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 10 Dec 2016 11:41:17 +0100 |
parents | b1d93286b315 |
children | 9a8fab016145 |
line wrap: on
line diff
--- a/Plugins/Samples/ModalityWorklists/Plugin.cpp Sat Dec 10 11:24:58 2016 +0100 +++ b/Plugins/Samples/ModalityWorklists/Plugin.cpp Sat Dec 10 11:41:17 2016 +0100 @@ -57,6 +57,27 @@ } +OrthancPlugins::FindMatcher* CreateMatcher(const OrthancPluginWorklistQuery* query, + const char* remoteAet) +{ + OrthancPlugins::MemoryBuffer dicom(context_); + dicom.GetDicomQuery(query); + + { + Json::Value json; + dicom.DicomToJson(json, OrthancPluginDicomToJsonFormat_Short, + static_cast<OrthancPluginDicomToJsonFlags>(0), 0); + + OrthancPlugins::LogInfo(context_, "Received worklist query from remote modality " + + std::string(remoteAet) + ":\n" + json.toStyledString()); + } + + return new OrthancPlugins::FindMatcher(context_, query); + //return new OrthancPlugins::FindMatcher(context_, dicom); +} + + + OrthancPluginErrorCode Callback(OrthancPluginWorklistAnswers* answers, const OrthancPluginWorklistQuery* query, const char* remoteAet, @@ -64,21 +85,11 @@ { try { - namespace fs = boost::filesystem; - - { - OrthancPlugins::MemoryBuffer dicom(context_); - dicom.GetDicomQuery(query); + // Construct an object to match the worklists in the database against the C-Find query + std::auto_ptr<OrthancPlugins::FindMatcher> matcher(CreateMatcher(query, remoteAet)); - Json::Value json; - dicom.DicomToJson(json, OrthancPluginDicomToJsonFormat_Short, - static_cast<OrthancPluginDicomToJsonFlags>(0), 0); - - OrthancPlugins::LogInfo(context_, "Received worklist query from remote modality " + - std::string(remoteAet) + ":\n" + json.toStyledString()); - } - - OrthancPlugins::FindMatcher matcher(context_, query); + // Loop over the regular files in the database folder + namespace fs = boost::filesystem; fs::path source(folder_); fs::directory_iterator end; @@ -97,7 +108,8 @@ if (extension == ".wl") { - MatchWorklist(answers, query, matcher, it->path().string()); + // We found a worklist (i.e. a DICOM find with extension ".wl"), match it against the query + MatchWorklist(answers, query, *matcher, it->path().string()); } } }