changeset 5087:df4a90a65af9

DicomModification::SetAllowManualIdentifiers() has been removed since it was always true -> code cleanup
author Alain Mazy <am@osimis.io>
date Mon, 26 Sep 2022 18:56:40 +0200
parents 0b27bbd19b1f
children 8d2c39e8880b
files NEWS OrthancFramework/Sources/DicomParsing/DicomModification.cpp OrthancFramework/Sources/DicomParsing/DicomModification.h OrthancServer/Sources/OrthancRestApi/OrthancRestAnonymizeModify.cpp OrthancServer/Sources/ServerJobs/Operations/ModifyInstanceOperation.cpp
diffstat 5 files changed, 6 insertions(+), 76 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Mon Sep 26 18:11:03 2022 +0200
+++ b/NEWS	Mon Sep 26 18:56:40 2022 +0200
@@ -11,6 +11,12 @@
   - allow modification of a patient without changing her PatientID
 
 
+OrthancFramework (C++)
+----------------------
+
+* DicomModification::SetAllowManualIdentifiers() has been removed since it was always true -> code cleanup.
+
+
 version 1.11.2 (2022-08-30)
 ===========================
 
--- a/OrthancFramework/Sources/DicomParsing/DicomModification.cpp	Mon Sep 26 18:11:03 2022 +0200
+++ b/OrthancFramework/Sources/DicomParsing/DicomModification.cpp	Mon Sep 26 18:56:40 2022 +0200
@@ -522,7 +522,6 @@
   DicomModification::DicomModification() :
     removePrivateTags_(false),
     level_(ResourceType_Instance),
-    allowManualIdentifiers_(true),
     keepStudyInstanceUid_(false),
     keepSeriesInstanceUid_(false),
     keepSopInstanceUid_(false),
@@ -922,58 +921,6 @@
     }
     
 
-    // Sanity checks at the patient level
-    bool isReplacedPatientId = (IsReplaced(DICOM_TAG_PATIENT_ID) ||
-                                uids_.find(DICOM_TAG_PATIENT_ID) != uids_.end());
-    
-    if (!allowManualIdentifiers_)
-    {
-      if (level_ == ResourceType_Patient && IsReplaced(DICOM_TAG_STUDY_INSTANCE_UID))
-      {
-        throw OrthancException(ErrorCode_BadRequest,
-                               "When modifying a patient, the StudyInstanceUID cannot be manually modified");
-      }
-
-      if (level_ == ResourceType_Patient && IsReplaced(DICOM_TAG_SERIES_INSTANCE_UID))
-      {
-        throw OrthancException(ErrorCode_BadRequest,
-                               "When modifying a patient, the SeriesInstanceUID cannot be manually modified");
-      }
-
-      if (level_ == ResourceType_Patient && IsReplaced(DICOM_TAG_SOP_INSTANCE_UID))
-      {
-        throw OrthancException(ErrorCode_BadRequest,
-                               "When modifying a patient, the SopInstanceUID cannot be manually modified");
-      }
-    }
-
-
-    // Sanity checks at the study level
-    if (!allowManualIdentifiers_)
-    {
-      if (level_ == ResourceType_Study && IsReplaced(DICOM_TAG_SERIES_INSTANCE_UID))
-      {
-        throw OrthancException(ErrorCode_BadRequest,
-                               "When modifying a study, the SeriesInstanceUID cannot be manually modified");
-      }
-
-      if (level_ == ResourceType_Study && IsReplaced(DICOM_TAG_SOP_INSTANCE_UID))
-      {
-        throw OrthancException(ErrorCode_BadRequest,
-                               "When modifying a study, the SopInstanceUID cannot be manually modified");
-      }
-    }
-
-
-    // Sanity checks at the series level
-    if (!allowManualIdentifiers_)
-    {
-      if (level_ == ResourceType_Series && IsReplaced(DICOM_TAG_SOP_INSTANCE_UID))
-      {
-        throw OrthancException(ErrorCode_BadRequest,
-                               "When modifying a series, the SopInstanceUID cannot be manually modified");
-      }
-    }
 
     // (0) Create a summary of the source file, if a custom generator
     // is provided
@@ -1114,17 +1061,6 @@
     }
   }
 
-  void DicomModification::SetAllowManualIdentifiers(bool check)
-  {
-    allowManualIdentifiers_ = check;
-  }
-
-  bool DicomModification::AreAllowManualIdentifiers() const
-  {
-    return allowManualIdentifiers_;
-  }
-
-
   static bool IsDatabaseKey(const DicomTag& tag)
   {
     return (tag == DICOM_TAG_PATIENT_ID ||
@@ -1346,7 +1282,6 @@
 
   static const char* REMOVE_PRIVATE_TAGS = "RemovePrivateTags";
   static const char* LEVEL = "Level";
-  static const char* ALLOW_MANUAL_IDENTIFIERS = "AllowManualIdentifiers";
   static const char* KEEP_STUDY_INSTANCE_UID = "KeepStudyInstanceUID";
   static const char* KEEP_SERIES_INSTANCE_UID = "KeepSeriesInstanceUID";
   static const char* KEEP_SOP_INSTANCE_UID = "KeepSOPInstanceUID";
@@ -1378,7 +1313,6 @@
     value = Json::objectValue;
     value[REMOVE_PRIVATE_TAGS] = removePrivateTags_;
     value[LEVEL] = EnumerationToString(level_);
-    value[ALLOW_MANUAL_IDENTIFIERS] = allowManualIdentifiers_;
     value[KEEP_STUDY_INSTANCE_UID] = keepStudyInstanceUid_;
     value[KEEP_SERIES_INSTANCE_UID] = keepSeriesInstanceUid_;
     value[KEEP_SOP_INSTANCE_UID] = keepSopInstanceUid_;
@@ -1523,7 +1457,6 @@
   {
     removePrivateTags_ = SerializationToolbox::ReadBoolean(serialized, REMOVE_PRIVATE_TAGS);
     level_ = StringToResourceType(SerializationToolbox::ReadString(serialized, LEVEL).c_str());
-    allowManualIdentifiers_ = SerializationToolbox::ReadBoolean(serialized, ALLOW_MANUAL_IDENTIFIERS);
     keepStudyInstanceUid_ = SerializationToolbox::ReadBoolean(serialized, KEEP_STUDY_INSTANCE_UID);
     keepSeriesInstanceUid_ = SerializationToolbox::ReadBoolean(serialized, KEEP_SERIES_INSTANCE_UID);
     updateReferencedRelationships_ = SerializationToolbox::ReadBoolean
--- a/OrthancFramework/Sources/DicomParsing/DicomModification.h	Mon Sep 26 18:11:03 2022 +0200
+++ b/OrthancFramework/Sources/DicomParsing/DicomModification.h	Mon Sep 26 18:56:40 2022 +0200
@@ -133,7 +133,6 @@
     ResourceType level_;
     UidMap uidMap_;
     SetOfTags privateTagsToKeep_;
-    bool allowManualIdentifiers_;
     bool keepStudyInstanceUid_;
     bool keepSeriesInstanceUid_;
     bool keepSopInstanceUid_;
@@ -224,10 +223,6 @@
 
     void Apply(ParsedDicomFile& toModify);
 
-    void SetAllowManualIdentifiers(bool check);
-
-    bool AreAllowManualIdentifiers() const;
-
     void ParseModifyRequest(const Json::Value& request);
 
     // "patientNameOverridden" is set to "true" iff. the PatientName
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestAnonymizeModify.cpp	Mon Sep 26 18:11:03 2022 +0200
+++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestAnonymizeModify.cpp	Mon Sep 26 18:56:40 2022 +0200
@@ -269,7 +269,6 @@
     }
 
     DicomModification modification;
-    modification.SetAllowManualIdentifiers(true);
 
     Json::Value request;
     ParseModifyRequest(request, modification, call);
@@ -314,7 +313,6 @@
     }
 
     DicomModification modification;
-    modification.SetAllowManualIdentifiers(true);
 
     Json::Value request;
     ParseAnonymizationRequest(request, modification, call);
--- a/OrthancServer/Sources/ServerJobs/Operations/ModifyInstanceOperation.cpp	Mon Sep 26 18:11:03 2022 +0200
+++ b/OrthancServer/Sources/ServerJobs/Operations/ModifyInstanceOperation.cpp	Mon Sep 26 18:56:40 2022 +0200
@@ -43,8 +43,6 @@
       throw OrthancException(ErrorCode_NullPointer);
     }
     
-    modification_->SetAllowManualIdentifiers(true);
-
     if (modification_->IsReplaced(DICOM_TAG_PATIENT_ID))
     {
       modification_->SetLevel(ResourceType_Patient);