代码整理
This commit is contained in:
+178
-187
@@ -104,85 +104,6 @@ namespace IRaCIS.Application.Services
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#region 阅片期 -全局和肿瘤学任务的生成
|
||||
|
||||
/// <summary>
|
||||
/// 添加阅片期任务
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private async Task AddReadingTask(Guid visitTaskId)
|
||||
{
|
||||
// ****** 先生成阅片期 阅片期任务阅片完成之后生成肿瘤学的 如果没有阅片期 直接生成肿瘤学 *********////
|
||||
#region 建立关系
|
||||
// 访视阅完产生 全局
|
||||
Dictionary<ModuleTypeEnum, ReadingCategory> typeChangeDic = new Dictionary<ModuleTypeEnum, ReadingCategory>();
|
||||
typeChangeDic.Add(ModuleTypeEnum.InPlanSubjectVisit, ReadingCategory.Visit);
|
||||
typeChangeDic.Add(ModuleTypeEnum.OutPlanSubjectVisit, ReadingCategory.Visit);
|
||||
//typeChange.Add(ModuleTypeEnum.Read, ReadingCategory.ReadingPeriod);
|
||||
typeChangeDic.Add(ModuleTypeEnum.Global, ReadingCategory.Global);
|
||||
typeChangeDic.Add(ModuleTypeEnum.Referee, ReadingCategory.Judge);
|
||||
typeChangeDic.Add(ModuleTypeEnum.Oncology, ReadingCategory.Oncology);
|
||||
#endregion
|
||||
var taskInfo = await _visitTaskRepository.Where(x => x.Id == visitTaskId).FirstNotNullAsync();
|
||||
List<ReadingGenerataTaskDTO> needReadList = new List<ReadingGenerataTaskDTO>();
|
||||
if (!taskInfo.IsAnalysisCreate)
|
||||
{
|
||||
// 任务类型
|
||||
switch (taskInfo.ReadingCategory)
|
||||
{
|
||||
case ReadingCategory.Visit:
|
||||
needReadList = await _readModuleRepository.Where(x => x.SubjectVisitId == taskInfo.SourceSubjectVisitId &&
|
||||
|
||||
x.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId &&
|
||||
x.ReadingSetType == ReadingSetType.ImageReading)
|
||||
.Select(x => new ReadingGenerataTaskDTO
|
||||
{
|
||||
IsUrgent = x.IsUrgent ?? false,
|
||||
SubjectId = x.SubjectId,
|
||||
VisitNum = x.VisitNum,
|
||||
ReadingName = x.ModuleName,
|
||||
ReadModuleId = x.Id,
|
||||
ReadingCategory = typeChangeDic[x.ModuleType],
|
||||
}).ToListAsync();
|
||||
if (needReadList.Any(x => x.ReadingCategory == ReadingCategory.Global))
|
||||
{
|
||||
needReadList = needReadList.Where(x => x.ReadingCategory != ReadingCategory.Oncology).ToList();
|
||||
}
|
||||
//needReadList = needReadList.Where(x => _visitTaskRepository.Where(y => y.SouceReadModuleId == x.ReadModuleId).Count() == 0).ToList();
|
||||
await _visitTaskHelpeService.AddTaskAsync(new GenerateTaskCommand()
|
||||
{
|
||||
OriginalVisitId = visitTaskId,
|
||||
ReadingCategory = GenerateTaskCategory.Global,
|
||||
TrialId = taskInfo.TrialId,
|
||||
ReadingGenerataTaskList = needReadList
|
||||
});
|
||||
break;
|
||||
// 肿瘤学
|
||||
case ReadingCategory.Global:
|
||||
var subjectVisitId = await _readModuleRepository.Where(x => x.Id == taskInfo.SouceReadModuleId).Select(x => x.SubjectVisitId).FirstOrDefaultAsync();
|
||||
var oncologyReadId = await _readModuleRepository.Where(x => x.SubjectVisitId == subjectVisitId && x.ModuleType == ModuleTypeEnum.Oncology
|
||||
&& x.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId
|
||||
|
||||
|
||||
).Select(x => x.Id).FirstOrDefaultAsync();
|
||||
await AddOncologyTask(oncologyReadId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 阅片页面 关联信息查询 以及基本验证
|
||||
|
||||
/// <summary>
|
||||
@@ -792,6 +713,114 @@ namespace IRaCIS.Application.Services
|
||||
#endregion
|
||||
|
||||
|
||||
#region 访视任务 - Dicom 阅片 表格问题 病灶的拆分与合并
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 拆分病灶
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task SplitLesion(SplitLesionInDto inDto)
|
||||
{
|
||||
await this.VerifyIsBaseLineTask(inDto.VisitTaskId);
|
||||
var rowAnswer = await _readingTableAnswerRowInfoRepository.Where(x => x.Id == inDto.RowId).AsNoTracking().FirstNotNullAsync();
|
||||
var tableAnswers = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.RowIndex == rowAnswer.RowIndex && x.QuestionId == inDto.QuestionId).Include(x => x.ReadingTableQuestionTrial).ToListAsync();
|
||||
var maxRowIndex = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.QuestionId == inDto.QuestionId && x.RowIndex < Math.Floor(rowAnswer.RowIndex + 1)).OrderByDescending(x => x.RowIndex).Select(x => x.RowIndex).FirstOrDefaultAsync();
|
||||
var newRowIndex = maxRowIndex + (decimal)0.01;
|
||||
|
||||
rowAnswer.RowIndex = newRowIndex;
|
||||
rowAnswer.MergeRowId = null;
|
||||
rowAnswer.SplitOrMergeType = SplitOrMergeType.Split;
|
||||
rowAnswer.SplitRowId = rowAnswer.Id;
|
||||
rowAnswer.Id = NewId.NextGuid();
|
||||
rowAnswer.InstanceId = null;
|
||||
rowAnswer.SeriesId = null;
|
||||
rowAnswer.IsCurrentTaskAdd = true;
|
||||
rowAnswer.MeasureData = string.Empty;
|
||||
|
||||
List<QuestionMark?> needRemoveMark = new List<QuestionMark?>()
|
||||
{
|
||||
QuestionMark.MajorAxis,
|
||||
QuestionMark.ShortAxis,
|
||||
};
|
||||
|
||||
tableAnswers.ForEach(x =>
|
||||
{
|
||||
x.Id = NewId.NextGuid();
|
||||
x.RowIndex = newRowIndex;
|
||||
x.VisitTaskId = inDto.VisitTaskId;
|
||||
x.RowId = rowAnswer.Id;
|
||||
x.Answer = needRemoveMark.Contains(x.ReadingTableQuestionTrial.QuestionMark) ? string.Empty : x.Answer;
|
||||
x.ReadingTableQuestionTrial = null;
|
||||
});
|
||||
await _readingTableAnswerRowInfoRepository.AddAsync(rowAnswer);
|
||||
await _readingTableQuestionAnswerRepository.AddRangeAsync(tableAnswers);
|
||||
await _readingTableAnswerRowInfoRepository.SaveChangesAsync();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 合并病灶
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task MergeLesion(MergeLesionInDto inDto)
|
||||
{
|
||||
await this.VerifyIsBaseLineTask(inDto.VisitTaskId);
|
||||
|
||||
var rowsInfo = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && (x.Id == inDto.MainRowId || x.Id == inDto.MergeRowId)).ToListAsync();
|
||||
|
||||
if (rowsInfo.Count() != 2)
|
||||
{
|
||||
throw new BusinessValidationFailedException("合并的病灶并非同一个访视任务");
|
||||
}
|
||||
|
||||
|
||||
var minaid = rowsInfo.Where(x => x.Id == inDto.MainRowId).Select(x => x.Id).FirstOrDefault();
|
||||
var mergeid = rowsInfo.Where(x => x.Id == inDto.MergeRowId).Select(x => x.Id).FirstOrDefault();
|
||||
|
||||
List<QuestionMark?> needRemoveMark = new List<QuestionMark?>()
|
||||
{
|
||||
QuestionMark.MajorAxis,
|
||||
QuestionMark.ShortAxis,
|
||||
};
|
||||
|
||||
var mainAnswer = await _readingTableQuestionAnswerRepository.Where(x => x.RowId == minaid).Include(x => x.ReadingTableQuestionTrial).ToListAsync();
|
||||
|
||||
foreach (var item in mainAnswer)
|
||||
{
|
||||
await _readingTableQuestionAnswerRepository.BatchUpdateNoTrackingAsync(x => x.RowId == mergeid && x.TableQuestionId == item.TableQuestionId, x => new ReadingTableQuestionAnswer()
|
||||
{
|
||||
Answer = needRemoveMark.Contains(item.ReadingTableQuestionTrial.QuestionMark) ? string.Empty : item.Answer,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
await _readingTableAnswerRowInfoRepository.UpdatePartialFromQueryAsync(mergeid, x => new ReadingTableAnswerRowInfo()
|
||||
{
|
||||
MergeRowId = minaid,
|
||||
SplitOrMergeType = SplitOrMergeType.Merge,
|
||||
});
|
||||
|
||||
|
||||
await _readingTableAnswerRowInfoRepository.UpdatePartialFromQueryAsync(mergeid, x => new ReadingTableAnswerRowInfo()
|
||||
{
|
||||
MergeRowId = minaid,
|
||||
SplitOrMergeType = SplitOrMergeType.Merge,
|
||||
});
|
||||
|
||||
await _readingTableAnswerRowInfoRepository.SaveChangesAsync();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region 访视任务 - Dicom 阅片 提交、修改
|
||||
|
||||
/// <summary>
|
||||
@@ -1085,112 +1114,6 @@ namespace IRaCIS.Application.Services
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region 访视任务 - Dicom 阅片 表格问题 病灶的拆分与合并
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 拆分病灶
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task SplitLesion(SplitLesionInDto inDto)
|
||||
{
|
||||
await this.VerifyIsBaseLineTask(inDto.VisitTaskId);
|
||||
var rowAnswer = await _readingTableAnswerRowInfoRepository.Where(x => x.Id == inDto.RowId).AsNoTracking().FirstNotNullAsync();
|
||||
var tableAnswers = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.RowIndex == rowAnswer.RowIndex && x.QuestionId == inDto.QuestionId).Include(x => x.ReadingTableQuestionTrial).ToListAsync();
|
||||
var maxRowIndex = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.QuestionId == inDto.QuestionId && x.RowIndex < Math.Floor(rowAnswer.RowIndex + 1)).OrderByDescending(x => x.RowIndex).Select(x => x.RowIndex).FirstOrDefaultAsync();
|
||||
var newRowIndex = maxRowIndex + (decimal)0.01;
|
||||
|
||||
rowAnswer.RowIndex = newRowIndex;
|
||||
rowAnswer.MergeRowId = null;
|
||||
rowAnswer.SplitOrMergeType = SplitOrMergeType.Split;
|
||||
rowAnswer.SplitRowId = rowAnswer.Id;
|
||||
rowAnswer.Id = NewId.NextGuid();
|
||||
rowAnswer.InstanceId = null;
|
||||
rowAnswer.SeriesId = null;
|
||||
rowAnswer.IsCurrentTaskAdd = true;
|
||||
rowAnswer.MeasureData = string.Empty;
|
||||
|
||||
List<QuestionMark?> needRemoveMark = new List<QuestionMark?>()
|
||||
{
|
||||
QuestionMark.MajorAxis,
|
||||
QuestionMark.ShortAxis,
|
||||
};
|
||||
|
||||
tableAnswers.ForEach(x =>
|
||||
{
|
||||
x.Id = NewId.NextGuid();
|
||||
x.RowIndex = newRowIndex;
|
||||
x.VisitTaskId = inDto.VisitTaskId;
|
||||
x.RowId = rowAnswer.Id;
|
||||
x.Answer = needRemoveMark.Contains(x.ReadingTableQuestionTrial.QuestionMark) ? string.Empty : x.Answer;
|
||||
x.ReadingTableQuestionTrial = null;
|
||||
});
|
||||
await _readingTableAnswerRowInfoRepository.AddAsync(rowAnswer);
|
||||
await _readingTableQuestionAnswerRepository.AddRangeAsync(tableAnswers);
|
||||
await _readingTableAnswerRowInfoRepository.SaveChangesAsync();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 合并病灶
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task MergeLesion(MergeLesionInDto inDto)
|
||||
{
|
||||
await this.VerifyIsBaseLineTask(inDto.VisitTaskId);
|
||||
|
||||
var rowsInfo = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && (x.Id == inDto.MainRowId || x.Id == inDto.MergeRowId)).ToListAsync();
|
||||
|
||||
if (rowsInfo.Count() != 2)
|
||||
{
|
||||
throw new BusinessValidationFailedException("合并的病灶并非同一个访视任务");
|
||||
}
|
||||
|
||||
|
||||
var minaid = rowsInfo.Where(x => x.Id == inDto.MainRowId).Select(x => x.Id).FirstOrDefault();
|
||||
var mergeid = rowsInfo.Where(x => x.Id == inDto.MergeRowId).Select(x => x.Id).FirstOrDefault();
|
||||
|
||||
List<QuestionMark?> needRemoveMark = new List<QuestionMark?>()
|
||||
{
|
||||
QuestionMark.MajorAxis,
|
||||
QuestionMark.ShortAxis,
|
||||
};
|
||||
|
||||
var mainAnswer = await _readingTableQuestionAnswerRepository.Where(x => x.RowId == minaid).Include(x => x.ReadingTableQuestionTrial).ToListAsync();
|
||||
|
||||
foreach (var item in mainAnswer)
|
||||
{
|
||||
await _readingTableQuestionAnswerRepository.BatchUpdateNoTrackingAsync(x => x.RowId == mergeid && x.TableQuestionId == item.TableQuestionId, x => new ReadingTableQuestionAnswer()
|
||||
{
|
||||
Answer = needRemoveMark.Contains(item.ReadingTableQuestionTrial.QuestionMark) ? string.Empty : item.Answer,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
await _readingTableAnswerRowInfoRepository.UpdatePartialFromQueryAsync(mergeid, x => new ReadingTableAnswerRowInfo()
|
||||
{
|
||||
MergeRowId = minaid,
|
||||
SplitOrMergeType = SplitOrMergeType.Merge,
|
||||
});
|
||||
|
||||
|
||||
await _readingTableAnswerRowInfoRepository.UpdatePartialFromQueryAsync(mergeid, x => new ReadingTableAnswerRowInfo()
|
||||
{
|
||||
MergeRowId = minaid,
|
||||
SplitOrMergeType = SplitOrMergeType.Merge,
|
||||
});
|
||||
|
||||
await _readingTableAnswerRowInfoRepository.SaveChangesAsync();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -1395,10 +1318,78 @@ namespace IRaCIS.Application.Services
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 阅片期 -全局和肿瘤学任务的生成
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private async Task AddReadingTask(Guid visitTaskId)
|
||||
{
|
||||
// ****** 先生成阅片期 阅片期任务阅片完成之后生成肿瘤学的 如果没有阅片期 直接生成肿瘤学 *********////
|
||||
#region 建立关系
|
||||
// 访视阅完产生 全局
|
||||
Dictionary<ModuleTypeEnum, ReadingCategory> typeChangeDic = new Dictionary<ModuleTypeEnum, ReadingCategory>();
|
||||
typeChangeDic.Add(ModuleTypeEnum.InPlanSubjectVisit, ReadingCategory.Visit);
|
||||
typeChangeDic.Add(ModuleTypeEnum.OutPlanSubjectVisit, ReadingCategory.Visit);
|
||||
//typeChange.Add(ModuleTypeEnum.Read, ReadingCategory.ReadingPeriod);
|
||||
typeChangeDic.Add(ModuleTypeEnum.Global, ReadingCategory.Global);
|
||||
typeChangeDic.Add(ModuleTypeEnum.Referee, ReadingCategory.Judge);
|
||||
typeChangeDic.Add(ModuleTypeEnum.Oncology, ReadingCategory.Oncology);
|
||||
#endregion
|
||||
var taskInfo = await _visitTaskRepository.Where(x => x.Id == visitTaskId).FirstNotNullAsync();
|
||||
List<ReadingGenerataTaskDTO> needReadList = new List<ReadingGenerataTaskDTO>();
|
||||
if (!taskInfo.IsAnalysisCreate)
|
||||
{
|
||||
// 任务类型
|
||||
switch (taskInfo.ReadingCategory)
|
||||
{
|
||||
case ReadingCategory.Visit:
|
||||
needReadList = await _readModuleRepository.Where(x => x.SubjectVisitId == taskInfo.SourceSubjectVisitId &&
|
||||
|
||||
x.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId &&
|
||||
x.ReadingSetType == ReadingSetType.ImageReading)
|
||||
.Select(x => new ReadingGenerataTaskDTO
|
||||
{
|
||||
IsUrgent = x.IsUrgent ?? false,
|
||||
SubjectId = x.SubjectId,
|
||||
VisitNum = x.VisitNum,
|
||||
ReadingName = x.ModuleName,
|
||||
ReadModuleId = x.Id,
|
||||
ReadingCategory = typeChangeDic[x.ModuleType],
|
||||
}).ToListAsync();
|
||||
if (needReadList.Any(x => x.ReadingCategory == ReadingCategory.Global))
|
||||
{
|
||||
needReadList = needReadList.Where(x => x.ReadingCategory != ReadingCategory.Oncology).ToList();
|
||||
}
|
||||
//needReadList = needReadList.Where(x => _visitTaskRepository.Where(y => y.SouceReadModuleId == x.ReadModuleId).Count() == 0).ToList();
|
||||
await _visitTaskHelpeService.AddTaskAsync(new GenerateTaskCommand()
|
||||
{
|
||||
OriginalVisitId = visitTaskId,
|
||||
ReadingCategory = GenerateTaskCategory.Global,
|
||||
TrialId = taskInfo.TrialId,
|
||||
ReadingGenerataTaskList = needReadList
|
||||
});
|
||||
break;
|
||||
// 肿瘤学
|
||||
case ReadingCategory.Global:
|
||||
var subjectVisitId = await _readModuleRepository.Where(x => x.Id == taskInfo.SouceReadModuleId).Select(x => x.SubjectVisitId).FirstOrDefaultAsync();
|
||||
var oncologyReadId = await _readModuleRepository.Where(x => x.SubjectVisitId == subjectVisitId && x.ModuleType == ModuleTypeEnum.Oncology
|
||||
&& x.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId
|
||||
|
||||
|
||||
).Select(x => x.Id).FirstOrDefaultAsync();
|
||||
await AddOncologyTask(oncologyReadId);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using IRaCIS.Core.Application.Service.Reading.Dto;
|
||||
using IRaCIS.Core.Infra.EFCore.Common;
|
||||
using Panda.DynamicWebApi.Attributes;
|
||||
using IRaCIS.Core.Application.Contracts;
|
||||
using MassTransit;
|
||||
|
||||
namespace IRaCIS.Application.Services
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user