comparison OrthancServer/Sources/ServerJobs/ResourceModificationJob.cpp @ 5142:45ce9dfa42e0

DicomModification: sanity checks
author Alain Mazy <am@osimis.io>
date Tue, 24 Jan 2023 15:05:40 +0100
parents 023569e7155b
children 2df546a76e17
comparison
equal deleted inserted replaced
5141:023569e7155b 5142:45ce9dfa42e0
678 replaceStudyMainDicomTags |= DicomMap::IsMainDicomTag(*it, ResourceType_Study); 678 replaceStudyMainDicomTags |= DicomMap::IsMainDicomTag(*it, ResourceType_Study);
679 replaceSeriesMainDicomTags |= DicomMap::IsMainDicomTag(*it, ResourceType_Series); 679 replaceSeriesMainDicomTags |= DicomMap::IsMainDicomTag(*it, ResourceType_Series);
680 replaceInstanceMainDicomTags |= DicomMap::IsMainDicomTag(*it, ResourceType_Instance); 680 replaceInstanceMainDicomTags |= DicomMap::IsMainDicomTag(*it, ResourceType_Instance);
681 } 681 }
682 682
683 if (modification_->IsKept(DICOM_TAG_SOP_INSTANCE_UID) 683 if ((modificationLevel == ResourceType_Study || modificationLevel == ResourceType_Patient)
684 && (modificationLevel == ResourceType_Series || modificationLevel == ResourceType_Study || modificationLevel == ResourceType_Patient)) 684 && !modification_->IsReplaced(DICOM_TAG_PATIENT_ID)
685 && modification_->IsKept(DICOM_TAG_STUDY_INSTANCE_UID) && modification_->IsKept(DICOM_TAG_SERIES_INSTANCE_UID) && modification_->IsKept(DICOM_TAG_SOP_INSTANCE_UID))
685 { 686 {
686 // if we keep the SOPInstanceUID, it very likely means that we are modifying existing resources 'in place' 687 // if we keep the SOPInstanceUID, it very likely means that we are modifying existing resources 'in place'
687 688
688 // we must make sure we do not delete them at the end of the job 689 // we must make sure we do not delete them at the end of the job
689 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) 690 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)
690 { 691 {
691 throw OrthancException(ErrorCode_BadRequest, 692 throw OrthancException(ErrorCode_BadRequest,
692 "When keeping SOPInstanceUID tag, you must set KeepSource to true to avoid deleting the modified files at the end of the process"); 693 "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");
693 } 694 }
694 695
695 // and we must make sure that we overwite them with the modified resources 696 // and we must make sure that we overwite them with the modified resources
696 if (IsKeepSource() && !GetContext().IsOverwriteInstances()) 697 if (IsKeepSource() && !GetContext().IsOverwriteInstances())
697 { 698 {
698 throw OrthancException(ErrorCode_BadRequest, 699 throw OrthancException(ErrorCode_BadRequest,
699 "When keeping SOPInstanceUID tag, you must have the 'OverwriteInstances' Orthanc configuration set to true in order to replace the modified resources"); 700 "When keeping StudyInstanceUID, SeriesInstanceUID and SOPInstanceUID tag, you must have the 'OverwriteInstances' Orthanc configuration set to true in order to replace the modified resources");
700 } 701 }
701 } 702 }
702 703
703 if (modificationLevel == ResourceType_Study && replacePatientMainDicomTags) 704 if (modificationLevel == ResourceType_Study && replacePatientMainDicomTags)
704 { 705 {