|
|
|
@ -63,14 +63,15 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 新增或者修改
|
|
|
|
|
/// 新增或者修改 (增加标准搜索,已修改)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="addOrEditReadingPeriodSet"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public async Task<IResponseOutput> AddOrUpdateReadingPeriodSet(ReadingPeriodSetAddOrEdit addOrEditReadingPeriodSet)
|
|
|
|
|
{
|
|
|
|
|
if (await _readingPeriodSetRepository.AnyAsync(x => x.Id != addOrEditReadingPeriodSet.Id&&x.IsTakeEffect!= ReadingPeriodStatus.Revocation && x.TrialId == addOrEditReadingPeriodSet.TrialId && x.ReadingPeriodName == addOrEditReadingPeriodSet.ReadingPeriodName))
|
|
|
|
|
if (await _readingPeriodSetRepository.AnyAsync(x => x.Id != addOrEditReadingPeriodSet.Id&&x.IsTakeEffect!= ReadingPeriodStatus.Revocation
|
|
|
|
|
&& x.TrialId == addOrEditReadingPeriodSet.TrialId && x.ReadingPeriodName == addOrEditReadingPeriodSet.ReadingPeriodName && x.TrialReadingCriterionId==addOrEditReadingPeriodSet.TrialReadingCriterionId))
|
|
|
|
|
{
|
|
|
|
|
return ResponseOutput.NotOk("阅片期名称重复,操作失败");
|
|
|
|
|
}
|
|
|
|
@ -121,7 +122,7 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取影像阅片的预览 // 需要清除之前已经选中的
|
|
|
|
|
/// 获取影像阅片的预览 // 需要清除之前已经选中的 (增加标准搜索,已修改)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost]
|
|
|
|
@ -134,7 +135,7 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
.WhereIf(inDto.ReadingScope== ReadingScopeEnum.Site, x => inDto.SiteIds.Contains(x.SiteId));
|
|
|
|
|
|
|
|
|
|
// 已经存在的访视 需要排除
|
|
|
|
|
var existsBubjectVisitsQuery= _readModuleRepository.Where(y => y.ReadingSetType == inDto.ReadingSetType && y.TrialId == inDto.TrialId).Select(x => x.SubjectVisitId);
|
|
|
|
|
var existsBubjectVisitsQuery= _readModuleRepository.Where(y => y.ReadingSetType == inDto.ReadingSetType && y.TrialId == inDto.TrialId && y.TrialReadingCriterionId == inDto.TrialReadingCriterionId).Select(x => x.SubjectVisitId);
|
|
|
|
|
|
|
|
|
|
visitQuery = visitQuery.Where(x => !existsBubjectVisitsQuery.Contains(x.Id))
|
|
|
|
|
.WhereIf(inDto.ExpirationDate != null, x => x.LatestScanDate <= inDto.ExpirationDate.Value)
|
|
|
|
@ -186,7 +187,7 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 添加对应的阅片
|
|
|
|
|
/// 添加对应的阅片 (增加标准不影响 因为阅片期设置关联了标准)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="inDto"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
@ -209,7 +210,7 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取选中的计划
|
|
|
|
|
/// 获取选中的计划 (增加标准不影响 因为阅片期设置关联了标准)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="inDto"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
@ -238,7 +239,7 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 分页获取
|
|
|
|
|
/// 分页获取 (增加标准搜索,已修改)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="query"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
@ -247,6 +248,7 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
{
|
|
|
|
|
var readQuery =_readingPeriodSetRepository.Where(t=>t.TrialId==query.TrialId).Include(x=>x.ReadingPeriodSites)
|
|
|
|
|
.WhereIf(query.ReadingPeriodName != null, x => x.ReadingPeriodName.Contains(query.ReadingPeriodName!))
|
|
|
|
|
.WhereIf(query.TrialReadingCriterionId != null, x => x.TrialReadingCriterionId==query.TrialReadingCriterionId)
|
|
|
|
|
.ProjectTo<ReadingPeriodSetView>(_mapper.ConfigurationProvider);
|
|
|
|
|
var pageList= await readQuery.ToPagedListAsync(query.PageIndex, query.PageSize, query.SortField == null ? nameof(ReadingPeriodSetView.CreateTime) : query.SortField,
|
|
|
|
|
query.Asc);
|
|
|
|
@ -272,20 +274,27 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取阅片期配置的截至访视的下拉框
|
|
|
|
|
/// 获取阅片期配置的截至访视的下拉框 (增加标准搜索,已修改)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="inDto"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPost]
|
|
|
|
|
public async Task<List<GetReadingVisitListOutDto>> GetReadingVisitList(GetReadingVisitListInDto inDto)
|
|
|
|
|
{
|
|
|
|
|
var maxVisitNum = await _readingPeriodSetRepository.Where(x => x.TrialId == inDto.TrialId && x.ReadingSetType == inDto.ReadingSetType&&x.IsTakeEffect== ReadingPeriodStatus.TakeEffect).MaxAsync(x => x.ExpirationVisitNum)??0;
|
|
|
|
|
var maxVisitNum = await _readingPeriodSetRepository
|
|
|
|
|
.WhereIf(inDto.TrialReadingCriterionId!=null,t=>t.TrialReadingCriterionId==inDto.TrialReadingCriterionId)
|
|
|
|
|
|
|
|
|
|
.Where(x => x.TrialId == inDto.TrialId && x.ReadingSetType == inDto.ReadingSetType&&x.IsTakeEffect== ReadingPeriodStatus.TakeEffect )
|
|
|
|
|
.MaxAsync(x => x.ExpirationVisitNum)??0;
|
|
|
|
|
var thisVisitNum = await _readingPeriodSetRepository.Where(x => x.Id == inDto.ReadingPeriodSetId).Select(x => x.ExpirationVisitNum).FirstOrDefaultAsync() ?? -1;
|
|
|
|
|
|
|
|
|
|
var globalVisitNum = new List<decimal>();
|
|
|
|
|
if (inDto.ReadingSetType == ReadingSetType.TumorReading)
|
|
|
|
|
{
|
|
|
|
|
globalVisitNum = await _readModuleRepository.Where(x => x.ReadingSetType == ReadingSetType.ImageReading && x.TrialId == inDto.TrialId).Select(x => x.VisitNum).Distinct().ToListAsync();
|
|
|
|
|
globalVisitNum = await _readModuleRepository
|
|
|
|
|
.WhereIf(inDto.TrialReadingCriterionId != null, t => t.TrialReadingCriterionId == inDto.TrialReadingCriterionId)
|
|
|
|
|
|
|
|
|
|
.Where(x => x.ReadingSetType == ReadingSetType.ImageReading && x.TrialId == inDto.TrialId).Select(x => x.VisitNum).Distinct().ToListAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List <GetReadingVisitListOutDto> result = await _visitStageRepository.Where(x => x.TrialId == inDto.TrialId )
|
|
|
|
@ -300,20 +309,22 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 设置阅片期配置是否生效
|
|
|
|
|
/// 设置阅片期配置是否生效 (增加标准搜索,已修改)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="indto"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
[HttpPut]
|
|
|
|
|
public async Task<IResponseOutput> SetReadingPeriodSetEffect(SetReadingPeriodSetEffect indto)
|
|
|
|
|
{
|
|
|
|
|
var readingPeriodSet = await _readingPeriodSetRepository.Where(x => x.Id == indto.Id).FirstNotNullAsync();
|
|
|
|
|
|
|
|
|
|
if (indto.IsTakeEffect == ReadingPeriodStatus.TakeEffect)
|
|
|
|
|
{
|
|
|
|
|
var readingPeriodSet = await _readingPeriodSetRepository.Where(x => x.Id == indto.Id).FirstNotNullAsync();
|
|
|
|
|
var plans = _readingPeriodPlanRepository.Where(x => x.ReadingPeriodSetId == indto.Id).Include(x => x.SubjectVisit)
|
|
|
|
|
.Include(x => x.ReadingPeriodSet).Include(x => x.SubjectVisit).ToList();
|
|
|
|
|
var needAddVisitIds = plans.Select(x => x.SubjectVisitId).ToList();
|
|
|
|
|
var repeatVisitNames = _readModuleRepository.Where(x => x.ReadingSetType == readingPeriodSet.ReadingSetType && needAddVisitIds.Contains(x.SubjectVisitId)).Select(x =>x.Subject.Code+"的"+ x.SubjectVisit.VisitName).ToList();
|
|
|
|
|
|
|
|
|
|
var repeatVisitNames = _readModuleRepository.Where(x => x.TrialReadingCriterionId== readingPeriodSet.TrialReadingCriterionId && x.ReadingSetType == readingPeriodSet.ReadingSetType && needAddVisitIds.Contains(x.SubjectVisitId)).Select(x =>x.Subject.Code+"的"+ x.SubjectVisit.VisitName).ToList();
|
|
|
|
|
if(repeatVisitNames.Count!=0)
|
|
|
|
|
{
|
|
|
|
|
return ResponseOutput.NotOk($"{string.Join(",", repeatVisitNames)}已经添加过阅片期,无法设置生效");
|
|
|
|
@ -334,6 +345,9 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
ReadingStatus = ReadingStatusEnum.TaskAllocate,
|
|
|
|
|
TrialId = readingPeriodSet.TrialId,
|
|
|
|
|
VisitNum = item.SubjectVisit.VisitNum,
|
|
|
|
|
|
|
|
|
|
//增加标准
|
|
|
|
|
TrialReadingCriterionId=readingPeriodSet.TrialReadingCriterionId
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -343,8 +357,9 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
switch (readingPeriodSet.ReadingSetType)
|
|
|
|
|
{
|
|
|
|
|
case ReadingSetType.ImageReading:
|
|
|
|
|
|
|
|
|
|
var taskInfoList = await _visitTaskRepository.Where(x => subjectVisitIds.Contains(x.SourceSubjectVisitId ?? default(Guid))&&x.TaskState==TaskState.Effect && x.ReadingTaskState == ReadingTaskState.HaveSigned&&!x.IsAnalysisCreate).ToListAsync();
|
|
|
|
|
//增加标准
|
|
|
|
|
var taskInfoList = await _visitTaskRepository.Where(x =>x.TrialReadingCriterionId==readingPeriodSet.TrialReadingCriterionId && subjectVisitIds.Contains(x.SourceSubjectVisitId ?? default(Guid)) &&
|
|
|
|
|
x.TaskState==TaskState.Effect && x.ReadingTaskState == ReadingTaskState.HaveSigned && !x.IsAnalysisCreate).ToListAsync();
|
|
|
|
|
|
|
|
|
|
foreach (var item in taskInfoList)
|
|
|
|
|
{
|
|
|
|
@ -378,10 +393,11 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
|
|
|
|
|
var trialInfo = await _trialRepository.Where(x => x.Id == readingPeriodSet.TrialId).FirstNotNullAsync();
|
|
|
|
|
|
|
|
|
|
var globalModuleIds = await _readModuleRepository.Where(x => subjectVisitIds.Contains(x.SubjectVisitId) && x.ModuleType == ModuleTypeEnum.Global).Select(x => x.Id).ToListAsync();
|
|
|
|
|
//增加标准
|
|
|
|
|
var globalModuleIds = await _readModuleRepository.Where(x => x.TrialReadingCriterionId == readingPeriodSet.TrialReadingCriterionId && subjectVisitIds.Contains(x.SubjectVisitId) && x.ModuleType == ModuleTypeEnum.Global).Select(x => x.Id).ToListAsync();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var globalTaskInfo = await _visitTaskRepository.Where(x => globalModuleIds.Contains(x.SouceReadModuleId ?? default(Guid)) && x.TaskState == TaskState.Effect && x.ReadingTaskState == ReadingTaskState.HaveSigned&&!x.IsAnalysisCreate).GroupBy(x=> new { x.SouceReadModuleId }).Select(x =>
|
|
|
|
|
//增加标准
|
|
|
|
|
var globalTaskInfo = await _visitTaskRepository.Where(x => x.TrialReadingCriterionId == readingPeriodSet.TrialReadingCriterionId && globalModuleIds.Contains(x.SouceReadModuleId ?? default(Guid)) && x.TaskState == TaskState.Effect && x.ReadingTaskState == ReadingTaskState.HaveSigned&&!x.IsAnalysisCreate).GroupBy(x=> new { x.SouceReadModuleId }).Select(x =>
|
|
|
|
|
new {
|
|
|
|
|
SouceReadModuleId=x.Key.SouceReadModuleId,
|
|
|
|
|
Count=x.ToList().Count,
|
|
|
|
@ -390,15 +406,17 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
JudgeTaskId = x.Select(x => x.JudgeVisitTaskId).FirstOrDefault(),
|
|
|
|
|
JudgeTaskResultId = x.Select(x => x.JudgeVisitTask.JudgeResultTaskId).FirstOrDefault(),
|
|
|
|
|
}).ToListAsync();
|
|
|
|
|
|
|
|
|
|
foreach (var item in globalTaskInfo)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (item.Count == (int)trialInfo.ReadingType)
|
|
|
|
|
{
|
|
|
|
|
//没有裁判 或者有裁判,并且裁判任务做完了
|
|
|
|
|
if (item.JudgeTaskId == null || item.JudgeTaskResultId != null)
|
|
|
|
|
{
|
|
|
|
|
var readModule = readModules.Where(x => x.Id == item.ReadModuleId).FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
await _visitTaskHelpeService.AddTaskAsync(new GenerateTaskCommand()
|
|
|
|
|
{
|
|
|
|
|
OriginalVisitId = item.TaskId,
|
|
|
|
@ -436,13 +454,14 @@ namespace IRaCIS.Application.Services
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
List<Guid> readModuleIds = await _readModuleRepository.Where(x => x.ReadingPeriodSetId == indto.Id).Select(x => x.Id).ToListAsync();
|
|
|
|
|
if (await _visitTaskRepository.AnyAsync(x => readModuleIds.Contains(x.SouceReadModuleId ?? default(Guid)) && x.ReadingTaskState == ReadingTaskState.HaveSigned && x.TaskState == TaskState.Effect))
|
|
|
|
|
|
|
|
|
|
if (await _visitTaskRepository.AnyAsync(x => x.TrialReadingCriterionId == readingPeriodSet.TrialReadingCriterionId && readModuleIds.Contains(x.SouceReadModuleId ?? default(Guid)) && x.ReadingTaskState == ReadingTaskState.HaveSigned && x.TaskState == TaskState.Effect))
|
|
|
|
|
{
|
|
|
|
|
throw new BusinessValidationFailedException("当前阅片已生成任务并且阅片完成,撤销失败。");
|
|
|
|
|
throw new BusinessValidationFailedException("当前标准阅片已生成任务并且阅片完成,撤销失败。");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await _visitTaskRepository.BatchUpdateNoTrackingAsync(x => readModuleIds.Contains(x.SouceReadModuleId ?? default(Guid)), x => new VisitTask()
|
|
|
|
|
await _visitTaskRepository.BatchUpdateNoTrackingAsync(x => x.TrialReadingCriterionId == readingPeriodSet.TrialReadingCriterionId && readModuleIds.Contains(x.SouceReadModuleId ?? default(Guid)), x => new VisitTask()
|
|
|
|
|
{
|
|
|
|
|
TaskState = TaskState.Adbandon
|
|
|
|
|
});
|
|
|
|
|