Uat_Study
he 2023-06-05 18:15:07 +08:00
parent 4e63395a35
commit 67d2067a28
1 changed files with 52 additions and 33 deletions

View File

@ -1373,11 +1373,21 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
/// <returns></returns>
public async Task<string> GetComparedTriggeringSODChange(ReadingCalculateDto inDto)
{
var compareTaskId = await this.GetCompareTaskId(inDto,QuestionType.TargetLesion);
var compareTaskId = await this.GetCompareTaskId(inDto, QuestionType.TargetLesion);
if (compareTaskId == null)
{
return string.Empty;
}
var lastTaskId = await GetLastVisitTaskId(inDto);
// 靶病灶评估为IUPD或者ICPD
var targetLesionIsIUorIC = await _readingTaskQuestionAnswerRepository.AnyAsync(x => x.VisitTaskId == lastTaskId && x.ReadingQuestionTrial.QuestionType == QuestionType.TargetLesion && (x.Answer==TargetAssessment.iUPD.GetEnumInt()|| x.Answer==TargetAssessment.iCPD.GetEnumInt()));
if (!targetLesionIsIUorIC)
{
return string.Empty;
}
var compareTaskSOD = (await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == compareTaskId && x.ReadingQuestionTrial.QuestionType == QuestionType.SOD).Select(x => x.Answer).FirstOrDefaultAsync()).IsNullOrEmptyReturn0();
var value = await GetSODData(inDto);
@ -1458,6 +1468,16 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
return string.Empty;
}
var lastTaskId = await GetLastVisitTaskId(inDto);
// 新靶病灶为IUPD或者ICPD
var newTargetLesionIsIUorIC = await _readingTaskQuestionAnswerRepository.AnyAsync(x => x.VisitTaskId == lastTaskId && x.ReadingQuestionTrial.QuestionType == QuestionType.NewTargetLesion && (x.Answer==NewTargetLesionAssessment.iUPD.GetEnumInt() || x.Answer==NewTargetLesionAssessment.iCPD.GetEnumInt()));
if (!newTargetLesionIsIUorIC)
{
return string.Empty;
}
var compareTaskiSOD = (await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == compareTaskId && x.ReadingQuestionTrial.QuestionType == QuestionType.ISOD).Select(x => x.Answer).FirstOrDefaultAsync()).IsNullOrEmptyReturn0();
var value = await GetiSODData(inDto);
@ -1758,55 +1778,54 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
QuestionType = x.ReadingQuestionTrial.QuestionType.Value
}).ToListAsync();
compareTaskList.ForEach(x =>
compareTaskList.ForEach(y =>
{
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()));
y.TargetAssessmentIsIUorIC = answers.Any(x =>x.VisitTaskId==y.VisitTaskId && x.QuestionType == QuestionType.TargetLesion && (x.Answer == TargetAssessment.iUPD.GetEnumInt() || x.Answer == TargetAssessment.iCPD.GetEnumInt()));
y.NewTargetLesionAssessmentIsIUorIC = answers.Any(x => x.VisitTaskId == y.VisitTaskId && 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)
for (int i = compareTaskList.Count()-1; i>=0; i--)
{
return compareTaskList[0].VisitTaskId;
}
else if (index > 0 && !compareTaskList[index-1].TargetAssessmentIsIUorIC)
{
return compareTaskList[index-1].VisitTaskId;
}
else
{
return compareTaskList[0].VisitTaskId;
if (i == 0)
{
return compareTaskList[0].VisitTaskId;
}
else
{
if (compareTaskList[i].TargetAssessmentIsIUorIC && !compareTaskList[i - 1].TargetAssessmentIsIUorIC)
{
return compareTaskList[i].VisitTaskId;
}
}
}
break;
case QuestionType.NewTargetLesion:
index = compareTaskList.FindLastIndex(x => x.NewTargetLesionAssessmentIsIUorIC);
if (index == -1)
for (int i = compareTaskList.Count() - 1; i >= 0; i--)
{
return compareTaskList[0].VisitTaskId;
}
else if (index > 0 && !compareTaskList[index - 1].NewTargetLesionAssessmentIsIUorIC)
{
return compareTaskList[index - 1].VisitTaskId;
}
else
{
return compareTaskList[0].VisitTaskId;
if (i == 0)
{
return compareTaskList[0].VisitTaskId;
}
else
{
if (compareTaskList[i].NewTargetLesionAssessmentIsIUorIC && !compareTaskList[i - 1].NewTargetLesionAssessmentIsIUorIC)
{
return compareTaskList[i].VisitTaskId;
}
}
}
break;
}