comparison OrthancServer/DicomModification.cpp @ 2194:3b40ca7470cc

"Keep" option for modifications to keep original DICOM identifiers (advanced feature)
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 02 Dec 2016 16:58:35 +0100
parents b5d4f9c156ad
children e3fd5bc429a2
comparison
equal deleted inserted replaced
2193:6ac6193a7935 2194:3b40ca7470cc
142 } 142 }
143 143
144 dicom.Replace(*tag, mapped, false /* don't try and decode data URI scheme for UIDs */, DicomReplaceMode_InsertIfAbsent); 144 dicom.Replace(*tag, mapped, false /* don't try and decode data URI scheme for UIDs */, DicomReplaceMode_InsertIfAbsent);
145 } 145 }
146 146
147 DicomModification::DicomModification() 147 DicomModification::DicomModification() :
148 { 148 removePrivateTags_(false),
149 removePrivateTags_ = false; 149 level_(ResourceType_Instance),
150 level_ = ResourceType_Instance; 150 allowManualIdentifiers_(true),
151 allowManualIdentifiers_ = true; 151 keepStudyInstanceUid_(false),
152 keepSeriesInstanceUid_(false),
153 keepSopInstanceUid_(false)
154 {
152 } 155 }
153 156
154 DicomModification::~DicomModification() 157 DicomModification::~DicomModification()
155 { 158 {
156 ClearReplacements(); 159 ClearReplacements();
162 RemoveInternal(tag); 165 RemoveInternal(tag);
163 166
164 if (tag.IsPrivate()) 167 if (tag.IsPrivate())
165 { 168 {
166 privateTagsToKeep_.insert(tag); 169 privateTagsToKeep_.insert(tag);
170 }
171
172 if (tag == DICOM_TAG_STUDY_INSTANCE_UID)
173 {
174 keepStudyInstanceUid_ = true;
175 }
176
177 if (tag == DICOM_TAG_SERIES_INSTANCE_UID)
178 {
179 keepSeriesInstanceUid_ = true;
180 }
181
182 if (tag == DICOM_TAG_SOP_INSTANCE_UID)
183 {
184 keepSopInstanceUid_ = true;
167 } 185 }
168 186
169 MarkNotOrthancAnonymization(); 187 MarkNotOrthancAnonymization();
170 } 188 }
171 189
464 482
465 // (4) Update the DICOM identifiers 483 // (4) Update the DICOM identifiers
466 if (level_ <= ResourceType_Study && 484 if (level_ <= ResourceType_Study &&
467 !IsReplaced(DICOM_TAG_STUDY_INSTANCE_UID)) 485 !IsReplaced(DICOM_TAG_STUDY_INSTANCE_UID))
468 { 486 {
469 MapDicomIdentifier(toModify, ResourceType_Study); 487 if (keepStudyInstanceUid_)
488 {
489 LOG(WARNING) << "Modifying a study while keeping its original StudyInstanceUID: This should be avoided!";
490 }
491 else
492 {
493 MapDicomIdentifier(toModify, ResourceType_Study);
494 }
470 } 495 }
471 496
472 if (level_ <= ResourceType_Series && 497 if (level_ <= ResourceType_Series &&
473 !IsReplaced(DICOM_TAG_SERIES_INSTANCE_UID)) 498 !IsReplaced(DICOM_TAG_SERIES_INSTANCE_UID))
474 { 499 {
475 MapDicomIdentifier(toModify, ResourceType_Series); 500 if (keepSeriesInstanceUid_)
501 {
502 LOG(WARNING) << "Modifying a series while keeping its original SeriesInstanceUID: This should be avoided!";
503 }
504 else
505 {
506 MapDicomIdentifier(toModify, ResourceType_Series);
507 }
476 } 508 }
477 509
478 if (level_ <= ResourceType_Instance && // Always true 510 if (level_ <= ResourceType_Instance && // Always true
479 !IsReplaced(DICOM_TAG_SOP_INSTANCE_UID)) 511 !IsReplaced(DICOM_TAG_SOP_INSTANCE_UID))
480 { 512 {
481 MapDicomIdentifier(toModify, ResourceType_Instance); 513 if (keepSopInstanceUid_)
514 {
515 LOG(WARNING) << "Modifying an instance while keeping its original SOPInstanceUID: This should be avoided!";
516 }
517 else
518 {
519 MapDicomIdentifier(toModify, ResourceType_Instance);
520 }
482 } 521 }
483 } 522 }
484 } 523 }