comparison OrthancServer/DicomModification.cpp @ 991:2f76b92addd4

keep private tags during anonymization
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 02 Jul 2014 11:56:08 +0200
parents b4b46e3e6017
children 80671157d051
comparison
equal deleted inserted replaced
990:7cbcd580cd21 991:2f76b92addd4
94 94
95 void DicomModification::Keep(const DicomTag& tag) 95 void DicomModification::Keep(const DicomTag& tag)
96 { 96 {
97 removals_.erase(tag); 97 removals_.erase(tag);
98 replacements_.erase(tag); 98 replacements_.erase(tag);
99
100 if (FromDcmtkBridge::IsPrivateTag(tag))
101 {
102 privateTagsToKeep_.insert(tag);
103 }
99 } 104 }
100 105
101 void DicomModification::Remove(const DicomTag& tag) 106 void DicomModification::Remove(const DicomTag& tag)
102 { 107 {
103 removals_.insert(tag); 108 removals_.insert(tag);
104 replacements_.erase(tag); 109 replacements_.erase(tag);
110 privateTagsToKeep_.erase(tag);
105 } 111 }
106 112
107 bool DicomModification::IsRemoved(const DicomTag& tag) const 113 bool DicomModification::IsRemoved(const DicomTag& tag) const
108 { 114 {
109 return removals_.find(tag) != removals_.end(); 115 return removals_.find(tag) != removals_.end();
111 117
112 void DicomModification::Replace(const DicomTag& tag, 118 void DicomModification::Replace(const DicomTag& tag,
113 const std::string& value) 119 const std::string& value)
114 { 120 {
115 removals_.erase(tag); 121 removals_.erase(tag);
122 privateTagsToKeep_.erase(tag);
116 replacements_[tag] = value; 123 replacements_[tag] = value;
117 } 124 }
118 125
119 bool DicomModification::IsReplaced(const DicomTag& tag) const 126 bool DicomModification::IsReplaced(const DicomTag& tag) const
120 { 127 {
151 removals_.clear(); 158 removals_.clear();
152 replacements_.clear(); 159 replacements_.clear();
153 removePrivateTags_ = true; 160 removePrivateTags_ = true;
154 level_ = ResourceType_Patient; 161 level_ = ResourceType_Patient;
155 uidMap_.clear(); 162 uidMap_.clear();
163 privateTagsToKeep_.clear();
156 164
157 // This is Table E.1-1 from PS 3.15-2008 - DICOM Part 15: Security and System Management Profiles 165 // This is Table E.1-1 from PS 3.15-2008 - DICOM Part 15: Security and System Management Profiles
158 removals_.insert(DicomTag(0x0008, 0x0014)); // Instance Creator UID 166 removals_.insert(DicomTag(0x0008, 0x0014)); // Instance Creator UID
159 //removals_.insert(DicomTag(0x0008, 0x0018)); // SOP Instance UID => set in Apply() 167 //removals_.insert(DicomTag(0x0008, 0x0018)); // SOP Instance UID => set in Apply()
160 removals_.insert(DicomTag(0x0008, 0x0050)); // Accession Number 168 removals_.insert(DicomTag(0x0008, 0x0050)); // Accession Number
259 } 267 }
260 268
261 // (1) Remove the private tags, if need be 269 // (1) Remove the private tags, if need be
262 if (removePrivateTags_) 270 if (removePrivateTags_)
263 { 271 {
264 toModify.RemovePrivateTags(); 272 toModify.RemovePrivateTags(privateTagsToKeep_);
265 } 273 }
266 274
267 // (2) Remove the tags specified by the user 275 // (2) Remove the tags specified by the user
268 for (Removals::const_iterator it = removals_.begin(); 276 for (SetOfTags::const_iterator it = removals_.begin();
269 it != removals_.end(); ++it) 277 it != removals_.end(); ++it)
270 { 278 {
271 toModify.Remove(*it); 279 toModify.Remove(*it);
272 } 280 }
273 281