# HG changeset patch # User Alain Mazy # Date 1773260136 -3600 # Node ID efa9c6284f8340fcbe36fb12341a02c7f2794fb1 # Parent 2c557f38484a3a88ec8d2ea20ad8c2891fdc26da More detailed error in modifications diff -r 2c557f38484a -r efa9c6284f83 OrthancServer/Sources/ServerJobs/ResourceModificationJob.cpp --- a/OrthancServer/Sources/ServerJobs/ResourceModificationJob.cpp Wed Mar 04 14:12:36 2026 +0100 +++ b/OrthancServer/Sources/ServerJobs/ResourceModificationJob.cpp Wed Mar 11 21:15:36 2026 +0100 @@ -807,12 +807,21 @@ mainPatientTag != mainPatientTags.end(); ++mainPatientTag) { if (targetPatientTags.HasTag(*mainPatientTag) && - (!modification_->IsReplaced(*mainPatientTag) || + ((!modification_->IsReplaced(*mainPatientTag) && targetPatientTags.GetStringValue(*mainPatientTag, "", false).size() > 0) || modification_->GetReplacementAsString(*mainPatientTag) != targetPatientTags.GetStringValue(*mainPatientTag, "", false))) { - throw OrthancException(ErrorCode_BadRequest, std::string("Trying to change patient tags in a study. " - "The Patient already exists and has other studies. All the 'Replace' tags should match the existing patient main dicom tags " - "and you should specify all Patient MainDicomTags in your query. Try using /patients/../modify instead to modify the patient. Failing tag: ") + mainPatientTag->Format()); + if (!modification_->IsReplaced(*mainPatientTag)) + { + throw OrthancException(ErrorCode_BadRequest, std::string("Trying to change patient tags in a study. " + "The Patient already exists and has other studies. All the 'Replace' tags should match the existing patient main dicom tags " + "and you should specify all Patient MainDicomTags in your query. Try using /patients/../modify instead to modify the patient. Missing tag in the 'Replace' tags: ") + mainPatientTag->Format()); + } + else + { + throw OrthancException(ErrorCode_BadRequest, std::string("Trying to change patient tags in a study. " + "The Patient already exists and has other studies. All the 'Replace' tags should match the existing patient main dicom tags " + "and you should specify all Patient MainDicomTags in your query. Try using /patients/../modify instead to modify the patient. Failing tag: ") + mainPatientTag->Format()); + } } else if (!targetPatientTags.HasTag(*mainPatientTag) && modification_->IsReplaced(*mainPatientTag) ) {