# HG changeset patch # User Sebastien Jodogne # Date 1480694315 -3600 # Node ID 3b40ca7470cc31a95469a9452aa1ac8ab9fba227 # Parent 6ac6193a7935865db07d3d81c627c84de7557ce0 "Keep" option for modifications to keep original DICOM identifiers (advanced feature) diff -r 6ac6193a7935 -r 3b40ca7470cc NEWS --- a/NEWS Fri Dec 02 16:04:00 2016 +0100 +++ b/NEWS Fri Dec 02 16:58:35 2016 +0100 @@ -17,6 +17,7 @@ * "Asynchronous" flag for URIs "/modalities/{...}/store" and "/peers/{...}/store" to avoid waiting for the completion of image transfers * Possibility to DELETE "dicom-as-json" attachments to reconstruct the JSON summaries +* "Keep" option for modifications to keep original DICOM identifiers (advanced feature) Plugins ------- diff -r 6ac6193a7935 -r 3b40ca7470cc OrthancServer/DicomModification.cpp --- a/OrthancServer/DicomModification.cpp Fri Dec 02 16:04:00 2016 +0100 +++ b/OrthancServer/DicomModification.cpp Fri Dec 02 16:58:35 2016 +0100 @@ -144,11 +144,14 @@ dicom.Replace(*tag, mapped, false /* don't try and decode data URI scheme for UIDs */, DicomReplaceMode_InsertIfAbsent); } - DicomModification::DicomModification() + DicomModification::DicomModification() : + removePrivateTags_(false), + level_(ResourceType_Instance), + allowManualIdentifiers_(true), + keepStudyInstanceUid_(false), + keepSeriesInstanceUid_(false), + keepSopInstanceUid_(false) { - removePrivateTags_ = false; - level_ = ResourceType_Instance; - allowManualIdentifiers_ = true; } DicomModification::~DicomModification() @@ -166,6 +169,21 @@ privateTagsToKeep_.insert(tag); } + if (tag == DICOM_TAG_STUDY_INSTANCE_UID) + { + keepStudyInstanceUid_ = true; + } + + if (tag == DICOM_TAG_SERIES_INSTANCE_UID) + { + keepSeriesInstanceUid_ = true; + } + + if (tag == DICOM_TAG_SOP_INSTANCE_UID) + { + keepSopInstanceUid_ = true; + } + MarkNotOrthancAnonymization(); } @@ -466,19 +484,40 @@ if (level_ <= ResourceType_Study && !IsReplaced(DICOM_TAG_STUDY_INSTANCE_UID)) { - MapDicomIdentifier(toModify, ResourceType_Study); + if (keepStudyInstanceUid_) + { + LOG(WARNING) << "Modifying a study while keeping its original StudyInstanceUID: This should be avoided!"; + } + else + { + MapDicomIdentifier(toModify, ResourceType_Study); + } } if (level_ <= ResourceType_Series && !IsReplaced(DICOM_TAG_SERIES_INSTANCE_UID)) { - MapDicomIdentifier(toModify, ResourceType_Series); + if (keepSeriesInstanceUid_) + { + LOG(WARNING) << "Modifying a series while keeping its original SeriesInstanceUID: This should be avoided!"; + } + else + { + MapDicomIdentifier(toModify, ResourceType_Series); + } } if (level_ <= ResourceType_Instance && // Always true !IsReplaced(DICOM_TAG_SOP_INSTANCE_UID)) { - MapDicomIdentifier(toModify, ResourceType_Instance); + if (keepSopInstanceUid_) + { + LOG(WARNING) << "Modifying an instance while keeping its original SOPInstanceUID: This should be avoided!"; + } + else + { + MapDicomIdentifier(toModify, ResourceType_Instance); + } } } } diff -r 6ac6193a7935 -r 3b40ca7470cc OrthancServer/DicomModification.h --- a/OrthancServer/DicomModification.h Fri Dec 02 16:04:00 2016 +0100 +++ b/OrthancServer/DicomModification.h Fri Dec 02 16:58:35 2016 +0100 @@ -57,6 +57,9 @@ UidMap uidMap_; SetOfTags privateTagsToKeep_; bool allowManualIdentifiers_; + bool keepStudyInstanceUid_; + bool keepSeriesInstanceUid_; + bool keepSopInstanceUid_; void MapDicomIdentifier(ParsedDicomFile& dicom, ResourceType level); diff -r 6ac6193a7935 -r 3b40ca7470cc OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp --- a/OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp Fri Dec 02 16:04:00 2016 +0100 +++ b/OrthancServer/OrthancRestApi/OrthancRestAnonymizeModify.cpp Fri Dec 02 16:58:35 2016 +0100 @@ -136,6 +136,16 @@ ParseReplacements(target, request["Replace"]); } + // The "Keep" operation only makes sense for the tags + // StudyInstanceUID, SeriesInstanceUID and SOPInstanceUID. Avoid + // this feature as much as possible, as this breaks the DICOM + // model of the real world, except if you know exactly what + // you're doing! + if (request.isMember("Keep")) + { + ParseListOfTags(target, request["Keep"], TagOperation_Keep); + } + return true; } else