changeset 5142:45ce9dfa42e0

DicomModification: sanity checks
author Alain Mazy <am@osimis.io>
date Tue, 24 Jan 2023 15:05:40 +0100
parents 023569e7155b
children 95d8e0540219
files OrthancServer/Sources/ServerJobs/ResourceModificationJob.cpp
diffstat 1 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/Sources/ServerJobs/ResourceModificationJob.cpp	Fri Jan 20 18:10:42 2023 +0100
+++ b/OrthancServer/Sources/ServerJobs/ResourceModificationJob.cpp	Tue Jan 24 15:05:40 2023 +0100
@@ -680,8 +680,9 @@
       replaceInstanceMainDicomTags |= DicomMap::IsMainDicomTag(*it, ResourceType_Instance);
     }
 
-    if (modification_->IsKept(DICOM_TAG_SOP_INSTANCE_UID) 
-        && (modificationLevel == ResourceType_Series || modificationLevel == ResourceType_Study || modificationLevel == ResourceType_Patient))
+    if ((modificationLevel == ResourceType_Study || modificationLevel == ResourceType_Patient)
+        && !modification_->IsReplaced(DICOM_TAG_PATIENT_ID) 
+        && modification_->IsKept(DICOM_TAG_STUDY_INSTANCE_UID) && modification_->IsKept(DICOM_TAG_SERIES_INSTANCE_UID) && modification_->IsKept(DICOM_TAG_SOP_INSTANCE_UID))
     {
       // if we keep the SOPInstanceUID, it very likely means that we are modifying existing resources 'in place'
 
@@ -689,14 +690,14 @@
       if (!IsKeepSource()) // note: we can refine this criteria -> this is valid only if all DicomUIDs are kept identical (but this can happen through Keep or Replace options)
       {
         throw OrthancException(ErrorCode_BadRequest,
-                              "When keeping SOPInstanceUID tag, you must set KeepSource to true to avoid deleting the modified files at the end of the process");
+                              "When keeping StudyInstanceUID, SeriesInstanceUID and SOPInstanceUID tag, you must set KeepSource to true to avoid deleting the modified files at the end of the process");
       }
 
       // and we must make sure that we overwite them with the modified resources
       if (IsKeepSource() && !GetContext().IsOverwriteInstances())
       {
         throw OrthancException(ErrorCode_BadRequest,
-                              "When keeping SOPInstanceUID tag, you must have the 'OverwriteInstances' Orthanc configuration set to true in order to replace the modified resources");
+                              "When keeping StudyInstanceUID, SeriesInstanceUID and SOPInstanceUID tag, you must have the 'OverwriteInstances' Orthanc configuration set to true in order to replace the modified resources");
       }
     }