diff --git a/IRaCIS.Core.Application/MassTransit/Consumer/ReadingRelationEmailConsumer.cs b/IRaCIS.Core.Application/MassTransit/Consumer/ReadingRelationEmailConsumer.cs index 0b90b7909..7c520dd97 100644 --- a/IRaCIS.Core.Application/MassTransit/Consumer/ReadingRelationEmailConsumer.cs +++ b/IRaCIS.Core.Application/MassTransit/Consumer/ReadingRelationEmailConsumer.cs @@ -107,14 +107,18 @@ public class UrgentMedicalReviewAddedEventConsumer( dictionValue[0], // 任务类型 {5} //dictionValue[1], // 阅片人是否同意 {6} dictionValue[2], // 审核状态 {6} - dictionValue[3] // 是否加急 {7} - + dictionValue[3], // 是否加急 {7} + _systemEmailConfig.SiteUrl // 链接 {8} ); return (topicStr, htmlBodyStr); }; - await CommonEmailHelper.GetEmailSubejctAndHtmlInfoAndBuildAsync(_emailNoticeConfigrepository, EmailBusinessScenario.EligibilityVerification_MedicalQC, messageToSend, emailConfigFunc); + await CommonEmailHelper.GetEmailSubejctAndHtmlInfoAndBuildAsync(_emailNoticeConfigrepository, + + context.Message.IsPD ? EmailBusinessScenario.PDVerification_MedicalQC : EmailBusinessScenario.EligibilityVerification_MedicalQC, + + messageToSend, emailConfigFunc); await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig); } @@ -125,6 +129,7 @@ public class UrgentIRRepliedMedicalReviewConsumer( IRepository _userRepository, IRepository _taskMedicalReviewRepository, IRepository _trialRepository, + IRepository _subjectVisitRepository, IRepository _readingQuestionCriterionTrialRepository, IRepository _visitTaskRepository, IRepository _dictionaryRepository, @@ -137,73 +142,85 @@ public class UrgentIRRepliedMedicalReviewConsumer( //IR 回复医学反馈通知MIM public async Task Consume(ConsumeContext context) { - //Console.WriteLine("发送【加急的医学反馈任务 通知MIM】邮件!!!"); - //var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US; + Console.WriteLine("发送(028,029) 【IR 回复医学反馈通知MIM】邮件!!!"); + var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US; - //var medicalReviewId = context.Message.MedicalReviewId; + var medicalReviewId = context.Message.MedicalReviewId; - //var medicalReview = await _taskMedicalReviewRepository.Where(x => x.Id == medicalReviewId).Include(x => x.VisitTask).Include(x => x.MedicalManagerUser).FirstOrDefaultAsync(); + var medicalReview = await _taskMedicalReviewRepository.Where(x => x.Id == medicalReviewId).Include(x => x.VisitTask).Include(x => x.MedicalManagerUser).FirstOrDefaultAsync(); - //if (medicalReview.MedicalManagerUserId == null) - //{ - // Console.WriteLine("MIMId为空 ID" + medicalReviewId); - // return; - //} - //var criterion = await _readingQuestionCriterionTrialRepository.FirstOrDefaultAsync(x => x.Id == medicalReview.VisitTask.TrialReadingCriterionId); - //var userinfo = await _userRepository.Where(x => x.Id == medicalReview.MedicalManagerUserId).FirstOrDefaultAsync(); + if (medicalReview.MedicalManagerUserId == null) + { + Console.WriteLine("MIMId为空 ID" + medicalReviewId); + return; + } + var criterion = await _readingQuestionCriterionTrialRepository.FirstOrDefaultAsync(x => x.Id == medicalReview.VisitTask.TrialReadingCriterionId); + var userinfo = await _userRepository.Where(x => x.Id == medicalReview.MedicalManagerUserId).FirstOrDefaultAsync(); - //var taskInfo = await _visitTaskRepository.Where(x => x.Id == medicalReview.VisitTaskId).Include(x => x.SourceSubjectVisit).Include(x => x.ReadModule).Include(x => x.Subject).FirstNotNullAsync(); + var taskInfo = await _visitTaskRepository.Where(x => x.Id == medicalReview.VisitTaskId).Include(x => x.SourceSubjectVisit).Include(x => x.ReadModule).Include(x => x.Subject).FirstNotNullAsync(); - //var messageToSend = new MimeMessage(); - ////发件地址 - //messageToSend.From.Add(new MailboxAddress(_systemEmailConfig.FromName, _systemEmailConfig.FromEmail)); - //messageToSend.To.Add(new MailboxAddress(String.Empty, userinfo.EMail)); - - //var trialInfo = await _trialRepository.FirstOrDefaultAsync(t => t.Id == medicalReview.TrialId); - //var companyName = isEn_US ? _systemEmailConfig.CompanyShortName : _systemEmailConfig.CompanyShortNameCN; + var visitid = taskInfo.SourceSubjectVisit == null ? taskInfo.ReadModule.SubjectVisitId : taskInfo.SourceSubjectVisitId; - //var dictionValue = await CommonEmailHelper.TranslationDictionary(new TranslationDictionaryDto() - //{ - - // DictionaryRepository = _dictionaryRepository, - // IsEn_US = isEn_US, + var subjectVisit = await _subjectVisitRepository.Where(x => x.Id == visitid).FirstOrDefaultAsync(); - // DictionaryList = new List() - // { - // new DictionaryDto (){DictionaryCode= "ReadingCategory",EnumValue=taskInfo.ReadingCategory.GetEnumInt(), }, - // new DictionaryDto (){DictionaryCode= "MedicalReviewDoctorUserIdea",EnumValue=medicalReview.DoctorUserIdeaEnum.GetEnumInt(), }, - // new DictionaryDto (){DictionaryCode= "MedicalReviewAuditState",EnumValue=medicalReview.AuditState.GetEnumInt(), }, - // new DictionaryDto (){DictionaryCode= "YesOrNo",EnumValue=taskInfo.IsUrgent.ToString(), } - // } - //}); - //Func<(string topicStr, string htmlBodyStr), (string topicStr, string htmlBodyStr)> emailConfigFunc = input => - //{ - // var topicStr = string.Format(input.topicStr, companyName, trialInfo.ResearchProgramNo); - // var htmlBodyStr = string.Format( - // CommonEmailHelper.ReplaceCompanyName(_systemEmailConfig, input.htmlBodyStr), - // userinfo.FullName, // 用户名 - // trialInfo.ExperimentName, // 项目 - // criterion.CriterionName, // 阅片标准 - // taskInfo.BlindSubjectCode.IsNullOrEmpty() ? taskInfo.Subject.Code : taskInfo.BlindSubjectCode, // 受试者 - // taskInfo.TaskBlindName, // 访视 - // dictionValue[0], // 任务类型 - // dictionValue[1], // 阅片人是否同意 - // dictionValue[2], // 审核状态 - // dictionValue[3] // 是否加急 - // ); + var messageToSend = new MimeMessage(); + //发件地址 + messageToSend.From.Add(new MailboxAddress(_systemEmailConfig.FromName, _systemEmailConfig.FromEmail)); + messageToSend.To.Add(new MailboxAddress(String.Empty, userinfo.EMail)); - // return (topicStr, htmlBodyStr); - //}; + var trialInfo = await _trialRepository.FirstOrDefaultAsync(t => t.Id == medicalReview.TrialId); + var companyName = isEn_US ? _systemEmailConfig.CompanyShortName : _systemEmailConfig.CompanyShortNameCN; - //await CommonEmailHelper.GetEmailSubejctAndHtmlInfoAndBuildAsync(_emailNoticeConfigrepository, EmailBusinessScenario.EligibilityVerification_MedicalQC, messageToSend, emailConfigFunc); - //await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig); + var dictionValue = await CommonEmailHelper.TranslationDictionary(new TranslationDictionaryDto() + { + + DictionaryRepository = _dictionaryRepository, + IsEn_US = isEn_US, + + + DictionaryList = new List() + { + new DictionaryDto (){DictionaryCode= "ReadingCategory",EnumValue=taskInfo.ReadingCategory.GetEnumInt(), }, + new DictionaryDto (){DictionaryCode= "MedicalReviewDoctorUserIdea",EnumValue=medicalReview.DoctorUserIdeaEnum.GetEnumInt(), }, + new DictionaryDto (){DictionaryCode= "MedicalReviewAuditState",EnumValue=medicalReview.AuditState.GetEnumInt(), }, + new DictionaryDto (){DictionaryCode= "YesOrNo",EnumValue=taskInfo.IsUrgent.ToString(), } + } + }); + + Func<(string topicStr, string htmlBodyStr), (string topicStr, string htmlBodyStr)> emailConfigFunc = input => + { + var topicStr = string.Format(input.topicStr, companyName, trialInfo.ResearchProgramNo); + var htmlBodyStr = string.Format( + CommonEmailHelper.ReplaceCompanyName(_systemEmailConfig, input.htmlBodyStr), + userinfo.FullName, // 用户名 {0} + trialInfo.ExperimentName, // 项目 {1} + criterion.CriterionName, // 阅片标准 {2} + taskInfo.BlindSubjectCode.IsNullOrEmpty() ? taskInfo.Subject.Code : taskInfo.BlindSubjectCode, // 受试者 {3} + taskInfo.TaskBlindName, // 访视 {4} + dictionValue[0], // 任务类型 {5} + dictionValue[1], // 阅片人是否同意 {6} + dictionValue[2], // 审核状态 {7} + dictionValue[3], // 是否加急 {8} + _systemEmailConfig.SiteUrl // 链接 {9} + ); + + return (topicStr, htmlBodyStr); + }; + + await CommonEmailHelper.GetEmailSubejctAndHtmlInfoAndBuildAsync(_emailNoticeConfigrepository, + + context.Message.IsPD ? EmailBusinessScenario.PDVerification_ExpeditedMedicalQCResponse : EmailBusinessScenario.EligibilityVerification_ExpeditedMedicalQCResponse, + + messageToSend, emailConfigFunc); + + await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig); } } diff --git a/IRaCIS.Core.Domain/_DomainEvent/ReadingEnrollOrPDRelationEvent.cs b/IRaCIS.Core.Domain/_DomainEvent/ReadingEnrollOrPDRelationEvent.cs index 12647f2ba..170809f01 100644 --- a/IRaCIS.Core.Domain/_DomainEvent/ReadingEnrollOrPDRelationEvent.cs +++ b/IRaCIS.Core.Domain/_DomainEvent/ReadingEnrollOrPDRelationEvent.cs @@ -25,6 +25,10 @@ public class UrgentMedicalReviewAddedEvent : DomainEvent public class UrgentIRRepliedMedicalReview : DomainEvent { public Guid ReadingMedicalReviewDialogId { get; set; } + + public Guid MedicalReviewId { get; set; } + + public bool IsPD { get; set; } } /// diff --git a/IRaCIS.Core.Infra.EFCore/Interceptor/AddDomainExt.cs b/IRaCIS.Core.Infra.EFCore/Interceptor/AddDomainExt.cs index 9651ef38b..0135866e8 100644 --- a/IRaCIS.Core.Infra.EFCore/Interceptor/AddDomainExt.cs +++ b/IRaCIS.Core.Infra.EFCore/Interceptor/AddDomainExt.cs @@ -220,7 +220,7 @@ public static class DBContext_Ext } else if (entry.State == EntityState.Added && readingMedicalReviewDialog.UserTypeEnumInt == (int)UserTypeEnum.IndependentReviewer) { - readingMedicalReviewDialog.AddDomainEvent(new UrgentIRRepliedMedicalReview() { ReadingMedicalReviewDialogId = readingMedicalReviewDialog.Id }); + readingMedicalReviewDialog.AddDomainEvent(new UrgentIRRepliedMedicalReview() { IsPD= findSubjectVisit.PDState == PDStateEnum.PDProgress, MedicalReviewId= readingMedicalReviewDialog.TaskMedicalReviewId, ReadingMedicalReviewDialogId = readingMedicalReviewDialog.Id }); } //添加进记录