计算修改
parent
7d00b51db2
commit
2e9afc2ce8
|
@ -469,16 +469,115 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
|||
{
|
||||
|
||||
await this.CalculateAvg(inDto);
|
||||
//var questionList = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == inDto.CriterionId && x.CustomCalculateMark != null).ToListAsync();
|
||||
//var tableQuestionList = await _readingTableQuestionTrialRepository.Where(x => x.TrialCriterionId == inDto.CriterionId && x.CustomCalculateMark != null).ToListAsync();
|
||||
inDto = await _generalCalculateService.GetReadingCalculateDto(inDto.VisitTaskId);
|
||||
var needAddList = new List<ReadingTaskQuestionAnswer>();
|
||||
List<ReadingCalculateData> calculateList = new List<ReadingCalculateData>()
|
||||
{
|
||||
// 脂肪平均
|
||||
new ReadingCalculateData (){QuestionType=QuestionType.TotalMeanFraction,GetDecimalFun=GetFatFractionAvg},
|
||||
};
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
//计算答案
|
||||
|
||||
|
||||
#region 计算答案
|
||||
if (calculate.GetDecimalFun != null)
|
||||
{
|
||||
item.Answer = (await calculate.GetDecimalFun(inDto)).ToString();
|
||||
|
||||
}
|
||||
else if (calculate.GetDecimalNullFun != null)
|
||||
{
|
||||
var value = await calculate.GetDecimalNullFun(inDto);
|
||||
item.Answer = value == null ? "NA" : value.Value.ToString();
|
||||
}
|
||||
else if (calculate.GetStringFun != null)
|
||||
{
|
||||
item.Answer = await calculate.GetStringFun(inDto);
|
||||
}
|
||||
#endregion
|
||||
// 修改修约小数位数
|
||||
|
||||
List<ValueOfType?> valueOfTypes = new List<ValueOfType?>() {
|
||||
|
||||
ValueOfType.Decimals,
|
||||
ValueOfType.Percentage
|
||||
};
|
||||
|
||||
if (inDto.DigitPlaces != -1)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
if (valueOfTypes.Contains(item.ValueType))
|
||||
{
|
||||
item.Answer = decimal.Round(decimal.Parse(item.Answer ?? "0"), inDto.DigitPlaces, MidpointRounding.AwayFromZero).ToString("F" + inDto.DigitPlaces.ToString());
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
needAddList.Add(new ReadingTaskQuestionAnswer()
|
||||
{
|
||||
Answer = item.Answer,
|
||||
ReadingQuestionTrialId = 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();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取脂肪分数平均值
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<decimal> GetFatFractionAvg(ReadingCalculateDto inDto)
|
||||
{
|
||||
decimal result = 0;
|
||||
var rowInfo = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.FatFraction).SelectMany(x => x.TableRowInfoList).ToList();
|
||||
|
||||
var tableQuestionList = rowInfo.SelectMany(x => x.TableQuestionList).ToList();
|
||||
|
||||
result = tableQuestionList.Where(x => x.QuestionMark == QuestionMark.AverageValue).Average(x => x.Answer.IsNullOrEmptyReturn0());
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算平均值
|
||||
|
|
|
@ -2691,6 +2691,11 @@ public enum SUVChangeVSBaseline
|
|||
/// 斑块3-匹配动脉段最小FCT
|
||||
/// </summary>
|
||||
Plaque3MinFCT = 1008,
|
||||
|
||||
/// <summary>
|
||||
/// 脂肪分数总平均值
|
||||
/// </summary>
|
||||
TotalMeanFraction = 1101,
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue