邮件修改

IRC_NewDev
he 2024-10-17 15:45:47 +08:00
parent 289811e0e6
commit eed4a584e3
4 changed files with 112 additions and 4 deletions

View File

@ -227,11 +227,114 @@ public class UrgentIRRepliedMedicalReviewConsumer(
/// <summary> /// <summary>
/// MIM 回复医学返回通知IR /// MIM 回复医学返回通知IR
/// </summary> /// </summary>
public class UrgentMIMRepliedMedicalReviewConsumer : IConsumer<UrgentMIMRepliedMedicalReview> public class UrgentMIMRepliedMedicalReviewConsumer(
IRepository<User> _userRepository,
IRepository<TaskMedicalReview> _taskMedicalReviewRepository,
IRepository<Trial> _trialRepository,
IRepository<SubjectVisit> _subjectVisitRepository,
IRepository<ReadingQuestionCriterionTrial> _readingQuestionCriterionTrialRepository,
IRepository<VisitTask> _visitTaskRepository,
IRepository<Dictionary> _dictionaryRepository,
IRepository<EmailNoticeConfig> _emailNoticeConfigrepository,
IOptionsMonitor<SystemEmailSendConfig> systemEmailConfig) : IConsumer<UrgentMIMRepliedMedicalReview>
{ {
public Task Consume(ConsumeContext<UrgentMIMRepliedMedicalReview> context)
private readonly SystemEmailSendConfig _systemEmailConfig = systemEmailConfig.CurrentValue;
/// <summary>
/// MIM 回复医学返回通知IR
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
public async Task Consume(ConsumeContext<UrgentMIMRepliedMedicalReview> context)
{ {
throw new NotImplementedException(); Console.WriteLine("发送(022) 【加急医学反馈】邮件!!!");
var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US;
var medicalReviewId = context.Message.MedicalReviewId;
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 taskInfo = await _visitTaskRepository.Where(x => x.Id == medicalReview.VisitTaskId).Include(x => x.SourceSubjectVisit).Include(x => x.ReadModule).Include(x => x.Subject).FirstNotNullAsync();
var userinfo = await _userRepository.Where(x => x.Id == taskInfo.DoctorUserId).FirstOrDefaultAsync();
var visitid = taskInfo.SourceSubjectVisit == null ? taskInfo.ReadModule.SubjectVisitId : taskInfo.SourceSubjectVisitId;
var subjectVisit = await _subjectVisitRepository.Where(x => x.Id == visitid).FirstOrDefaultAsync();
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 dictionValue = await CommonEmailHelper.TranslationDictionary(new TranslationDictionaryDto()
{
DictionaryRepository = _dictionaryRepository,
IsEn_US = isEn_US,
DictionaryList = new List<DictionaryDto>()
{
new DictionaryDto (){DictionaryCode= "ReadingCategory",EnumValue=taskInfo.ReadingCategory.GetEnumInt(), },
new DictionaryDto (){DictionaryCode= "IsPass",EnumValue=medicalReview.IsHaveQuestion.ToString(), },// 审核结论
new DictionaryDto (){DictionaryCode= "AuditAdvice",EnumValue=medicalReview.AuditAdviceEnum.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}
taskInfo.BlindSubjectCode.IsNullOrEmpty() ? taskInfo.Subject.Code : taskInfo.BlindSubjectCode, // 受试者 {2}
taskInfo.TaskBlindName, // 访视 {3}
criterion.CriterionName, // 阅片标准 {4}
dictionValue[0], // 任务类型 {5}
dictionValue[1], // 审核结论 {6}
dictionValue[2], // 医学审核建议 {7}
dictionValue[3], // 是否加急 {8}
_systemEmailConfig.SiteUrl // 链接 {9}
);
return (topicStr, htmlBodyStr);
};
await CommonEmailHelper.GetEmailSubejctAndHtmlInfoAndBuildAsync(_emailNoticeConfigrepository,
EmailBusinessScenario.ExpeditedMedicalQCToIR,
messageToSend, emailConfigFunc);
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
} }
} }

View File

@ -76,6 +76,9 @@ public class TaskMedicalReview : BaseFullAuditEntity
public Guid VisitTaskId { get; set; } public Guid VisitTaskId { get; set; }
public Guid TrialId { get; set; } public Guid TrialId { get; set; }
/// <summary>
/// 审核结论 false 为通过 true 为不通过
/// </summary>
[Comment("是否有问题")] [Comment("是否有问题")]
public bool IsHaveQuestion { get; set; } = false; public bool IsHaveQuestion { get; set; } = false;

View File

@ -37,6 +37,8 @@ public class UrgentIRRepliedMedicalReview : DomainEvent
public class UrgentMIMRepliedMedicalReview : DomainEvent public class UrgentMIMRepliedMedicalReview : DomainEvent
{ {
public Guid ReadingMedicalReviewDialogId { get; set; } public Guid ReadingMedicalReviewDialogId { get; set; }
public Guid MedicalReviewId { get; set; }
} }

View File

@ -216,7 +216,7 @@ public static class DBContext_Ext
{ {
if (entry.State == EntityState.Added && readingMedicalReviewDialog.UserTypeEnumInt == (int)UserTypeEnum.MIM) if (entry.State == EntityState.Added && readingMedicalReviewDialog.UserTypeEnumInt == (int)UserTypeEnum.MIM)
{ {
readingMedicalReviewDialog.AddDomainEvent(new UrgentMIMRepliedMedicalReview() { ReadingMedicalReviewDialogId = readingMedicalReviewDialog.Id }); readingMedicalReviewDialog.AddDomainEvent(new UrgentMIMRepliedMedicalReview() { MedicalReviewId = readingMedicalReviewDialog.TaskMedicalReviewId, ReadingMedicalReviewDialogId = readingMedicalReviewDialog.Id });
} }
else if (entry.State == EntityState.Added && readingMedicalReviewDialog.UserTypeEnumInt == (int)UserTypeEnum.IndependentReviewer) else if (entry.State == EntityState.Added && readingMedicalReviewDialog.UserTypeEnumInt == (int)UserTypeEnum.IndependentReviewer)
{ {