diff --git a/IRaCIS.Core.Application/MassTransit/Consumer/CommonEmailHelper.cs b/IRaCIS.Core.Application/MassTransit/Consumer/CommonEmailHelper.cs
index cbb6444e8..1c96a3b31 100644
--- a/IRaCIS.Core.Application/MassTransit/Consumer/CommonEmailHelper.cs
+++ b/IRaCIS.Core.Application/MassTransit/Consumer/CommonEmailHelper.cs
@@ -1,4 +1,5 @@
-using IRaCIS.Core.Domain.Share;
+using DocumentFormat.OpenXml;
+using IRaCIS.Core.Domain.Share;
using IRaCIS.Core.Infrastructure;
using MimeKit;
using System;
@@ -58,4 +59,44 @@ public static class CommonEmailHelper
.Replace("{company abbreviation}", isEn_US ? _systemEmailConfig.CompanyShortName : _systemEmailConfig.CompanyShortNameCN);
return str;
}
+
+ ///
+ /// 翻译字典
+ ///
+ ///
+ ///
+ public static string TranslationDictionary(TranslationDictionaryDto inDto)
+ {
+ var dic = inDto.DictionaryRepository.Where(x => x.Parent.Code == inDto.DictionaryCode && x.Code == inDto.EnumValue).FirstOrDefault();
+
+ return dic == null ? string.Empty : (inDto.IsEn_US ? dic.Value : dic.ValueCN);
+ }
+}
+
+
+///
+/// 转换字典的Dto
+///
+public class TranslationDictionaryDto
+{
+ ///
+ /// 字典仓储
+ ///
+ public IRepository DictionaryRepository { get; set; }
+
+ ///
+ /// 字典Code
+ ///
+ public string DictionaryCode { get; set; }
+
+ ///
+ /// 枚举值
+ ///
+ public string EnumValue { get; set; }
+
+ ///
+ /// 是否是英文
+ ///
+ public bool IsEn_US { get; set; }
+
}
diff --git a/IRaCIS.Core.Application/MassTransit/Consumer/ReadingRelationEmailConsumer.cs b/IRaCIS.Core.Application/MassTransit/Consumer/ReadingRelationEmailConsumer.cs
index 33e82753e..ed884bf8e 100644
--- a/IRaCIS.Core.Application/MassTransit/Consumer/ReadingRelationEmailConsumer.cs
+++ b/IRaCIS.Core.Application/MassTransit/Consumer/ReadingRelationEmailConsumer.cs
@@ -1,9 +1,15 @@
-using IRaCIS.Core.Application.MassTransit.Command;
+using IRaCIS.Core.Application.Helper;
+using IRaCIS.Core.Application.MassTransit.Command;
using IRaCIS.Core.Domain;
using IRaCIS.Core.Domain.BaseModel;
+using IRaCIS.Core.Domain.Models;
+using IRaCIS.Core.Domain.Share;
using MassTransit;
+using Microsoft.Extensions.Options;
+using MimeKit;
using System;
using System.Collections.Generic;
+using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -13,11 +19,76 @@ namespace IRaCIS.Core.Application.MassTransit.Consumer;
///
/// 加急的医学反馈任务 通知MIM
///
-public class UrgentMedicalReviewAddedEventConsumer : IConsumer
+public class UrgentMedicalReviewAddedEventConsumer(
+ IRepository _userRepository,
+ IRepository _taskMedicalReviewRepository,
+ IRepository _trialRepository,
+ IRepository _readingQuestionCriterionTrialRepository,
+ IRepository _trialSiteSurveyRepository,
+ IRepository _emailNoticeConfigrepository,
+ IOptionsMonitor systemEmailConfig
+ ) : IConsumer
{
- public Task Consume(ConsumeContext context)
+ private readonly SystemEmailSendConfig _systemEmailConfig = systemEmailConfig.CurrentValue;
+
+ ///
+ /// 加急的医学反馈任务 通知MIM
+ ///
+ ///
+ ///
+ ///
+ public async Task Consume(ConsumeContext context)
{
- throw new NotImplementedException();
+ 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 userinfo = await _userRepository.Where(x => x.Id == medicalReview.MedicalManagerUserId).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;
+
+ 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, // 阅片标准
+ // 受试者
+ // 访视
+ // 任务类型
+ // 阅片人是否同意
+ // 审核状态
+ // 是否加急
+
+ );
+
+ return (topicStr, htmlBodyStr);
+ };
+
+ await CommonEmailHelper.GetEmailSubejctAndHtmlInfoAndBuildAsync(_emailNoticeConfigrepository, EmailBusinessScenario.SiteSurveyReject, messageToSend, emailConfigFunc);
+
+ await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
}
}
diff --git a/IRaCIS.Core.Domain/Allocation/TaskMedicalReview.cs b/IRaCIS.Core.Domain/Allocation/TaskMedicalReview.cs
index 5160bed64..d2950a0f7 100644
--- a/IRaCIS.Core.Domain/Allocation/TaskMedicalReview.cs
+++ b/IRaCIS.Core.Domain/Allocation/TaskMedicalReview.cs
@@ -69,6 +69,9 @@ public class TaskMedicalReview : BaseFullAuditEntity
[Comment("阅片人是否认同")]
public MedicalReviewDoctorUserIdea DoctorUserIdeaEnum { get; set; }
+ ///
+ /// mim
+ ///
public Guid? MedicalManagerUserId { get; set; }
public Guid VisitTaskId { get; set; }
public Guid TrialId { get; set; }
diff --git a/IRaCIS.Core.Domain/_DomainEvent/ReadingEnrollOrPDRelationEvent.cs b/IRaCIS.Core.Domain/_DomainEvent/ReadingEnrollOrPDRelationEvent.cs
index 1285847a6..c83db2497 100644
--- a/IRaCIS.Core.Domain/_DomainEvent/ReadingEnrollOrPDRelationEvent.cs
+++ b/IRaCIS.Core.Domain/_DomainEvent/ReadingEnrollOrPDRelationEvent.cs
@@ -1,5 +1,6 @@
using IRaCIS.Core.Domain.BaseModel;
using IRaCIS.Core.Domain.Share;
+using IRaCIS.Core.Domain.Models;
using System;
using System.Collections.Generic;
using System.Linq;