changeset 3446:52da6e9335dd

Allow anonymizing/modifying instances without the PatientID tag
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 25 Jun 2019 10:51:01 +0200
parents 4944b03bb9c6
children d30668b1a44a
files Core/DicomParsing/ParsedDicomFile.cpp NEWS
diffstat 2 files changed, 15 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/Core/DicomParsing/ParsedDicomFile.cpp	Mon Jun 24 17:46:18 2019 +0200
+++ b/Core/DicomParsing/ParsedDicomFile.cpp	Tue Jun 25 10:51:01 2019 +0200
@@ -915,12 +915,23 @@
   {
     std::string patientId, studyUid, seriesUid, instanceUid;
 
-    if (!GetTagValue(patientId, DICOM_TAG_PATIENT_ID) ||
-        !GetTagValue(studyUid, DICOM_TAG_STUDY_INSTANCE_UID) ||
+    if (!GetTagValue(patientId, DICOM_TAG_PATIENT_ID))
+    {
+      /**
+       * If "PatientID" is absent, be tolerant by considering it
+       * equals the empty string, then proceed. In Orthanc <= 1.5.6,
+       * an exception "Bad file format" was generated.
+       * https://groups.google.com/d/msg/orthanc-users/aphG_h1AHVg/rfOTtTPTAgAJ
+       * https://bitbucket.org/sjodogne/orthanc/commits/4c45e018bd3de3cfa21d6efc6734673aaaee4435
+       **/
+      patientId.clear();
+    }        
+    
+    if (!GetTagValue(studyUid, DICOM_TAG_STUDY_INSTANCE_UID) ||
         !GetTagValue(seriesUid, DICOM_TAG_SERIES_INSTANCE_UID) ||
         !GetTagValue(instanceUid, DICOM_TAG_SOP_INSTANCE_UID))
     {
-      throw OrthancException(ErrorCode_BadFileFormat, "missing PatientID, StudyInstanceUID, SeriesInstanceUID or SOPInstanceUID");
+      throw OrthancException(ErrorCode_BadFileFormat, "missing StudyInstanceUID, SeriesInstanceUID or SOPInstanceUID");
     }
 
     return DicomInstanceHasher(patientId, studyUid, seriesUid, instanceUid);
--- a/NEWS	Mon Jun 24 17:46:18 2019 +0200
+++ b/NEWS	Tue Jun 25 10:51:01 2019 +0200
@@ -27,6 +27,7 @@
 * Allow the serialization of signed 16bpp images in PAM format
 * HTTP header "Accept-Encoding" is honored for streams without built-in support for compression
 * The default HTTP timeout is now 60 seconds (instead of 10 seconds in previous versions)
+* Allow anonymizing/modifying instances without the PatientID tag
 * Fix issue #106 (Unable to export preview as jpeg from Lua script)
 * Fix issue #136 (C-FIND request fails when found DICOM file does not have certain tags)
 * Fix issue #137 (C-STORE fails for unknown SOP Class although server is configured to accept any)