Mercurial > hg > orthanc
diff OrthancFramework/Sources/DicomParsing/DicomModification.cpp @ 5137:15109c3f0f7d
added sanity checks in DicomModificationJob + automatically reconstruct resources at the end of a DicomModificationJob
author | Alain Mazy <am@osimis.io> |
---|---|
date | Wed, 18 Jan 2023 17:58:51 +0100 |
parents | 482f3e80ed0a |
children | 023569e7155b |
line wrap: on
line diff
--- a/OrthancFramework/Sources/DicomParsing/DicomModification.cpp Tue Jan 17 17:54:38 2023 +0100 +++ b/OrthancFramework/Sources/DicomParsing/DicomModification.cpp Wed Jan 18 17:58:51 2023 +0100 @@ -544,6 +544,7 @@ void DicomModification::Keep(const DicomTag& tag) { + keep_.insert(tag); removals_.erase(tag); clearings_.erase(tag); uids_.erase(tag); @@ -640,6 +641,11 @@ return replacements_.find(tag) != replacements_.end(); } + bool DicomModification::IsKept(const DicomTag& tag) const + { + return keep_.find(tag) != keep_.end(); + } + const Json::Value& DicomModification::GetReplacement(const DicomTag& tag) const { Replacements::const_iterator it = replacements_.find(tag); @@ -849,6 +855,7 @@ isAnonymization_ = true; + keep_.clear(); removals_.clear(); clearings_.clear(); removedRanges_.clear(); @@ -926,7 +933,7 @@ IsRemoved(DICOM_TAG_SERIES_INSTANCE_UID) || IsRemoved(DICOM_TAG_SOP_INSTANCE_UID)) { - throw OrthancException(ErrorCode_BadRequest); + throw OrthancException(ErrorCode_BadRequest, "It is forbidden to remove one of the main Dicom identifiers"); } if (!allowManualIdentifiers_) @@ -1843,4 +1850,13 @@ (tag == DICOM_TAG_SOP_INSTANCE_UID && !keepSopInstanceUid_)); } + + void DicomModification::GetReplacedTags(std::set<DicomTag>& target) const + { + target.clear(); + for (Replacements::const_iterator it = replacements_.begin(); it != replacements_.end(); it++) + { + target.insert(it->first); + } + } }