From b25c72c153c41011667b9468631394be09b3f123 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 22 Aug 2024 10:01:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E9=80=81=E9=82=AE=E4=BB=B6+pacs?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/Common/MailService.cs | 46 +++++++++++++++---- .../Service/Management/UserFeedBackService.cs | 1 + .../Service/Visit/PatientService.cs | 2 +- .../Common/EmailScenarioEnum.cs | 6 ++- 4 files changed, 45 insertions(+), 10 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Common/MailService.cs b/IRaCIS.Core.Application/Service/Common/MailService.cs index f71f70f4a..55feb7ae4 100644 --- a/IRaCIS.Core.Application/Service/Common/MailService.cs +++ b/IRaCIS.Core.Application/Service/Common/MailService.cs @@ -136,7 +136,7 @@ namespace IRaCIS.Application.Services public async Task GetEmailConfigInfoAsync(EmailBusinessScenario scenario) { - var configInfo = await _emailNoticeConfigrepository.Where(t => t.BusinessScenarioEnum == scenario).Include(t=>t.EmailNoticeUserTypeList).FirstOrDefaultAsync(); + var configInfo = await _emailNoticeConfigrepository.Where(t => t.BusinessScenarioEnum == scenario).Include(t => t.EmailNoticeUserTypeList).FirstOrDefaultAsync(); if (configInfo == null) { @@ -758,11 +758,13 @@ namespace IRaCIS.Application.Services var companyName = _userInfo.IsEn_Us ? _systemEmailConfig.CompanyShortName : _systemEmailConfig.CompanyShortNameCN; - var emailConfigInfo = await GetEmailConfigInfoAsync(feedBack.VisitTaskId != null? EmailBusinessScenario.IRImageError:(feedBack.TrialId != null? EmailBusinessScenario.TrialFeedBack: EmailBusinessScenario.SysFeedBack)); + var emialScenario = feedBack.VisitTaskId != null ? EmailBusinessScenario.IRImageError : (feedBack.SubjectVisitId != null ? EmailBusinessScenario.TrialSubjectVisitFeedBack : (feedBack.TrialId != null ? EmailBusinessScenario.TrialFeedBack : EmailBusinessScenario.SysFeedBack)); + + var emailConfigInfo = await GetEmailConfigInfoAsync(emialScenario); var userTypeEnumList = emailConfigInfo.EmailNoticeUserTypeList.Where(t => t.EmailUserType == EmailUserType.To).Select(t => t.UserType).ToList(); - var emailList = await _repository.Where(t => userTypeEnumList.Contains(t.UserTypeEnum) && + var emailList = await _repository.Where(t => userTypeEnumList.Contains(t.UserTypeEnum) && (isHaveTrialId ? t.UserTrials.Any(t => t.TrialId == feedBack.TrialId) : true)).Select(t => new { t.EMail, t.UserTypeEnum, t.FullName }).ToListAsync(); @@ -771,10 +773,11 @@ namespace IRaCIS.Application.Services messageToSend.To.Add(new MailboxAddress(email.FullName, email.EMail)); } + var userNames = string.Join(',', emailList.Select(t => t.FullName)); + //影像阅片反馈 pm if (feedBack.VisitTaskId != null) { - var userNames = string.Join(',', emailList.Where(email => email.UserTypeEnum == UserTypeEnum.ProjectManager).Select(t => t.FullName)); var emailType = await _repository.Where(t => t.Parent.Code == "Email_BusinessScenario" && t.ParentId != null && t.Code == ((int)EmailBusinessScenario.IRImageError).ToString()).Select(t => _userInfo.IsEn_Us ? t.Value : t.ValueCN).FirstOrDefaultAsync(); @@ -783,7 +786,7 @@ namespace IRaCIS.Application.Services Func<(string topicStr, string htmlBodyStr), (string topicStr, string htmlBodyStr)> emailConfigFunc = input => { - var topicStr = string.Format(input.topicStr, info.SubejctCode, info.VisitName, info.ResearchProgramNo); + var topicStr = string.Format(input.topicStr, info.ResearchProgramNo, info.SubejctCode, info.VisitName); var htmlBodyStr = string.Format(ReplaceCompanyName(input.htmlBodyStr), userNames, @@ -804,10 +807,38 @@ namespace IRaCIS.Application.Services await GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario.IRImageError, messageToSend, emailConfigFunc); } + else if (feedBack.SubjectVisitId != null) + { + var emailType = await _repository.Where(t => t.Parent.Code == "Email_BusinessScenario" && t.ParentId != null && t.Code == ((int)EmailBusinessScenario.TrialSubjectVisitFeedBack).ToString()).Select(t => _userInfo.IsEn_Us ? t.Value : t.ValueCN).FirstOrDefaultAsync(); + + + var info = await _repository.Where(t => t.Id == feedBack.SubjectVisitId).Select(t => new { t.Trial.ResearchProgramNo, t.Trial.TrialCode, SubejctCode = t.Subject.Code, t.VisitName }).FirstNotNullAsync(); + + Func<(string topicStr, string htmlBodyStr), (string topicStr, string htmlBodyStr)> emailConfigFunc = input => + { + var topicStr = string.Format(input.topicStr, info.ResearchProgramNo, info.SubejctCode, info.VisitName); + + var htmlBodyStr = string.Format(ReplaceCompanyName(input.htmlBodyStr), + userNames, + info.TrialCode, + info.SubejctCode, + info.VisitName, + feedBack.CreateUser.UserTypeRole.UserTypeShortName, + feedBack.CreateUser.FullName, + emailType, + feedBack.QuestionDescription, + _systemEmailConfig.SiteUrl + ); + + return (topicStr, htmlBodyStr); + }; + + + await GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario.TrialSubjectVisit, messageToSend, emailConfigFunc); + } //项目相关的反馈 pm admin else if (feedBack.TrialId != null) { - var userNames = string.Join(',', emailList.Where(email => email.UserTypeEnum == UserTypeEnum.ProjectManager || email.UserTypeEnum == UserTypeEnum.Admin).Select(t => t.FullName)); var emailType = await _repository.Where(t => t.Parent.Code == "Email_BusinessScenario" && t.ParentId != null && t.Code == ((int)EmailBusinessScenario.TrialFeedBack).ToString()).Select(t => _userInfo.IsEn_Us ? t.Value : t.ValueCN).FirstOrDefaultAsync(); @@ -835,11 +866,10 @@ namespace IRaCIS.Application.Services await GetEmailSubejctAndHtmlInfoAndBuildAsync(EmailBusinessScenario.TrialFeedBack, messageToSend, emailConfigFunc); } - //项目无关的反馈 admin zyss + //项目无关的反馈 admin else { - var userNames = string.Join(',', emailList.Where(email => email.UserTypeEnum == UserTypeEnum.ZYSS || email.UserTypeEnum == UserTypeEnum.Admin).Select(t => t.FullName)); Func<(string topicStr, string htmlBodyStr), (string topicStr, string htmlBodyStr)> emailConfigFunc = input => { diff --git a/IRaCIS.Core.Application/Service/Management/UserFeedBackService.cs b/IRaCIS.Core.Application/Service/Management/UserFeedBackService.cs index 7862f41e7..0b790efb5 100644 --- a/IRaCIS.Core.Application/Service/Management/UserFeedBackService.cs +++ b/IRaCIS.Core.Application/Service/Management/UserFeedBackService.cs @@ -113,6 +113,7 @@ namespace IRaCIS.Core.Application.Service var entity = await _userFeedBackRepository.InsertOrUpdateAsync(addOrEditUserFeedBack, true); + //任务反馈的添加更新都需要发送邮件,其他的是添加的时候发送 if (addOrEditUserFeedBack.VisitTaskId != null || addOrEditUserFeedBack.Id == null) { await mailService.UserFeedBackMail(entity.Id); diff --git a/IRaCIS.Core.Application/Service/Visit/PatientService.cs b/IRaCIS.Core.Application/Service/Visit/PatientService.cs index dce64507d..b0d189b76 100644 --- a/IRaCIS.Core.Application/Service/Visit/PatientService.cs +++ b/IRaCIS.Core.Application/Service/Visit/PatientService.cs @@ -69,7 +69,7 @@ namespace IRaCIS.Application.Services } - + [HttpGet] public async Task>> GetPatientSeriesList(Guid scpStudyId, [FromServices] IRepository _seriesRepository, [FromServices] IRepository _instanceRepository diff --git a/IRaCIS.Core.Domain.Share/Common/EmailScenarioEnum.cs b/IRaCIS.Core.Domain.Share/Common/EmailScenarioEnum.cs index 2520324b9..fca247f42 100644 --- a/IRaCIS.Core.Domain.Share/Common/EmailScenarioEnum.cs +++ b/IRaCIS.Core.Domain.Share/Common/EmailScenarioEnum.cs @@ -91,7 +91,11 @@ namespace IRaCIS.Core.Domain.Share SysFeedBack=26, - TrialFeedBack=27 + TrialFeedBack=27, + + TrialSubjectVisitFeedBack = 28, + + }