From eed4a584e30684386d0457a6619a72b02f371ffa Mon Sep 17 00:00:00 2001
From: he <109787524@qq.com>
Date: Thu, 17 Oct 2024 15:45:47 +0800
Subject: [PATCH] =?UTF-8?q?=E9=82=AE=E4=BB=B6=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Consumer/ReadingRelationEmailConsumer.cs | 109 +++++++++++++++++-
.../Allocation/TaskMedicalReview.cs | 3 +
.../ReadingEnrollOrPDRelationEvent.cs | 2 +
.../Interceptor/AddDomainExt.cs | 2 +-
4 files changed, 112 insertions(+), 4 deletions(-)
diff --git a/IRaCIS.Core.Application/MassTransit/Consumer/ReadingRelationEmailConsumer.cs b/IRaCIS.Core.Application/MassTransit/Consumer/ReadingRelationEmailConsumer.cs
index 7c520dd97..f6ff6c5f8 100644
--- a/IRaCIS.Core.Application/MassTransit/Consumer/ReadingRelationEmailConsumer.cs
+++ b/IRaCIS.Core.Application/MassTransit/Consumer/ReadingRelationEmailConsumer.cs
@@ -227,11 +227,114 @@ public class UrgentIRRepliedMedicalReviewConsumer(
///
/// MIM 回复医学返回通知IR
///
-public class UrgentMIMRepliedMedicalReviewConsumer : IConsumer
+public class UrgentMIMRepliedMedicalReviewConsumer(
+ IRepository _userRepository,
+ IRepository _taskMedicalReviewRepository,
+ IRepository _trialRepository,
+ IRepository _subjectVisitRepository,
+ IRepository _readingQuestionCriterionTrialRepository,
+ IRepository _visitTaskRepository,
+ IRepository _dictionaryRepository,
+ IRepository _emailNoticeConfigrepository,
+ IOptionsMonitor systemEmailConfig) : IConsumer
{
- public Task Consume(ConsumeContext context)
+
+ private readonly SystemEmailSendConfig _systemEmailConfig = systemEmailConfig.CurrentValue;
+
+ ///
+ /// MIM 回复医学返回通知IR
+ ///
+ ///
+ ///
+ public async Task Consume(ConsumeContext 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()
+ {
+ 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);
}
}
diff --git a/IRaCIS.Core.Domain/Allocation/TaskMedicalReview.cs b/IRaCIS.Core.Domain/Allocation/TaskMedicalReview.cs
index d2950a0f7..b2c80102e 100644
--- a/IRaCIS.Core.Domain/Allocation/TaskMedicalReview.cs
+++ b/IRaCIS.Core.Domain/Allocation/TaskMedicalReview.cs
@@ -76,6 +76,9 @@ public class TaskMedicalReview : BaseFullAuditEntity
public Guid VisitTaskId { get; set; }
public Guid TrialId { get; set; }
+ ///
+ /// 审核结论 false 为通过 true 为不通过
+ ///
[Comment("是否有问题")]
public bool IsHaveQuestion { get; set; } = false;
diff --git a/IRaCIS.Core.Domain/_DomainEvent/ReadingEnrollOrPDRelationEvent.cs b/IRaCIS.Core.Domain/_DomainEvent/ReadingEnrollOrPDRelationEvent.cs
index 170809f01..0c210c440 100644
--- a/IRaCIS.Core.Domain/_DomainEvent/ReadingEnrollOrPDRelationEvent.cs
+++ b/IRaCIS.Core.Domain/_DomainEvent/ReadingEnrollOrPDRelationEvent.cs
@@ -37,6 +37,8 @@ public class UrgentIRRepliedMedicalReview : DomainEvent
public class UrgentMIMRepliedMedicalReview : DomainEvent
{
public Guid ReadingMedicalReviewDialogId { get; set; }
+
+ public Guid MedicalReviewId { get; set; }
}
diff --git a/IRaCIS.Core.Infra.EFCore/Interceptor/AddDomainExt.cs b/IRaCIS.Core.Infra.EFCore/Interceptor/AddDomainExt.cs
index 0135866e8..7d26f4e2c 100644
--- a/IRaCIS.Core.Infra.EFCore/Interceptor/AddDomainExt.cs
+++ b/IRaCIS.Core.Infra.EFCore/Interceptor/AddDomainExt.cs
@@ -216,7 +216,7 @@ public static class DBContext_Ext
{
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)
{