Mercurial > hg > orthanc
comparison OrthancServer/main.cpp @ 1802:138664eb59de worklists
sample worklist plugin
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 20 Nov 2015 15:54:07 +0100 |
parents | 30e97a1f4093 |
children | f08978b1f45b cd213ebcaefd |
comparison
equal
deleted
inserted
replaced
1801:2c60c357ee3e | 1802:138664eb59de |
---|---|
50 #include "OrthancMoveRequestHandler.h" | 50 #include "OrthancMoveRequestHandler.h" |
51 #include "ServerToolbox.h" | 51 #include "ServerToolbox.h" |
52 #include "../Plugins/Engine/OrthancPlugins.h" | 52 #include "../Plugins/Engine/OrthancPlugins.h" |
53 #include "FromDcmtkBridge.h" | 53 #include "FromDcmtkBridge.h" |
54 | 54 |
55 #include "Search/HierarchicalMatcher.h" | |
56 | |
57 using namespace Orthanc; | 55 using namespace Orthanc; |
58 | |
59 | |
60 | |
61 | 56 |
62 | 57 |
63 class OrthancStoreRequestHandler : public IStoreRequestHandler | 58 class OrthancStoreRequestHandler : public IStoreRequestHandler |
64 { | 59 { |
65 private: | 60 private: |
91 server_.Store(id, toStore); | 86 server_.Store(id, toStore); |
92 } | 87 } |
93 } | 88 } |
94 }; | 89 }; |
95 | 90 |
96 | |
97 | |
98 | |
99 class OrthancWorklistRequestHandler : public IWorklistRequestHandler | |
100 { | |
101 private: | |
102 ServerContext& server_; | |
103 | |
104 public: | |
105 OrthancWorklistRequestHandler(ServerContext& context) : | |
106 server_(context) | |
107 { | |
108 } | |
109 | |
110 virtual void Handle(DicomFindAnswers& answers, | |
111 ParsedDicomFile& query, | |
112 const std::string& remoteIp, | |
113 const std::string& remoteAet, | |
114 const std::string& calledAet) | |
115 { | |
116 LOG(WARNING) << "Worklist Find query from " << remoteAet << " to " << calledAet; | |
117 | |
118 bool caseSensitivePN = Configuration::GetGlobalBoolParameter("CaseSensitivePN", false); | |
119 HierarchicalMatcher matcher(query, caseSensitivePN); | |
120 | |
121 boost::filesystem::path source("/tmp/worklists/db/ORTHANCTEST"); | |
122 boost::filesystem::directory_iterator end; | |
123 | |
124 try | |
125 { | |
126 for (boost::filesystem::directory_iterator it(source); it != end; ++it) | |
127 { | |
128 if (is_regular_file(it->status())) | |
129 { | |
130 std::string extension = boost::filesystem::extension(it->path()); | |
131 Toolbox::ToLowerCase(extension); | |
132 | |
133 if (extension == ".wl") | |
134 { | |
135 std::string s; | |
136 Toolbox::ReadFile(s, it->path().string()); | |
137 ParsedDicomFile f(s); | |
138 | |
139 if (matcher.Match(f)) | |
140 { | |
141 std::auto_ptr<ParsedDicomFile> e(matcher.Extract(f)); | |
142 answers.Add(*e); | |
143 } | |
144 } | |
145 } | |
146 } | |
147 } | |
148 catch (boost::filesystem::filesystem_error&) | |
149 { | |
150 LOG(ERROR) << "Inexistent folder while scanning for worklists: " << source; | |
151 } | |
152 | |
153 answers.SetComplete(true); // All the worklists have been returned | |
154 } | |
155 }; | |
156 | 91 |
157 | 92 |
158 class MyDicomServerFactory : | 93 class MyDicomServerFactory : |
159 public IStoreRequestHandlerFactory, | 94 public IStoreRequestHandlerFactory, |
160 public IFindRequestHandlerFactory, | 95 public IFindRequestHandlerFactory, |