Compare commits
No commits in common. "f97cfd58c0526bde0249f21d68f78c6568b6641f" and "2a0d01c161c4ff3ae985589d88100e40a7b86de6" have entirely different histories.
f97cfd58c0
...
2a0d01c161
|
|
@ -341,103 +341,11 @@ public class UrgentMIMRepliedMedicalReviewConsumer(
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加急阅片 IR 申请重阅 或者PM 申请重阅
|
/// 加急阅片 IR 申请重阅 或者PM 申请重阅
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class UrgentIRApplyedReReadingConsumer(
|
public class UrgentIRApplyedReReadingConsumer : IConsumer<UrgentApplyedReReading>
|
||||||
IRepository<User> _userRepository,
|
|
||||||
IRepository<TrialUser> _trialUseRepository,
|
|
||||||
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<UrgentApplyedReReading>
|
|
||||||
{
|
{
|
||||||
|
public Task Consume(ConsumeContext<UrgentApplyedReReading> context)
|
||||||
private readonly SystemEmailSendConfig _systemEmailConfig = systemEmailConfig.CurrentValue;
|
|
||||||
public async Task Consume(ConsumeContext<UrgentApplyedReReading> context)
|
|
||||||
{
|
{
|
||||||
Console.WriteLine("发送(024,25) 【加急医学反馈】邮件!!!");
|
throw new NotImplementedException();
|
||||||
var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US;
|
|
||||||
|
|
||||||
var visitTaskId = context.Message.VisitTaskId;
|
|
||||||
|
|
||||||
var taskInfo = await _visitTaskRepository.Where(x => x.Id == visitTaskId).Include(x => x.SourceSubjectVisit).Include(x => x.ReadModule).Include(x => x.Subject).FirstNotNullAsync();
|
|
||||||
var criterion = await _readingQuestionCriterionTrialRepository.FirstOrDefaultAsync(x => x.Id == taskInfo.TrialReadingCriterionId);
|
|
||||||
|
|
||||||
|
|
||||||
var doctorInfo = await _userRepository.Where(x => x.Id == taskInfo.DoctorUserId).FirstOrDefaultAsync();
|
|
||||||
|
|
||||||
var trialUser = await _trialUseRepository.Where(x => x.TrialId == taskInfo.TrialId).Include(x => x.User).Select(x=>x.User).ToListAsync();
|
|
||||||
|
|
||||||
var userinfoList = trialUser.Where(x => x.UserTypeEnum == UserTypeEnum.ProjectManager||x.UserTypeEnum==UserTypeEnum.APM).ToList();
|
|
||||||
if (context.Message.ReReadingApplyState == ReReadingApplyState.TrialGroupHaveApplyed)
|
|
||||||
{
|
|
||||||
userinfoList = trialUser.Where(x => x.UserTypeEnum == UserTypeEnum.CPM || x.UserTypeEnum == UserTypeEnum.SPM).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
var visitid = taskInfo.SourceSubjectVisit == null ? taskInfo.ReadModule.SubjectVisitId : taskInfo.SourceSubjectVisitId;
|
|
||||||
|
|
||||||
|
|
||||||
var subjectVisit = await _subjectVisitRepository.Where(x => x.Id == visitid).FirstOrDefaultAsync();
|
|
||||||
|
|
||||||
|
|
||||||
foreach (var userinfo in userinfoList)
|
|
||||||
{
|
|
||||||
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 == taskInfo.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= "RequestReReadingResult",EnumValue="0", }, //审批结果 都是待审批
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
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}
|
|
||||||
dictionValue[0], // 任务类型 {4}
|
|
||||||
doctorInfo.FullName, // 阅片人 {5}
|
|
||||||
criterion.CriterionName, // 阅片标准 {6}
|
|
||||||
dictionValue[1], // 审批结果 {7}
|
|
||||||
_systemEmailConfig.SiteUrl // 链接 {8}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
);
|
|
||||||
|
|
||||||
return (topicStr, htmlBodyStr);
|
|
||||||
};
|
|
||||||
|
|
||||||
await CommonEmailHelper.GetEmailSubejctAndHtmlInfoAndBuildAsync(_emailNoticeConfigrepository,
|
|
||||||
|
|
||||||
context.Message.ReReadingApplyState == ReReadingApplyState.TrialGroupHaveApplyed? EmailBusinessScenario.ReReadFromPMApproval: EmailBusinessScenario.ReReadFromIRApproval,
|
|
||||||
|
|
||||||
messageToSend, emailConfigFunc);
|
|
||||||
|
|
||||||
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue