Uat_Study
he 2023-03-31 10:24:27 +08:00
parent 2838a21a2f
commit 57257a66ba
7 changed files with 246 additions and 189 deletions

View File

@ -1108,6 +1108,14 @@
<param name="visitTaskId"></param>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Service.ReadingCalculate.GeneralCalculateService.AddConvertedTaskFocus(System.Guid,System.Guid)">
<summary>
添加转化任务病灶信息
</summary>
<param name="visitTaskId"></param>
<param name="beforeConvertedTaskId"></param>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Service.ReadingCalculate.GeneralCalculateService.GetReadingReportTaskList(System.Guid)">
<summary>
获取阅片报告任务List
@ -2157,6 +2165,14 @@
<param name="visitTaskId"></param>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Service.IGeneralCalculateService.AddConvertedTaskFocus(System.Guid,System.Guid)">
<summary>
添加转化任务病灶信息
</summary>
<param name="visitTaskId"></param>
<param name="beforeConvertedTaskId"></param>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Service.IReadingCalculateService.CalculateTask(IRaCIS.Core.Application.Service.Reading.Dto.CalculateTaskInDto)">
<summary>
自动计算 并修改值

View File

@ -115,7 +115,7 @@ namespace IRaCIS.Core.Application.Service
public async Task AddConvertedTask(Guid taskId)
{
var originalTask = await _visitTaskRepository.Where(x => x.Id == taskId).Include(x => x.TrialReadingCriterion).FirstNotNullAsync();
var taskInfo = await _visitTaskRepository.Where(x => x.Id == taskId).IgnoreAutoIncludes().AsNoTracking().FirstNotNullAsync();
taskInfo.ReadingTaskState = ReadingTaskState.Reading;
@ -144,126 +144,7 @@ namespace IRaCIS.Core.Application.Service
});
var taskAnswer = await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == taskId && x.ReadingQuestionTrial.Type != "calculation").IgnoreAutoIncludes().AsNoTracking().ToListAsync();
taskAnswer.ForEach(x => {
x.VisitTaskId = taskInfo.Id;
x.Id = NewId.NextGuid();
});
var tableRowAnswers = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == taskId).AsNoTracking().ProjectTo<CopyTableAnswerRowInfo>(_mapper.ConfigurationProvider).IgnoreAutoIncludes().ToListAsync();
tableRowAnswers.ForEach(x =>
{
x.VisitTaskId = taskInfo.Id;
x.IsCurrentTaskAdd = false;
x.FristAddTaskId = taskInfo.Id;
x.Id = NewId.NextGuid();
});
tableRowAnswers.ForEach(x =>
{
x.SplitRowId = tableRowAnswers.Where(y => y.OriginalId == x.SplitRowId).Select(y => y.Id).FirstOrDefault();
x.MergeRowId = tableRowAnswers.Where(y => y.OriginalId == x.MergeRowId).Select(y => y.Id).FirstOrDefault();
});
var tableAnswer = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == taskId).IgnoreAutoIncludes().AsNoTracking().ToListAsync();
tableAnswer.ForEach(x =>
{
x.Id = NewId.NextGuid();
x.VisitTaskId = taskInfo.Id;
x.RowId = tableRowAnswers.Where(y => y.OriginalId == x.RowId).Select(x => x.Id).FirstOrDefault();
});
var addrowInfo = _mapper.Map<List<ReadingTableAnswerRowInfo>>(tableRowAnswers);
switch (originalTask.TrialReadingCriterion.CriterionType)
{
case CriterionType.IRECIST1Point1:
//非靶病灶全部数据复制,不可更改。支持如果状态为:显著增大需要自动改为: 显著增大(iUPD)
var stateQuestionId = await _readingTableQuestionTrialRepository.Where(x => x.TrialCriterionId == originalTask.TrialReadingCriterionId
&& x.ReadingQuestionTrial.LesionType == LesionType.NonTargetLesions && x.QuestionMark == QuestionMark.State).Select(x => x.Id).FirstOrDefaultAsync();
tableAnswer.ForEach(x =>
{
if (x.TableQuestionId == stateQuestionId && x.Answer.EqEnum(NoTargetState.Increase))
{
x.Answer = NoTargetState.IUPD.GetEnumInt();
}
});
// 新转换为其它既往新病灶: 状态为消失、疑似、无法评估的新病灶自动转换为:其它既往新病灶,且不可以编辑
// 找到新病灶问题
var newLesionQuestion = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == originalTask.TrialReadingCriterionId && x.LesionType == LesionType.NewLesions).FirstOrDefaultAsync();
// 找到其他既往新病灶
var otherLesionQuestion = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == originalTask.TrialReadingCriterionId && x.LesionType == LesionType.OtherPreviousNewLesion).FirstOrDefaultAsync();
if (newLesionQuestion != null && otherLesionQuestion != null)
{
// 找到表格问题
var newLesionTableQuestionList = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionId == newLesionQuestion.Id).ToListAsync();
// 找到表格问题
var otherLesionTableQuestionList = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionId == otherLesionQuestion.Id).ToListAsync();
// 找到病灶状态
var newstateQuestionId = newLesionTableQuestionList.Where(x => x.QuestionMark == QuestionMark.State).Select(x => x.Id).FirstOrDefault();
var stateAnswers = new List<string>() {
NewLesionState.Loss.GetEnumInt(),
NewLesionState.Suspected.GetEnumInt(),
NewLesionState.UnableEvaluate.GetEnumInt()
};
var needRowIds = tableAnswer.Where(x => x.TableQuestionId == newstateQuestionId && stateAnswers.Contains(x.Answer)).Select(x => x.RowId).Distinct().ToList();
addrowInfo.ForEach(x =>
{
if (needRowIds.Contains(x.Id))
{
x.QuestionId = otherLesionQuestion.Id;
x.OrderMark = otherLesionQuestion.OrderMark;
x.RowMark = otherLesionQuestion.OrderMark + x.RowIndex.GetLesionMark();
}
});
tableAnswer.ForEach(x =>
{
if (needRowIds.Contains(x.RowId))
{
x.QuestionId = otherLesionQuestion.Id;
var newLesionTableQuestion = newLesionTableQuestionList.Where(y => y.Id == x.TableQuestionId).FirstOrDefault();
if (newLesionTableQuestion != null)
{
x.TableQuestionId = otherLesionTableQuestionList.Where(y => y.QuestionMark == newLesionTableQuestion.QuestionMark).Select(x => x.Id).FirstOrDefault();
}
}
});
}
break;
}
await _readingTaskQuestionAnswerRepository.AddRangeAsync(taskAnswer);
await _readingTableAnswerRowInfoRepository.AddRangeAsync(addrowInfo);
await _readingTableQuestionAnswerRepository.AddRangeAsync(tableAnswer);
await _visitTaskRepository.SaveChangesAsync();
}

View File

@ -1,6 +1,7 @@
using IRaCIS.Core.Application.Service.Reading.Dto;
using IRaCIS.Core.Domain.Share;
using IRaCIS.Core.Infra.EFCore.Common;
using MassTransit;
using System;
using System.Collections.Generic;
using System.Linq;
@ -141,6 +142,140 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
return readingData;
}
/// <summary>
/// 添加转化任务病灶信息
/// </summary>
/// <param name="visitTaskId"></param>
/// <param name="beforeConvertedTaskId"></param>
/// <returns></returns>
public async Task AddConvertedTaskFocus(Guid visitTaskId, Guid beforeConvertedTaskId)
{
var originalTask = await _visitTaskRepository.Where(x => x.Id == beforeConvertedTaskId).Include(x => x.TrialReadingCriterion).FirstNotNullAsync();
var taskAnswer = await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == visitTaskId && x.ReadingQuestionTrial.Type != "calculation").IgnoreAutoIncludes().AsNoTracking().ToListAsync();
taskAnswer.ForEach(x => {
x.VisitTaskId = beforeConvertedTaskId;
x.Id = NewId.NextGuid();
});
var tableRowAnswers = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == visitTaskId).AsNoTracking().ProjectTo<CopyTableAnswerRowInfo>(_mapper.ConfigurationProvider).IgnoreAutoIncludes().ToListAsync();
tableRowAnswers.ForEach(x =>
{
x.VisitTaskId = beforeConvertedTaskId;
x.IsCurrentTaskAdd = false;
x.FristAddTaskId = beforeConvertedTaskId;
x.Id = NewId.NextGuid();
});
tableRowAnswers.ForEach(x =>
{
x.SplitRowId = tableRowAnswers.Where(y => y.OriginalId == x.SplitRowId).Select(y => y.Id).FirstOrDefault();
x.MergeRowId = tableRowAnswers.Where(y => y.OriginalId == x.MergeRowId).Select(y => y.Id).FirstOrDefault();
});
var tableAnswer = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == visitTaskId).IgnoreAutoIncludes().AsNoTracking().ToListAsync();
tableAnswer.ForEach(x =>
{
x.Id = NewId.NextGuid();
x.VisitTaskId = beforeConvertedTaskId;
x.RowId = tableRowAnswers.Where(y => y.OriginalId == x.RowId).Select(x => x.Id).FirstOrDefault();
});
var addrowInfo = _mapper.Map<List<ReadingTableAnswerRowInfo>>(tableRowAnswers);
switch (originalTask.TrialReadingCriterion.CriterionType)
{
case CriterionType.IRECIST1Point1:
//非靶病灶全部数据复制,不可更改。支持如果状态为:显著增大需要自动改为: 显著增大(iUPD)
var stateQuestionId = await _readingTableQuestionTrialRepository.Where(x => x.TrialCriterionId == originalTask.TrialReadingCriterionId
&& x.ReadingQuestionTrial.LesionType == LesionType.NonTargetLesions && x.QuestionMark == QuestionMark.State).Select(x => x.Id).FirstOrDefaultAsync();
tableAnswer.ForEach(x =>
{
if (x.TableQuestionId == stateQuestionId && x.Answer.EqEnum(NoTargetState.Increase))
{
x.Answer = NoTargetState.IUPD.GetEnumInt();
}
});
// 新转换为其它既往新病灶: 状态为消失、疑似、无法评估的新病灶自动转换为:其它既往新病灶,且不可以编辑
// 找到新病灶问题
var newLesionQuestion = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == originalTask.TrialReadingCriterionId && x.LesionType == LesionType.NewLesions).FirstOrDefaultAsync();
// 找到其他既往新病灶
var otherLesionQuestion = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == originalTask.TrialReadingCriterionId && x.LesionType == LesionType.OtherPreviousNewLesion).FirstOrDefaultAsync();
if (newLesionQuestion != null && otherLesionQuestion != null)
{
// 找到表格问题
var newLesionTableQuestionList = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionId == newLesionQuestion.Id).ToListAsync();
// 找到表格问题
var otherLesionTableQuestionList = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionId == otherLesionQuestion.Id).ToListAsync();
// 找到病灶状态
var newstateQuestionId = newLesionTableQuestionList.Where(x => x.QuestionMark == QuestionMark.State).Select(x => x.Id).FirstOrDefault();
var stateAnswers = new List<string>() {
NewLesionState.Loss.GetEnumInt(),
NewLesionState.Suspected.GetEnumInt(),
NewLesionState.UnableEvaluate.GetEnumInt()
};
var needRowIds = tableAnswer.Where(x => x.TableQuestionId == newstateQuestionId && stateAnswers.Contains(x.Answer)).Select(x => x.RowId).Distinct().ToList();
addrowInfo.ForEach(x =>
{
if (needRowIds.Contains(x.Id))
{
x.QuestionId = otherLesionQuestion.Id;
x.OrderMark = otherLesionQuestion.OrderMark;
x.RowMark = otherLesionQuestion.OrderMark + x.RowIndex.GetLesionMark();
}
});
tableAnswer.ForEach(x =>
{
if (needRowIds.Contains(x.RowId))
{
x.QuestionId = otherLesionQuestion.Id;
var newLesionTableQuestion = newLesionTableQuestionList.Where(y => y.Id == x.TableQuestionId).FirstOrDefault();
if (newLesionTableQuestion != null)
{
x.TableQuestionId = otherLesionTableQuestionList.Where(y => y.QuestionMark == newLesionTableQuestion.QuestionMark).Select(x => x.Id).FirstOrDefault();
}
}
});
}
break;
}
await _readingTaskQuestionAnswerRepository.AddRangeAsync(taskAnswer);
await _readingTableAnswerRowInfoRepository.AddRangeAsync(addrowInfo);
await _readingTableQuestionAnswerRepository.AddRangeAsync(tableAnswer);
await _readingTableQuestionAnswerRepository.SaveChangesAsync();
}
/// <summary>
/// 获取阅片报告任务List
/// </summary>

View File

@ -730,89 +730,98 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
// 判断当前任务是否是基线
if (taskinfo.SourceSubjectVisitId != baseLineVisitId)
{
// 判断当前任务是是否有表格问题答案
if (!(await _readingTableQuestionAnswerRepository.AnyAsync(x => x.VisitTaskId == visitTaskId)))
{
var LastVisitTaskId = await _visitTaskRepository.Where(x =>( x.ReadingCategory == ReadingCategory.Visit &&
x.TrialReadingCriterionId == taskinfo.TrialReadingCriterionId &&
x.IsAnalysisCreate== taskinfo.IsAnalysisCreate&&
x.DoctorUserId == taskinfo.DoctorUserId &&
x.IsSelfAnalysis== taskinfo.IsSelfAnalysis &&
x.SubjectId == taskinfo.SubjectId && x.ReadingTaskState == ReadingTaskState.HaveSigned && x.ArmEnum == taskinfo.ArmEnum
&& x.VisitTaskNum < taskinfo.VisitTaskNum && x.TaskState == TaskState.Effect)||(x.Id==taskinfo.BeforeConvertedTaskId)
).OrderByDescending(x => x.VisitTaskNum).Select(x => x.Id).FirstOrDefaultAsync();
var copyTableAnswers = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == LastVisitTaskId).Select(x => new CopyTableAnswerDto()
if (taskinfo.BeforeConvertedTaskId != null)
{
Answer = x.Answer,
QuestionId = x.QuestionId,
RowId = x.RowId,
QuestionMark = x.ReadingTableQuestionTrial.QuestionMark,
TableQuestionId = x.TableQuestionId,
RowIndex = x.RowIndex,
TrialId = x.TrialId
}).ToListAsync();
await _generalCalculateService.AddConvertedTaskFocus(taskinfo.Id, taskinfo.BeforeConvertedTaskId.Value);
}
else
var tableRowAnswers = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == LastVisitTaskId).ProjectTo<CopyTableAnswerRowInfo>(_mapper.ConfigurationProvider).ToListAsync();
tableRowAnswers.ForEach(x =>
{
x.VisitTaskId = visitTaskId;
x.IsCurrentTaskAdd = false;
x.Id = NewId.NextGuid();
x.SeriesId = null;
x.InstanceId = null;
x.MeasureData = string.Empty;
x.PicturePath= string.Empty;
});
var LastVisitTaskId = await _visitTaskRepository.Where(x => (x.ReadingCategory == ReadingCategory.Visit &&
x.TrialReadingCriterionId == taskinfo.TrialReadingCriterionId &&
x.IsAnalysisCreate == taskinfo.IsAnalysisCreate &&
x.DoctorUserId == taskinfo.DoctorUserId &&
x.IsSelfAnalysis == taskinfo.IsSelfAnalysis &&
x.SubjectId == taskinfo.SubjectId && x.ReadingTaskState == ReadingTaskState.HaveSigned && x.ArmEnum == taskinfo.ArmEnum
&& x.VisitTaskNum < taskinfo.VisitTaskNum && x.TaskState == TaskState.Effect) || (x.Id == taskinfo.BeforeConvertedTaskId)
).OrderByDescending(x => x.VisitTaskNum).Select(x => x.Id).FirstOrDefaultAsync();
tableRowAnswers.ForEach(x =>
{
x.SplitRowId = tableRowAnswers.Where(y => y.OriginalId == x.SplitRowId).Select(y => y.Id).FirstOrDefault();
x.MergeRowId = tableRowAnswers.Where(y => y.OriginalId == x.MergeRowId).Select(y => y.Id).FirstOrDefault();
});
List<QuestionMark?> notNeedCopyMarks = new List<QuestionMark?>()
var copyTableAnswers = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == LastVisitTaskId).Select(x => new CopyTableAnswerDto()
{
Answer = x.Answer,
QuestionId = x.QuestionId,
RowId = x.RowId,
QuestionMark = x.ReadingTableQuestionTrial.QuestionMark,
TableQuestionId = x.TableQuestionId,
RowIndex = x.RowIndex,
TrialId = x.TrialId
}).ToListAsync();
var tableRowAnswers = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == LastVisitTaskId).ProjectTo<CopyTableAnswerRowInfo>(_mapper.ConfigurationProvider).ToListAsync();
tableRowAnswers.ForEach(x =>
{
x.VisitTaskId = visitTaskId;
x.IsCurrentTaskAdd = false;
x.Id = NewId.NextGuid();
x.SeriesId = null;
x.InstanceId = null;
x.MeasureData = string.Empty;
x.PicturePath = string.Empty;
});
tableRowAnswers.ForEach(x =>
{
x.SplitRowId = tableRowAnswers.Where(y => y.OriginalId == x.SplitRowId).Select(y => y.Id).FirstOrDefault();
x.MergeRowId = tableRowAnswers.Where(y => y.OriginalId == x.MergeRowId).Select(y => y.Id).FirstOrDefault();
});
List<QuestionMark?> notNeedCopyMarks = new List<QuestionMark?>()
{
QuestionMark.MajorAxis,
QuestionMark.ShortAxis,
QuestionMark.State,
};
if (taskinfo.IsConvertedTask)
{
notNeedCopyMarks = new List<QuestionMark?>()
if (taskinfo.IsConvertedTask)
{
notNeedCopyMarks = new List<QuestionMark?>()
{
QuestionMark.MajorAxis,
QuestionMark.ShortAxis,
};
}
var tableAnswers = copyTableAnswers.Select(x => new ReadingTableQuestionAnswer
{
Id = NewId.NextGuid(),
Answer = notNeedCopyMarks.Contains(x.QuestionMark) ? string.Empty : x.Answer,
QuestionId = x.QuestionId,
RowIndex = x.RowIndex,
RowId = tableRowAnswers.Where(y => y.OriginalId == x.RowId).Select(x => x.Id).FirstOrDefault(),
TableQuestionId = x.TableQuestionId,
TrialId = x.TrialId,
VisitTaskId = visitTaskId,
});
var addList = _mapper.Map<List<ReadingTableAnswerRowInfo>>(tableRowAnswers);
await _readingTableAnswerRowInfoRepository.AddRangeAsync(addList);
await _readingTableQuestionAnswerRepository.AddRangeAsync(tableAnswers);
await _readingTableQuestionAnswerRepository.SaveChangesAsync();
}
var tableAnswers = copyTableAnswers.Select(x => new ReadingTableQuestionAnswer
{
Id = NewId.NextGuid(),
Answer = notNeedCopyMarks.Contains(x.QuestionMark) ? string.Empty : x.Answer,
QuestionId = x.QuestionId,
RowIndex = x.RowIndex,
RowId = tableRowAnswers.Where(y => y.OriginalId == x.RowId).Select(x => x.Id).FirstOrDefault(),
TableQuestionId = x.TableQuestionId,
TrialId = x.TrialId,
VisitTaskId = visitTaskId,
});
var addList= _mapper.Map<List<ReadingTableAnswerRowInfo>>(tableRowAnswers);
await _readingTableAnswerRowInfoRepository.AddRangeAsync(addList);
await _readingTableQuestionAnswerRepository.AddRangeAsync(tableAnswers);
await _readingTableQuestionAnswerRepository.SaveChangesAsync();
}
}

View File

@ -23,5 +23,13 @@ namespace IRaCIS.Core.Application.Service
/// <param name="visitTaskId"></param>
/// <returns></returns>
Task<List<VisitTaskInfo>> GetReadingReportTaskList(Guid visitTaskId);
/// <summary>
/// 添加转化任务病灶信息
/// </summary>
/// <param name="visitTaskId"></param>
/// <param name="beforeConvertedTaskId"></param>
/// <returns></returns>
Task AddConvertedTaskFocus(Guid visitTaskId, Guid beforeConvertedTaskId);
}
}

View File

@ -1001,4 +1001,12 @@ update ReadingQuestionSystem set GroupId= (select top 1 id from ReadingQuestio
-----------------
update ShortcutKey set Text='Page Up' where Text='PageUp'
update ShortcutKey set Text='Page Down' where Text='PageDown'
update ShortcutKey set Text='Page Down' where Text='PageDown'
---------------------Groupid
update ReadingQuestionTrial set GroupId= (select top 1 id from ReadingQuestionTrial a where a.Type='group' and a.GroupName=ReadingQuestionTrial.GroupName and a.ReadingQuestionCriterionTrialId=ReadingQuestionTrial.ReadingQuestionCriterionTrialId) where ReadingQuestionTrial.Type!='group' and GroupId is null
update ReadingQuestionSystem set GroupId= (select top 1 id from ReadingQuestionSystem a where a.Type='group' and a.GroupName=ReadingQuestionSystem.GroupName and a.ReadingQuestionCriterionSystemId=ReadingQuestionSystem.ReadingQuestionCriterionSystemId) where ReadingQuestionSystem.Type!='group' and GroupId is null

View File

@ -152,10 +152,10 @@ namespace IRaCIS.Core.Infrastructure.Extention
return new ResponseOutput<T>().NotOk(msg, data, code);
}
public static IResponseOutput<T> NotOk<T>( T data = default, ApiResponseCodeEnum code = ApiResponseCodeEnum.BusinessValidationFailed)
{
return new ResponseOutput<T>().NotOk("", data, code);
}
//public static IResponseOutput<T> NotOk<T>( T data = default, ApiResponseCodeEnum code = ApiResponseCodeEnum.BusinessValidationFailed)
//{
// return new ResponseOutput<T>().NotOk("", data, code);
//}
/// <summary>
/// 失败