Mercurial > hg > orthanc
changeset 2535:d3476d90dcb7
DicomModification::SetDicomIdentifierGenerator()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 17 Apr 2018 13:03:34 +0200 |
parents | 373d75b90d3b |
children | e0e377a48626 |
files | Core/DicomParsing/DicomModification.cpp Core/DicomParsing/DicomModification.h |
diffstat | 2 files changed, 44 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/Core/DicomParsing/DicomModification.cpp Tue Apr 17 11:42:01 2018 +0200 +++ b/Core/DicomParsing/DicomModification.cpp Tue Apr 17 13:03:34 2018 +0200 @@ -247,7 +247,19 @@ if (previous == uidMap_.end()) { - mapped = FromDcmtkBridge::GenerateUniqueIdentifier(level); + if (identifierGenerator_ == NULL) + { + mapped = FromDcmtkBridge::GenerateUniqueIdentifier(level); + } + else + { + if (!identifierGenerator_->Apply(mapped, original, level, currentSource_)) + { + LOG(ERROR) << "Unable to generate an anonymized ID"; + throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); + } + } + uidMap_.insert(std::make_pair(std::make_pair(level, original), mapped)); } else @@ -302,7 +314,8 @@ allowManualIdentifiers_(true), keepStudyInstanceUid_(false), keepSeriesInstanceUid_(false), - updateReferencedRelationships_(true) + updateReferencedRelationships_(true), + identifierGenerator_(NULL) { } @@ -948,6 +961,14 @@ } + // (0) Create a summary of the source file, if a custom generator + // is provided + if (identifierGenerator_ != NULL) + { + toModify.ExtractDicomSummary(currentSource_); + } + + // (1) Remove the private tags, if need be if (removePrivateTags_) {
--- a/Core/DicomParsing/DicomModification.h Tue Apr 17 11:42:01 2018 +0200 +++ b/Core/DicomParsing/DicomModification.h Tue Apr 17 13:03:34 2018 +0200 @@ -53,6 +53,19 @@ TagOperation_Remove }; + class IDicomIdentifierGenerator : public boost::noncopyable + { + public: + virtual ~IDicomIdentifierGenerator() + { + } + + virtual bool Apply(std::string& target, + const std::string& sourceIdentifier, + ResourceType level, + const DicomMap& sourceDicom) = 0; + }; + private: class RelationshipsVisitor; @@ -71,6 +84,9 @@ bool keepStudyInstanceUid_; bool keepSeriesInstanceUid_; bool updateReferencedRelationships_; + DicomMap currentSource_; + + IDicomIdentifierGenerator* identifierGenerator_; std::string MapDicomIdentifier(const std::string& original, ResourceType level); @@ -151,5 +167,10 @@ void ParseAnonymizationRequest(bool& patientNameReplaced, const Json::Value& request); + + void SetDicomIdentifierGenerator(IDicomIdentifierGenerator& generator) + { + identifierGenerator_ = &generator; + } }; }