|
|
|
@ -8,6 +8,7 @@ using IRaCIS.Core.Infra.EFCore.Common;
|
|
|
|
using MassTransit;
|
|
|
|
using MassTransit;
|
|
|
|
using Microsoft.Extensions.Options;
|
|
|
|
using Microsoft.Extensions.Options;
|
|
|
|
using MimeKit;
|
|
|
|
using MimeKit;
|
|
|
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Globalization;
|
|
|
|
using System.Globalization;
|
|
|
|
@ -47,6 +48,8 @@ public class CRCSubmitedAndQCToAuditEventConsumer(
|
|
|
|
var userinfoList = trialUser.Where(x => x.UserTypeEnum == UserTypeEnum.IQC).ToList();
|
|
|
|
var userinfoList = trialUser.Where(x => x.UserTypeEnum == UserTypeEnum.IQC).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var pmandAPm = trialUser.Where(x => x.UserTypeEnum == UserTypeEnum.APM || x.UserTypeEnum == UserTypeEnum.ProjectManager).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
var trialInfo = await _trialRepository.FirstOrDefaultAsync(t => t.Id == subjectVisit.TrialId);
|
|
|
|
var trialInfo = await _trialRepository.FirstOrDefaultAsync(t => t.Id == subjectVisit.TrialId);
|
|
|
|
|
|
|
|
|
|
|
|
var auditStateCode = "AuditStatePE";
|
|
|
|
var auditStateCode = "AuditStatePE";
|
|
|
|
@ -77,6 +80,10 @@ public class CRCSubmitedAndQCToAuditEventConsumer(
|
|
|
|
messageToSend.From.Add(new MailboxAddress(_systemEmailConfig.FromName, _systemEmailConfig.FromEmail));
|
|
|
|
messageToSend.From.Add(new MailboxAddress(_systemEmailConfig.FromName, _systemEmailConfig.FromEmail));
|
|
|
|
messageToSend.To.Add(new MailboxAddress(String.Empty, userinfo.EMail));
|
|
|
|
messageToSend.To.Add(new MailboxAddress(String.Empty, userinfo.EMail));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var pm in pmandAPm)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
messageToSend.Cc.Add(new MailboxAddress(String.Empty, pm.EMail));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var companyName = isEn_US ? _systemEmailConfig.CompanyShortName : _systemEmailConfig.CompanyShortNameCN;
|
|
|
|
var companyName = isEn_US ? _systemEmailConfig.CompanyShortName : _systemEmailConfig.CompanyShortNameCN;
|
|
|
|
|
|
|
|
|
|
|
|
@ -143,7 +150,12 @@ public class CRCRepliedQCChallengeEventConsumer(
|
|
|
|
|
|
|
|
|
|
|
|
var trialUser = await _trialUseRepository.Where(x => x.TrialId == subjectVisit.TrialId).Include(x => x.User).Select(x => x.User).ToListAsync();
|
|
|
|
var trialUser = await _trialUseRepository.Where(x => x.TrialId == subjectVisit.TrialId).Include(x => x.User).Select(x => x.User).ToListAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var userinfoList = trialUser.Where(x => x.UserTypeEnum == UserTypeEnum.IQC).ToList();
|
|
|
|
var userinfoList = trialUser.Where(x => x.UserTypeEnum == UserTypeEnum.IQC).ToList();
|
|
|
|
|
|
|
|
var pmandAPm = trialUser.Where(x => x.UserTypeEnum == UserTypeEnum.APM || x.UserTypeEnum == UserTypeEnum.ProjectManager).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var trialInfo = await _trialRepository.FirstOrDefaultAsync(t => t.Id == subjectVisit.TrialId);
|
|
|
|
var trialInfo = await _trialRepository.FirstOrDefaultAsync(t => t.Id == subjectVisit.TrialId);
|
|
|
|
|
|
|
|
|
|
|
|
@ -155,7 +167,10 @@ public class CRCRepliedQCChallengeEventConsumer(
|
|
|
|
messageToSend.From.Add(new MailboxAddress(_systemEmailConfig.FromName, _systemEmailConfig.FromEmail));
|
|
|
|
messageToSend.From.Add(new MailboxAddress(_systemEmailConfig.FromName, _systemEmailConfig.FromEmail));
|
|
|
|
messageToSend.To.Add(new MailboxAddress(String.Empty, userinfo.EMail));
|
|
|
|
messageToSend.To.Add(new MailboxAddress(String.Empty, userinfo.EMail));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var pm in pmandAPm)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
messageToSend.Cc.Add(new MailboxAddress(String.Empty, pm.EMail));
|
|
|
|
|
|
|
|
}
|
|
|
|
var companyName = isEn_US ? _systemEmailConfig.CompanyShortName : _systemEmailConfig.CompanyShortNameCN;
|
|
|
|
var companyName = isEn_US ? _systemEmailConfig.CompanyShortName : _systemEmailConfig.CompanyShortNameCN;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -389,11 +404,110 @@ public class CRCRepliedCheckChallengeEventConsumer(
|
|
|
|
/// PM 一致性核查 通知CRC (016,017)
|
|
|
|
/// PM 一致性核查 通知CRC (016,017)
|
|
|
|
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
public class PMRepliedCheckChallengeEventConsumer : IConsumer<PMRepliedCheckChallengeEvent>
|
|
|
|
public class PMRepliedCheckChallengeEventConsumer(
|
|
|
|
|
|
|
|
IRepository<User> _userRepository,
|
|
|
|
|
|
|
|
IRepository<TrialUser> _trialUseRepository,
|
|
|
|
|
|
|
|
IRepository<SubjectVisit> _subjectVisitRepository,
|
|
|
|
|
|
|
|
IRepository<Trial> _trialRepository,
|
|
|
|
|
|
|
|
IRepository<CheckChallengeDialog> _checkChallengeDialogRepository,
|
|
|
|
|
|
|
|
IRepository<QCChallengeDialog> _qCChallengeDialogRepository,
|
|
|
|
|
|
|
|
IRepository<Dictionary> _dictionaryRepository,
|
|
|
|
|
|
|
|
IRepository<EmailNoticeConfig> _emailNoticeConfigrepository,
|
|
|
|
|
|
|
|
IOptionsMonitor<SystemEmailSendConfig> systemEmailConfig) : IConsumer<PMRepliedCheckChallengeEvent>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public Task Consume(ConsumeContext<PMRepliedCheckChallengeEvent> context)
|
|
|
|
|
|
|
|
|
|
|
|
private readonly SystemEmailSendConfig _systemEmailConfig = systemEmailConfig.CurrentValue;
|
|
|
|
|
|
|
|
public async Task Consume(ConsumeContext<PMRepliedCheckChallengeEvent> context)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw new NotImplementedException();
|
|
|
|
Console.WriteLine("发送(016,017) 【 PM 一致性核查 通知CRC】邮件!!!");
|
|
|
|
|
|
|
|
var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US;
|
|
|
|
|
|
|
|
var checkChallengeDialog = await _checkChallengeDialogRepository.Where(x => x.Id == context.Message.CheckChallengeDialogId).FirstNotNullAsync();
|
|
|
|
|
|
|
|
var subjectVisitId = context.Message.SubjectVisitId;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var subjectVisit = await _subjectVisitRepository.Where(x => x.Id == subjectVisitId).Include(x => x.Subject).FirstNotNullAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var trialUser = await _trialUseRepository.Where(x => x.TrialId == subjectVisit.TrialId).Include(x => x.User).Select(x => x.User).ToListAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var userinfoList = trialUser.Where(x => x.UserTypeEnum == UserTypeEnum.ClinicalResearchCoordinator).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var craInfo = trialUser.Where(x => x.UserTypeEnum == UserTypeEnum.CRA).FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var trialInfo = await _trialRepository.FirstOrDefaultAsync(t => t.Id == subjectVisit.TrialId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string json = checkChallengeDialog.ParamInfo;
|
|
|
|
|
|
|
|
List<string> modalities = new List<string>();
|
|
|
|
|
|
|
|
if (json.IsNotNullOrEmpty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
List<Dictionary<string, string>> studies = JsonConvert.DeserializeObject<List<Dictionary<string, string>>>(json);
|
|
|
|
|
|
|
|
foreach (var study in studies)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (study.ContainsKey("Modality"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
modalities.Add(study["Modality"]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
modalities = modalities.Distinct().ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var dictionValue = await CommonEmailHelper.TranslationDictionary(new TranslationDictionaryDto()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DictionaryRepository = _dictionaryRepository,
|
|
|
|
|
|
|
|
IsEn_US = isEn_US,
|
|
|
|
|
|
|
|
DictionaryList = new List<DictionaryDto>()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
new DictionaryDto (){DictionaryCode= "CheckState",EnumValue=subjectVisit.CheckState.GetEnumInt(), }, //核查状态
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
|
|
|
if (craInfo != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
messageToSend.Cc.Add(new MailboxAddress(String.Empty, craInfo.EMail));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var companyName = isEn_US ? _systemEmailConfig.CompanyShortName : _systemEmailConfig.CompanyShortNameCN;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Func<(string topicStr, string htmlBodyStr), (string topicStr, string htmlBodyStr)> emailConfigFunc = input =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var subjectCode = subjectVisit.Subject.Code;
|
|
|
|
|
|
|
|
var topicStr = string.Format(input.topicStr, trialInfo.ResearchProgramNo, subjectCode, subjectVisit.VisitName);
|
|
|
|
|
|
|
|
var htmlBodyStr = string.Format(
|
|
|
|
|
|
|
|
CommonEmailHelper.ReplaceCompanyName(_systemEmailConfig, input.htmlBodyStr),
|
|
|
|
|
|
|
|
userinfo.FullName, // 用户名 {0}
|
|
|
|
|
|
|
|
trialInfo.ExperimentName, // 项目 {1}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
subjectCode, // 受试者 {2}
|
|
|
|
|
|
|
|
subjectVisit.VisitName, // 访视 {3}
|
|
|
|
|
|
|
|
string.Join(',', modalities), // 检查类型 {4}
|
|
|
|
|
|
|
|
dictionValue[0], // 核查状态 {5}
|
|
|
|
|
|
|
|
checkChallengeDialog.TalkContent,// 质疑内容{6}
|
|
|
|
|
|
|
|
_systemEmailConfig.SiteUrl // 链接 {7}
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (topicStr, htmlBodyStr);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await CommonEmailHelper.GetEmailSubejctAndHtmlInfoAndBuildAsync(_emailNoticeConfigrepository,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context.Message.IsPd ? EmailBusinessScenario.PDVerification_UnderDR : EmailBusinessScenario.EligibilityVerification_UnderDR,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
messageToSend, emailConfigFunc);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -487,12 +601,106 @@ public class CheckStateChangedToAuditEventConsumer(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// QC 领取了质控任务
|
|
|
|
/// QC 领取了质控任务 (007,008)
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
public class QCClaimTaskEventConsumer : IConsumer<QCClaimTaskEvent>
|
|
|
|
public class QCClaimTaskEventConsumer(
|
|
|
|
|
|
|
|
IRepository<User> _userRepository,
|
|
|
|
|
|
|
|
IRepository<TrialUser> _trialUseRepository,
|
|
|
|
|
|
|
|
IRepository<SubjectVisit> _subjectVisitRepository,
|
|
|
|
|
|
|
|
IRepository<Trial> _trialRepository,
|
|
|
|
|
|
|
|
IRepository<QCChallenge> _qCChallengeRepository,
|
|
|
|
|
|
|
|
IRepository<QCChallengeDialog> _qCChallengeDialogRepository,
|
|
|
|
|
|
|
|
IRepository<Dictionary> _dictionaryRepository,
|
|
|
|
|
|
|
|
IRepository<EmailNoticeConfig> _emailNoticeConfigrepository,
|
|
|
|
|
|
|
|
IOptionsMonitor<SystemEmailSendConfig> systemEmailConfig) : IConsumer<QCClaimTaskEvent>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public Task Consume(ConsumeContext<QCClaimTaskEvent> context)
|
|
|
|
private readonly SystemEmailSendConfig _systemEmailConfig = systemEmailConfig.CurrentValue;
|
|
|
|
|
|
|
|
public async Task Consume(ConsumeContext<QCClaimTaskEvent> context)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw new NotImplementedException();
|
|
|
|
Console.WriteLine("发送(Code007,008) 【QC 领取了质控任务】邮件!!!");
|
|
|
|
|
|
|
|
var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var subjectVisitId = context.Message.SubjectVisitId;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var subjectVisit = await _subjectVisitRepository.Where(x => x.Id == subjectVisitId).Include(x => x.Subject).Include(x => x.CurrentActionUser).FirstNotNullAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var subjectVisitList = await _subjectVisitRepository.Where(x => x.CurrentActionUserId == context.Message.CurrentActionUserId && x.TrialId == subjectVisit.TrialId).Include(x => x.Subject).ToListAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var trialUser = await _trialUseRepository.Where(x => x.TrialId == subjectVisit.TrialId).Include(x => x.User).Select(x => x.User).ToListAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var pmandAPm = trialUser.Where(x => x.UserTypeEnum == UserTypeEnum.APM || x.UserTypeEnum == UserTypeEnum.ProjectManager).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var trialInfo = await _trialRepository.FirstOrDefaultAsync(t => t.Id == subjectVisit.TrialId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var userinfo = subjectVisit.CurrentActionUser;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var messageToSend = new MimeMessage();
|
|
|
|
|
|
|
|
//发件地址
|
|
|
|
|
|
|
|
messageToSend.From.Add(new MailboxAddress(_systemEmailConfig.FromName, _systemEmailConfig.FromEmail));
|
|
|
|
|
|
|
|
messageToSend.To.Add(new MailboxAddress(String.Empty, userinfo.EMail));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var pm in pmandAPm)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
messageToSend.Cc.Add(new MailboxAddress(String.Empty, pm.EMail));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var companyName = isEn_US ? _systemEmailConfig.CompanyShortName : _systemEmailConfig.CompanyShortNameCN;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var auditStateCode = "AuditStatePE";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (trialInfo.QCProcessEnum == TrialQCProcess.DoubleAudit)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
auditStateCode = "AuditStateRC";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var dictionValue = await CommonEmailHelper.TranslationDictionary(new TranslationDictionaryDto()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
DictionaryRepository = _dictionaryRepository,
|
|
|
|
|
|
|
|
IsEn_US = isEn_US,
|
|
|
|
|
|
|
|
DictionaryList = new List<DictionaryDto>()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
new DictionaryDto (){DictionaryCode= auditStateCode,EnumValue=subjectVisit.AuditState.GetEnumInt(), }, //审核状态
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var subjectcodes = subjectVisitList.Select(x => x.Subject.Code).ToList();
|
|
|
|
|
|
|
|
var visitnames = subjectVisitList.Select(x => x.VisitName).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Func<(string topicStr, string htmlBodyStr), (string topicStr, string htmlBodyStr)> emailConfigFunc = input =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var subjectCode = subjectVisit.Subject.Code;
|
|
|
|
|
|
|
|
var topicStr = string.Format(input.topicStr, trialInfo.ResearchProgramNo, subjectCode, subjectVisit.VisitName);
|
|
|
|
|
|
|
|
var htmlBodyStr = string.Format(
|
|
|
|
|
|
|
|
CommonEmailHelper.ReplaceCompanyName(_systemEmailConfig, input.htmlBodyStr),
|
|
|
|
|
|
|
|
userinfo.FullName, // 用户名 {0}
|
|
|
|
|
|
|
|
trialInfo.ExperimentName, // 项目 {1}
|
|
|
|
|
|
|
|
string.Join(',', subjectcodes), // 受试者 {2}
|
|
|
|
|
|
|
|
string.Join(',', visitnames), // 访视 {3}
|
|
|
|
|
|
|
|
dictionValue[0], // 审核状态 {4}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_systemEmailConfig.SiteUrl // 链接 {5}
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (topicStr, htmlBodyStr);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await CommonEmailHelper.GetEmailSubejctAndHtmlInfoAndBuildAsync(_emailNoticeConfigrepository,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context.Message.IsPd ? EmailBusinessScenario.PDVerification_PendingImageQCClaim : EmailBusinessScenario.EligibilityVerification_PendingClaim,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
messageToSend, emailConfigFunc);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|