diff --git a/IRaCIS.Core.Application/Service/Doctor/DTO/DoctorModel.cs b/IRaCIS.Core.Application/Service/Doctor/DTO/DoctorModel.cs index 7ed96e5d2..9f8793b4b 100644 --- a/IRaCIS.Core.Application/Service/Doctor/DTO/DoctorModel.cs +++ b/IRaCIS.Core.Application/Service/Doctor/DTO/DoctorModel.cs @@ -415,6 +415,27 @@ namespace IRaCIS.Application.Contracts /// 项目Id /// public Guid? TrialId { get; set; } + + public SaveSummarizeInfo SaveSummarizeInfoType { get; set; } = SaveSummarizeInfo.SaveSelf; + } + + public enum SaveSummarizeInfo + { + /// + /// 保存自己 + /// + SaveSelf = 0, + + /// + /// 保存并覆盖 + /// + SaveAndCover = 1, + + /// + /// 保存并新增 + /// + SaveAndAdd = 2, + } public class UpdateGneralSituationDto diff --git a/IRaCIS.Core.Application/Service/Doctor/DoctorService.cs b/IRaCIS.Core.Application/Service/Doctor/DoctorService.cs index 7fd5474e4..cdbe0e831 100644 --- a/IRaCIS.Core.Application/Service/Doctor/DoctorService.cs +++ b/IRaCIS.Core.Application/Service/Doctor/DoctorService.cs @@ -262,6 +262,37 @@ namespace IRaCIS.Core.Application.Service } } + if (inDto.TrialId != null && inDto.SaveSummarizeInfoType!= SaveSummarizeInfo.SaveSelf) + { + switch (inDto.SaveSummarizeInfoType) + { + case SaveSummarizeInfo.SaveAndCover: + await _doctorSummarizeRepository.BatchUpdateNoTrackingAsync(x => + x.DoctorId == inDto.DoctorId && x.TrialId == null && + x.IndicationEn == inDto.IndicationEn && x.Indication == inDto.Indication, x => new DoctorSummarize() + { + Summarize = inDto.Summarize, + SummarizeEn = inDto.SummarizeEn + }); + break; + case SaveSummarizeInfo.SaveAndAdd: + var exists = await _doctorSummarizeRepository.AnyAsync(x => x.DoctorId == inDto.DoctorId && x.TrialId == null && + (x.IndicationEn == inDto.IndicationEn || x.Indication == inDto.Indication)); + if (exists) + { + throw new BusinessValidationFailedException(_localizer["DoctorSummarize_repeat"]); + } + else + { + var needData = inDto.Clone(); + needData.TrialId = null; + await _doctorSummarizeRepository.InsertOrUpdateAsync(needData, true); + } + break; + } + } + + if (inDto.TrialId == null && inDto.IsMain) {