Mercurial > hg > orthanc
annotate OrthancServer/OrthancFindRequestHandler.cpp @ 689:2d0a347e8cfc
switch to 2014
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 03 Feb 2014 16:06:58 +0100 |
parents | efc4928be6fb |
children | 2e67366aab83 |
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 |
689 | 3 * Copyright (C) 2012-2014 Medical Physics Department, CHU of Liege, |
565
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" |
618 | 39 #include "OrthancInitialization.h" |
565
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 namespace Orthanc |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 { |
615 | 43 static bool IsWildcard(const std::string& constraint) |
44 { | |
45 return (constraint.find('-') != std::string::npos || | |
46 constraint.find('*') != std::string::npos || | |
47 constraint.find('\\') != std::string::npos || | |
48 constraint.find('?') != std::string::npos); | |
49 } | |
50 | |
610 | 51 static std::string ToLowerCase(const std::string& s) |
52 { | |
53 std::string result = s; | |
54 Toolbox::ToLowerCase(result); | |
55 return result; | |
56 } | |
57 | |
608 | 58 static bool ApplyRangeConstraint(const std::string& value, |
59 const std::string& constraint) | |
60 { | |
610 | 61 size_t separator = constraint.find('-'); |
62 std::string lower = ToLowerCase(constraint.substr(0, separator)); | |
63 std::string upper = ToLowerCase(constraint.substr(separator + 1)); | |
64 std::string v = ToLowerCase(value); | |
65 | |
66 if (lower.size() == 0 && upper.size() == 0) | |
67 { | |
68 return false; | |
69 } | |
70 | |
71 if (lower.size() == 0) | |
72 { | |
73 return v <= upper; | |
74 } | |
75 | |
76 if (upper.size() == 0) | |
77 { | |
78 return v >= lower; | |
79 } | |
80 | |
81 return (v >= lower && v <= upper); | |
608 | 82 } |
83 | |
84 | |
85 static bool ApplyListConstraint(const std::string& value, | |
86 const std::string& constraint) | |
87 { | |
610 | 88 std::string v1 = ToLowerCase(value); |
608 | 89 |
90 std::vector<std::string> items; | |
91 Toolbox::TokenizeString(items, constraint, '\\'); | |
92 | |
93 for (size_t i = 0; i < items.size(); i++) | |
94 { | |
95 Toolbox::ToLowerCase(items[i]); | |
96 if (items[i] == v1) | |
97 { | |
98 return true; | |
99 } | |
100 } | |
101 | |
102 return false; | |
103 } | |
104 | |
105 | |
106 static bool Matches(const std::string& value, | |
107 const std::string& constraint) | |
108 { | |
109 // http://www.itk.org/Wiki/DICOM_QueryRetrieve_Explained | |
110 // http://dicomiseasy.blogspot.be/2012/01/dicom-queryretrieve-part-i.html | |
111 | |
112 if (constraint.find('-') != std::string::npos) | |
113 { | |
114 return ApplyRangeConstraint(value, constraint); | |
115 } | |
116 | |
117 if (constraint.find('\\') != std::string::npos) | |
118 { | |
119 return ApplyListConstraint(value, constraint); | |
120 } | |
121 | |
122 if (constraint.find('*') != std::string::npos || | |
123 constraint.find('?') != std::string::npos) | |
124 { | |
125 // TODO - Cache the constructed regular expression | |
126 boost::regex pattern(Toolbox::WildcardToRegularExpression(constraint), | |
127 boost::regex::icase /* case insensitive search */); | |
128 return boost::regex_match(value, pattern); | |
129 } | |
130 else | |
131 { | |
610 | 132 return ToLowerCase(value) == ToLowerCase(constraint); |
608 | 133 } |
134 } | |
135 | |
136 | |
137 static bool LookupOneInstance(std::string& result, | |
138 ServerIndex& index, | |
139 const std::string& id, | |
140 ResourceType type) | |
141 { | |
142 if (type == ResourceType_Instance) | |
143 { | |
144 result = id; | |
145 return true; | |
146 } | |
147 | |
148 std::string childId; | |
149 | |
150 { | |
151 std::list<std::string> children; | |
152 index.GetChildInstances(children, id); | |
153 | |
656 | 154 if (children.empty()) |
608 | 155 { |
156 return false; | |
157 } | |
158 | |
159 childId = children.front(); | |
160 } | |
161 | |
162 return LookupOneInstance(result, index, childId, GetChildResourceType(type)); | |
163 } | |
164 | |
165 | |
166 static bool Matches(const Json::Value& resource, | |
167 const DicomArray& query) | |
168 { | |
169 for (size_t i = 0; i < query.GetSize(); i++) | |
170 { | |
171 if (query.GetElement(i).GetValue().IsNull() || | |
172 query.GetElement(i).GetTag() == DICOM_TAG_QUERY_RETRIEVE_LEVEL || | |
611
9924aec1d694
filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
610
diff
changeset
|
173 query.GetElement(i).GetTag() == DICOM_TAG_SPECIFIC_CHARACTER_SET || |
9924aec1d694
filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
610
diff
changeset
|
174 query.GetElement(i).GetTag() == DICOM_TAG_MODALITIES_IN_STUDY) |
608 | 175 { |
176 continue; | |
177 } | |
178 | |
179 std::string tag = query.GetElement(i).GetTag().Format(); | |
180 std::string value; | |
181 if (resource.isMember(tag)) | |
182 { | |
183 value = resource.get(tag, Json::arrayValue).get("Value", "").asString(); | |
184 } | |
185 | |
186 if (!Matches(value, query.GetElement(i).GetValue().AsString())) | |
187 { | |
188 return false; | |
189 } | |
190 } | |
191 | |
192 return true; | |
193 } | |
194 | |
195 | |
196 static void AddAnswer(DicomFindAnswers& answers, | |
197 const Json::Value& resource, | |
198 const DicomArray& query) | |
199 { | |
200 DicomMap result; | |
201 | |
202 for (size_t i = 0; i < query.GetSize(); i++) | |
203 { | |
204 if (query.GetElement(i).GetTag() != DICOM_TAG_QUERY_RETRIEVE_LEVEL && | |
205 query.GetElement(i).GetTag() != DICOM_TAG_SPECIFIC_CHARACTER_SET) | |
206 { | |
207 std::string tag = query.GetElement(i).GetTag().Format(); | |
208 std::string value; | |
209 if (resource.isMember(tag)) | |
210 { | |
211 value = resource.get(tag, Json::arrayValue).get("Value", "").asString(); | |
212 result.SetValue(query.GetElement(i).GetTag(), value); | |
213 } | |
214 } | |
215 } | |
216 | |
217 answers.Add(result); | |
218 } | |
219 | |
220 | |
615 | 221 static bool ApplyModalitiesInStudyFilter(std::list<std::string>& filteredStudies, |
222 const std::list<std::string>& studies, | |
612 | 223 const DicomMap& input, |
224 ServerIndex& index) | |
225 { | |
615 | 226 filteredStudies.clear(); |
612 | 227 |
228 const DicomValue& v = input.GetValue(DICOM_TAG_MODALITIES_IN_STUDY); | |
229 if (v.IsNull()) | |
230 { | |
231 return false; | |
232 } | |
233 | |
234 // Move the allowed modalities into a "std::set" | |
235 std::vector<std::string> tmp; | |
236 Toolbox::TokenizeString(tmp, v.AsString(), '\\'); | |
237 | |
238 std::set<std::string> modalities; | |
239 for (size_t i = 0; i < tmp.size(); i++) | |
240 { | |
241 modalities.insert(tmp[i]); | |
242 } | |
243 | |
244 // Loop over the studies | |
615 | 245 for (std::list<std::string>::const_iterator |
656 | 246 it = studies.begin(); it != studies.end(); ++it) |
612 | 247 { |
248 try | |
249 { | |
250 // We are considering a single study. Check whether one of | |
251 // its child series matches one of the modalities. | |
252 Json::Value study; | |
615 | 253 if (index.LookupResource(study, *it, ResourceType_Study)) |
612 | 254 { |
255 // Loop over the series of the considered study. | |
256 for (Json::Value::ArrayIndex j = 0; j < study["Series"].size(); j++) // (*) | |
257 { | |
258 Json::Value series; | |
259 if (index.LookupResource(series, study["Series"][j].asString(), ResourceType_Series)) | |
260 { | |
261 // Get the modality of this series | |
262 if (series["MainDicomTags"].isMember("Modality")) | |
263 { | |
264 std::string modality = series["MainDicomTags"]["Modality"].asString(); | |
265 if (modalities.find(modality) != modalities.end()) | |
266 { | |
267 // This series of the considered study matches one | |
268 // of the required modalities. Take the study into | |
269 // consideration for future filtering. | |
615 | 270 filteredStudies.push_back(*it); |
612 | 271 |
272 // We have finished considering this study. Break the study loop at (*). | |
273 break; | |
274 } | |
275 } | |
276 } | |
277 } | |
278 } | |
279 } | |
280 catch (OrthancException&) | |
281 { | |
282 // This resource has probably been deleted during the find request | |
283 } | |
284 } | |
285 | |
286 return true; | |
287 } | |
288 | |
289 | |
615 | 290 static bool LookupCandidateResourcesInternal(/* out */ std::list<std::string>& resources, |
291 /* in */ ServerIndex& index, | |
292 /* in */ ResourceType level, | |
293 /* in */ const DicomMap& query, | |
294 /* in */ DicomTag tag) | |
295 { | |
296 if (query.HasTag(tag)) | |
297 { | |
298 const DicomValue& value = query.GetValue(tag); | |
299 if (!value.IsNull()) | |
300 { | |
301 std::string str = query.GetValue(tag).AsString(); | |
302 if (!IsWildcard(str)) | |
303 { | |
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, | |
665 | 317 /* in */ const DicomMap& query, |
318 /* in */ ModalityManufacturer manufacturer) | |
615 | 319 { |
320 // TODO : Speed up using full querying against the MainDicomTags. | |
321 | |
322 resources.clear(); | |
323 | |
324 bool done = false; | |
325 | |
326 switch (level) | |
327 { | |
328 case ResourceType_Patient: | |
329 done = LookupCandidateResourcesInternal(resources, index, level, query, DICOM_TAG_PATIENT_ID); | |
330 break; | |
331 | |
332 case ResourceType_Study: | |
333 done = LookupCandidateResourcesInternal(resources, index, level, query, DICOM_TAG_STUDY_INSTANCE_UID); | |
334 break; | |
335 | |
336 case ResourceType_Series: | |
337 done = LookupCandidateResourcesInternal(resources, index, level, query, DICOM_TAG_SERIES_INSTANCE_UID); | |
338 break; | |
339 | |
340 case ResourceType_Instance: | |
665 | 341 if (manufacturer == ModalityManufacturer_MedInria) |
342 { | |
343 std::list<std::string> series; | |
344 | |
345 if (LookupCandidateResourcesInternal(series, index, ResourceType_Series, query, DICOM_TAG_SERIES_INSTANCE_UID) && | |
346 series.size() == 1) | |
347 { | |
348 index.GetChildInstances(resources, series.front()); | |
349 done = true; | |
350 } | |
351 } | |
352 else | |
353 { | |
354 done = LookupCandidateResourcesInternal(resources, index, level, query, DICOM_TAG_SOP_INSTANCE_UID); | |
355 } | |
356 | |
615 | 357 break; |
358 | |
359 default: | |
360 break; | |
361 } | |
362 | |
363 if (!done) | |
364 { | |
365 Json::Value allResources; | |
366 index.GetAllUuids(allResources, level); | |
367 assert(allResources.type() == Json::arrayValue); | |
368 | |
369 for (Json::Value::ArrayIndex i = 0; i < allResources.size(); i++) | |
370 { | |
371 resources.push_back(allResources[i].asString()); | |
372 } | |
373 } | |
374 } | |
375 | |
376 | |
618 | 377 void OrthancFindRequestHandler::Handle(DicomFindAnswers& answers, |
665 | 378 const DicomMap& input, |
379 const std::string& callingAETitle) | |
565
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
380 { |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
381 /** |
665 | 382 * Retrieve the manufacturer of this modality. |
383 **/ | |
384 | |
385 ModalityManufacturer manufacturer; | |
386 | |
387 { | |
388 std::string symbolicName, address; | |
389 int port; | |
390 | |
391 if (!LookupDicomModalityUsingAETitle(callingAETitle, symbolicName, address, port, manufacturer)) | |
392 { | |
393 throw OrthancException("Unknown modality"); | |
394 } | |
395 } | |
396 | |
397 | |
398 /** | |
565
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
399 * Retrieve the query level. |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
400 **/ |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
401 |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
402 const DicomValue* levelTmp = input.TestAndGetValue(DICOM_TAG_QUERY_RETRIEVE_LEVEL); |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
403 if (levelTmp == NULL) |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
404 { |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
405 throw OrthancException(ErrorCode_BadRequest); |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
406 } |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
407 |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
408 ResourceType level = StringToResourceType(levelTmp->AsString().c_str()); |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
409 |
665 | 410 switch (manufacturer) |
565
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
411 { |
665 | 412 case ModalityManufacturer_MedInria: |
413 // MedInria makes FIND requests at the instance level before starting MOVE | |
414 break; | |
415 | |
416 default: | |
417 if (level != ResourceType_Patient && | |
418 level != ResourceType_Study && | |
419 level != ResourceType_Series) | |
420 { | |
421 throw OrthancException(ErrorCode_NotImplemented); | |
422 } | |
565
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
423 } |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
424 |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
425 |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
426 /** |
615 | 427 * Retrieve the candidate resources for this query level. Whenever |
428 * possible, we avoid returning ALL the resources for this query | |
429 * level, as it would imply reading the JSON file on the harddisk | |
430 * for each of them. | |
608 | 431 **/ |
432 | |
615 | 433 std::list<std::string> resources; |
665 | 434 LookupCandidateResources(resources, context_.GetIndex(), level, input, manufacturer); |
608 | 435 |
611
9924aec1d694
filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
610
diff
changeset
|
436 |
9924aec1d694
filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
610
diff
changeset
|
437 /** |
9924aec1d694
filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
610
diff
changeset
|
438 * 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
|
439 * extension to standard DICOM) |
9924aec1d694
filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
610
diff
changeset
|
440 * 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
|
441 **/ |
9924aec1d694
filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
610
diff
changeset
|
442 |
9924aec1d694
filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
610
diff
changeset
|
443 if (level == ResourceType_Study && |
9924aec1d694
filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
610
diff
changeset
|
444 input.HasTag(DICOM_TAG_MODALITIES_IN_STUDY)) |
9924aec1d694
filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
610
diff
changeset
|
445 { |
615 | 446 std::list<std::string> filtered; |
612 | 447 if (ApplyModalitiesInStudyFilter(filtered, resources, input, context_.GetIndex())) |
611
9924aec1d694
filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
610
diff
changeset
|
448 { |
612 | 449 resources = filtered; |
611
9924aec1d694
filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
610
diff
changeset
|
450 } |
9924aec1d694
filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
610
diff
changeset
|
451 } |
9924aec1d694
filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
610
diff
changeset
|
452 |
9924aec1d694
filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
610
diff
changeset
|
453 |
608 | 454 /** |
455 * Loop over all the resources for this query level. | |
565
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
456 **/ |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
457 |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
458 DicomArray query(input); |
615 | 459 for (std::list<std::string>::const_iterator |
656 | 460 resource = resources.begin(); resource != resources.end(); ++resource) |
565
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
461 { |
608 | 462 try |
565
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
463 { |
608 | 464 std::string instance; |
615 | 465 if (LookupOneInstance(instance, context_.GetIndex(), *resource, level)) |
565
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
466 { |
615 | 467 Json::Value info; |
468 context_.ReadJson(info, instance); | |
608 | 469 |
615 | 470 if (Matches(info, query)) |
608 | 471 { |
615 | 472 AddAnswer(answers, info, query); |
608 | 473 } |
565
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
474 } |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
475 } |
608 | 476 catch (OrthancException&) |
477 { | |
611
9924aec1d694
filtering on modalities
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
610
diff
changeset
|
478 // This resource has probably been deleted during the find request |
608 | 479 } |
565
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
480 } |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
481 } |
c931ac02db82
refactoring of find class
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
482 } |
682
efc4928be6fb
Recover pixel data for more transfer syntaxes (notably JPEG)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
665
diff
changeset
|
483 |
efc4928be6fb
Recover pixel data for more transfer syntaxes (notably JPEG)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
665
diff
changeset
|
484 |
efc4928be6fb
Recover pixel data for more transfer syntaxes (notably JPEG)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
665
diff
changeset
|
485 |
efc4928be6fb
Recover pixel data for more transfer syntaxes (notably JPEG)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
665
diff
changeset
|
486 /** |
efc4928be6fb
Recover pixel data for more transfer syntaxes (notably JPEG)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
665
diff
changeset
|
487 * TODO : Case-insensitive match for PN value representation (Patient |
efc4928be6fb
Recover pixel data for more transfer syntaxes (notably JPEG)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
665
diff
changeset
|
488 * Name). Case-senstive match for all the other value representations. |
efc4928be6fb
Recover pixel data for more transfer syntaxes (notably JPEG)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
665
diff
changeset
|
489 * |
efc4928be6fb
Recover pixel data for more transfer syntaxes (notably JPEG)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
665
diff
changeset
|
490 * Reference: DICOM PS 3.4 |
efc4928be6fb
Recover pixel data for more transfer syntaxes (notably JPEG)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
665
diff
changeset
|
491 * - C.2.2.2.1 ("Single Value Matching") |
efc4928be6fb
Recover pixel data for more transfer syntaxes (notably JPEG)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
665
diff
changeset
|
492 * - C.2.2.2.4 ("Wild Card Matching") |
efc4928be6fb
Recover pixel data for more transfer syntaxes (notably JPEG)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
665
diff
changeset
|
493 * http://medical.nema.org/Dicom/2011/11_04pu.pdf ( |
efc4928be6fb
Recover pixel data for more transfer syntaxes (notably JPEG)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
665
diff
changeset
|
494 **/ |