计算修改
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
1a3ebe1fc4
commit
e389c1e581
|
@ -234,6 +234,22 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public class OCTInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 斑块编号
|
||||
/// </summary>
|
||||
public int PlaqueNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 值
|
||||
/// </summary>
|
||||
public decimal Data { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 阅片计算Dto
|
||||
/// </summary>
|
||||
|
|
|
@ -460,6 +460,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
|||
|
||||
// 计算斑块数据统计和PVA数据
|
||||
await this.CalculatePatchDataStatisticsAndPVA(inDto);
|
||||
inDto = await _generalCalculateService.GetReadingCalculateDto(inDto.VisitTaskId);
|
||||
|
||||
List<ReadingCalculateData> calculateList = new List<ReadingCalculateData>()
|
||||
{
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using IRaCIS.Core.Application.ViewModel;
|
||||
using IRaCIS.Core.Domain.Share;
|
||||
using IRaCIS.Core.Infra.EFCore.Common;
|
||||
using MassTransit;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
|
@ -446,20 +447,19 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
|||
#region 计算 这里顺序非常重要 后面计算的值要依赖前面计算的结果
|
||||
var needAddList = new List<ReadingTaskQuestionAnswer>();
|
||||
|
||||
|
||||
// 计算斑块统计数据
|
||||
await this.CalculatePatchDataStatistics(inDto);
|
||||
inDto = await _generalCalculateService.GetReadingCalculateDto(inDto.VisitTaskId);
|
||||
List<ReadingCalculateData> calculateList = new List<ReadingCalculateData>()
|
||||
{
|
||||
//// 匹配动脉段最小FCT
|
||||
//new ReadingCalculateData (){QuestionType=QuestionType.MinFCT,GetDecimalNullFun=GetAllMinFCT},
|
||||
// 斑块1-匹配动脉段最小FCT
|
||||
new ReadingCalculateData (){QuestionType=QuestionType.Plaque1MinFCT,GetDecimalNullFun=GetPlaque1MinFCT},
|
||||
|
||||
// // 平均最小FCT
|
||||
// new ReadingCalculateData (){QuestionType=QuestionType.AverageMinFCT,GetDecimalNullFun=GetAvgMinFCT},
|
||||
// 斑块2-匹配动脉段最小FCT
|
||||
new ReadingCalculateData (){QuestionType=QuestionType.Plaque2MinFCT,GetDecimalNullFun=GetPlaque2MinFCT},
|
||||
|
||||
// // 脂质角度平均值
|
||||
// new ReadingCalculateData (){QuestionType=QuestionType.AvgLipidAngle,GetDecimalNullFun=GetAvgMinLipidAngle},
|
||||
|
||||
// // 脂质角度最大值
|
||||
// new ReadingCalculateData (){QuestionType=QuestionType.MaxLipidAngle,GetDecimalNullFun=GetAllMaxLipidAngle},
|
||||
// 斑块3-匹配动脉段最小FCT
|
||||
new ReadingCalculateData (){QuestionType=QuestionType.Plaque3MinFCT,GetDecimalNullFun=GetPlaque3MinFCT},
|
||||
|
||||
|
||||
|
||||
|
@ -567,12 +567,189 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
|
|||
// FCT 问题信息
|
||||
var fCTQuestionInfo = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.FCT).FirstOrDefault();
|
||||
|
||||
List<OCTInfo> oCTFCTInfos=new List<OCTInfo> ();
|
||||
|
||||
|
||||
foreach (var item in fCTQuestionInfo!.TableRowInfoList)
|
||||
{
|
||||
oCTFCTInfos.Add(new OCTInfo()
|
||||
{
|
||||
PlaqueNum = item.TableQuestionList.Where(x => x.QuestionMark == QuestionMark.PlaqueNumber).Select(x => int.Parse(x.Answer)).FirstOrDefault(),
|
||||
Data = item.TableQuestionList.Where(x => x.QuestionMark == QuestionMark.AvgFCT).Select(x => decimal.Parse(x.Answer)).FirstOrDefault(),
|
||||
});
|
||||
}
|
||||
|
||||
// 脂质角度 问题信息
|
||||
var lipidAngleQuestionInfo = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.LipidAngle).FirstOrDefault();
|
||||
List<OCTInfo> lipidAngleInfos = new List<OCTInfo>();
|
||||
foreach (var item in lipidAngleQuestionInfo!.TableRowInfoList)
|
||||
{
|
||||
lipidAngleInfos.Add(new OCTInfo()
|
||||
{
|
||||
PlaqueNum = item.TableQuestionList.Where(x => x.QuestionMark == QuestionMark.PlaqueNumber).Select(x => int.Parse(x.Answer)).FirstOrDefault(),
|
||||
Data = item.TableQuestionList.Where(x => x.QuestionMark == QuestionMark.LipidAngle).Select(x => decimal.Parse(x.Answer)).FirstOrDefault(),
|
||||
});
|
||||
}
|
||||
|
||||
// 所有的斑块编号
|
||||
var plaqueNumbers = oCTFCTInfos.Select(x => x.PlaqueNum).ToList().Union(lipidAngleInfos.Select(x => x.PlaqueNum).ToList()).Distinct().OrderBy(x => x).ToList();
|
||||
|
||||
List<ReadingTableAnswerRowInfo> tableAnsweRowInfos = new List<ReadingTableAnswerRowInfo>();
|
||||
List<ReadingTableQuestionAnswer> tableAnswers = new List<ReadingTableQuestionAnswer>();
|
||||
|
||||
// 斑块统计问题的Id
|
||||
var patchDataStatisticsInfo = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == inDto.TrialReadingCriterionId && x.LesionType == LesionType.PatchDataStatistics).FirstNotNullAsync();
|
||||
|
||||
// 斑块统计表格问题
|
||||
|
||||
var patchDataTableQuestion = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionId == patchDataStatisticsInfo.Id).ToListAsync();
|
||||
|
||||
#region 取小数
|
||||
string GetDigitPlacesData(string value)
|
||||
{
|
||||
if (inDto.DigitPlaces != -1)
|
||||
{
|
||||
value = decimal.Round(decimal.Parse(value ?? "0"), inDto.DigitPlaces).ToString("F" + inDto.DigitPlaces.ToString());
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
foreach (var item in plaqueNumbers)
|
||||
{
|
||||
var newRowId = NewId.NextGuid();
|
||||
|
||||
var thisnumTableRows = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.PatchDataStatistics).SelectMany(x => x.TableRowInfoList).Where(x => x.TableQuestionList.Any(y => y.QuestionMark == QuestionMark.PlaqueNumber && y.Answer == item.ToString())).ToList();
|
||||
|
||||
// 斑块数据统计
|
||||
tableAnsweRowInfos.Add(new ReadingTableAnswerRowInfo()
|
||||
{
|
||||
Id = newRowId,
|
||||
QuestionId = patchDataStatisticsInfo.Id,
|
||||
VisitTaskId = inDto.VisitTaskId,
|
||||
TrialId = inDto.TrialId,
|
||||
RowIndex = item,
|
||||
IsCurrentTaskAdd = true,
|
||||
BlindName = inDto.BlindName,
|
||||
OrderMark = patchDataStatisticsInfo.OrderMark,
|
||||
FristAddTaskNum = inDto.VisitTaskNum,
|
||||
FristAddTaskId = inDto.VisitTaskId,
|
||||
RowMark = patchDataStatisticsInfo.OrderMark + decimal.Parse(item.ToString()).GetLesionMark()
|
||||
});
|
||||
|
||||
|
||||
// 斑块编号
|
||||
tableAnswers.Add(new ReadingTableQuestionAnswer()
|
||||
{
|
||||
Answer = item.ToString(),
|
||||
Id = NewId.NextGuid(),
|
||||
QuestionId = patchDataStatisticsInfo.Id,
|
||||
TrialId = inDto.TrialId,
|
||||
VisitTaskId = inDto.VisitTaskId,
|
||||
RowId = newRowId,
|
||||
RowIndex = item,
|
||||
TableQuestionId = patchDataTableQuestion.Where(x => x.QuestionMark == QuestionMark.PlaqueNumber).Select(x => x.Id).FirstOrDefault(),
|
||||
});
|
||||
|
||||
|
||||
|
||||
// 匹配动脉段最小FCT
|
||||
tableAnswers.Add(new ReadingTableQuestionAnswer()
|
||||
{
|
||||
Answer = GetDigitPlacesData(oCTFCTInfos.Where(x => x.PlaqueNum == item).MinOrDefault(x => x.Data).ToString()),
|
||||
Id = NewId.NextGuid(),
|
||||
QuestionId = patchDataStatisticsInfo.Id,
|
||||
TrialId = inDto.TrialId,
|
||||
VisitTaskId = inDto.VisitTaskId,
|
||||
RowId = newRowId,
|
||||
RowIndex = item,
|
||||
TableQuestionId = patchDataTableQuestion.Where(x => x.QuestionMark == QuestionMark.MiniMumFCT).Select(x => x.Id).FirstOrDefault(),
|
||||
});
|
||||
|
||||
// 平均最小FCT
|
||||
tableAnswers.Add(new ReadingTableQuestionAnswer()
|
||||
{
|
||||
Answer = GetDigitPlacesData(oCTFCTInfos.Where(x => x.PlaqueNum == item).Average(x => x.Data).ToString()),
|
||||
Id = NewId.NextGuid(),
|
||||
QuestionId = patchDataStatisticsInfo.Id,
|
||||
TrialId = inDto.TrialId,
|
||||
VisitTaskId = inDto.VisitTaskId,
|
||||
RowId = newRowId,
|
||||
RowIndex = item,
|
||||
TableQuestionId = patchDataTableQuestion.Where(x => x.QuestionMark == QuestionMark.AvgMinFCT).Select(x => x.Id).FirstOrDefault(),
|
||||
});
|
||||
|
||||
// 脂质角度平均值
|
||||
tableAnswers.Add(new ReadingTableQuestionAnswer()
|
||||
{
|
||||
Answer = GetDigitPlacesData(lipidAngleInfos.Where(x => x.PlaqueNum == item).Average(x => x.Data).ToString()),
|
||||
Id = NewId.NextGuid(),
|
||||
QuestionId = patchDataStatisticsInfo.Id,
|
||||
TrialId = inDto.TrialId,
|
||||
VisitTaskId = inDto.VisitTaskId,
|
||||
RowId = newRowId,
|
||||
RowIndex = item,
|
||||
TableQuestionId = patchDataTableQuestion.Where(x => x.QuestionMark == QuestionMark.AvgLipidAngle).Select(x => x.Id).FirstOrDefault(),
|
||||
});
|
||||
|
||||
// 脂质角度最大值
|
||||
tableAnswers.Add(new ReadingTableQuestionAnswer()
|
||||
{
|
||||
Answer = GetDigitPlacesData(lipidAngleInfos.Where(x => x.PlaqueNum == item).MaxOrDefault(x => x.Data).ToString()),
|
||||
Id = NewId.NextGuid(),
|
||||
QuestionId = patchDataStatisticsInfo.Id,
|
||||
TrialId = inDto.TrialId,
|
||||
VisitTaskId = inDto.VisitTaskId,
|
||||
RowId = newRowId,
|
||||
RowIndex = item,
|
||||
TableQuestionId = patchDataTableQuestion.Where(x => x.QuestionMark == QuestionMark.MaxAvgLipidAngle).Select(x => x.Id).FirstOrDefault(),
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
await _readingTableAnswerRowInfoRepository.BatchDeleteNoTrackingAsync(x =>x.QuestionId== patchDataStatisticsInfo.Id && x.VisitTaskId == inDto.VisitTaskId);
|
||||
await _readingTableQuestionAnswerRepository.BatchDeleteNoTrackingAsync(x => x.QuestionId == patchDataStatisticsInfo.Id && x.VisitTaskId == inDto.VisitTaskId);
|
||||
await _readingTableAnswerRowInfoRepository.AddRangeAsync(tableAnsweRowInfos);
|
||||
await _readingTableQuestionAnswerRepository.AddRangeAsync(tableAnswers);
|
||||
await _readingTableQuestionAnswerRepository.SaveChangesAsync();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 斑块1-匹配动脉段最小FCT
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<decimal?> GetPlaque1MinFCT(ReadingCalculateDto inDto)
|
||||
{
|
||||
return inDto.QuestionInfo.Where(x => x.LesionType == LesionType.PatchDataStatistics).SelectMany(x => x.TableRowInfoList).Where(x => x.TableQuestionList.Any(y => y.QuestionMark == QuestionMark.PlaqueNumber && y.Answer.IsNullOrEmptyReturn0() == 1)).SelectMany(x => x.TableQuestionList)
|
||||
.Where(x => x.QuestionMark == QuestionMark.MiniMumFCT).Select(x => x.Answer).FirstIsNullReturnEmpty().IsNullOrEmptyReturn0();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 斑块2-匹配动脉段最小FCT
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<decimal?> GetPlaque2MinFCT(ReadingCalculateDto inDto)
|
||||
{
|
||||
return inDto.QuestionInfo.Where(x => x.LesionType == LesionType.PatchDataStatistics).SelectMany(x => x.TableRowInfoList).Where(x => x.TableQuestionList.Any(y => y.QuestionMark == QuestionMark.PlaqueNumber && y.Answer.IsNullOrEmptyReturn0() == 2)).SelectMany(x => x.TableQuestionList)
|
||||
.Where(x => x.QuestionMark == QuestionMark.MiniMumFCT).Select(x => x.Answer).FirstIsNullReturnEmpty().IsNullOrEmptyReturn0();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 斑块3-匹配动脉段最小FCT
|
||||
/// </summary>
|
||||
/// <param name="inDto"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<decimal?> GetPlaque3MinFCT(ReadingCalculateDto inDto)
|
||||
{
|
||||
return inDto.QuestionInfo.Where(x => x.LesionType == LesionType.PatchDataStatistics).SelectMany(x => x.TableRowInfoList).Where(x => x.TableQuestionList.Any(y => y.QuestionMark == QuestionMark.PlaqueNumber && y.Answer.IsNullOrEmptyReturn0() == 3)).SelectMany(x => x.TableQuestionList)
|
||||
.Where(x => x.QuestionMark == QuestionMark.MiniMumFCT).Select(x => x.Answer).FirstIsNullReturnEmpty().IsNullOrEmptyReturn0();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 验证访视提交
|
||||
|
|
|
@ -2115,11 +2115,11 @@ public enum SUVChangeVSBaseline
|
|||
/// FCT三次测量最小值
|
||||
/// </summary>
|
||||
MinFCT = 1014,
|
||||
|
||||
/// <summary>
|
||||
/// FCT三次测量平均值
|
||||
/// </summary>
|
||||
AvgMin=1015,
|
||||
|
||||
/// <summary>
|
||||
/// FCT三次测量平均值
|
||||
/// </summary>
|
||||
AvgFCT = 1015,
|
||||
|
||||
/// <summary>
|
||||
/// 脂质角度
|
||||
|
@ -2134,7 +2134,7 @@ public enum SUVChangeVSBaseline
|
|||
/// <summary>
|
||||
/// 平均最小FCT
|
||||
/// </summary>
|
||||
AvgMinFCT=1018,
|
||||
AvgMinFCT=1018,
|
||||
|
||||
/// <summary>
|
||||
/// 脂质角度平均值
|
||||
|
|
Loading…
Reference in New Issue