comparison OrthancServer/OrthancFindRequestHandler.cpp @ 4020:320cde762fd9

collect private creators from the C-Find query itself; use DefaultPrivateCreator otherwise
author Alain Mazy <alain@mazy.be>
date Tue, 09 Jun 2020 11:37:35 +0200
parents 914b15dedae3
children 1ac958787c01 cc6ed76bba27
comparison
equal deleted inserted replaced
4018:9d2d2c1afcec 4020:320cde762fd9
301 const DicomMap& mainDicomTags, 301 const DicomMap& mainDicomTags,
302 const Json::Value* dicomAsJson, 302 const Json::Value* dicomAsJson,
303 const DicomArray& query, 303 const DicomArray& query,
304 const std::list<DicomTag>& sequencesToReturn, 304 const std::list<DicomTag>& sequencesToReturn,
305 const DicomMap* counters, 305 const DicomMap* counters,
306 const std::string& defaultPrivateCreator) 306 const std::string& defaultPrivateCreator,
307 const std::map<uint16_t, std::string>& privateCreators)
307 { 308 {
308 DicomMap match; 309 DicomMap match;
309 310
310 if (dicomAsJson != NULL) 311 if (dicomAsJson != NULL)
311 { 312 {
396 content.append(item); 397 content.append(item);
397 } 398 }
398 399
399 if (tag->IsPrivate()) 400 if (tag->IsPrivate())
400 { 401 {
401 dicom.Replace(*tag, content, false, DicomReplaceMode_InsertIfAbsent, defaultPrivateCreator); // TODO: instead of taking the default private creator, we should get the private createor of the current "group" 402 if (privateCreators.find(tag->GetGroup()) != privateCreators.end())
403 {
404 dicom.Replace(*tag, content, false, DicomReplaceMode_InsertIfAbsent, privateCreators.at(tag->GetGroup()).c_str());
405 }
406 else
407 {
408 dicom.Replace(*tag, content, false, DicomReplaceMode_InsertIfAbsent, defaultPrivateCreator);
409 }
402 } 410 }
403 else 411 else
404 { 412 {
405 dicom.Replace(*tag, content, false, DicomReplaceMode_InsertIfAbsent, "" /* no private creator */); 413 dicom.Replace(*tag, content, false, DicomReplaceMode_InsertIfAbsent, "" /* no private creator */);
406 } 414 }
490 ServerContext& context_; 498 ServerContext& context_;
491 ResourceType level_; 499 ResourceType level_;
492 const DicomMap& query_; 500 const DicomMap& query_;
493 DicomArray queryAsArray_; 501 DicomArray queryAsArray_;
494 const std::list<DicomTag>& sequencesToReturn_; 502 const std::list<DicomTag>& sequencesToReturn_;
495 std::string defaultPrivateCreator_; 503 std::string defaultPrivateCreator_; // the private creator to use if the group is not defined in the query itself
504 const std::map<uint16_t, std::string>& privateCreators_; // the private creators defined in the query itself
496 505
497 public: 506 public:
498 LookupVisitor(DicomFindAnswers& answers, 507 LookupVisitor(DicomFindAnswers& answers,
499 ServerContext& context, 508 ServerContext& context,
500 ResourceType level, 509 ResourceType level,
501 const DicomMap& query, 510 const DicomMap& query,
502 const std::list<DicomTag>& sequencesToReturn) : 511 const std::list<DicomTag>& sequencesToReturn,
512 const std::map<uint16_t, std::string>& privateCreators) :
503 answers_(answers), 513 answers_(answers),
504 context_(context), 514 context_(context),
505 level_(level), 515 level_(level),
506 query_(query), 516 query_(query),
507 queryAsArray_(query), 517 queryAsArray_(query),
508 sequencesToReturn_(sequencesToReturn) 518 sequencesToReturn_(sequencesToReturn),
519 privateCreators_(privateCreators)
509 { 520 {
510 answers_.SetComplete(false); 521 answers_.SetComplete(false);
511 522
512 { 523 {
513 OrthancConfiguration::ReaderLock lock; 524 OrthancConfiguration::ReaderLock lock;
552 const Json::Value* dicomAsJson) 563 const Json::Value* dicomAsJson)
553 { 564 {
554 std::unique_ptr<DicomMap> counters(ComputeCounters(context_, instanceId, level_, query_)); 565 std::unique_ptr<DicomMap> counters(ComputeCounters(context_, instanceId, level_, query_));
555 566
556 AddAnswer(answers_, mainDicomTags, dicomAsJson, 567 AddAnswer(answers_, mainDicomTags, dicomAsJson,
557 queryAsArray_, sequencesToReturn_, counters.get(), defaultPrivateCreator_); 568 queryAsArray_, sequencesToReturn_, counters.get(), defaultPrivateCreator_, privateCreators_);
558 } 569 }
559 }; 570 };
560 571
561 572
562 void OrthancFindRequestHandler::Handle(DicomFindAnswers& answers, 573 void OrthancFindRequestHandler::Handle(DicomFindAnswers& answers,
626 LOG(INFO) << " (" << it->Format() 637 LOG(INFO) << " (" << it->Format()
627 << ") " << FromDcmtkBridge::GetTagName(*it, "") 638 << ") " << FromDcmtkBridge::GetTagName(*it, "")
628 << " : sequence tag whose content will be copied"; 639 << " : sequence tag whose content will be copied";
629 } 640 }
630 641
642 // collect the private creators from the query itself
643 std::map<uint16_t, std::string> privateCreators;
644 for (size_t i = 0; i < query.GetSize(); i++)
645 {
646 const DicomElement& element = query.GetElement(i);
647 if (element.GetTag().IsPrivate() && element.GetTag().GetElement() == 0x10)
648 {
649 privateCreators[element.GetTag().GetGroup()] = element.GetValue().GetContent();
650 }
651 }
631 652
632 /** 653 /**
633 * Build up the query object. 654 * Build up the query object.
634 **/ 655 **/
635 656
688 **/ 709 **/
689 710
690 size_t limit = (level == ResourceType_Instance) ? maxInstances_ : maxResults_; 711 size_t limit = (level == ResourceType_Instance) ? maxInstances_ : maxResults_;
691 712
692 713
693 LookupVisitor visitor(answers, context_, level, *filteredInput, sequencesToReturn); 714 LookupVisitor visitor(answers, context_, level, *filteredInput, sequencesToReturn, privateCreators);
694 context_.Apply(visitor, lookup, level, 0 /* "since" is not relevant to C-FIND */, limit); 715 context_.Apply(visitor, lookup, level, 0 /* "since" is not relevant to C-FIND */, limit);
695 } 716 }
696 717
697 718
698 void OrthancFindRequestHandler::FormatOrigin(Json::Value& origin, 719 void OrthancFindRequestHandler::FormatOrigin(Json::Value& origin,