Merge branch 'master' of http://192.168.1.2:8033/IRaCIS_Core_Api
commit
bcad91dc18
|
@ -1220,6 +1220,11 @@
|
|||
首次转变的任务ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:IRaCIS.Core.Application.Service.ReadingCalculate.IRECIST1Point1CalculateService.compareTaskList">
|
||||
<summary>
|
||||
触发任务list
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.ReadingCalculate.IRECIST1Point1CalculateService.GetDeleteLesionStatrIndex(IRaCIS.Core.Application.Service.Reading.Dto.DeleteReadingRowAnswerInDto)">
|
||||
<summary>
|
||||
删除病灶获取起始病灶序号(RECIST1Point1 固定是1)
|
||||
|
@ -1233,7 +1238,7 @@
|
|||
<param name="indto"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.ReadingCalculate.IRECIST1Point1CalculateService.TestCalculate(System.Guid,IRaCIS.Core.Domain.Share.QuestionType)">
|
||||
<member name="M:IRaCIS.Core.Application.Service.ReadingCalculate.IRECIST1Point1CalculateService.TestCalculate(System.Guid,System.Nullable{IRaCIS.Core.Domain.Share.QuestionType})">
|
||||
<summary>
|
||||
测试计算
|
||||
</summary>
|
||||
|
@ -1458,9 +1463,9 @@
|
|||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:IRaCIS.Core.Application.Service.ReadingCalculate.IRECIST1Point1CalculateService.GetFirstChangeTaskId(IRaCIS.Core.Application.Service.Reading.Dto.ReadingCalculateDto)">
|
||||
<member name="M:IRaCIS.Core.Application.Service.ReadingCalculate.IRECIST1Point1CalculateService.GetCompareTaskId(IRaCIS.Core.Application.Service.Reading.Dto.ReadingCalculateDto,IRaCIS.Core.Domain.Share.QuestionType)">
|
||||
<summary>
|
||||
获取第一次转变访视任务Id
|
||||
获取比较任务Id 需要之前一次访视为IUPD或者ICPD
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
|
@ -7444,6 +7449,16 @@
|
|||
<member name="T:IRaCIS.Core.Application.ViewModel.SystemNoticeAddOrEdit">
|
||||
<summary> SystemNoticeAddOrEdit 列表查询参数模型</summary>
|
||||
</member>
|
||||
<member name="P:IRaCIS.Core.Application.ViewModel.TirggerTaskInfo.TargetAssessmentIsIUorIC">
|
||||
<summary>
|
||||
靶病灶是否为IUPD或者ICPD
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:IRaCIS.Core.Application.ViewModel.TirggerTaskInfo.NewTargetLesionAssessmentIsIUorIC">
|
||||
<summary>
|
||||
靶病灶是否为IUPD或者ICPD
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:IRaCIS.Core.Application.ViewModel.VisitStudyTime.SubjectVisitId">
|
||||
<summary>
|
||||
访视Id
|
||||
|
|
|
@ -479,6 +479,9 @@ namespace IRaCIS.Application.Services
|
|||
// 在修改前 去除这个问题
|
||||
x.BeforeQuestionList = x.BeforeQuestionList.Where(x => x.QuestionType != QuestionType.SiteVisitForTumorEvaluation).ToList();
|
||||
|
||||
|
||||
x.AfterQuestionList = x.AfterQuestionList.Where(x => x.QuestionType == QuestionType.SiteVisitForTumorEvaluation|| x.GlobalAnswerType != GlobalAnswerType.Question).ToList();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
@ -11,6 +12,39 @@ namespace IRaCIS.Core.Application.ViewModel
|
|||
public Guid VisitTaskId { get; set; }
|
||||
}
|
||||
|
||||
public class ReadingTaskQuestionAnswerDto : ReadingTaskQuestionAnswer
|
||||
{
|
||||
public QuestionType QuestionType { get; set; }
|
||||
}
|
||||
public class TirggerTaskInfo
|
||||
{
|
||||
public Guid VisitTaskId { get; set; }
|
||||
|
||||
public decimal VisitNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 靶病灶是否为IUPD或者ICPD
|
||||
/// </summary>
|
||||
public bool TargetAssessmentIsIUorIC { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 靶病灶是否为IUPD或者ICPD
|
||||
/// </summary>
|
||||
public bool NewTargetLesionAssessmentIsIUorIC { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class TirggerAnswerInfo
|
||||
{
|
||||
public Guid VisitTaskId { get; set; }
|
||||
|
||||
public QuestionType QuestionType { get; set; }
|
||||
|
||||
public string Answer { get; set; } = string.Empty;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class VisitStudyTime
|
||||
{
|
||||
/// <summary>
|
||||
|
|
|
@ -88,6 +88,11 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
|||
/// 首次转变的任务ID
|
||||
/// </summary>
|
||||
public Guid? firstChangeTaskId;
|
||||
|
||||
/// <summary>
|
||||
/// 触发任务list
|
||||
/// </summary>
|
||||
public List<TirggerTaskInfo>? compareTaskList = null;
|
||||
#endregion
|
||||
|
||||
#region 删除病灶获取起始病灶序号
|
||||
|
@ -394,14 +399,22 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
|||
/// <param name="visitTaskId"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task TestCalculate(Guid visitTaskId, QuestionType type)
|
||||
[HttpGet]
|
||||
public async Task TestCalculate(Guid visitTaskId, QuestionType? type)
|
||||
{
|
||||
//_logger.LogError("测试计算");
|
||||
ReadingCalculateDto readingData = await _generalCalculateService.GetReadingCalculateDto(visitTaskId);
|
||||
// await _generalCalculateService.LogRecord(readingData, "其他既往新病灶", LesionType.OtherPreviousNewLesion);
|
||||
if (type == null)
|
||||
{
|
||||
await ReadingCalculate(readingData);
|
||||
}
|
||||
else
|
||||
|
||||
{
|
||||
await ReadingCalculate(readingData, new List<QuestionType>() { type.Value });
|
||||
}
|
||||
|
||||
await ReadingCalculate(readingData,new List<QuestionType>() { type});
|
||||
}
|
||||
|
||||
|
||||
|
@ -462,7 +475,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
|||
{
|
||||
|
||||
#region 计算 这里顺序非常重要 后面计算的值要依赖前面计算的结果
|
||||
var needAddList = new List<ReadingTaskQuestionAnswer>();
|
||||
var needAddList = new List<ReadingTaskQuestionAnswerDto>();
|
||||
|
||||
|
||||
List<ReadingCalculateData> calculateList = new List<ReadingCalculateData>()
|
||||
|
@ -498,13 +511,13 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
|||
new ReadingCalculateData (){QuestionType=QuestionType.NETarget,GetStringFun=GetNETarget},
|
||||
|
||||
// 与触发iRECIST访视相比SOD变化量
|
||||
new ReadingCalculateData (){QuestionType=QuestionType.ComparedTriggeringSODChange,GetDecimalNullFun=GetComparedTriggeringSODChange,IsConvertedTask=true},
|
||||
new ReadingCalculateData (){QuestionType=QuestionType.ComparedTriggeringSODChange,GetStringFun=GetComparedTriggeringSODChange,IsConvertedTask=true},
|
||||
|
||||
// 新靶病灶直径之和(iSOD)
|
||||
new ReadingCalculateData (){QuestionType=QuestionType.ISOD,GetDecimalNullFun=GetiSODData,IsConvertedTask=true},
|
||||
|
||||
// 与触发iRECIST访视相比iSOD变化量
|
||||
new ReadingCalculateData (){QuestionType=QuestionType.ComparedTriggeringiSODChange,GetDecimalNullFun=GetComparedTriggeringiSODChange,IsConvertedTask=true},
|
||||
new ReadingCalculateData (){QuestionType=QuestionType.ComparedTriggeringiSODChange,GetStringFun=GetComparedTriggeringiSODChange,IsConvertedTask=true},
|
||||
|
||||
// 靶病灶评估
|
||||
new ReadingCalculateData (){QuestionType=QuestionType.TargetLesion,GetStringFun=GetTargetLesionEvaluate,IsConvertedTask=false},
|
||||
|
@ -710,9 +723,10 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
|||
|
||||
|
||||
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
needAddList.Add(new ReadingTaskQuestionAnswerDto()
|
||||
{
|
||||
Answer = item.Answer,
|
||||
QuestionType= calculate.QuestionType,
|
||||
ReadingQuestionTrialId = item.QuestionId,
|
||||
});
|
||||
}
|
||||
|
@ -732,11 +746,33 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
var questionIds = needAddList.Select(x => x.ReadingQuestionTrialId).ToList();
|
||||
|
||||
await _readingTaskQuestionAnswerRepository.BatchDeleteNoTrackingAsync(x => questionIds.Contains(x.ReadingQuestionTrialId) && x.VisitTaskId == inDto.VisitTaskId);
|
||||
|
||||
// 这里在某些条件下 要删除 sod变化量 和isod变化量
|
||||
// 靶病灶评估为IUPD或者ICPD
|
||||
|
||||
var targetLesionIsIUorIC = needAddList.Any(x => x.QuestionType == QuestionType.TargetLesion && (x.Answer.EqEnum(TargetAssessment.iUPD) || x.Answer.EqEnum(TargetAssessment.iCPD)));
|
||||
|
||||
// 新靶病灶为IUPD或者ICPD
|
||||
var newTargetLesionIsIUorIC = needAddList.Any(x => x.QuestionType == QuestionType.NewTargetLesion && (x.Answer.EqEnum(NewTargetLesionAssessment.iUPD) || x.Answer.EqEnum(NewTargetLesionAssessment.iCPD)));
|
||||
|
||||
|
||||
needAddList.ForEach(x =>
|
||||
{
|
||||
|
||||
if (x.QuestionType == QuestionType.ComparedTriggeringSODChange && !targetLesionIsIUorIC)
|
||||
{
|
||||
x.Answer = string.Empty;
|
||||
}
|
||||
else if (x.QuestionType == QuestionType.ComparedTriggeringiSODChange && !newTargetLesionIsIUorIC)
|
||||
{
|
||||
x.Answer = string.Empty;
|
||||
}
|
||||
|
||||
x.SubjectId = inDto.SubjectId;
|
||||
x.ReadingQuestionCriterionTrialId = inDto.CriterionId;
|
||||
x.VisitTaskId = inDto.VisitTaskId;
|
||||
|
@ -1335,18 +1371,22 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
|||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<decimal?> GetComparedTriggeringSODChange(ReadingCalculateDto inDto)
|
||||
public async Task<string> GetComparedTriggeringSODChange(ReadingCalculateDto inDto)
|
||||
{
|
||||
var firstChangeTaskId = await this.GetFirstChangeTaskId(inDto);
|
||||
var compareTaskId = await this.GetCompareTaskId(inDto,QuestionType.TargetLesion);
|
||||
if (compareTaskId == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
var firstChangeSOD = (await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == firstChangeTaskId && x.ReadingQuestionTrial.QuestionType == QuestionType.SOD).Select(x => x.Answer).FirstOrDefaultAsync()).IsNullOrEmptyReturn0();
|
||||
|
||||
var value = await GetSODData(inDto);
|
||||
|
||||
if (value == null || inDto.IsBaseLine|| !inDto.IsConvertedTask||inDto.BeforeConvertedTaskId!=null)
|
||||
{
|
||||
return null;
|
||||
return string.Empty;
|
||||
}
|
||||
return value.NullChange0() - firstChangeSOD;
|
||||
return (value.NullChange0() - firstChangeSOD).ToString();
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -1409,20 +1449,24 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
|||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<decimal?> GetComparedTriggeringiSODChange(ReadingCalculateDto inDto)
|
||||
public async Task<string> GetComparedTriggeringiSODChange(ReadingCalculateDto inDto)
|
||||
{
|
||||
|
||||
var firstChangeTaskId = await GetFirstChangeTaskId(inDto);
|
||||
var compareTaskId = await this.GetCompareTaskId(inDto, QuestionType.NewTargetLesion);
|
||||
if (compareTaskId == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var firstChangeiSOD = (await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == firstChangeTaskId && x.ReadingQuestionTrial.QuestionType == QuestionType.ISOD).Select(x => x.Answer).FirstOrDefaultAsync()).IsNullOrEmptyReturn0();
|
||||
var firstChangeiSOD = (await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == compareTaskId && x.ReadingQuestionTrial.QuestionType == QuestionType.ISOD).Select(x => x.Answer).FirstOrDefaultAsync()).IsNullOrEmptyReturn0();
|
||||
|
||||
var value = await GetiSODData(inDto);
|
||||
|
||||
if (value == null || inDto.IsBaseLine || !inDto.IsConvertedTask || inDto.BeforeConvertedTaskId != null)
|
||||
{
|
||||
return null;
|
||||
return string.Empty;
|
||||
}
|
||||
return value.NullChange0() - firstChangeiSOD;
|
||||
return (value.NullChange0() - firstChangeiSOD).ToString();
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -1666,33 +1710,109 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取第一次转变访视任务Id
|
||||
/// 获取比较任务Id 需要之前一次访视为IUPD或者ICPD
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private async Task<Guid> GetFirstChangeTaskId(ReadingCalculateDto inDto)
|
||||
{
|
||||
|
||||
if (firstChangeTaskId != null)
|
||||
{
|
||||
return firstChangeTaskId.Value;
|
||||
}
|
||||
else
|
||||
private async Task<Guid?> GetCompareTaskId(ReadingCalculateDto inDto,QuestionType questionType)
|
||||
{
|
||||
var taskinfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).ProjectTo<VisitTaskDto>(_mapper.ConfigurationProvider).FirstNotNullAsync();
|
||||
var taskId = await _visitTaskRepository.Where(x => x.ReadingCategory == ReadingCategory.Visit &&
|
||||
var lastTaskId = await GetLastVisitTaskId(inDto);
|
||||
|
||||
|
||||
if (compareTaskList == null)
|
||||
{
|
||||
// 先找到第一个转变任务的number 直接找是否为转变任务 查询耗性能
|
||||
var firstChangeVisitTaskNum = 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.BeforeConvertedTaskId != null && x.TaskState == TaskState.Effect
|
||||
).OrderBy(x => x.VisitTaskNum).Select(x => x.Id).FirstOrDefaultAsync();
|
||||
firstChangeTaskId = taskId;
|
||||
return taskId;
|
||||
).OrderBy(x => x.VisitTaskNum).Select(x => x.VisitTaskNum).FirstOrDefaultAsync();
|
||||
|
||||
// 找到转变之后 所有任务
|
||||
compareTaskList = 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 >= firstChangeVisitTaskNum && x.VisitTaskNum < taskinfo.VisitTaskNum && x.TaskState == TaskState.Effect
|
||||
).OrderBy(x => x.VisitTaskNum).Select(x => new TirggerTaskInfo()
|
||||
{
|
||||
VisitTaskId = x.Id,
|
||||
VisitNum = x.VisitTaskNum,
|
||||
}).ToListAsync();
|
||||
|
||||
// 获取所有任务Id
|
||||
var visitTaskids = compareTaskList.Select(x => x.VisitTaskId).ToList();
|
||||
|
||||
// 找到所有任务的靶病灶评估和非靶病灶评估
|
||||
var answers = await _readingTaskQuestionAnswerRepository.Where(x => (x.ReadingQuestionTrial.QuestionType == QuestionType.TargetLesion || x.ReadingQuestionTrial.QuestionType == QuestionType.NewTargetLesion) &&
|
||||
visitTaskids.Contains(x.VisitTaskId)
|
||||
).Select(x => new TirggerAnswerInfo()
|
||||
{
|
||||
VisitTaskId = x.VisitTaskId,
|
||||
Answer = x.Answer,
|
||||
QuestionType = x.ReadingQuestionTrial.QuestionType.Value
|
||||
}).ToListAsync();
|
||||
|
||||
compareTaskList.ForEach(x =>
|
||||
{
|
||||
x.TargetAssessmentIsIUorIC = answers.Any(x => questionType == QuestionType.TargetLesion && (x.Answer == TargetAssessment.iUPD.GetEnumInt() || x.Answer == TargetAssessment.iCPD.GetEnumInt()));
|
||||
x.NewTargetLesionAssessmentIsIUorIC = answers.Any(x => questionType == QuestionType.NewTargetLesion && (x.Answer == NewTargetLesionAssessment.iUPD.GetEnumInt() || x.Answer == NewTargetLesionAssessment.iCPD.GetEnumInt()));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Guid? compareTaskId = null;
|
||||
if(compareTaskList.Count()==0)
|
||||
{
|
||||
return compareTaskId;
|
||||
}
|
||||
int index = 0;
|
||||
switch (questionType)
|
||||
{
|
||||
case QuestionType.TargetLesion:
|
||||
index = compareTaskList.FindLastIndex(x => x.TargetAssessmentIsIUorIC);
|
||||
if (index == -1)
|
||||
{
|
||||
return compareTaskList[0].VisitTaskId;
|
||||
}
|
||||
else if (index > 0 && !compareTaskList[index-1].TargetAssessmentIsIUorIC)
|
||||
{
|
||||
return compareTaskList[index-1].VisitTaskId;
|
||||
}
|
||||
else
|
||||
{
|
||||
return compareTaskList[0].VisitTaskId;
|
||||
}
|
||||
case QuestionType.NewTargetLesion:
|
||||
index = compareTaskList.FindLastIndex(x => x.NewTargetLesionAssessmentIsIUorIC);
|
||||
if (index == -1)
|
||||
{
|
||||
return compareTaskList[0].VisitTaskId;
|
||||
}
|
||||
else if (index > 0 && !compareTaskList[index - 1].NewTargetLesionAssessmentIsIUorIC)
|
||||
{
|
||||
return compareTaskList[index - 1].VisitTaskId;
|
||||
}
|
||||
else
|
||||
{
|
||||
return compareTaskList[0].VisitTaskId;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return compareTaskId;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 计算阅片问题 外层问题
|
||||
|
@ -1745,7 +1865,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
|||
var tableQuestion = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.TargetLesion).SelectMany(x => x.TableRowInfoList).ToList();
|
||||
var lastVisitTaskId = await GetLastVisitTaskId(inDto);
|
||||
var targetLesionQuestionId = inDto.QuestionInfo.Where(x => x.QuestionType == QuestionType.TargetLesion).Select(x => x.QuestionId).FirstOrDefault();
|
||||
var firstChangeTaskId = await GetFirstChangeTaskId(inDto);
|
||||
|
||||
var sodQuestionId = inDto.QuestionInfo.Where(x => x.QuestionType == QuestionType.SOD).Select(x => x.QuestionId).FirstOrDefault();
|
||||
IRECISTTargetLesionDto resultData = new IRECISTTargetLesionDto()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue