comparison OrthancServer/OrthancFindRequestHandler.cpp @ 665:41b3e5ccb291

fix for medInria
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 07 Nov 2013 16:25:28 +0100
parents 08eca5d86aad
children 3bdb5db8e839 efc4928be6fb
comparison
equal deleted inserted replaced
664:855adbdd75a6 665:41b3e5ccb291
312 312
313 313
314 static void LookupCandidateResources(/* out */ std::list<std::string>& resources, 314 static void LookupCandidateResources(/* out */ std::list<std::string>& resources,
315 /* in */ ServerIndex& index, 315 /* in */ ServerIndex& index,
316 /* in */ ResourceType level, 316 /* in */ ResourceType level,
317 /* in */ const DicomMap& query) 317 /* in */ const DicomMap& query,
318 /* in */ ModalityManufacturer manufacturer)
318 { 319 {
319 // TODO : Speed up using full querying against the MainDicomTags. 320 // TODO : Speed up using full querying against the MainDicomTags.
320 321
321 resources.clear(); 322 resources.clear();
322 323
335 case ResourceType_Series: 336 case ResourceType_Series:
336 done = LookupCandidateResourcesInternal(resources, index, level, query, DICOM_TAG_SERIES_INSTANCE_UID); 337 done = LookupCandidateResourcesInternal(resources, index, level, query, DICOM_TAG_SERIES_INSTANCE_UID);
337 break; 338 break;
338 339
339 case ResourceType_Instance: 340 case ResourceType_Instance:
340 done = LookupCandidateResourcesInternal(resources, index, level, query, DICOM_TAG_SOP_INSTANCE_UID); 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
341 break; 357 break;
342 358
343 default: 359 default:
344 break; 360 break;
345 } 361 }
357 } 373 }
358 } 374 }
359 375
360 376
361 void OrthancFindRequestHandler::Handle(DicomFindAnswers& answers, 377 void OrthancFindRequestHandler::Handle(DicomFindAnswers& answers,
362 const DicomMap& input) 378 const DicomMap& input,
363 { 379 const std::string& callingAETitle)
380 {
381 /**
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
364 /** 398 /**
365 * Retrieve the query level. 399 * Retrieve the query level.
366 **/ 400 **/
367 401
368 const DicomValue* levelTmp = input.TestAndGetValue(DICOM_TAG_QUERY_RETRIEVE_LEVEL); 402 const DicomValue* levelTmp = input.TestAndGetValue(DICOM_TAG_QUERY_RETRIEVE_LEVEL);
371 throw OrthancException(ErrorCode_BadRequest); 405 throw OrthancException(ErrorCode_BadRequest);
372 } 406 }
373 407
374 ResourceType level = StringToResourceType(levelTmp->AsString().c_str()); 408 ResourceType level = StringToResourceType(levelTmp->AsString().c_str());
375 409
376 if (level != ResourceType_Patient && 410 switch (manufacturer)
377 level != ResourceType_Study && 411 {
378 level != ResourceType_Series) 412 case ModalityManufacturer_MedInria:
379 { 413 // MedInria makes FIND requests at the instance level before starting MOVE
380 throw OrthancException(ErrorCode_NotImplemented); 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 }
381 } 423 }
382 424
383 425
384 /** 426 /**
385 * Retrieve the candidate resources for this query level. Whenever 427 * Retrieve the candidate resources for this query level. Whenever
387 * level, as it would imply reading the JSON file on the harddisk 429 * level, as it would imply reading the JSON file on the harddisk
388 * for each of them. 430 * for each of them.
389 **/ 431 **/
390 432
391 std::list<std::string> resources; 433 std::list<std::string> resources;
392 LookupCandidateResources(resources, context_.GetIndex(), level, input); 434 LookupCandidateResources(resources, context_.GetIndex(), level, input, manufacturer);
393 435
394 436
395 /** 437 /**
396 * Apply filtering on modalities for studies, if asked (this is an 438 * Apply filtering on modalities for studies, if asked (this is an
397 * extension to standard DICOM) 439 * extension to standard DICOM)