diff Core/DicomParsing/DicomModification.cpp @ 2535:d3476d90dcb7

DicomModification::SetDicomIdentifierGenerator()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 17 Apr 2018 13:03:34 +0200
parents 6db878376018
children 2f3007bf0708
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_)
     {