Test.EIImageViewer
he 2023-03-01 14:55:13 +08:00
commit 9975eced9b
14 changed files with 673 additions and 129 deletions

View File

@ -31,7 +31,7 @@ namespace IRaCIS.Core.API
//周期性任务1天执行一次
RecurringJob.AddOrUpdate<IIRaCISCacheHangfireJob>(t => t.MemoryCacheTrialStatus(), Cron.Daily);
RecurringJob.AddOrUpdate<IIRaCISCacheHangfireJob>(t => t.ProjectStartCache(), Cron.Daily);
#endregion

View File

@ -1,5 +1,6 @@
using EasyCaching.Core;
using IRaCIS.Core.Domain.Share;
using Microsoft.EntityFrameworkCore.SqlServer.Query.Internal;
using Microsoft.Extensions.Logging;
namespace IRaCIS.Application.Services.BackGroundJob
@ -7,7 +8,13 @@ namespace IRaCIS.Application.Services.BackGroundJob
public interface IIRaCISCacheHangfireJob
{
Task ProjectStartCache();
Task MemoryCacheTrialStatus();
Task MemoryCacheAnonymizeData();
Task CacheUserTypePermission(Guid? cacheUserTypeId);
}
public class IRaCISCacheHangfireJob: IIRaCISCacheHangfireJob
{
@ -16,50 +23,77 @@ namespace IRaCIS.Application.Services.BackGroundJob
private readonly ILogger<IRaCISCacheHangfireJob> _logger;
private readonly IRepository<SystemAnonymization> _systemAnonymizationRepository;
public IRaCISCacheHangfireJob(IRepository<Trial> trialRepository, IRepository<SystemAnonymization> systemAnonymizationRepository, IEasyCachingProvider provider,ILogger<IRaCISCacheHangfireJob> logger)
private readonly IRepository<UserTypeMenu> _userTypeMenuRepository;
public IRaCISCacheHangfireJob(IRepository<Trial> trialRepository,
IRepository<SystemAnonymization> systemAnonymizationRepository, IRepository<UserTypeMenu> userTypeMenuRepository,
IEasyCachingProvider provider,ILogger<IRaCISCacheHangfireJob> logger)
{
_trialRepository = trialRepository;
_provider = provider;
_logger = logger;
_systemAnonymizationRepository = systemAnonymizationRepository;
_userTypeMenuRepository = userTypeMenuRepository;
}
public async Task MemoryCacheTrialStatus()
public async Task ProjectStartCache()
{
_logger.LogInformation("hangfire 定时任务开始~");
_logger.LogInformation("hangfire 定时缓存项目状态任务开始~");
try
{
await CacheTrialStatusAsync();
await MemoryCacheTrialStatus();
await CacheAnonymizeAsync();
await MemoryCacheAnonymizeData();
await CacheUserTypePermission();
}
catch (Exception e)
{
_logger.LogError("hangfire 定时任务执行失败"+e.Message);
_logger.LogError("hangfire 定时任务执行失败" + e.Message);
}
_logger.LogInformation("hangfire 定时任务执行结束");
_logger.LogInformation("hangfire 定时任务执行结束");
}
private async Task CacheTrialStatusAsync()
public async Task MemoryCacheTrialStatus()
{
var list = await _trialRepository.Select(t => new { TrialId = t.Id, TrialStatusStr = t.TrialStatusStr })
var list = await _trialRepository.Select(t => new { TrialId = t.Id, TrialStatusStr = t.TrialStatusStr })
.ToListAsync();
list.ForEach(t => _provider.Set(t.TrialId.ToString(), t.TrialStatusStr, TimeSpan.FromDays(7)));
}
private async Task CacheAnonymizeAsync()
public async Task MemoryCacheAnonymizeData()
{
var systemAnonymizationList = await _systemAnonymizationRepository.Where(t => t.IsEnable).ToListAsync();
var systemAnonymizationList = await _systemAnonymizationRepository.Where(t => t.IsEnable).ToListAsync();
_provider.Set(StaticData.Anonymize.Anonymize_AddFixedFiled, systemAnonymizationList.Where(t => t.IsAdd && t.IsFixed).ToList(), TimeSpan.FromDays(7));
_provider.Set(StaticData.Anonymize.Anonymize_AddIRCInfoFiled, systemAnonymizationList.Where(t => t.IsAdd && t.IsFixed == false).ToList(), TimeSpan.FromDays(7));
_provider.Set(StaticData.Anonymize.Anonymize_FixedField, systemAnonymizationList.Where(t => t.IsAdd == false && t.IsFixed).ToList(), TimeSpan.FromDays(7));
_provider.Set(StaticData.Anonymize.Anonymize_IRCInfoField, systemAnonymizationList.Where(t => t.IsAdd == false && t.IsFixed == false).ToList(), TimeSpan.FromDays(7));
}
public async Task CacheUserTypePermission(Guid? cacheUserTypeId=null)
{
var permissionList = await _userTypeMenuRepository.Where(t => t.Menu.MenuType == "F")
.WhereIf(cacheUserTypeId != null, t => t.UserTypeId == cacheUserTypeId.Value).Select(t => new { t.UserTypeId, t.Menu.PermissionStr }).ToListAsync();
foreach (var userTypeGroup in permissionList.GroupBy(t => t.UserTypeId))
{
_provider.Set($"{StaticData.CacheKey.UserTypeId}_{userTypeGroup.Key}", userTypeGroup.Select(t => t.PermissionStr).ToList(), TimeSpan.FromDays(7));
}
}
}
}

View File

@ -409,6 +409,26 @@ public static class FileStoreHelper
return (serverFilePath, relativePath, fileRealName);
}
// 获取 入组确认 PD 进展发送邮件Word|PDF 存放路径
public static (string PhysicalPath, string RelativePath, string FileRealName) GetSubjectEnrollConfirmOrPDEmailPath(IWebHostEnvironment _hostEnvironment, string fileName, Guid trialId, Guid siteId, Guid subjectId)
{
var rootPath = FileStoreHelper.GetIRaCISRootDataFolder(_hostEnvironment);
string uploadFolderPath = Path.Combine(rootPath, StaticData.Folder.TrialDataFolder, trialId.ToString(), siteId.ToString(), subjectId.ToString());
if (!Directory.Exists(uploadFolderPath)) Directory.CreateDirectory(uploadFolderPath);
var (trustedFileNameForFileStorage, fileRealName) = FileStoreHelper.GetStoreFileName(fileName);
var relativePath = $"/{StaticData.Folder.IRaCISDataFolder}/{StaticData.Folder.TrialDataFolder}/{trialId}/{siteId}/{subjectId}/{trustedFileNameForFileStorage}";
var serverFilePath = Path.Combine(uploadFolderPath, trustedFileNameForFileStorage);
return (serverFilePath, relativePath, fileRealName);
}
public static string GetSubjectVisitDicomFolderPhysicalPath(IWebHostEnvironment _hostEnvironment,Guid trialId, Guid siteId, Guid subjectId, Guid subjectVisitId)
{

View File

@ -602,12 +602,40 @@
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Service.TrialEmailNoticeConfigService.BaseBusinessScenarioSendEmailAsync(System.Guid,System.Nullable{System.Boolean})">
<member name="M:IRaCIS.Core.Application.Service.TrialEmailNoticeConfigService.BaseBusinessScenarioSendEmailAsync(System.Guid,System.Nullable{System.Boolean},IRaCIS.Core.Domain.Share.Common.EmailStoreSendMode,System.String)">
<summary>
测试邮件 带附件 填充word --前端不需要用
测试邮件 带附件 填充word --前端不需
</summary>
<param name="visitTaskId"></param>
<param name="isMedicalReviewAndSuggestApplyReReading"></param>
<param name="isHandSend"> 为空 代表 正常任务自动发送为true 代表医学审核手动发送 为false 代表医学审核自动发送 </param>
<param name="emailStoreMode"></param>
<param name="sendFileRelativePath"></param>
<returns></returns>
<exception cref="T:IRaCIS.Core.Infrastructure.BusinessValidationFailedException"></exception>
</member>
<member name="M:IRaCIS.Core.Application.Service.TrialEmailNoticeConfigService.ManualGenerateEmailFile(IRaCIS.Core.Application.ViewModel.GenerateEmailCommand)">
<summary>
手动生成入组确认 或者PD 进展的邮件 如果能发送,会返回文件的路径,否则会给出提示
</summary>
<param name="generateEmailCommand"></param>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Service.TrialEmailNoticeConfigService.ManualSendEmail(System.Guid,System.String)">
<summary>
手动发送邮件
</summary>
<param name="visitTaskId"></param>
<param name="sendFileRelativePath"></param>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Service.TrialEmailNoticeConfigService.TranslatePdStateAsync(System.Guid,IRaCIS.Core.Domain.Share.ReadingCategory,IRaCIS.Core.Domain.Share.CriterionType,System.Nullable{System.Boolean})">
<summary>
</summary>
<param name="visitTaskId"> 任务Id</param>
<param name="readingCategory"> 任务类型</param>
<param name="criterionType">标准类型</param>
<param name="IsGlobalGenerate"> 是否是全局产生(区分裁判任务)</param>
<returns></returns>
<exception cref="T:IRaCIS.Core.Infrastructure.BusinessValidationFailedException"></exception>
</member>

View File

@ -108,6 +108,16 @@ namespace IRaCIS.Core.Application.ViewModel
}
public class GenerateEmailCommand
{
public Guid SubjectId { get; set; }
public Guid TrialReadingCriterionId { get; set; }
public CommonDocumentBusinessScenario BusinessScenarioEnum { get; set; }
}
///<summary> TrialEmailNoticeConfigAddOrEdit 列表查询参数模型</summary>
public class TrialEmailNoticeConfigAddOrEdit
{

View File

@ -6,23 +6,31 @@
using IRaCIS.Core.Application.ViewModel;
using IRaCIS.Core.Domain.Share;
using IRaCIS.Core.Domain.Share.Common;
namespace IRaCIS.Core.Application.Interfaces
{
{
/// <summary>
/// ITrialEmailNoticeConfigService
/// </summary>
public interface ITrialEmailNoticeConfigService
{
{
Task<List<TrialEmailNoticeConfigView>> GetTrialEmailNoticeConfigList(TrialEmailNoticeConfigQuery inQuery);
Task<IResponseOutput> AddOrUpdateTrialEmailNoticeConfig(TrialEmailNoticeConfigAddOrEdit addOrEditTrialEmailNoticeConfig);
Task<IResponseOutput> DeleteTrialEmailNoticeConfig(Guid trialEmailNoticeConfigId);
Task<List<TrialEmailNoticeConfigView>> GetTrialEmailNoticeConfigList(TrialEmailNoticeConfigQuery inQuery);
Task BaseBusinessScenarioSendEmailAsync( Guid visitTaskId, bool? isMedicalReviewAndSuggestApplyReReading = null);
Task<IResponseOutput> AddOrUpdateTrialEmailNoticeConfig(TrialEmailNoticeConfigAddOrEdit addOrEditTrialEmailNoticeConfig);
Task<IResponseOutput> DeleteTrialEmailNoticeConfig(Guid trialEmailNoticeConfigId);
Task<string> BaseBusinessScenarioSendEmailAsync(Guid visitTaskId, bool? isMedicalReviewAndSuggestApplyReReading = null, EmailStoreSendMode emailStoreMode = EmailStoreSendMode.StoreLocalSend, string sendFileRelativePath="");
}
}
public class EmailStoreSendDto
{
public EmailStoreSendMode EmailStoreSendMode { get; set; } = EmailStoreSendMode.StoreLocalSend;
public string SendFileRelativePath { get; set; }
}
}

View File

@ -17,6 +17,9 @@ using IRaCIS.Core.Application.Contracts;
using IRaCIS.Core.Application.Filter;
using MiniSoftware;
using IRaCIS.Core.Application.Service.Reading.Dto;
using IRaCIS.Core.Domain.Share.Common;
using System.IO;
using System.Linq;
namespace IRaCIS.Core.Application.Service
{
@ -36,15 +39,22 @@ namespace IRaCIS.Core.Application.Service
public IRepository<VisitTask> _visitTaskRepository { get; }
public IRepository<TrialUser> _trialUserRepository { get; }
public IRepository<Subject> _subjectRepository { get; }
public IRepository<SubjectVisit> _subjectVisitRepository { get; }
public TrialEmailNoticeConfigService(IRepository<TrialEmailNoticeConfig> trialEmailNoticeConfigRepository, IRepository<VisitTask> visitTaskRepository,
IRepository<Trial> trialRepository,
IRepository<TrialUser> trialUserRepository, IRepository<TaskMedicalReview> taskMedicalReviewRepository)
IRepository<TrialUser> trialUserRepository, IRepository<TaskMedicalReview> taskMedicalReviewRepository, IRepository<Subject> subjectRepository, IRepository<SubjectVisit> subjectVisitRepository)
{
_trialEmailNoticeConfigRepository = trialEmailNoticeConfigRepository;
_visitTaskRepository = visitTaskRepository;
this._trialRepository = trialRepository;
_trialUserRepository = trialUserRepository;
_taskMedicalReviewRepository = taskMedicalReviewRepository;
_subjectRepository = subjectRepository;
_subjectVisitRepository = subjectVisitRepository;
}
/// <summary>
@ -165,20 +175,21 @@ namespace IRaCIS.Core.Application.Service
private async Task<bool> DealMedicalReviewTasKGenerateAndIsSendAsync(Guid trialId, bool? isMedicalReviewAndSuggestApplyReReading,string pdAnswer, List<Guid> taskIdList, List<Guid> minUserIdList)
private async Task<bool> DealMedicalReviewTasKGenerateAndIsSendAsync(Guid trialId, bool? isHandSend, string pdAnswer, List<Guid> taskIdList, List<Guid> minUserIdList)
{
var isNeedSend = true;
if (pdAnswer == "是")
//手动发送的时候,也有可能答案是是 此时是 这里不发送,发送已经生成的文件
if (pdAnswer == "是" && isHandSend==null)
{
isNeedSend = true;
}
else
{
if (isMedicalReviewAndSuggestApplyReReading == null)
//正常阅片为否的
if (isHandSend == null)
{
isNeedSend = false;
@ -189,7 +200,7 @@ namespace IRaCIS.Core.Application.Service
}
}
else if (isMedicalReviewAndSuggestApplyReReading == true)
else if (isHandSend == true)
{
//手动发送
isNeedSend = false;
@ -202,20 +213,22 @@ namespace IRaCIS.Core.Application.Service
}
return isNeedSend;
}
/// <summary>
/// 测试邮件 带附件 填充word --前端不需要用
/// 测试邮件 带附件 填充word --前端不需
/// </summary>
/// <param name="visitTaskId"></param>
/// <param name="isMedicalReviewAndSuggestApplyReReading"></param>
/// <param name="isHandSend"> 为空 代表 正常任务自动发送为true 代表医学审核手动发送 为false 代表医学审核自动发送 </param>
/// <param name="emailStoreMode"></param>
/// <param name="sendFileRelativePath"></param>
/// <returns></returns>
/// <exception cref="BusinessValidationFailedException"></exception>
public async Task BaseBusinessScenarioSendEmailAsync(Guid visitTaskId, bool? isMedicalReviewAndSuggestApplyReReading)
public async Task<string> BaseBusinessScenarioSendEmailAsync(Guid visitTaskId, bool? isHandSend, EmailStoreSendMode emailStoreMode, string sendFileRelativePath)
{
CommonDocumentBusinessScenario? businessScenarioEnum = null;
@ -249,6 +262,7 @@ namespace IRaCIS.Core.Application.Service
t.SubjectId,
t.Subject.SiteId,
t.DoctorUserId,
t.ReadingTaskState,
t.ReadingCategory,
t.SignTime,
@ -292,7 +306,7 @@ namespace IRaCIS.Core.Application.Service
}
else
{
return;
return string.Empty;
}
}
@ -317,7 +331,7 @@ namespace IRaCIS.Core.Application.Service
{
//throw new BusinessValidationFailedException("找不到该项目标准场景下邮件的配置");
return;
return string.Empty;
}
@ -382,7 +396,6 @@ namespace IRaCIS.Core.Application.Service
}
#endregion
#region 确保 邮件Html存在
//邮件附件
@ -403,55 +416,21 @@ namespace IRaCIS.Core.Application.Service
#endregion
var answer = "否";
var isNeedSend = true;
var minUserIdList = _trialUserRepository.Where(t => t.User.UserTypeEnum == Domain.Share.UserTypeEnum.MIM && t.TrialId == taskInfo.TrialId).Select(t => t.UserId).ToList();
#region 不同场景 Tile 设置
//入组确认 根据每个标准配置的是否自动发送,发送邮件与否
if (businessScenarioEnum == CommonDocumentBusinessScenario.EnrollConfirmed)
{
//如果其他阅片人已经做了,说明发送了入组确认报告,第二个人做完就不发送了
if (await _visitTaskRepository.AnyAsync(t => t.SourceSubjectVisitId == taskInfo.SourceSubjectVisitId && t.TaskState == TaskState.Effect && t.IsAnalysisCreate == false &&
t.Id != visitTaskId && t.ReadingTaskState == ReadingTaskState.HaveSigned && t.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId))
sendEmailConfig.TopicDescription = $"【入组确认报告】关于{taskInfo.ResearchProgramNo}项目{taskInfo.SubjectCode}受试者";
using (StreamReader SourceReader = System.IO.File.OpenText(pathToFile))
{
isNeedSend = false;
var templateInfo = SourceReader.ReadToEnd();
sendEmailConfig.HtmlBodyStr = string.Format(templateInfo,
$" 附件为入组确认报告,请查收 "
);
}
else
{
sendEmailConfig.TopicDescription = $"【入组确认报告】关于{taskInfo.ResearchProgramNo}项目{taskInfo.SubjectCode}受试者";
using (StreamReader SourceReader = System.IO.File.OpenText(pathToFile))
{
var templateInfo = SourceReader.ReadToEnd();
sendEmailConfig.HtmlBodyStr = string.Format(templateInfo,
$" 附件为入组确认报告,请查收 "
);
}
if (await _repository.Where<ReadingTableQuestionAnswer>().AnyAsync(x => x.VisitTaskId == visitTaskId && x.Answer == TargetState.Exist.GetEnumInt() &&
x.ReadingTableQuestionTrial.QuestionMark == QuestionMark.State && x.ReadingQuestionTrial.LesionType == LesionType.TargetLesion))
{
answer = "是";
//把另外一个人的任务设置为不加急(如果项目加急是否 subject 加急是否)
var urgent = _repository.Where<SubjectVisit>(t => t.Id == taskInfo.SourceSubjectVisitId).Select(t => new { IsSubjectUrgent = t.Subject.IsUrgent, t.Trial.IsUrgent }).FirstOrDefault();
if (urgent?.IsUrgent == false || urgent?.IsSubjectUrgent == false)
{
await _visitTaskRepository.BatchUpdateNoTrackingAsync(t => t.SourceSubjectVisitId == taskInfo.SourceSubjectVisitId && t.TaskState == TaskState.Effect && t.IsAnalysisCreate == false &&
t.Id != visitTaskId && t.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId, u => new VisitTask() { IsUrgent = false });
}
}
isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isMedicalReviewAndSuggestApplyReReading, answer, new List<Guid>() { visitTaskId }, minUserIdList);
}
}
else if (businessScenarioEnum == CommonDocumentBusinessScenario.PDConfirmed)
{
@ -466,6 +445,91 @@ namespace IRaCIS.Core.Application.Service
$" 附件为疾病进展确认报告,请查收 "
);
}
}
else
{
//
}
#endregion
#region 不同标准 不同项目配置 发送邮件的时机 处理具体逻辑
var answer = "否";
var isNeedSend = true;
var minUserIdList = _trialUserRepository.Where(t => t.User.UserTypeEnum == Domain.Share.UserTypeEnum.MIM && t.TrialId == taskInfo.TrialId).Select(t => t.UserId).ToList();
//入组确认 根据每个标准配置的是否自动发送,发送邮件与否
if (businessScenarioEnum == CommonDocumentBusinessScenario.EnrollConfirmed)
{
if (await _repository.Where<ReadingTableQuestionAnswer>().AnyAsync(x => x.VisitTaskId == visitTaskId && x.Answer == TargetState.Exist.GetEnumInt() &&
x.ReadingTableQuestionTrial.QuestionMark == QuestionMark.State && x.ReadingQuestionTrial.LesionType == LesionType.TargetLesion))
{
answer = "是";
}
//如果其他阅片人已经做了,说明发送了入组确认报告,第二个人做完就不发送了
//入组确认一直交给第一个人,如果第一个人重阅 还未做完,第二个人先做完了,此时不发
var existFirstEnrollTask= await _visitTaskRepository.Where(t => t.SourceSubjectVisitId == taskInfo.SourceSubjectVisitId && t.IsAnalysisCreate == false
&& t.ReadingTaskState == ReadingTaskState.HaveSigned && t.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId).OrderBy(t=>t.SignTime).FirstOrDefaultAsync();
//入组确认的医生已确定
if(existFirstEnrollTask!= null)
{
if(taskInfo.DoctorUserId==existFirstEnrollTask.DoctorUserId)
{
isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isHandSend, answer, new List<Guid>() { visitTaskId }, minUserIdList);
if (answer == "是")
{
//把另外一个人的任务设置为不加急(如果项目加急是否 subject 加急是否)
var urgent = _repository.Where<SubjectVisit>(t => t.Id == taskInfo.SourceSubjectVisitId).Select(t => new { IsSubjectUrgent = t.Subject.IsUrgent, t.Trial.IsUrgent }).FirstOrDefault();
if (urgent?.IsUrgent == false || urgent?.IsSubjectUrgent == false)
{
await _visitTaskRepository.BatchUpdateNoTrackingAsync(t => t.SourceSubjectVisitId == taskInfo.SourceSubjectVisitId && t.TaskState == TaskState.Effect && t.IsAnalysisCreate == false &&
t.Id != visitTaskId && t.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId, u => new VisitTask() { IsUrgent = false });
}
}
}
else
{
isNeedSend = false;
}
}
else
{
isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isHandSend, answer, new List<Guid>() { visitTaskId }, minUserIdList);
if (answer == "是")
{
//把另外一个人的任务设置为不加急(如果项目加急是否 subject 加急是否)
var urgent = _repository.Where<SubjectVisit>(t => t.Id == taskInfo.SourceSubjectVisitId).Select(t => new { IsSubjectUrgent = t.Subject.IsUrgent, t.Trial.IsUrgent }).FirstOrDefault();
if (urgent?.IsUrgent == false || urgent?.IsSubjectUrgent == false)
{
await _visitTaskRepository.BatchUpdateNoTrackingAsync(t => t.SourceSubjectVisitId == taskInfo.SourceSubjectVisitId && t.TaskState == TaskState.Effect && t.IsAnalysisCreate == false &&
t.Id != visitTaskId && t.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId, u => new VisitTask() { IsUrgent = false });
}
}
}
}
else if (businessScenarioEnum == CommonDocumentBusinessScenario.PDConfirmed)
{
//有序
@ -509,7 +573,7 @@ namespace IRaCIS.Core.Application.Service
throw new BusinessValidationFailedException("单重有序阅片 该类型的任务不应进入此处逻辑,请联系后台开发核查!");
}
isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isMedicalReviewAndSuggestApplyReReading, answer, new List<Guid>() { visitTaskId }, minUserIdList);
isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isHandSend, answer, new List<Guid>() { visitTaskId }, minUserIdList);
}
@ -534,16 +598,16 @@ namespace IRaCIS.Core.Application.Service
answer = await TranslatePdStateAsync(visitTaskId, taskInfo.ReadingCategory, taskInfo.CriterionType);
isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isMedicalReviewAndSuggestApplyReReading, answer, taskList.Select(t => t.Id).ToList(), minUserIdList);
isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isHandSend, answer, taskList.Select(t => t.Id).ToList(), minUserIdList);
}
//双人 产生裁判,并且裁判完成 发
else if (taskList.Count == 3 && taskList.Count(t => t.ReadingTaskState == ReadingTaskState.HaveSigned) == 3 && taskList.Where(t => t.ReadingCategory == ReadingCategory.Judge).Count() == 1)
{
var judgeResultId = taskList.Where(t => t.ReadingCategory == ReadingCategory.Judge).First().JudgeResultTaskId.Value;
answer = await TranslatePdStateAsync(judgeResultId, ReadingCategory.Visit, taskInfo.CriterionType);
answer = await TranslatePdStateAsync(taskList.Where(t => t.ReadingCategory == ReadingCategory.Judge).First().Id, ReadingCategory.Judge, taskInfo.CriterionType);
isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isMedicalReviewAndSuggestApplyReReading, answer, taskList.Select(t => t.Id).ToList(), minUserIdList);
isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isHandSend, answer, taskList.Select(t => t.Id).ToList(), minUserIdList);
}
else
@ -580,15 +644,16 @@ namespace IRaCIS.Core.Application.Service
answer = await TranslatePdStateAsync(visitTaskId, taskInfo.ReadingCategory, taskInfo.CriterionType);
isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isMedicalReviewAndSuggestApplyReReading, answer, taskList.Select(t => t.Id).ToList(), minUserIdList);
isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isHandSend, answer, taskList.Select(t => t.Id).ToList(), minUserIdList);
}
//双人全局产生裁判
else if (taskList.Count == 3 && taskList.Count(t => t.ReadingTaskState == ReadingTaskState.HaveSigned) == 3 && taskList.Where(t => t.ReadingCategory == ReadingCategory.Judge).Count() == 1 && taskList.Where(t => t.ReadingCategory == ReadingCategory.Global).Count() == 2)
{
answer = await TranslatePdStateAsync(taskList.Where(t => t.ReadingCategory == ReadingCategory.Judge).First().Id, ReadingCategory.Judge, taskInfo.CriterionType);
var judgeResultId = taskList.Where(t => t.ReadingCategory == ReadingCategory.Judge).First().JudgeResultTaskId.Value;
answer = await TranslatePdStateAsync(judgeResultId, ReadingCategory.Global, taskInfo.CriterionType);
isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isMedicalReviewAndSuggestApplyReReading, answer, taskList.Select(t => t.Id).ToList(), minUserIdList);
isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isHandSend, answer, taskList.Select(t => t.Id).ToList(), minUserIdList);
}
else
@ -642,14 +707,15 @@ namespace IRaCIS.Core.Application.Service
{
answer = await TranslatePdStateAsync(visitTaskId, taskInfo.ReadingCategory, taskInfo.CriterionType);
isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isMedicalReviewAndSuggestApplyReReading, answer, new List<Guid>() { visitTaskId }, minUserIdList);
isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isHandSend, answer, new List<Guid>() { visitTaskId }, minUserIdList);
}
//双重 截止访视只在阅片期的时候存在 要求PD确认的访视 肯定是非截止访视
else if (taskInfo.ReadingType == ReadingMethod.Double && taskInfo.ArbitrationRule == ArbitrationRule.Visit)
{
//在两位阅片人读完访视后,如果有裁判者等裁判读完,如果无裁判则等第二个人的读完
var taskList = await _visitTaskRepository.Where(t => t.SourceSubjectVisitId == taskInfo.SourceSubjectVisitId && t.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId && t.IsAnalysisCreate == false && t.TaskState == TaskState.Effect && (t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Judge)).ToListAsync();
var taskList = await _visitTaskRepository.Where(t => t.SourceSubjectVisitId == taskInfo.SourceSubjectVisitId && t.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId && t.IsAnalysisCreate == false && t.TaskState == TaskState.Effect
&& (t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Judge)).ToListAsync();
//这里要求 到这里已经如果有裁判 已经生成裁判了保存数据库
if (taskList.Count == 2 && taskList.Count(t => t.ReadingTaskState == ReadingTaskState.HaveSigned && t.ReadingCategory == ReadingCategory.Visit) == 2)
@ -657,13 +723,14 @@ namespace IRaCIS.Core.Application.Service
answer = await TranslatePdStateAsync(visitTaskId, taskInfo.ReadingCategory, taskInfo.CriterionType);
isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isMedicalReviewAndSuggestApplyReReading, answer, taskList.Select(t => t.Id).ToList(), minUserIdList);
isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isHandSend, answer, taskList.Select(t => t.Id).ToList(), minUserIdList);
}
else if (taskList.Count == 3 && taskList.Count(t => t.ReadingTaskState == ReadingTaskState.HaveSigned) == 3 && taskList.Where(t => t.ReadingCategory == ReadingCategory.Judge).Count() == 1)
{
var judgeResultId = taskList.Where(t => t.ReadingCategory == ReadingCategory.Judge).First().JudgeResultTaskId.Value;
answer = await TranslatePdStateAsync(judgeResultId, ReadingCategory.Visit, taskInfo.CriterionType);
answer = await TranslatePdStateAsync(taskList.Where(t => t.ReadingCategory == ReadingCategory.Judge).First().Id, ReadingCategory.Judge, taskInfo.CriterionType);
isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isMedicalReviewAndSuggestApplyReReading, answer, taskList.Select(t => t.Id).ToList(), minUserIdList);
isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isHandSend, answer, taskList.Select(t => t.Id).ToList(), minUserIdList);
}
@ -699,7 +766,7 @@ namespace IRaCIS.Core.Application.Service
}
else
@ -707,21 +774,64 @@ namespace IRaCIS.Core.Application.Service
isNeedSend = false;
}
#endregion
#region MiniWord 组织字典 发送
if (emailStoreMode == EmailStoreSendMode.NotStoreLocalOnlySentEmail)
{
var phyPath = FileStoreHelper.GetPhysicalFilePath(_hostEnvironment, sendFileRelativePath);
//先预先生成了邮件,发送预先生成的邮件
sendEmailConfig.EmailAttachMentConfigList.Add(new EmailAttachMentConfig()
{
FileName = $"{taskInfo.SubjectCode}_{emailConfig.FileName}",
FileStream = File.OpenRead(phyPath),
});
await SendEmailHelper.SendEmailAsync(sendEmailConfig);
return string.Empty;
}
var value = new Dictionary<string, object>()
{
["SponsorName"] = taskInfo.SponsorName,
["ResearchProgramNo"] = taskInfo.ResearchProgramNo,
["TrialSiteCode"] = taskInfo.TrialSiteCode,
["SubjectCode"] = taskInfo.SubjectCode,
["VisitName"] = taskInfo.SourceSubjectVisitId != null ? taskInfo.VisitName : taskInfo.ModuleVisitName,
["EarliestScanDate"] = taskInfo.SourceSubjectVisitId != null ? taskInfo.VisitEarliestScanDate : taskInfo.ModuleEarliestScanDate,
["SignTime"] = taskInfo.SignTime,
["Result"] = answer
};
var (serverFilePath, relativePath, fileRealName) = FileStoreHelper.GetSubjectEnrollConfirmOrPDEmailPath(_hostEnvironment, Path.GetFileName(path), taskInfo.TrialId, taskInfo.SiteId, taskInfo.SubjectId);
if (emailStoreMode == EmailStoreSendMode.StoreLocalSend || emailStoreMode == EmailStoreSendMode.OnlyStoreLocalNotSentEmail)
{
MiniSoftware.MiniWord.SaveAsByTemplate(serverFilePath, path, value);
}
//手动生成发送的邮件内容,但是并不发送
if (emailStoreMode == EmailStoreSendMode.OnlyStoreLocalNotSentEmail)
{
isNeedSend = false;
return relativePath;
}
//正常的即时生成邮件 并发送邮件
if (isNeedSend)
{
var value = new Dictionary<string, object>()
{
["SponsorName"] = taskInfo.SponsorName,
["ResearchProgramNo"] = taskInfo.ResearchProgramNo,
["TrialSiteCode"] = taskInfo.TrialSiteCode,
["SubjectCode"] = taskInfo.SubjectCode,
["VisitName"] = taskInfo.SourceSubjectVisitId != null ? taskInfo.VisitName : taskInfo.ModuleVisitName,
["EarliestScanDate"] = taskInfo.SourceSubjectVisitId != null ? taskInfo.VisitEarliestScanDate : taskInfo.ModuleEarliestScanDate,
["SignTime"] = taskInfo.SignTime,
["Result"] = answer
};
MemoryStream memoryStream = new MemoryStream();
@ -731,7 +841,7 @@ namespace IRaCIS.Core.Application.Service
sendEmailConfig.EmailAttachMentConfigList.Add(new EmailAttachMentConfig()
{
FileName = emailConfig.FileName,
FileName =$"{taskInfo.SubjectCode}_{emailConfig.FileName}" ,
FileStream = memoryStream
});
@ -740,6 +850,15 @@ namespace IRaCIS.Core.Application.Service
await SendEmailHelper.SendEmailAsync(sendEmailConfig);
}
return string.Empty;
#endregion
@ -747,8 +866,285 @@ namespace IRaCIS.Core.Application.Service
/// <summary>
/// 手动生成入组确认 或者PD 进展的邮件 如果能发送,会返回文件的路径,否则会给出提示
/// </summary>
/// <param name="generateEmailCommand"></param>
private async Task<string> TranslatePdStateAsync(Guid visitTaskId, ReadingCategory readingCategory, CriterionType criterionType)
/// <returns></returns>
[HttpPost]
public async Task<IResponseOutput> ManualGenerateEmailFile(GenerateEmailCommand generateEmailCommand)
{
var subjectId = generateEmailCommand.SubjectId;
var businessScenarioEnum = generateEmailCommand.BusinessScenarioEnum;
var trialReadingCriterionId = generateEmailCommand.TrialReadingCriterionId;
var trialConfig = await _subjectRepository.Where(t => t.Id == subjectId).Select(t => new { t.Trial.IsEnrollementQualificationConfirm, t.Trial.IsPDProgressView }).FirstNotNullAsync();
//找到入组确认 或者Pd 进展 已生成任务的 访视
var subjectVisitList = await _subjectVisitRepository.Where(t => t.SubjectId == subjectId & t.CheckState == CheckStateEnum.CVPassed && (t.IsEnrollmentConfirm == true || t.PDState == PDStateEnum.PDProgress)).ToListAsync();
if (businessScenarioEnum == CommonDocumentBusinessScenario.EnrollConfirmed)
{
if (trialConfig.IsEnrollementQualificationConfirm == false)
{
return ResponseOutput.NotOk("项目未配置入组确认!");
}
var exisitBaseline = subjectVisitList.FirstOrDefault(t => t.IsEnrollmentConfirm);
if (exisitBaseline == null)
{
return ResponseOutput.NotOk("不存在配置了入组确认的并且生成任务的基线访视");
}
else
{
//入组确认不用管项目的 有序 无序 单重 双重 阅片
//找到最早签名的
var firstSignTask = await _visitTaskRepository.Where(t => t.SourceSubjectVisitId == exisitBaseline.Id /*&& t.TaskState == TaskState.Effect*/ && t.IsAnalysisCreate == false
&& t.ReadingTaskState == ReadingTaskState.HaveSigned && t.TrialReadingCriterionId == trialReadingCriterionId).OrderBy(t=>t.SignTime).FirstOrDefaultAsync();
if (firstSignTask != null)
{
var task = await _visitTaskRepository.Where(t => t.SourceSubjectVisitId == exisitBaseline.Id && t.TaskState == TaskState.Effect && t.DoctorUserId== firstSignTask.DoctorUserId && t.IsAnalysisCreate == false
&& t.ReadingTaskState == ReadingTaskState.HaveSigned && t.TrialReadingCriterionId == trialReadingCriterionId).OrderBy(t => t.SignTime).FirstOrDefaultAsync();
//如果存在做完的该任务
if (task == null)
{
return ResponseOutput.NotOk("做入组确认的阅片人基线任务没有阅片完!");
}
else
{
var filePath = await BaseBusinessScenarioSendEmailAsync(task.Id, true, EmailStoreSendMode.OnlyStoreLocalNotSentEmail, string.Empty);
return ResponseOutput.Ok(new { RelativePath = filePath, TaskName = task.TaskName, VisitTaskId = task.Id });
}
}
else
{
return ResponseOutput.NotOk("当前未有阅片人读完基线任务!");
}
}
}
else if (businessScenarioEnum == CommonDocumentBusinessScenario.PDConfirmed)
{
if (trialConfig.IsPDProgressView == false)
{
return ResponseOutput.NotOk("项目未配置PD进展");
}
//是否是截止访视 截止访视在全局发 否则就在当前访视发
var pdSubjectVisitIdList = subjectVisitList.Where(t => t.PDState == PDStateEnum.PDProgress).OrderBy(t => t.VisitNum).Select(t => (Guid?)t.Id).ToList();
if (pdSubjectVisitIdList.Count == 0)
{
return ResponseOutput.NotOk("不存在配置了PD进展的并且生成任务的访视");
}
var currentLatestPdVisitId = pdSubjectVisitIdList.Last();
//标准配置
var trialReadingCriterionConfig = await _repository.Where<ReadingQuestionCriterionTrial>(t => t.Id == trialReadingCriterionId).Select(t => new
{ TrialReadingCriterionId = t.Id, t.ReadingType, t.IsReadingTaskViewInOrder, t.CriterionType, t.ArbitrationRule }).FirstNotNullAsync();
// 项目双重
if (trialReadingCriterionConfig.ReadingType == ReadingMethod.Double)
{
//仲裁在访视上面
if (trialReadingCriterionConfig.ArbitrationRule == ArbitrationRule.Visit)
{
//在两位阅片人读完访视后,如果有裁判者等裁判读完,如果无裁判则等第二个人的读完
var taskList = await _visitTaskRepository.Where(t => t.SourceSubjectVisitId == currentLatestPdVisitId && t.TrialReadingCriterionId == trialReadingCriterionId && t.IsAnalysisCreate == false
&& t.TaskState == TaskState.Effect && (t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Judge)).ToListAsync();
var totalTaskCount = taskList.Count;
var finishedCount = taskList.Where(t => t.ReadingTaskState == ReadingTaskState.HaveSigned).Count();
//发送随访的
if (totalTaskCount == 2 && totalTaskCount == finishedCount)
{
var task = taskList.FirstOrDefault(t => t.ReadingCategory == ReadingCategory.Visit);
var filePath = await BaseBusinessScenarioSendEmailAsync(task.Id, true, EmailStoreSendMode.OnlyStoreLocalNotSentEmail, string.Empty);
return ResponseOutput.Ok(new { RelativePath = filePath, TaskName = task.TaskName, VisitTaskId = task.Id });
}
//发送全局
else if (totalTaskCount == 3 && totalTaskCount == finishedCount)
{
var task = taskList.FirstOrDefault(t => t.ReadingCategory == ReadingCategory.Judge);
var filePath = await BaseBusinessScenarioSendEmailAsync(task.Id, true, EmailStoreSendMode.OnlyStoreLocalNotSentEmail, string.Empty);
return ResponseOutput.Ok(new { RelativePath = filePath, TaskName = task.TaskName, VisitTaskId = task.Id });
}
else
{
return ResponseOutput.NotOk("当前受试者最新PD访视阅片任务完成状态不符合发送条件");
}
}
//仲裁在阅片期上
else if (trialReadingCriterionConfig.ArbitrationRule == ArbitrationRule.Reading)
{
var existReadModule = await _repository.Where<ReadModule>(t => t.TrialReadingCriterionId == trialReadingCriterionId && t.SubjectVisitId == currentLatestPdVisitId && t.ReadingSetType == ReadingSetType.ImageReading)
.FirstOrDefaultAsync();
if (existReadModule == null)
{
return ResponseOutput.NotOk("项目配置了阅片期仲裁但是当前受试者最新PD访视没有影像学阅片期");
}
else
{
var taskList = await _visitTaskRepository.Where(t => t.TrialReadingCriterionId == trialReadingCriterionId && t.IsAnalysisCreate == false && t.TaskState == TaskState.Effect && t.SouceReadModuleId == existReadModule.Id
&& (t.ReadingCategory == ReadingCategory.Global || t.ReadingCategory == ReadingCategory.Judge)).ToListAsync();
var totalTaskCount = taskList.Count;
var finishedCount = taskList.Where(t => t.ReadingTaskState == ReadingTaskState.HaveSigned).Count();
//发送全局的
if (totalTaskCount == 2 && totalTaskCount == finishedCount)
{
var task = taskList.FirstOrDefault(t => t.ReadingCategory == ReadingCategory.Global);
var filePath = await BaseBusinessScenarioSendEmailAsync(task.Id, true, EmailStoreSendMode.OnlyStoreLocalNotSentEmail, string.Empty);
return ResponseOutput.Ok(new { RelativePath = filePath, TaskName = task.TaskName, VisitTaskId = task.Id });
}
//发送全局裁判的
else if (totalTaskCount == 3 && totalTaskCount == finishedCount)
{
var task = taskList.FirstOrDefault(t => t.ReadingCategory == ReadingCategory.Judge);
var filePath = await BaseBusinessScenarioSendEmailAsync(task.Id, true, EmailStoreSendMode.OnlyStoreLocalNotSentEmail, string.Empty);
return ResponseOutput.Ok(new { RelativePath = filePath, TaskName = task.TaskName, VisitTaskId = task.Id });
}
else
{
return ResponseOutput.NotOk("当前受试者最新PD访视阅片期任务完成状态不符合发送条件");
}
}
}
else
{
return ResponseOutput.NotOk("未定义该仲裁规则发送业务逻辑!");
}
}
// 项目单重 判断最新的Pd 访视是否完成 是否有阅片期即可
else if (trialReadingCriterionConfig.ReadingType == ReadingMethod.Single)
{
var task = await _visitTaskRepository.Where(t => t.SourceSubjectVisitId == currentLatestPdVisitId && t.TaskState == TaskState.Effect && t.IsAnalysisCreate == false
&& t.ReadingTaskState == ReadingTaskState.HaveSigned && t.TrialReadingCriterionId == trialReadingCriterionId).FirstOrDefaultAsync();
if (task == null)
{
return ResponseOutput.NotOk("当前受试者最新PD访视任务未阅片完成");
}
else
{
//存在阅片期 那么就是截止访视
var existReadModule = await _repository.Where<ReadModule>(t => t.TrialReadingCriterionId == trialReadingCriterionId && t.SubjectVisitId == currentLatestPdVisitId && t.ReadingSetType == ReadingSetType.ImageReading)
.FirstOrDefaultAsync();
if (existReadModule != null)
{
var global = await _visitTaskRepository.Where(t => t.SouceReadModuleId == currentLatestPdVisitId && t.TaskState == TaskState.Effect && t.IsAnalysisCreate == false
&& t.ReadingTaskState == ReadingTaskState.HaveSigned && t.TrialReadingCriterionId == trialReadingCriterionId).FirstOrDefaultAsync();
if (global != null)
{
var filePath = await BaseBusinessScenarioSendEmailAsync(global.Id, true, EmailStoreSendMode.OnlyStoreLocalNotSentEmail, string.Empty);
return ResponseOutput.Ok(new { RelativePath = filePath, TaskName = task.TaskName, VisitTaskId = task.Id });
}
else
{
return ResponseOutput.NotOk("当前受试者阅片期任务未阅片完成");
}
}
else//非截止访视 在访视读完后,发送
{
var filePath = await BaseBusinessScenarioSendEmailAsync(task.Id, true, EmailStoreSendMode.OnlyStoreLocalNotSentEmail, string.Empty);
return ResponseOutput.Ok(new { RelativePath = filePath, TaskName = task.TaskName, VisitTaskId = task.Id });
}
}
}
else
{
return ResponseOutput.NotOk("当前项目配置,未定义单双重外发送业务逻辑!");
}
}
else
{
return ResponseOutput.NotOk("当前项目配置,未定义发送业务逻辑!");
}
}
/// <summary>
/// 手动发送邮件
/// </summary>
/// <param name="visitTaskId"></param>
/// <param name="sendFileRelativePath"></param>
/// <returns></returns>
[HttpPut]
public async Task<IResponseOutput> ManualSendEmail(Guid visitTaskId, string sendFileRelativePath)
{
var filePath = await BaseBusinessScenarioSendEmailAsync(visitTaskId, true, EmailStoreSendMode.NotStoreLocalOnlySentEmail, sendFileRelativePath);
return ResponseOutput.Ok();
}
/// <summary>
///
/// </summary>
/// <param name="visitTaskId"> 任务Id</param>
/// <param name="readingCategory"> 任务类型</param>
/// <param name="criterionType">标准类型</param>
/// <param name="IsGlobalGenerate"> 是否是全局产生(区分裁判任务)</param>
/// <returns></returns>
/// <exception cref="BusinessValidationFailedException"></exception>
private async Task<string> TranslatePdStateAsync(Guid visitTaskId, ReadingCategory readingCategory, CriterionType criterionType, bool? IsGlobalGenerate=null)
{
var answer = string.Empty;
@ -786,15 +1182,15 @@ namespace IRaCIS.Core.Application.Service
}
}
else if (readingCategory == ReadingCategory.Judge)
{
//var judgeResultTaskId = await _visitTaskRepository.Where(t => t.Id == visitTaskId).Select(t => t.JudgeResultTaskId).FirstNotNullAsync();
//else if (readingCategory == ReadingCategory.Judge)
//{
// var judgeResultTaskId = await _visitTaskRepository.Where(t => t.Id == visitTaskId).Select(t => t.JudgeResultTaskId).FirstNotNullAsync();
var questionAnsewer = await _repository.Where<ReadingTaskQuestionAnswer>(t => t.VisitTaskId == visitTaskId && t.ReadingQuestionTrial.QuestionType == QuestionType.Tumor).FirstNotNullAsync();
// var questionAnsewer = await _repository.Where<ReadingTaskQuestionAnswer>(t => t.VisitTaskId == judgeResultTaskId && t.ReadingQuestionTrial.QuestionType == QuestionType.Tumor).FirstNotNullAsync();
answer = questionAnsewer.Answer;
}
// answer = questionAnsewer.Answer;
//}
else
{
throw new BusinessValidationFailedException("不应有 除访视、裁判、全局其他类型的任务进行发送邮件,请核查业务逻辑");
@ -826,14 +1222,14 @@ namespace IRaCIS.Core.Application.Service
answer = questionAnsewer.Answer;
}
else if (readingCategory == ReadingCategory.Judge)
{
//var judgeResultTaskId = await _visitTaskRepository.Where(t => t.Id == visitTaskId).Select(t => t.JudgeResultTaskId).FirstNotNullAsync();
//else if (readingCategory == ReadingCategory.Judge)
//{
// //var judgeResultTaskId = await _visitTaskRepository.Where(t => t.Id == visitTaskId).Select(t => t.JudgeResultTaskId).FirstNotNullAsync();
var questionAnsewer = await _repository.Where<ReadingTaskQuestionAnswer>(t => t.VisitTaskId == visitTaskId && t.ReadingQuestionTrial.QuestionType == QuestionType.SiteVisitForTumorEvaluation).FirstNotNullAsync();
// var questionAnsewer = await _repository.Where<ReadingTaskQuestionAnswer>(t => t.VisitTaskId == visitTaskId && t.ReadingQuestionTrial.QuestionType == QuestionType.SiteVisitForTumorEvaluation).FirstNotNullAsync();
answer = questionAnsewer.Answer;
}
// answer = questionAnsewer.Answer;
//}
else
{
throw new BusinessValidationFailedException("不应有 除访视、裁判、全局其他类型的任务进行发送邮件,请核查业务逻辑");

View File

@ -209,6 +209,21 @@ namespace IRaCIS.Core.Application.Services
var dicModalityList = _dictionaryRepository.Where(t => t.Code == "Modality").SelectMany(t => t.ChildList.Select(c => c.Value)).ToList();
var modalityForEdit = dicModalityList.Contains(modality) ? modality : String.Empty;
if (modality == "MR")
{
modalityForEdit = "MRI";
}
if (modality == "PT")
{
modalityForEdit = "PET";
}
if(modality== "PT、CT")
{
modalityForEdit = "PET-CT";
}
dicomStudy = new DicomStudy
{
@ -217,7 +232,7 @@ namespace IRaCIS.Core.Application.Services
/* StudyTime = dataset.GetSingleValueOrDefault(DicomTag.StudyDate, DateTime.Now).Add(dataset.GetSingleValueOrDefault(DicomTag.StudyTime, DateTime.Now).TimeOfDay),*///dataset.GetDateTime(DicomTag.StudyDate, DicomTag.StudyTime),
StudyTime = dataset.GetSingleValueOrDefault(DicomTag.StudyDate, string.Empty) == string.Empty ? null : dataset.GetSingleValue<DateTime>(DicomTag.StudyDate).Add(dataset.GetSingleValueOrDefault(DicomTag.StudyTime, string.Empty) == string.Empty ? TimeSpan.Zero : dataset.GetSingleValue<DateTime>(DicomTag.StudyTime).TimeOfDay),
Modalities = modality,
ModalityForEdit = modality == "MR" ? "MRI": (dicModalityList.Contains(modality) ? modality : String.Empty),
ModalityForEdit = modalityForEdit,
Description = dataset.GetSingleValueOrDefault(DicomTag.StudyDescription, string.Empty),
InstitutionName = dataset.GetSingleValueOrDefault(DicomTag.InstitutionName, string.Empty),
PatientId = dataset.GetSingleValueOrDefault(DicomTag.PatientID, string.Empty),

View File

@ -1335,11 +1335,9 @@ namespace IRaCIS.Core.Application.Image.QA
}
//非基线设置为PD的话 或者设置为末次访视 根据配置自动生成阅片期
if (!dbSubjectVisit.IsBaseLine && dbSubjectVisit.PDState == PDStateEnum.PDProgress && dbSubjectVisit.IsFinalVisit)
if (!dbSubjectVisit.IsBaseLine && (dbSubjectVisit.PDState == PDStateEnum.PDProgress || dbSubjectVisit.IsFinalVisit) )
{
//该标准需要添加阅片期
foreach (var trialReadingCriterionId in trialReadingCriterionIdList)
{

View File

@ -684,7 +684,7 @@ namespace IRaCIS.Core.Application.Service
});
await _trialEmailNoticeConfigService.BaseBusinessScenarioSendEmailAsync(medicalReviewInfo.VisitTaskId, true&& medicalReviewInfo.IsApplyHeavyReading);
await _trialEmailNoticeConfigService.BaseBusinessScenarioSendEmailAsync(medicalReviewInfo.VisitTaskId, true&& medicalReviewInfo.IsApplyHeavyReading);
var result = await _taskMedicalReviewRepository.SaveChangesAsync();
return ResponseOutput.Result(result);

View File

@ -11,6 +11,7 @@ using Newtonsoft.Json;
using IRaCIS.Core.Application.Service;
using IRaCIS.Core.Application.ViewModel;
using IRaCIS.Core.Application.Filter;
using IRaCIS.Core.Domain.Models;
namespace IRaCIS.Application.Services
{
@ -451,6 +452,8 @@ namespace IRaCIS.Application.Services
// 创建任务关联关系
await this.CreateTaskRelated(inDto.VisitTaskId);
await _trialEmailNoticeConfigService.BaseBusinessScenarioSendEmailAsync(inDto.VisitTaskId);
return ResponseOutput.Ok(result);
}

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IRaCIS.Core.Domain.Share.Common
{
public enum EmailStoreSendMode
{
//不存储本地 发送
NotStoreLocalSend = 0,
//存储本地发送
StoreLocalSend = 1,
//存储本地不发送
OnlyStoreLocalNotSentEmail = 2,
//不存储本地 发送
NotStoreLocalOnlySentEmail = 3,
}
}

View File

@ -15,6 +15,7 @@ namespace IRaCIS.Core.Domain.Models
[JsonIgnore]
[ForeignKey("UserTypeId")]
public UserType UserType { get; set; }
}
}

View File

@ -72,6 +72,9 @@ public static class StaticData
public static string StudyMaxCode = "StudyMaxCode";
public static string TaskMaxCode = "TaskMaxCode";
public const string UserTypeId = "UserTypeId";
}