修改一版
parent
b80fd3cd25
commit
a2f5f9abc2
|
@ -113,6 +113,8 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
|
||||||
|
|
||||||
public string BlindName { get; set; }
|
public string BlindName { get; set; }
|
||||||
|
|
||||||
|
public decimal VisitTaskNum { get; set; }
|
||||||
|
|
||||||
public Guid VisitTaskId { get; set; }
|
public Guid VisitTaskId { get; set; }
|
||||||
|
|
||||||
public Guid BaseLineTaskId { get; set; }
|
public Guid BaseLineTaskId { get; set; }
|
||||||
|
@ -219,6 +221,10 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
|
||||||
public string BlindName { get; set; }
|
public string BlindName { get; set; }
|
||||||
|
|
||||||
public decimal SOD { get; set; }
|
public decimal SOD { get; set; }
|
||||||
|
|
||||||
|
public decimal VisitTaskNum { get; set; }
|
||||||
|
|
||||||
|
public decimal NewLesionsCount { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ChangeAllTaskDto
|
public class ChangeAllTaskDto
|
||||||
|
@ -234,6 +240,8 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
|
||||||
|
|
||||||
public Func<ReadingCalculateDto, Task<decimal>> GetDecimalFun { get; set; }
|
public Func<ReadingCalculateDto, Task<decimal>> GetDecimalFun { get; set; }
|
||||||
|
|
||||||
|
public Func<ReadingCalculateDto, Task<int>> GetIntFun { get; set; }
|
||||||
|
|
||||||
public Func<ReadingCalculateDto, Task<decimal?>> GetDecimalNullFun { get; set; }
|
public Func<ReadingCalculateDto, Task<decimal?>> GetDecimalNullFun { get; set; }
|
||||||
|
|
||||||
public Func<ReadingCalculateDto, Task<string>> GetStringFun { get; set; }
|
public Func<ReadingCalculateDto, Task<string>> GetStringFun { get; set; }
|
||||||
|
|
|
@ -997,7 +997,8 @@ namespace IRaCIS.Application.Services
|
||||||
|
|
||||||
if (rowCount > item.MaxRowCount.Value - 1)
|
if (rowCount > item.MaxRowCount.Value - 1)
|
||||||
{
|
{
|
||||||
throw new BusinessValidationFailedException($"问题{item.QuestionName}最大相同问题数为{item.MaxRowCount.Value},当前已存在{rowCount}条!");
|
//throw new BusinessValidationFailedException($"问题{item.QuestionName}最大相同问题数为{item.MaxRowCount.Value},当前已存在{rowCount}条!");
|
||||||
|
throw new BusinessValidationFailedException($"当前器官上已有{rowCount}个病灶!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -127,6 +127,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||||
ArmEnum = visitTask.ArmEnum,
|
ArmEnum = visitTask.ArmEnum,
|
||||||
VisitName = subjectVisit.VisitName,
|
VisitName = subjectVisit.VisitName,
|
||||||
BlindName = subjectVisit.BlindName,
|
BlindName = subjectVisit.BlindName,
|
||||||
|
VisitTaskNum = visitTask.VisitTaskNum,
|
||||||
};
|
};
|
||||||
|
|
||||||
return readingData;
|
return readingData;
|
||||||
|
|
|
@ -1,6 +1,15 @@
|
||||||
using IRaCIS.Core.Application.Service.Reading.Dto;
|
using IRaCIS.Core.Application.Service.Reading.Dto;
|
||||||
using IRaCIS.Core.Application.ViewModel;
|
|
||||||
using IRaCIS.Core.Domain.Share;
|
using IRaCIS.Core.Domain.Share;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using IRaCIS.Core.Domain.Models;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using IRaCIS.Core.Application.Interfaces;
|
||||||
|
using IRaCIS.Core.Application.ViewModel;
|
||||||
|
using Panda.DynamicWebApi.Attributes;
|
||||||
|
using IRaCIS.Core.Infra.EFCore.Common;
|
||||||
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
|
|
||||||
|
using IRaCIS.Core.Infrastructure;
|
||||||
using MassTransit;
|
using MassTransit;
|
||||||
|
|
||||||
namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||||
|
@ -50,107 +59,370 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<AddTaskLesionAnswerFromLastTaskOutDto> AddTaskLesionAnswerFromLastTask(AddTaskLesionAnswerFromLastTaskInDto inDto)
|
public async Task<AddTaskLesionAnswerFromLastTaskOutDto> AddTaskLesionAnswerFromLastTask(AddTaskLesionAnswerFromLastTaskInDto inDto)
|
||||||
{
|
{
|
||||||
return new AddTaskLesionAnswerFromLastTaskOutDto();
|
|
||||||
//var visitTaskId = inDto.VisitTaskId;
|
|
||||||
|
|
||||||
//var taskinfo = await _visitTaskRepository.Where(x => x.Id == visitTaskId).FirstNotNullAsync();
|
var visitTaskId = inDto.VisitTaskId;
|
||||||
|
|
||||||
//var baseLineVisitId = await _subjectVisitRepository.Where(x => x.SubjectId == taskinfo.SubjectId && x.IsBaseLine).Select(x => x.Id).FirstOrDefaultAsync();
|
var taskinfo = await _visitTaskRepository.Where(x => x.Id == visitTaskId).FirstNotNullAsync();
|
||||||
|
|
||||||
//// 判断当前任务是否是基线
|
var baseLineVisitId = await _subjectVisitRepository.Where(x => x.SubjectId == taskinfo.SubjectId && x.IsBaseLine).Select(x => x.Id).FirstOrDefaultAsync();
|
||||||
//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.SubjectId == taskinfo.SubjectId && x.ReadingTaskState == ReadingTaskState.HaveSigned && x.VisitTaskNum < taskinfo.VisitTaskNum && x.TaskState == TaskState.Effect && x.ArmEnum == taskinfo.ArmEnum
|
|
||||||
// ).OrderByDescending(x => x.VisitTaskNum).Select(x => x.Id).FirstOrDefaultAsync();
|
|
||||||
|
|
||||||
// var copyTableAnswers = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == LastVisitTaskId
|
// 判断当前任务是否是基线
|
||||||
// ).Select(x => new CopyTableAnswerDto()
|
if (taskinfo.SourceSubjectVisitId != baseLineVisitId)
|
||||||
// {
|
{
|
||||||
// Answer = x.Answer,
|
// 判断当前任务是是否有表格问题答案
|
||||||
// QuestionId = x.QuestionId,
|
if (!(await _readingTableQuestionAnswerRepository.AnyAsync(x => x.VisitTaskId == visitTaskId)))
|
||||||
// RowId = x.RowId,
|
{
|
||||||
// QuestionMark = x.ReadingTableQuestionTrial.QuestionMark,
|
var LastVisitTaskId = await _visitTaskRepository.Where(x => x.ReadingCategory == ReadingCategory.Visit &&
|
||||||
// TableQuestionId = x.TableQuestionId,
|
x.TrialReadingCriterionId == taskinfo.TrialReadingCriterionId &&
|
||||||
// RowIndex = x.RowIndex,
|
x.SubjectId == taskinfo.SubjectId && x.ReadingTaskState == ReadingTaskState.HaveSigned && x.VisitTaskNum < taskinfo.VisitTaskNum && x.TaskState == TaskState.Effect && x.ArmEnum == taskinfo.ArmEnum
|
||||||
// TrialId = x.TrialId
|
).OrderByDescending(x => x.VisitTaskNum).Select(x => x.Id).FirstOrDefaultAsync();
|
||||||
// }).ToListAsync();
|
|
||||||
|
|
||||||
// var tableRowAnswers = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == LastVisitTaskId).ProjectTo<CopyTableAnswerRowInfo>(_mapper.ConfigurationProvider).ToListAsync();
|
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();
|
||||||
|
|
||||||
// tableRowAnswers.ForEach(x =>
|
var tableRowAnswers = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == LastVisitTaskId).ProjectTo<CopyTableAnswerRowInfo>(_mapper.ConfigurationProvider).ToListAsync();
|
||||||
// {
|
|
||||||
// x.VisitTaskId = visitTaskId;
|
|
||||||
// x.IsCurrentTaskAdd = false;
|
|
||||||
// x.Id = NewId.NextGuid();
|
|
||||||
// x.SeriesId = null;
|
|
||||||
// x.InstanceId = null;
|
|
||||||
// x.MeasureData = string.Empty;
|
|
||||||
// });
|
|
||||||
|
|
||||||
// tableRowAnswers.ForEach(x =>
|
tableRowAnswers.ForEach(x =>
|
||||||
// {
|
{
|
||||||
// x.SplitRowId = tableRowAnswers.Where(y => y.OriginalId == x.SplitRowId).Select(y => y.Id).FirstOrDefault();
|
x.VisitTaskId = visitTaskId;
|
||||||
// x.MergeRowId = tableRowAnswers.Where(y => y.OriginalId == x.MergeRowId).Select(y => y.Id).FirstOrDefault();
|
x.IsCurrentTaskAdd = false;
|
||||||
// });
|
x.Id = NewId.NextGuid();
|
||||||
|
x.SeriesId = null;
|
||||||
|
x.InstanceId = null;
|
||||||
|
x.MeasureData = string.Empty;
|
||||||
|
});
|
||||||
|
|
||||||
// List<QuestionMark?> notNeedCopyMarks = new List<QuestionMark?>()
|
tableRowAnswers.ForEach(x =>
|
||||||
// {
|
{
|
||||||
// QuestionMark.State,
|
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();
|
||||||
|
x.MergeRow = null;
|
||||||
|
x.SplitRow = null;
|
||||||
|
});
|
||||||
|
|
||||||
// var tableAnswers = copyTableAnswers.Select(x => new ReadingTableQuestionAnswer
|
List<QuestionMark?> notNeedCopyMarks = new List<QuestionMark?>()
|
||||||
// {
|
{
|
||||||
// Id = NewId.NextGuid(),
|
QuestionMark.State,
|
||||||
// Answer = notNeedCopyMarks.Contains(x.QuestionMark) ? string.Empty : x.Answer,
|
};
|
||||||
// QuestionId = x.QuestionId,
|
|
||||||
// RowIndex = x.RowIndex,
|
var tableAnswers = copyTableAnswers.Select(x => new ReadingTableQuestionAnswer
|
||||||
// RowId = tableRowAnswers.Where(y => y.OriginalId == x.RowId).Select(x => x.Id).FirstOrDefault(),
|
{
|
||||||
// TableQuestionId = x.TableQuestionId,
|
Id = NewId.NextGuid(),
|
||||||
// TrialId = x.TrialId,
|
Answer = notNeedCopyMarks.Contains(x.QuestionMark) ? string.Empty : x.Answer,
|
||||||
// VisitTaskId = visitTaskId,
|
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,
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// await _visitTaskRepository.UpdatePartialFromQueryAsync(visitTaskId, x => new VisitTask()
|
try
|
||||||
// {
|
{
|
||||||
// ReadingTaskState = ReadingTaskState.Reading,
|
var newLesionQuestion = await _readingQuestionTrialRepository.Where(x => x.LesionType == LesionType.NewLesions && x.ReadingQuestionCriterionTrialId == taskinfo.TrialReadingCriterionId).FirstNotNullAsync();
|
||||||
|
var alwaysNewLesionsQuestion = await _readingQuestionTrialRepository.Where(x => x.LesionType == LesionType.AlwaysNewLesions && x.ReadingQuestionCriterionTrialId == taskinfo.TrialReadingCriterionId).FirstNotNullAsync();
|
||||||
|
var newLesionTableQuestions = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionId == newLesionQuestion.Id).ToListAsync();
|
||||||
|
var alwaysNewLesionsTableQuestions = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionId == alwaysNewLesionsQuestion.Id).ToListAsync();
|
||||||
|
|
||||||
// });
|
Dictionary<Guid, Guid> alwaysTableQuestionIdDic = new Dictionary<Guid, Guid>();
|
||||||
|
|
||||||
// tableRowAnswers.ForEach(x =>
|
newLesionTableQuestions.ForEach(x =>
|
||||||
// {
|
{
|
||||||
// x.MergeRow = null;
|
|
||||||
// x.SplitRow = null;
|
alwaysTableQuestionIdDic.Add(
|
||||||
// });
|
x.Id,
|
||||||
|
alwaysNewLesionsTableQuestions.Where(y => y.QuestionName == x.QuestionName).Select(y => y.Id).FirstOrDefault()
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
var maxNewLesionsRowIndex = tableRowAnswers.Where(x => x.QuestionId == newLesionQuestion.Id).OrderByDescending(x => x.RowIndex).Select(x => x.RowIndex).FirstOrDefault();
|
||||||
|
maxNewLesionsRowIndex = Math.Floor(maxNewLesionsRowIndex);
|
||||||
|
foreach (var item in tableRowAnswers.Where(x => x.QuestionId == newLesionQuestion.Id).OrderBy(x=>x.RowIndex))
|
||||||
|
{
|
||||||
|
maxNewLesionsRowIndex++;
|
||||||
|
item.QuestionId = alwaysNewLesionsQuestion.Id;
|
||||||
|
item.RowIndex = maxNewLesionsRowIndex;
|
||||||
|
|
||||||
|
foreach (var tableAnswer in tableAnswers.Where(y=>y.RowId== item.Id))
|
||||||
|
{
|
||||||
|
tableAnswer.QuestionId= alwaysNewLesionsQuestion.Id;
|
||||||
|
tableAnswer.TableQuestionId = alwaysTableQuestionIdDic[tableAnswer.TableQuestionId];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
|
||||||
|
throw new BusinessValidationFailedException($"PCWG3标准配置异常!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
await _visitTaskRepository.UpdatePartialFromQueryAsync(visitTaskId, x => new VisitTask()
|
||||||
|
{
|
||||||
|
ReadingTaskState = ReadingTaskState.Reading,
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// await _readingTableAnswerRowInfoRepository.AddRangeAsync(tableRowAnswers);
|
await _readingTableAnswerRowInfoRepository.AddRangeAsync(tableRowAnswers);
|
||||||
// await _readingTableQuestionAnswerRepository.AddRangeAsync(tableAnswers);
|
await _readingTableQuestionAnswerRepository.AddRangeAsync(tableAnswers);
|
||||||
// await _readingTableQuestionAnswerRepository.SaveChangesAsync();
|
await _readingTableQuestionAnswerRepository.SaveChangesAsync();
|
||||||
|
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
|
|
||||||
//return new AddTaskLesionAnswerFromLastTaskOutDto()
|
return new AddTaskLesionAnswerFromLastTaskOutDto()
|
||||||
//{
|
{
|
||||||
|
|
||||||
// IsBaseLine = taskinfo.SourceSubjectVisitId == baseLineVisitId,
|
IsBaseLine = taskinfo.SourceSubjectVisitId == baseLineVisitId,
|
||||||
//};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 计算任务
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="inDto"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
public async Task CalculateTask(CalculateTaskInDto inDto)
|
public async Task CalculateTask(CalculateTaskInDto inDto)
|
||||||
{
|
{
|
||||||
|
ReadingCalculateDto readingData = await _generalCalculateService.GetReadingCalculateDto(inDto.VisitTaskId);
|
||||||
|
readingData.IsChangeOtherTask = inDto.IsChangeOtherTask;
|
||||||
|
await ReadingCalculate(readingData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 自动计算
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="inDto"></param>
|
||||||
|
/// <param name="calculateType"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task ReadingCalculate(ReadingCalculateDto inDto, List<QuestionType> calculateType = null)
|
||||||
|
{
|
||||||
|
|
||||||
|
#region 计算 这里顺序非常重要 后面计算的值要依赖前面计算的结果
|
||||||
|
var needAddList = new List<ReadingTaskQuestionAnswer>();
|
||||||
|
|
||||||
|
|
||||||
|
List<ReadingCalculateData> calculateList = new List<ReadingCalculateData>()
|
||||||
|
{
|
||||||
|
// 基线病灶计数
|
||||||
|
new ReadingCalculateData (){QuestionType=QuestionType.BaseLineLesionsCount,GetIntFun=GetBaseLineLesionsCount},
|
||||||
|
|
||||||
|
// 新病灶计数
|
||||||
|
new ReadingCalculateData (){QuestionType=QuestionType.NewLesionsCount,GetIntFun=GetNewLesionsCount},
|
||||||
|
|
||||||
|
// 既往新病灶
|
||||||
|
new ReadingCalculateData (){QuestionType=QuestionType.AlwaysNewLesionsCount,GetIntFun=GetAlwaysNewLesionsCount},
|
||||||
|
|
||||||
|
// 自治疗后第二个访视点以来持续的新骨病变数量
|
||||||
|
new ReadingCalculateData (){QuestionType=QuestionType.NewBoneLesionsCount,GetIntFun=GetNewBoneLesionCount},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
if (calculateType != null)
|
||||||
|
{
|
||||||
|
calculateList = calculateList.Where(x => calculateType.Contains(x.QuestionType)).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
foreach (var calculate in calculateList)
|
||||||
|
{
|
||||||
|
var item = inDto.QuestionInfo.FirstOrDefault(x => x.QuestionType == calculate.QuestionType);
|
||||||
|
|
||||||
|
if (item != null)
|
||||||
|
{
|
||||||
|
//计算答案
|
||||||
|
if (inDto.IsOnlyChangeAllTask == false)
|
||||||
|
{
|
||||||
|
|
||||||
|
#region 计算答案
|
||||||
|
|
||||||
|
var value = await calculate.GetIntFun(inDto);
|
||||||
|
|
||||||
|
switch (calculate.QuestionType)
|
||||||
|
{
|
||||||
|
case QuestionType.NewLesionsCount:
|
||||||
|
if (inDto.VisitTaskNum >= 1)
|
||||||
|
{
|
||||||
|
item.Answer = value.ToString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
item.Answer = nameof(YesOrNoOrNa.NA);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case QuestionType.AlwaysNewLesionsCount:
|
||||||
|
if (inDto.VisitTaskNum >= 2)
|
||||||
|
{
|
||||||
|
item.Answer = value.ToString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
item.Answer = nameof(YesOrNoOrNa.NA);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case QuestionType.NewBoneLesionsCount:
|
||||||
|
if (inDto.VisitTaskNum >= 3)
|
||||||
|
{
|
||||||
|
item.Answer = value.ToString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
item.Answer = nameof(YesOrNoOrNa.NA);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
item.Answer = value.ToString();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||||
|
{
|
||||||
|
Answer = item.Answer,
|
||||||
|
ReadingQuestionTrialId = item.QuestionId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改全局
|
||||||
|
if (inDto.IsChangeOtherTask && calculate.ChangeAllTaskFun != null)
|
||||||
|
{
|
||||||
|
await calculate.ChangeAllTaskFun(new ChangeAllTaskDto()
|
||||||
|
{
|
||||||
|
calculateDto = inDto,
|
||||||
|
QuestionId = item.QuestionId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#region 基线病灶计数
|
||||||
|
/// <summary>
|
||||||
|
/// 基线病灶计数
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="inDto"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<int> GetBaseLineLesionsCount(ReadingCalculateDto inDto)
|
||||||
|
{
|
||||||
|
return inDto.QuestionInfo.Where(x => x.LesionType == LesionType.BaselineLesions).Select(x => x.TableRowInfoList).Count();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 新病灶计数
|
||||||
|
/// <summary>
|
||||||
|
/// 获取新病灶计数
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="inDto"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<int> GetNewLesionsCount(ReadingCalculateDto inDto)
|
||||||
|
{
|
||||||
|
return inDto.QuestionInfo.Where(x => x.LesionType == LesionType.NewLesions).SelectMany(x => x.TableRowInfoList)
|
||||||
|
.Where(x=>x.TableQuestionList.Any(y=>y.QuestionMark==QuestionMark.State&&y.Answer== EvaluationOfState.Exists.GetEnumInt()))
|
||||||
|
.Count();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region 既往新病灶计数
|
||||||
|
/// <summary>
|
||||||
|
/// 既往新病灶计数
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="inDto"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<int> GetAlwaysNewLesionsCount(ReadingCalculateDto inDto)
|
||||||
|
{
|
||||||
|
return inDto.QuestionInfo.Where(x => x.LesionType == LesionType.AlwaysNewLesions).SelectMany(x => x.TableRowInfoList)
|
||||||
|
.Where(x => x.TableQuestionList.Any(y => y.QuestionMark == QuestionMark.State && y.Answer == EvaluationOfState.Exists.GetEnumInt()))
|
||||||
|
.Count();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region 既往新病灶计数
|
||||||
|
/// <summary>
|
||||||
|
/// 自治疗后第二个访视点以来持续的新骨病变数量
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="inDto"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<int> GetNewBoneLesionCount(ReadingCalculateDto inDto)
|
||||||
|
{
|
||||||
|
if (inDto.VisitTaskNum < 3)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
List<VisitTaskAnswerInfo> visitTaskAnswerList = await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId != inDto.VisitTaskId && x.VisitTask.ReadingCategory == ReadingCategory.Visit
|
||||||
|
&& x.VisitTask.IsAnalysisCreate == inDto.IsAnalysisCreate
|
||||||
|
&& x.VisitTask.IsSelfAnalysis == inDto.IsSelfAnalysis
|
||||||
|
&& x.SubjectId == inDto.SubjectId && x.VisitTask.ReadingTaskState == ReadingTaskState.HaveSigned && x.VisitTask.ArmEnum == inDto.ArmEnum && x.VisitTask.TaskState == TaskState.Effect && x.ReadingQuestionTrial.QuestionType == QuestionType.NewLesionsCount)
|
||||||
|
.Select(x => new VisitTaskAnswerInfo
|
||||||
|
{
|
||||||
|
VisitTaskId = x.VisitTaskId,
|
||||||
|
QuestionId = x.ReadingQuestionTrialId,
|
||||||
|
VisitName = x.VisitTask.SourceSubjectVisit.VisitName,
|
||||||
|
BlindName = x.VisitTask.SourceSubjectVisit.BlindName,
|
||||||
|
VisitTaskNum=x.VisitTask.VisitTaskNum,
|
||||||
|
NewLesionsCount = x.Answer.IsNullOrEmptyReturn0(),
|
||||||
|
}).ToListAsync();
|
||||||
|
|
||||||
|
visitTaskAnswerList = visitTaskAnswerList.Where(x => x.VisitTaskNum >= 2).ToList();
|
||||||
|
|
||||||
|
return int.Parse( Math.Floor(visitTaskAnswerList.Sum(x => x.NewLesionsCount)).ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
public async Task<object> GetReportVerify(GetReportVerifyInDto inDto)
|
public async Task<object> GetReportVerify(GetReportVerifyInDto inDto)
|
||||||
{
|
{
|
||||||
return new() {
|
return new() {
|
||||||
|
|
|
@ -64,16 +64,13 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||||
Type thisServiceType = CalculateServiceDic[thisCriterionType];
|
Type thisServiceType = CalculateServiceDic[thisCriterionType];
|
||||||
_useCriterion = _criterionServices.FirstOrDefault(x => x.GetType().Name == thisServiceType.Name + "Proxy");
|
_useCriterion = _criterionServices.FirstOrDefault(x => x.GetType().Name == thisServiceType.Name + "Proxy");
|
||||||
|
|
||||||
if (criterionType == null)
|
|
||||||
{
|
|
||||||
throw new BusinessValidationFailedException($"当前标准计算未开发好");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
|
||||||
throw new BusinessValidationFailedException($"当前标准计算未开发好");
|
_useCriterion = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _useCriterion;
|
return _useCriterion;
|
||||||
|
@ -93,8 +90,13 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task CalculateTask(CalculateTaskInDto inDto)
|
public async Task CalculateTask(CalculateTaskInDto inDto)
|
||||||
{
|
{
|
||||||
|
|
||||||
var service = await this.GetService(inDto.VisitTaskId);
|
var service = await this.GetService(inDto.VisitTaskId);
|
||||||
await service.CalculateTask(inDto);
|
if (service != null)
|
||||||
|
{
|
||||||
|
await service.CalculateTask(inDto);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -105,7 +107,11 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||||
public async Task VerifyVisitTaskQuestions(VerifyVisitTaskQuestionsInDto inDto)
|
public async Task VerifyVisitTaskQuestions(VerifyVisitTaskQuestionsInDto inDto)
|
||||||
{
|
{
|
||||||
var service = await this.GetService(inDto.VisitTaskId);
|
var service = await this.GetService(inDto.VisitTaskId);
|
||||||
await service.VerifyVisitTaskQuestions(inDto);
|
if (service != null)
|
||||||
|
{
|
||||||
|
await service.VerifyVisitTaskQuestions(inDto);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -116,7 +122,15 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||||
public async Task<AddTaskLesionAnswerFromLastTaskOutDto> AddTaskLesionAnswerFromLastTask(AddTaskLesionAnswerFromLastTaskInDto inDto)
|
public async Task<AddTaskLesionAnswerFromLastTaskOutDto> AddTaskLesionAnswerFromLastTask(AddTaskLesionAnswerFromLastTaskInDto inDto)
|
||||||
{
|
{
|
||||||
var service = await this.GetService(inDto.VisitTaskId);
|
var service = await this.GetService(inDto.VisitTaskId);
|
||||||
return await service.AddTaskLesionAnswerFromLastTask(inDto);
|
if (service != null)
|
||||||
|
{
|
||||||
|
return await service.AddTaskLesionAnswerFromLastTask(inDto);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new AddTaskLesionAnswerFromLastTaskOutDto();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -127,7 +141,16 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
||||||
public async Task<object> GetReportVerify(GetReportVerifyInDto inDto)
|
public async Task<object> GetReportVerify(GetReportVerifyInDto inDto)
|
||||||
{
|
{
|
||||||
var service = await this.GetService(inDto.VisitTaskId);
|
var service = await this.GetService(inDto.VisitTaskId);
|
||||||
return await service.GetReportVerify(inDto);
|
|
||||||
|
if (service != null)
|
||||||
|
{
|
||||||
|
return await service.GetReportVerify(inDto);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new { };
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -317,6 +317,30 @@ namespace IRaCIS.Core.Domain.Share
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 病灶评估状态
|
||||||
|
/// </summary>
|
||||||
|
public enum EvaluationOfState
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 消失
|
||||||
|
/// </summary>
|
||||||
|
Loss = 1,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 存在
|
||||||
|
/// </summary>
|
||||||
|
Exists = 2,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 良性或不可评估
|
||||||
|
/// </summary>
|
||||||
|
Benign = 3
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 新病灶评估
|
/// 新病灶评估
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -900,6 +924,26 @@ namespace IRaCIS.Core.Domain.Share
|
||||||
/// 是否存在疾病
|
/// 是否存在疾病
|
||||||
/// </summary>
|
/// </summary>
|
||||||
ExistDisease = 15,
|
ExistDisease = 15,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 基线病灶计数
|
||||||
|
/// </summary>
|
||||||
|
BaseLineLesionsCount = 16,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 新病灶计数
|
||||||
|
/// </summary>
|
||||||
|
NewLesionsCount = 17,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 既往新病灶
|
||||||
|
/// </summary>
|
||||||
|
AlwaysNewLesionsCount = 18,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 自治疗后第二个访视点以来持续的新骨病变数量
|
||||||
|
/// </summary>
|
||||||
|
NewBoneLesionsCount = 19,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in New Issue