comparison OrthancServer/ServerIndex.cpp @ 1002:b067017a8a5b lua-scripting

anonymization refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 04 Jul 2014 16:31:14 +0200
parents 84513f2ee1f3
children a226e0959d8b
comparison
equal deleted inserted replaced
1001:f3929718ea7e 1002:b067017a8a5b
382 } 382 }
383 383
384 384
385 StoreStatus ServerIndex::Store(const DicomMap& dicomSummary, 385 StoreStatus ServerIndex::Store(const DicomMap& dicomSummary,
386 const Attachments& attachments, 386 const Attachments& attachments,
387 const std::string& remoteAet) 387 const std::string& remoteAet,
388 const MetadataMap* metadata)
388 { 389 {
389 boost::mutex::scoped_lock lock(mutex_); 390 boost::mutex::scoped_lock lock(mutex_);
390 listener_->Reset(); 391 listener_->Reset();
391 392
392 DicomInstanceHasher hasher(dicomSummary); 393 DicomInstanceHasher hasher(dicomSummary);
517 it != attachments.end(); ++it) 518 it != attachments.end(); ++it)
518 { 519 {
519 db_->AddAttachment(instance, *it); 520 db_->AddAttachment(instance, *it);
520 } 521 }
521 522
522 // Attach the metadata 523 // Attach the user-specified metadata
524 if (metadata)
525 {
526 for (MetadataMap::const_iterator
527 it = metadata->begin(); it != metadata->end(); ++it)
528 {
529 switch (it->first.first)
530 {
531 case ResourceType_Patient:
532 db_->SetMetadata(patient, it->first.second, it->second);
533 break;
534
535 case ResourceType_Study:
536 db_->SetMetadata(study, it->first.second, it->second);
537 break;
538
539 case ResourceType_Series:
540 db_->SetMetadata(series, it->first.second, it->second);
541 break;
542
543 case ResourceType_Instance:
544 db_->SetMetadata(instance, it->first.second, it->second);
545 break;
546
547 default:
548 throw OrthancException(ErrorCode_ParameterOutOfRange);
549 }
550 }
551 }
552
553 // Attach the auto-computer metadata
523 std::string now = Toolbox::GetNowIsoString(); 554 std::string now = Toolbox::GetNowIsoString();
524 db_->SetMetadata(instance, MetadataType_Instance_ReceptionDate, now); 555 db_->SetMetadata(instance, MetadataType_Instance_ReceptionDate, now);
525 db_->SetMetadata(series, MetadataType_LastUpdate, now); 556 db_->SetMetadata(series, MetadataType_LastUpdate, now);
526 db_->SetMetadata(study, MetadataType_LastUpdate, now); 557 db_->SetMetadata(study, MetadataType_LastUpdate, now);
527 db_->SetMetadata(patient, MetadataType_LastUpdate, now); 558 db_->SetMetadata(patient, MetadataType_LastUpdate, now);
1692 1723
1693 t.Commit(0); 1724 t.Commit(0);
1694 } 1725 }
1695 1726
1696 1727
1728 bool ServerIndex::GetMetadata(Json::Value& target,
1729 const std::string& publicId)
1730 {
1731 boost::mutex::scoped_lock lock(mutex_);
1732
1733 target = Json::objectValue;
1734
1735 ResourceType type;
1736 int64_t id;
1737 if (!db_->LookupResource(publicId, id, type))
1738 {
1739 return false;
1740 }
1741
1742 std::list<MetadataType> metadata;
1743 db_->ListAvailableMetadata(metadata, id);
1744
1745 for (std::list<MetadataType>::const_iterator
1746 it = metadata.begin(); it != metadata.end(); it++)
1747 {
1748 std::string key = EnumerationToString(*it);
1749 std::string value = db_->GetMetadata(id, *it);
1750 target[key] = value;
1751 }
1752
1753 return true;
1754 }
1755
1756
1697 } 1757 }