Mercurial > hg > orthanc
annotate OrthancServer/OrthancFindRequestHandler.cpp @ 615:ec0b7a51d7bd find-move-scp
speed up find
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 24 Oct 2013 11:42:46 +0200 |
parents | fdd5f7f9c4d7 |
children | 5ab377df6d8b |
rev | line source |
---|---|
565
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /** |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 * Copyright (C) 2012-2013 Medical Physics Department, CHU of Liege, |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 * Belgium |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 * |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 * This program is free software: you can redistribute it and/or |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 * modify it under the terms of the GNU General Public License as |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 * published by the Free Software Foundation, either version 3 of the |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 * License, or (at your option) any later version. |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 * |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 * In addition, as a special exception, the copyright holders of this |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 * program give permission to link the code of its release with the |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 * that use the same license as the "OpenSSL" library), and distribute |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 * the linked executables. You must obey the GNU General Public License |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 * in all respects for all of the code used other than "OpenSSL". If you |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 * modify file(s) with this exception, you may extend this exception to |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 * your version of the file(s), but you are not obligated to do so. If |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 * you do not wish to do so, delete this exception statement from your |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 * version. If you delete this exception statement from all source files |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 * in the program, then also delete it here. |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 * |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 * This program is distributed in the hope that it will be useful, but |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 * WITHOUT ANY WARRANTY; without even the implied warranty of |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 * General Public License for more details. |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 * |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 * You should have received a copy of the GNU General Public License |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 **/ |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 #include "OrthancFindRequestHandler.h" |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 #include <glog/logging.h> |
608 | 35 #include <boost/regex.hpp> |
565
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 #include "../Core/DicomFormat/DicomArray.h" |
608 | 38 #include "ServerToolbox.h" |
565
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 namespace Orthanc |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 { |
615 | 42 static bool IsWildcard(const std::string& constraint) |
43 { | |
44 return (constraint.find('-') != std::string::npos || | |
45 constraint.find('*') != std::string::npos || | |
46 constraint.find('\\') != std::string::npos || | |
47 constraint.find('?') != std::string::npos); | |
48 } | |
49 | |
610 | 50 static std::string ToLowerCase(const std::string& s) |
51 { | |
52 std::string result = s; | |
53 Toolbox::ToLowerCase(result); | |
54 return result; | |
55 } | |
56 | |
608 | 57 static bool ApplyRangeConstraint(const std::string& value, |
58 const std::string& constraint) | |
59 { | |
610 | 60 size_t separator = constraint.find('-'); |
61 std::string lower = ToLowerCase(constraint.substr(0, separator)); | |
62 std::string upper = ToLowerCase(constraint.substr(separator + 1)); | |
63 std::string v = ToLowerCase(value); | |
64 | |
65 if (lower.size() == 0 && upper.size() == 0) | |
66 { | |
67 return false; | |
68 } | |
69 | |
70 if (lower.size() == 0) | |
71 { | |
72 return v <= upper; | |
73 } | |
74 | |
75 if (upper.size() == 0) | |
76 { | |
77 return v >= lower; | |
78 } | |
79 | |
80 return (v >= lower && v <= upper); | |
608 | 81 } |
82 | |
83 | |
84 static bool ApplyListConstraint(const std::string& value, | |
85 const std::string& constraint) | |
86 { | |
610 | 87 std::string v1 = ToLowerCase(value); |
608 | 88 |
89 std::vector<std::string> items; | |
90 Toolbox::TokenizeString(items, constraint, '\\'); | |
91 | |
92 for (size_t i = 0; i < items.size(); i++) | |
93 { | |
94 Toolbox::ToLowerCase(items[i]); | |
95 if (items[i] == v1) | |
96 { | |
97 return true; | |
98 } | |
99 } | |
100 | |
101 return false; | |
102 } | |
103 | |
104 | |
105 static bool Matches(const std::string& value, | |
106 const std::string& constraint) | |
107 { | |
108 // http://www.itk.org/Wiki/DICOM_QueryRetrieve_Explained | |
109 // http://dicomiseasy.blogspot.be/2012/01/dicom-queryretrieve-part-i.html | |
110 | |
111 if (constraint.find('-') != std::string::npos) | |
112 { | |
113 return ApplyRangeConstraint(value, constraint); | |
114 } | |
115 | |
116 if (constraint.find('\\') != std::string::npos) | |
117 { | |
118 return ApplyListConstraint(value, constraint); | |
119 } | |
120 | |
121 if (constraint.find('*') != std::string::npos || | |
122 constraint.find('?') != std::string::npos) | |
123 { | |
124 // TODO - Cache the constructed regular expression | |
125 boost::regex pattern(Toolbox::WildcardToRegularExpression(constraint), | |
126 boost::regex::icase /* case insensitive search */); | |
127 return boost::regex_match(value, pattern); | |
128 } | |
129 else | |
130 { | |
610 | 131 return ToLowerCase(value) == ToLowerCase(constraint); |
608 | 132 } |
133 } | |
134 | |
135 | |
136 static bool LookupOneInstance(std::string& result, | |
137 ServerIndex& index, | |
138 const std::string& id, | |
139 ResourceType type) | |
140 { | |
141 if (type == ResourceType_Instance) | |
142 { | |
143 result = id; | |
144 return true; | |
145 } | |
146 | |
147 std::string childId; | |
148 | |
149 { | |
150 std::list<std::string> children; | |
151 index.GetChildInstances(children, id); | |
152 | |
153 if (children.size() == 0) | |
154 { | |
155 return false; | |
156 } | |
157 | |
158 childId = children.front(); | |
159 } | |
160 | |
161 return LookupOneInstance(result, index, childId, GetChildResourceType(type)); | |
162 } | |
163 | |
164 | |
165 static bool Matches(const Json::Value& resource, | |
166 const DicomArray& query) | |
167 { | |
168 for (size_t i = 0; i < query.GetSize(); i++) | |
169 { | |
170 if (query.GetElement(i).GetValue().IsNull() || | |
171 query.GetElement(i).GetTag() == DICOM_TAG_QUERY_RETRIEVE_LEVEL || | |
611
9924aec1d694
filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
610
diff
changeset
|
172 query.GetElement(i).GetTag() == DICOM_TAG_SPECIFIC_CHARACTER_SET || |
9924aec1d694
filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
610
diff
changeset
|
173 query.GetElement(i).GetTag() == DICOM_TAG_MODALITIES_IN_STUDY) |
608 | 174 { |
175 continue; | |
176 } | |
177 | |
178 std::string tag = query.GetElement(i).GetTag().Format(); | |
179 std::string value; | |
180 if (resource.isMember(tag)) | |
181 { | |
182 value = resource.get(tag, Json::arrayValue).get("Value", "").asString(); | |
183 } | |
184 | |
185 if (!Matches(value, query.GetElement(i).GetValue().AsString())) | |
186 { | |
187 return false; | |
188 } | |
189 } | |
190 | |
191 return true; | |
192 } | |
193 | |
194 | |
195 static void AddAnswer(DicomFindAnswers& answers, | |
196 const Json::Value& resource, | |
197 const DicomArray& query) | |
198 { | |
199 DicomMap result; | |
200 | |
201 for (size_t i = 0; i < query.GetSize(); i++) | |
202 { | |
203 if (query.GetElement(i).GetTag() != DICOM_TAG_QUERY_RETRIEVE_LEVEL && | |
204 query.GetElement(i).GetTag() != DICOM_TAG_SPECIFIC_CHARACTER_SET) | |
205 { | |
206 std::string tag = query.GetElement(i).GetTag().Format(); | |
207 std::string value; | |
208 if (resource.isMember(tag)) | |
209 { | |
210 value = resource.get(tag, Json::arrayValue).get("Value", "").asString(); | |
211 result.SetValue(query.GetElement(i).GetTag(), value); | |
212 } | |
213 } | |
214 } | |
215 | |
216 answers.Add(result); | |
217 } | |
218 | |
219 | |
615 | 220 static bool ApplyModalitiesInStudyFilter(std::list<std::string>& filteredStudies, |
221 const std::list<std::string>& studies, | |
612 | 222 const DicomMap& input, |
223 ServerIndex& index) | |
224 { | |
615 | 225 filteredStudies.clear(); |
612 | 226 |
227 const DicomValue& v = input.GetValue(DICOM_TAG_MODALITIES_IN_STUDY); | |
228 if (v.IsNull()) | |
229 { | |
230 return false; | |
231 } | |
232 | |
233 // Move the allowed modalities into a "std::set" | |
234 std::vector<std::string> tmp; | |
235 Toolbox::TokenizeString(tmp, v.AsString(), '\\'); | |
236 | |
237 std::set<std::string> modalities; | |
238 for (size_t i = 0; i < tmp.size(); i++) | |
239 { | |
240 modalities.insert(tmp[i]); | |
241 } | |
242 | |
243 // Loop over the studies | |
615 | 244 for (std::list<std::string>::const_iterator |
245 it = studies.begin(); it != studies.end(); it++) | |
612 | 246 { |
247 try | |
248 { | |
249 // We are considering a single study. Check whether one of | |
250 // its child series matches one of the modalities. | |
251 Json::Value study; | |
615 | 252 if (index.LookupResource(study, *it, ResourceType_Study)) |
612 | 253 { |
254 // Loop over the series of the considered study. | |
255 for (Json::Value::ArrayIndex j = 0; j < study["Series"].size(); j++) // (*) | |
256 { | |
257 Json::Value series; | |
258 if (index.LookupResource(series, study["Series"][j].asString(), ResourceType_Series)) | |
259 { | |
260 // Get the modality of this series | |
261 if (series["MainDicomTags"].isMember("Modality")) | |
262 { | |
263 std::string modality = series["MainDicomTags"]["Modality"].asString(); | |
264 if (modalities.find(modality) != modalities.end()) | |
265 { | |
266 // This series of the considered study matches one | |
267 // of the required modalities. Take the study into | |
268 // consideration for future filtering. | |
615 | 269 filteredStudies.push_back(*it); |
612 | 270 |
271 // We have finished considering this study. Break the study loop at (*). | |
272 break; | |
273 } | |
274 } | |
275 } | |
276 } | |
277 } | |
278 } | |
279 catch (OrthancException&) | |
280 { | |
281 // This resource has probably been deleted during the find request | |
282 } | |
283 } | |
284 | |
285 return true; | |
286 } | |
287 | |
288 | |
615 | 289 static bool LookupCandidateResourcesInternal(/* out */ std::list<std::string>& resources, |
290 /* in */ ServerIndex& index, | |
291 /* in */ ResourceType level, | |
292 /* in */ const DicomMap& query, | |
293 /* in */ DicomTag tag) | |
294 { | |
295 if (query.HasTag(tag)) | |
296 { | |
297 const DicomValue& value = query.GetValue(tag); | |
298 if (!value.IsNull()) | |
299 { | |
300 std::string str = query.GetValue(tag).AsString(); | |
301 if (!IsWildcard(str)) | |
302 { | |
303 printf(">> [%s]\n", str.c_str()); | |
304 index.LookupTagValue(resources, tag, str/*, level*/); | |
305 return true; | |
306 } | |
307 } | |
308 } | |
309 | |
310 return false; | |
311 } | |
312 | |
313 | |
314 static void LookupCandidateResources(/* out */ std::list<std::string>& resources, | |
315 /* in */ ServerIndex& index, | |
316 /* in */ ResourceType level, | |
317 /* in */ const DicomMap& query) | |
318 { | |
319 // TODO : Speed up using full querying against the MainDicomTags. | |
320 | |
321 resources.clear(); | |
322 | |
323 bool done = false; | |
324 | |
325 switch (level) | |
326 { | |
327 case ResourceType_Patient: | |
328 done = LookupCandidateResourcesInternal(resources, index, level, query, DICOM_TAG_PATIENT_ID); | |
329 break; | |
330 | |
331 case ResourceType_Study: | |
332 done = LookupCandidateResourcesInternal(resources, index, level, query, DICOM_TAG_STUDY_INSTANCE_UID); | |
333 break; | |
334 | |
335 case ResourceType_Series: | |
336 done = LookupCandidateResourcesInternal(resources, index, level, query, DICOM_TAG_SERIES_INSTANCE_UID); | |
337 break; | |
338 | |
339 case ResourceType_Instance: | |
340 done = LookupCandidateResourcesInternal(resources, index, level, query, DICOM_TAG_SOP_INSTANCE_UID); | |
341 break; | |
342 | |
343 default: | |
344 break; | |
345 } | |
346 | |
347 if (!done) | |
348 { | |
349 Json::Value allResources; | |
350 index.GetAllUuids(allResources, level); | |
351 assert(allResources.type() == Json::arrayValue); | |
352 | |
353 for (Json::Value::ArrayIndex i = 0; i < allResources.size(); i++) | |
354 { | |
355 resources.push_back(allResources[i].asString()); | |
356 } | |
357 } | |
358 } | |
359 | |
360 | |
565
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
361 void OrthancFindRequestHandler::Handle(const DicomMap& input, |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
362 DicomFindAnswers& answers) |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
363 { |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
364 LOG(WARNING) << "Find-SCU request received"; |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
365 |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
366 /** |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
367 * Retrieve the query level. |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
368 **/ |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
369 |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
370 const DicomValue* levelTmp = input.TestAndGetValue(DICOM_TAG_QUERY_RETRIEVE_LEVEL); |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
371 if (levelTmp == NULL) |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
372 { |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
373 throw OrthancException(ErrorCode_BadRequest); |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
374 } |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
375 |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
376 ResourceType level = StringToResourceType(levelTmp->AsString().c_str()); |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
377 |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
378 if (level != ResourceType_Patient && |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
379 level != ResourceType_Study && |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
380 level != ResourceType_Series) |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
381 { |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
382 throw OrthancException(ErrorCode_NotImplemented); |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
383 } |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
384 |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
385 |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
386 /** |
615 | 387 * Retrieve the candidate resources for this query level. Whenever |
388 * possible, we avoid returning ALL the resources for this query | |
389 * level, as it would imply reading the JSON file on the harddisk | |
390 * for each of them. | |
608 | 391 **/ |
392 | |
615 | 393 std::list<std::string> resources; |
394 LookupCandidateResources(resources, context_.GetIndex(), level, input); | |
608 | 395 |
611
9924aec1d694
filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
610
diff
changeset
|
396 |
9924aec1d694
filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
610
diff
changeset
|
397 /** |
9924aec1d694
filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
610
diff
changeset
|
398 * Apply filtering on modalities for studies, if asked (this is an |
9924aec1d694
filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
610
diff
changeset
|
399 * extension to standard DICOM) |
9924aec1d694
filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
610
diff
changeset
|
400 * http://www.medicalconnections.co.uk/kb/Filtering_on_and_Retrieving_the_Modality_in_a_C_FIND |
9924aec1d694
filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
610
diff
changeset
|
401 **/ |
9924aec1d694
filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
610
diff
changeset
|
402 |
9924aec1d694
filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
610
diff
changeset
|
403 if (level == ResourceType_Study && |
9924aec1d694
filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
610
diff
changeset
|
404 input.HasTag(DICOM_TAG_MODALITIES_IN_STUDY)) |
9924aec1d694
filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
610
diff
changeset
|
405 { |
615 | 406 std::list<std::string> filtered; |
612 | 407 if (ApplyModalitiesInStudyFilter(filtered, resources, input, context_.GetIndex())) |
611
9924aec1d694
filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
610
diff
changeset
|
408 { |
612 | 409 resources = filtered; |
611
9924aec1d694
filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
610
diff
changeset
|
410 } |
9924aec1d694
filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
610
diff
changeset
|
411 } |
9924aec1d694
filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
610
diff
changeset
|
412 |
9924aec1d694
filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
610
diff
changeset
|
413 |
608 | 414 /** |
415 * Loop over all the resources for this query level. | |
565
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
416 **/ |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
417 |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
418 DicomArray query(input); |
615 | 419 for (std::list<std::string>::const_iterator |
420 resource = resources.begin(); resource != resources.end(); resource++) | |
565
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
421 { |
608 | 422 try |
565
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
423 { |
608 | 424 std::string instance; |
615 | 425 if (LookupOneInstance(instance, context_.GetIndex(), *resource, level)) |
565
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
426 { |
615 | 427 Json::Value info; |
428 context_.ReadJson(info, instance); | |
608 | 429 |
615 | 430 if (Matches(info, query)) |
608 | 431 { |
615 | 432 AddAnswer(answers, info, query); |
608 | 433 } |
565
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
434 } |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
435 } |
608 | 436 catch (OrthancException&) |
437 { | |
611
9924aec1d694
filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
610
diff
changeset
|
438 // This resource has probably been deleted during the find request |
608 | 439 } |
565
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
440 } |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
441 } |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
442 } |