Test.EIImageViewer
parent
5663a3f74c
commit
93322582ed
|
@ -3717,6 +3717,13 @@
|
|||
<param name="inDto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.ReadingCalculateService.ReadingCalculate(IRaCIS.Core.Application.Service.Reading.Dto.ReadingCalculateDto)">
|
||||
<summary>
|
||||
自动计算
|
||||
</summary>
|
||||
<param name="inDto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.ReadingCalculateService.VerifyVisitTaskQuestions(IRaCIS.Core.Application.Service.Reading.Dto.VerifyVisitTaskQuestionsInDto)">
|
||||
<summary>
|
||||
验证访视提交
|
||||
|
@ -3731,13 +3738,6 @@
|
|||
<param name="visitTaskId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.ReadingCalculateService.ReadingCalculate(IRaCIS.Core.Application.Service.Reading.Dto.ReadingCalculateDto)">
|
||||
<summary>
|
||||
自动计算
|
||||
</summary>
|
||||
<param name="inDto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.ReadingCalculateService.GetSODData(IRaCIS.Core.Application.Service.Reading.Dto.ReadingCalculateDto)">
|
||||
<summary>
|
||||
获取SOD
|
||||
|
|
|
@ -179,6 +179,22 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
|
|||
|
||||
public decimal SOD { get; set; }
|
||||
}
|
||||
|
||||
public class ChangeAllTaskDto
|
||||
{
|
||||
public ReadingCalculateDto calculateDto { get; set; }
|
||||
|
||||
public Guid QuestionId { get; set; }
|
||||
}
|
||||
|
||||
public class ReadingCalculateData
|
||||
{
|
||||
public QuestionType QuestionType { get; set; }
|
||||
|
||||
public Func<ReadingCalculateDto, Task<dynamic>> GetSingleDataFun { get; set; }
|
||||
|
||||
public Func<ChangeAllTaskDto,Task> ChangeAllTaskFun { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
|
||||
#region 临时对象 单个请求的生命周期 避免重复查询数据库
|
||||
private List<VisitTaskAnswerInfo> visitTaskAnswerList;
|
||||
private decimal? sODData;
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
|
@ -70,6 +71,180 @@ namespace IRaCIS.Core.Application.Service
|
|||
await ReadingCalculate(readingData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自动计算
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task ReadingCalculate(ReadingCalculateDto inDto)
|
||||
{
|
||||
// 找到所有访视任务的Id
|
||||
|
||||
var visitTaskIds = await _visitTaskRepository.Where(x => !x.IsAnalysisCreate && x.ReadingCategory == ReadingCategory.Visit &&
|
||||
x.TaskState == TaskState.Effect && x.ReadingTaskState == ReadingTaskState.HaveSigned && x.DoctorUserId == inDto.DoctorUserId).Select(x => x.Id).ToListAsync();
|
||||
|
||||
|
||||
|
||||
|
||||
#region 计算 这里顺序非常重要 后面计算的值要依赖前面计算的结果
|
||||
var needAddList = new List<ReadingTaskQuestionAnswer>();
|
||||
// 循环找要计算的值进行计算
|
||||
foreach (var item in inDto.QuestionInfo.Where(x => x.QuestionType != null))
|
||||
{
|
||||
|
||||
switch (item.QuestionType)
|
||||
{
|
||||
// 靶病灶径线之和(SOD)
|
||||
case QuestionType.SOD:
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = (await GetSODData(inDto)).ToString(),
|
||||
ReadingQuestionTrialId = item.QuestionId,
|
||||
});
|
||||
break;
|
||||
|
||||
// 非淋巴结靶病灶长径之和
|
||||
case QuestionType.SumOfDiameter:
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = (await GetSumOfDiameter(inDto)).ToString(),
|
||||
ReadingQuestionTrialId = item.QuestionId,
|
||||
});
|
||||
break;
|
||||
// 与基线SOD相比变化量(mm)
|
||||
case QuestionType.SODChange:
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = (await GetSODChange(inDto)).ToString(),
|
||||
ReadingQuestionTrialId = item.QuestionId,
|
||||
});
|
||||
break;
|
||||
// 与基线访视相比SOD变化百分比
|
||||
case QuestionType.SODPercent:
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = (await GetSODPercent(inDto)).ToString(),
|
||||
ReadingQuestionTrialId = item.QuestionId,
|
||||
});
|
||||
break;
|
||||
// 与整个访视期间最低点相比增加的值(mm) 其他任务需要改
|
||||
case QuestionType.LowestIncrease:
|
||||
|
||||
if (!inDto.IsChangeOtherTask)
|
||||
{
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = (await GetLowestIncrease(inDto)).ToString(),
|
||||
ReadingQuestionTrialId = item.QuestionId,
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
await ChangeAllLowestIncrease(new ChangeAllTaskDto()
|
||||
{
|
||||
calculateDto = inDto,
|
||||
QuestionId = item.QuestionId,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
// 与整个访视期间最低点相比增加的百分比 其他任务需要改
|
||||
case QuestionType.LowPercent:
|
||||
|
||||
if (!inDto.IsChangeOtherTask)
|
||||
{
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = (await GetLowPercent(inDto)).ToString(),
|
||||
ReadingQuestionTrialId = item.QuestionId,
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
await ChangeAllLowPercent(inDto, item.QuestionId);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
// 整个访视期间最低点访视名称 其他任务需要改
|
||||
case QuestionType.LowVisit:
|
||||
var answer = (await GetLowVisit(inDto)).ToString();
|
||||
if (!inDto.IsChangeOtherTask)
|
||||
{
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = answer,
|
||||
ReadingQuestionTrialId = item.QuestionId,
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
if (inDto.IsChangeOtherTask)
|
||||
{
|
||||
await this.ChangeAllVisitTaskAnswer(visitTaskIds, item.QuestionId, answer);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
// 是否存在非淋巴结靶病灶
|
||||
case QuestionType.IsLymphTarget:
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = await GetIsLymphTarget(inDto),
|
||||
ReadingQuestionTrialId = item.QuestionId,
|
||||
});
|
||||
break;
|
||||
// 是否存在淋巴结靶病灶且该病灶比上一访视短径增加5MM以上
|
||||
case QuestionType.IsAddFive:
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = await GetIsAddFive(inDto),
|
||||
ReadingQuestionTrialId = item.QuestionId,
|
||||
});
|
||||
break;
|
||||
|
||||
// 被评估为NE的单个靶病灶
|
||||
case QuestionType.NETarget:
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = await GetNETarget(inDto),
|
||||
ReadingQuestionTrialId = item.QuestionId,
|
||||
});
|
||||
break;
|
||||
|
||||
// 整体肿瘤评估
|
||||
case QuestionType.Tumor:
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = await GetTumor(inDto),
|
||||
ReadingQuestionTrialId = item.QuestionId,
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var questionIds = needAddList.Select(x => x.ReadingQuestionTrialId).ToList();
|
||||
|
||||
await _readingTaskQuestionAnswerRepository.BatchDeleteNoTrackingAsync(x => questionIds.Contains(x.ReadingQuestionTrialId) && x.VisitTaskId == inDto.VisitTaskId);
|
||||
needAddList.ForEach(x =>
|
||||
{
|
||||
x.SubjectId = inDto.SubjectId;
|
||||
x.ReadingQuestionCriterionTrialId = inDto.CriterionId;
|
||||
x.VisitTaskId = inDto.VisitTaskId;
|
||||
x.TrialId = inDto.TrialId;
|
||||
x.SubjectId = inDto.SubjectId;
|
||||
});
|
||||
|
||||
await _readingTaskQuestionAnswerRepository.AddRangeAsync(needAddList);
|
||||
|
||||
await _readingTaskQuestionAnswerRepository.SaveChangesAsync();
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 验证访视提交
|
||||
/// </summary>
|
||||
|
@ -174,200 +349,7 @@ namespace IRaCIS.Core.Application.Service
|
|||
return readingData;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自动计算
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task ReadingCalculate(ReadingCalculateDto inDto)
|
||||
{
|
||||
// 找到所有访视任务的Id
|
||||
|
||||
var visitTaskIds = await _visitTaskRepository.Where(x => !x.IsAnalysisCreate && x.ReadingCategory == ReadingCategory.Visit &&
|
||||
x.TaskState == TaskState.Effect && x.ReadingTaskState == ReadingTaskState.HaveSigned&&x.DoctorUserId==inDto.DoctorUserId).Select(x => x.Id).ToListAsync();
|
||||
|
||||
|
||||
#region 先计算
|
||||
// 先计算然后保存结果 因为计算的结果在下面的计算可能会用到
|
||||
var needFirstCalculateTypes = new List<QuestionType?>()
|
||||
{
|
||||
QuestionType.SOD,
|
||||
};
|
||||
|
||||
var needFirstAddList = new List<ReadingTaskQuestionAnswer>();
|
||||
|
||||
foreach (var item in inDto.QuestionInfo.Where(x => needFirstCalculateTypes.Contains(x.QuestionType)))
|
||||
{
|
||||
switch (item.QuestionType)
|
||||
{
|
||||
// 靶病灶径线之和(SOD)
|
||||
case QuestionType.SOD:
|
||||
needFirstAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = (await GetSODData(inDto)).ToString(),
|
||||
ReadingQuestionTrialId = item.QuestionId,
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var needFirstAddIds = needFirstAddList.Select(x => x.ReadingQuestionTrialId).ToList();
|
||||
await _readingTaskQuestionAnswerRepository.BatchDeleteNoTrackingAsync(x => needFirstAddIds.Contains(x.ReadingQuestionTrialId) && x.VisitTaskId == inDto.VisitTaskId);
|
||||
needFirstAddList.ForEach(x =>
|
||||
{
|
||||
x.SubjectId = inDto.SubjectId;
|
||||
x.ReadingQuestionCriterionTrialId = inDto.CriterionId;
|
||||
x.VisitTaskId = inDto.VisitTaskId;
|
||||
x.TrialId = inDto.TrialId;
|
||||
x.SubjectId = inDto.SubjectId;
|
||||
});
|
||||
|
||||
await _readingTaskQuestionAnswerRepository.AddRangeAsync(needFirstAddList);
|
||||
|
||||
await _readingTaskQuestionAnswerRepository.SaveChangesAsync();
|
||||
#endregion
|
||||
|
||||
var needAddList = new List<ReadingTaskQuestionAnswer>();
|
||||
// 循环找要计算的值进行计算
|
||||
foreach (var item in inDto.QuestionInfo.Where(x => x.QuestionType != null).Where(x=> !needFirstCalculateTypes.Contains(x.QuestionType)))
|
||||
{
|
||||
switch (item.QuestionType)
|
||||
{
|
||||
|
||||
// 非淋巴结靶病灶长径之和
|
||||
case QuestionType.SumOfDiameter:
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = (await GetSumOfDiameter(inDto)).ToString(),
|
||||
ReadingQuestionTrialId = item.QuestionId,
|
||||
});
|
||||
break;
|
||||
// 与基线SOD相比变化量(mm)
|
||||
case QuestionType.SODChange:
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = (await GetSODChange(inDto)).ToString(),
|
||||
ReadingQuestionTrialId = item.QuestionId,
|
||||
});
|
||||
break;
|
||||
// 与基线访视相比SOD变化百分比
|
||||
case QuestionType.SODPercent:
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = (await GetSODPercent(inDto)).ToString(),
|
||||
ReadingQuestionTrialId = item.QuestionId,
|
||||
});
|
||||
break;
|
||||
// 与整个访视期间最低点相比增加的值(mm) 其他任务需要改
|
||||
case QuestionType.LowestIncrease:
|
||||
|
||||
if (!inDto.IsChangeOtherTask)
|
||||
{
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = (await GetLowestIncrease(inDto)).ToString(),
|
||||
ReadingQuestionTrialId = item.QuestionId,
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
await ChangeAllLowestIncrease(inDto, item.QuestionId);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
// 与整个访视期间最低点相比增加的百分比 其他任务需要改
|
||||
case QuestionType.LowPercent:
|
||||
|
||||
if (!inDto.IsChangeOtherTask)
|
||||
{
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = (await GetLowPercent(inDto)).ToString(),
|
||||
ReadingQuestionTrialId = item.QuestionId,
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
await ChangeAllLowPercent(inDto, item.QuestionId);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
// 整个访视期间最低点访视名称 其他任务需要改
|
||||
case QuestionType.LowVisit:
|
||||
var answer = (await GetLowVisit(inDto)).ToString();
|
||||
if (!inDto.IsChangeOtherTask)
|
||||
{
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = answer,
|
||||
ReadingQuestionTrialId = item.QuestionId,
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
if (inDto.IsChangeOtherTask)
|
||||
{
|
||||
await this.ChangeAllVisitTaskAnswer(visitTaskIds, item.QuestionId, answer);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
// 是否存在非淋巴结靶病灶
|
||||
case QuestionType.IsLymphTarget:
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = await GetIsLymphTarget(inDto),
|
||||
ReadingQuestionTrialId = item.QuestionId,
|
||||
});
|
||||
break;
|
||||
// 是否存在淋巴结靶病灶且该病灶比上一访视短径增加5MM以上
|
||||
case QuestionType.IsAddFive:
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = await GetIsAddFive(inDto),
|
||||
ReadingQuestionTrialId = item.QuestionId,
|
||||
});
|
||||
break;
|
||||
|
||||
// 被评估为NE的单个靶病灶
|
||||
case QuestionType.NETarget:
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = await GetNETarget(inDto),
|
||||
ReadingQuestionTrialId = item.QuestionId,
|
||||
});
|
||||
break;
|
||||
|
||||
// 整体肿瘤评估
|
||||
case QuestionType.Tumor:
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = await GetTumor(inDto),
|
||||
ReadingQuestionTrialId = item.QuestionId,
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var questionIds = needAddList.Select(x => x.ReadingQuestionTrialId).ToList();
|
||||
|
||||
await _readingTaskQuestionAnswerRepository.BatchDeleteNoTrackingAsync(x => questionIds.Contains(x.ReadingQuestionTrialId) && x.VisitTaskId == inDto.VisitTaskId);
|
||||
needAddList.ForEach(x =>
|
||||
{
|
||||
x.SubjectId = inDto.SubjectId;
|
||||
x.ReadingQuestionCriterionTrialId = inDto.CriterionId;
|
||||
x.VisitTaskId = inDto.VisitTaskId;
|
||||
x.TrialId = inDto.TrialId;
|
||||
x.SubjectId = inDto.SubjectId;
|
||||
});
|
||||
|
||||
await _readingTaskQuestionAnswerRepository.AddRangeAsync(needAddList);
|
||||
|
||||
await _readingTaskQuestionAnswerRepository.SaveChangesAsync();
|
||||
}
|
||||
|
||||
|
||||
|
||||
#region 获取SOD
|
||||
|
@ -382,6 +364,11 @@ namespace IRaCIS.Core.Application.Service
|
|||
/// <returns></returns>
|
||||
public async Task<decimal> GetSODData(ReadingCalculateDto inDto)
|
||||
{
|
||||
if (sODData != null)
|
||||
{
|
||||
return sODData.Value;
|
||||
}
|
||||
|
||||
var tableQuestion = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.TargetLesion).SelectMany(x => x.TableRowInfoList).ToList();
|
||||
|
||||
decimal result = 0;
|
||||
|
@ -401,8 +388,10 @@ namespace IRaCIS.Core.Application.Service
|
|||
}
|
||||
}
|
||||
|
||||
sODData = result;
|
||||
|
||||
return result;
|
||||
return sODData.Value;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -631,13 +620,13 @@ namespace IRaCIS.Core.Application.Service
|
|||
/// <param name="inDto"></param>
|
||||
/// <param name="questionId"></param>
|
||||
/// <returns></returns>
|
||||
public async Task ChangeAllLowestIncrease(ReadingCalculateDto inDto,Guid questionId)
|
||||
public async Task ChangeAllLowestIncrease(ChangeAllTaskDto inDto)
|
||||
{
|
||||
var visitTaskList = await GetVisitTaskAnswerList(inDto);
|
||||
var visitTaskList = await GetVisitTaskAnswerList(inDto.calculateDto);
|
||||
var lowSod = visitTaskList.Select(x => x.SOD).OrderBy(x => x).FirstOrDefault();
|
||||
foreach (var item in visitTaskList)
|
||||
{
|
||||
await _readingTaskQuestionAnswerRepository.BatchUpdateNoTrackingAsync(x => x.VisitTaskId == item.VisitTaskId && x.ReadingQuestionTrialId == questionId, x => new ReadingTaskQuestionAnswer()
|
||||
await _readingTaskQuestionAnswerRepository.BatchUpdateNoTrackingAsync(x => x.VisitTaskId == item.VisitTaskId && x.ReadingQuestionTrialId == inDto.QuestionId, x => new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = (item.SOD - lowSod).ToString()
|
||||
}) ;
|
||||
|
|
|
@ -277,6 +277,9 @@ namespace IRaCIS.Core.Domain.Share
|
|||
State = 7,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 问题类型 这里序号关系着计算顺序 请勿修改
|
||||
/// </summary>
|
||||
public enum QuestionType
|
||||
{
|
||||
/// <summary>
|
||||
|
|
Loading…
Reference in New Issue