Mercurial > hg > orthanc
comparison OrthancServer/OrthancFindRequestHandler.cpp @ 1751:fb569ee09a69 db-changes
LookupResource complete
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 27 Oct 2015 16:05:42 +0100 |
parents | ec66a16aa398 |
children | c3d8ec63a179 |
comparison
equal
deleted
inserted
replaced
1750:55d52567bebb | 1751:fb569ee09a69 |
---|---|
28 * You should have received a copy of the GNU General Public License | 28 * You should have received a copy of the GNU General Public License |
29 * along with this program. If not, see <http://www.gnu.org/licenses/>. | 29 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
30 **/ | 30 **/ |
31 | 31 |
32 | 32 |
33 #define USE_LOOKUP_RESOURCE 0 | |
34 | |
35 | |
36 | |
33 #include "PrecompiledHeadersServer.h" | 37 #include "PrecompiledHeadersServer.h" |
34 #include "OrthancFindRequestHandler.h" | 38 #include "OrthancFindRequestHandler.h" |
35 | 39 |
36 #include "../Core/Logging.h" | 40 #include "../Core/Logging.h" |
37 #include "../Core/DicomFormat/DicomArray.h" | 41 #include "../Core/DicomFormat/DicomArray.h" |
39 #include "OrthancInitialization.h" | 43 #include "OrthancInitialization.h" |
40 #include "FromDcmtkBridge.h" | 44 #include "FromDcmtkBridge.h" |
41 | 45 |
42 #include "ResourceFinder.h" | 46 #include "ResourceFinder.h" |
43 #include "DicomFindQuery.h" | 47 #include "DicomFindQuery.h" |
48 #include "Search/LookupResource.h" | |
44 | 49 |
45 #include <boost/regex.hpp> | 50 #include <boost/regex.hpp> |
46 | 51 |
47 | 52 |
48 namespace Orthanc | 53 namespace Orthanc |
274 | 279 |
275 /** | 280 /** |
276 * Build up the query object. | 281 * Build up the query object. |
277 **/ | 282 **/ |
278 | 283 |
284 #if USE_LOOKUP_RESOURCE == 1 | |
285 LookupResource finder(level); | |
286 #else | |
279 CFindQuery findQuery(answers, context_.GetIndex(), query); | 287 CFindQuery findQuery(answers, context_.GetIndex(), query); |
280 findQuery.SetLevel(level); | 288 findQuery.SetLevel(level); |
281 | 289 #endif |
290 | |
282 for (size_t i = 0; i < query.GetSize(); i++) | 291 for (size_t i = 0; i < query.GetSize(); i++) |
283 { | 292 { |
284 const DicomTag tag = query.GetElement(i).GetTag(); | 293 const DicomTag tag = query.GetElement(i).GetTag(); |
285 | 294 |
286 if (query.GetElement(i).GetValue().IsNull() || | 295 if (query.GetElement(i).GetValue().IsNull() || |
295 { | 304 { |
296 // An empty string corresponds to a "*" wildcard constraint, so we ignore it | 305 // An empty string corresponds to a "*" wildcard constraint, so we ignore it |
297 continue; | 306 continue; |
298 } | 307 } |
299 | 308 |
309 #if USE_LOOKUP_RESOURCE == 1 | |
310 // TODO SetModalitiesInStudy(value); | |
311 | |
312 finder.Add(tag, value, caseSensitivePN); | |
313 | |
314 #else | |
315 | |
300 if (tag == DICOM_TAG_MODALITIES_IN_STUDY) | 316 if (tag == DICOM_TAG_MODALITIES_IN_STUDY) |
301 { | 317 { |
302 findQuery.SetModalitiesInStudy(value); | 318 findQuery.SetModalitiesInStudy(value); |
303 } | 319 } |
304 else | 320 else |
305 { | 321 { |
306 findQuery.SetConstraint(tag, value, caseSensitivePN); | 322 findQuery.SetConstraint(tag, value, caseSensitivePN); |
307 } | 323 } |
324 #endif | |
308 } | 325 } |
309 | 326 |
310 | 327 |
311 /** | 328 /** |
312 * Run the query. | 329 * Run the query. |
313 **/ | 330 **/ |
314 | 331 |
332 #if USE_LOOKUP_RESOURCE != 1 | |
315 ResourceFinder finder(context_); | 333 ResourceFinder finder(context_); |
334 #endif | |
316 | 335 |
317 switch (level) | 336 switch (level) |
318 { | 337 { |
319 case ResourceType_Patient: | 338 case ResourceType_Patient: |
320 case ResourceType_Study: | 339 case ResourceType_Study: |
329 default: | 348 default: |
330 throw OrthancException(ErrorCode_InternalError); | 349 throw OrthancException(ErrorCode_InternalError); |
331 } | 350 } |
332 | 351 |
333 std::list<std::string> tmp; | 352 std::list<std::string> tmp; |
353 | |
354 #if USE_LOOKUP_RESOURCE == 1 | |
355 bool finished = context_.Apply(tmp, finder); | |
356 #else | |
334 bool finished = finder.Apply(tmp, findQuery); | 357 bool finished = finder.Apply(tmp, findQuery); |
358 #endif | |
335 | 359 |
336 LOG(INFO) << "Number of matching resources: " << tmp.size(); | 360 LOG(INFO) << "Number of matching resources: " << tmp.size(); |
337 | 361 |
338 return finished; | 362 return finished; |
339 } | 363 } |