changeset 4789:51ec061516c9

Fix handling of option "DeidentifyLogs", notably for tags (0010,0010) and (0010,0020)
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 09 Sep 2021 13:02:33 +0200
parents b47ee86a0d10
children 9754d5f2f38a
files NEWS OrthancFramework/Sources/DicomParsing/DicomModification.cpp OrthancFramework/Sources/DicomParsing/DicomModification.h OrthancServer/Sources/ServerContext.cpp
diffstat 4 files changed, 28 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Mon Sep 06 22:13:07 2021 +0200
+++ b/NEWS	Thu Sep 09 13:02:33 2021 +0200
@@ -1,6 +1,8 @@
 Pending changes in the mainline
 ===============================
 
+* Fix handling of option "DeidentifyLogs", notably for tags (0010,0010) and (0010,0020)
+
 
 Version 1.9.7 (2021-08-31)
 ==========================
--- a/OrthancFramework/Sources/DicomParsing/DicomModification.cpp	Mon Sep 06 22:13:07 2021 +0200
+++ b/OrthancFramework/Sources/DicomParsing/DicomModification.cpp	Thu Sep 09 13:02:33 2021 +0200
@@ -1808,4 +1808,25 @@
       }
     }
   }
+
+
+  bool DicomModification::IsAlteredTag(const DicomTag& tag) const
+  {
+    return (uids_.find(tag) != uids_.end() ||
+            IsCleared(tag) ||
+            IsRemoved(tag) ||
+            IsReplaced(tag) ||
+            (tag.IsPrivate() &&
+             ArePrivateTagsRemoved() &&
+             privateTagsToKeep_.find(tag) == privateTagsToKeep_.end()) ||
+            (isAnonymization_ && (
+              tag == DICOM_TAG_PATIENT_NAME ||
+              tag == DICOM_TAG_PATIENT_ID)) ||
+            (tag == DICOM_TAG_STUDY_INSTANCE_UID &&
+             !keepStudyInstanceUid_) ||
+            (tag == DICOM_TAG_SERIES_INSTANCE_UID &&
+             !keepSeriesInstanceUid_) ||
+            (tag == DICOM_TAG_SOP_INSTANCE_UID &&
+             !keepSopInstanceUid_));
+  }
 }
--- a/OrthancFramework/Sources/DicomParsing/DicomModification.h	Mon Sep 06 22:13:07 2021 +0200
+++ b/OrthancFramework/Sources/DicomParsing/DicomModification.h	Thu Sep 09 13:02:33 2021 +0200
@@ -252,5 +252,7 @@
     void Replace(const DicomPath& path,
                  const Json::Value& value,   // Encoded using UTF-8
                  bool safeForAnonymization);
+
+    bool IsAlteredTag(const DicomTag& tag) const;
   };
 }
--- a/OrthancServer/Sources/ServerContext.cpp	Mon Sep 06 22:13:07 2021 +0200
+++ b/OrthancServer/Sources/ServerContext.cpp	Thu Sep 09 13:02:33 2021 +0200
@@ -1987,10 +1987,9 @@
     static const std::string redactedContent = "*** POTENTIAL PHI ***";
 
     const DicomTag& tag = element.GetTag();
-    if (deidentifyLogs_ && (
-          logsDeidentifierRules_.IsCleared(tag) ||
-          logsDeidentifierRules_.IsRemoved(tag) ||
-          logsDeidentifierRules_.IsReplaced(tag)))
+    if (deidentifyLogs_ &&
+        !element.GetValue().GetContent().empty() &&
+        logsDeidentifierRules_.IsAlteredTag(tag))
     {
       return redactedContent;
     }