changeset 6055:9691db8cf787

fix Deidentification method
author Alain Mazy <am@orthanc.team>
date Fri, 21 Mar 2025 18:13:42 +0100 (2 months ago)
parents 0a0362c50882
children bfdb4930b69d
files NEWS OrthancFramework/Sources/DicomFormat/DicomTag.h OrthancFramework/Sources/DicomParsing/DicomModification.cpp
diffstat 3 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Thu Mar 20 18:50:13 2025 +0100
+++ b/NEWS	Fri Mar 21 18:13:42 2025 +0100
@@ -27,6 +27,12 @@
 * Enabled support of the 1.2.840.10008.1.2.1.99 transfer syntax
   (Deflated Explicit VR Little Endian) in static builds + fix length of saved files.
   https://discourse.orthanc-server.org/t/transcoding-to-deflated-transfer-syntax-fails/5489
+* When anonymizing a resource while forcing some value with the 'Replace' fields, the tag
+  0012,0063 was cleared out because the DICOM Anonymization profile was not strictly followed.
+  From now on:
+  - 0012,0063 will contain "Orthanc {version} - {Anonymization profile}" if no 'Replace' is used.
+  - 0012,0063 will contain "Orthanc {version}" if 'Replace' is used.
+  (https://orthanc.uclouvain.be/bugs/show_bug.cgi?id=240)
 * Housekeeper plugin:
   - When encountering an error, the housekeeper now skips the resource and continues processing.
 * Orthanc Explorer:
--- a/OrthancFramework/Sources/DicomFormat/DicomTag.h	Thu Mar 20 18:50:13 2025 +0100
+++ b/OrthancFramework/Sources/DicomFormat/DicomTag.h	Fri Mar 21 18:13:42 2025 +0100
@@ -106,8 +106,9 @@
   static const DicomTag DICOM_TAG_SOP_CLASS_UID(0x0008, 0x0016);
   static const DicomTag DICOM_TAG_MEDIA_STORAGE_SOP_CLASS_UID(0x0002, 0x0002);
   static const DicomTag DICOM_TAG_MEDIA_STORAGE_SOP_INSTANCE_UID(0x0002, 0x0003);
+  static const DicomTag DICOM_TAG_PATIENT_IDENTITY_REMOVED(0x0012, 0x0062);
   static const DicomTag DICOM_TAG_DEIDENTIFICATION_METHOD(0x0012, 0x0063);
-
+  
   // DICOM tags used for fMRI (thanks to Will Ryder)
   static const DicomTag DICOM_TAG_NUMBER_OF_TEMPORAL_POSITIONS(0x0020, 0x0105);
   static const DicomTag DICOM_TAG_TEMPORAL_POSITION_IDENTIFIER(0x0020, 0x0100);
--- a/OrthancFramework/Sources/DicomParsing/DicomModification.cpp	Thu Mar 20 18:50:13 2025 +0100
+++ b/OrthancFramework/Sources/DicomParsing/DicomModification.cpp	Fri Mar 21 18:13:42 2025 +0100
@@ -47,6 +47,9 @@
 static const std::string ORTHANC_DEIDENTIFICATION_METHOD_2023b =
   "Orthanc " ORTHANC_VERSION " - PS 3.15-2023b Table E.1-1 Basic Profile";
 
+static const std::string ORTHANC_UNSAFE_DEIDENTIFICATION =
+  "Orthanc " ORTHANC_VERSION;
+
 namespace Orthanc
 {
   namespace
@@ -434,8 +437,7 @@
           it->second->asString() == ORTHANC_DEIDENTIFICATION_METHOD_2021b ||
           it->second->asString() == ORTHANC_DEIDENTIFICATION_METHOD_2023b)
       {
-        delete it->second;
-        replacements_.erase(it);
+        ReplaceInternal(DICOM_TAG_DEIDENTIFICATION_METHOD, ORTHANC_UNSAFE_DEIDENTIFICATION);
       }
     }
   }
@@ -916,7 +918,7 @@
     }
 
     // Set the PatientIdentityRemoved tag
-    ReplaceInternal(DicomTag(0x0012, 0x0062), "YES");
+    ReplaceInternal(DICOM_TAG_PATIENT_IDENTITY_REMOVED, "YES");
 
     // (*) Choose a random patient name and ID
     uids_.insert(DICOM_TAG_PATIENT_ID);