Merge branch 'Test_IRC_Net8' of http://192.168.3.68:2000/XCKJ/irc-netcore-api into Test_IRC_Net8
continuous-integration/drone/push Build is passing Details

IRC_NewDev
hang 2024-09-25 10:59:42 +08:00
commit cf9823c682
7 changed files with 282 additions and 17 deletions

View File

@ -3947,6 +3947,13 @@
<param name="calculateType"></param>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Service.ReadingCalculate.OCTCalculateService.CalculatePatchDataStatistics(IRaCIS.Core.Application.Service.Reading.Dto.ReadingCalculateDto)">
<summary>
计算斑块的统计数据
</summary>
<param name="inDto"></param>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Service.ReadingCalculate.OCTCalculateService.VerifyVisitTaskQuestions(IRaCIS.Core.Application.Service.Reading.Dto.VerifyVisitTaskQuestionsInDto)">
<summary>
验证访视提交

View File

@ -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>

View File

@ -1139,7 +1139,7 @@ namespace IRaCIS.Core.Application.Service
ReadingQestionType.BasicTable,
ReadingQestionType.Group,
};
qusetionList = qusetionList.Where(x => x.IsShowInDicom && types.Contains(x.Type)).OrderBy(x => x.ShowOrder).ToList();
qusetionList = qusetionList.Where(x => x.IsShowInDicom || types.Contains(x.Type)).OrderBy(x => x.ShowOrder).ToList();
if (inDto.TaskId != null)

View File

@ -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>()
{
@ -723,6 +724,8 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
}
await _readingTableAnswerRowInfoRepository.BatchDeleteNoTrackingAsync(x => x.QuestionId == questionInfo.Id && x.VisitTaskId == taskinfo.Id);
await _readingTableQuestionAnswerRepository.BatchDeleteNoTrackingAsync(x => x.QuestionId == questionInfo.Id && x.VisitTaskId == taskinfo.Id);
await _readingTableAnswerRowInfoRepository.AddRangeAsync(tableAnsweRowInfos);
await _readingTableQuestionAnswerRepository.AddRangeAsync(tableAnswers);
await _readingTableQuestionAnswerRepository.SaveChangesAsync();

View File

@ -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;
@ -21,6 +22,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
IRepository<SubjectVisit> _subjectVisitRepository,
IRepository<TumorAssessment_IRECIST1Point1> _tumorAssessmentRepository,
IGeneralCalculateService _generalCalculateService,
IVisitTaskHelpeService _visitTaskHelpeService,
IRepository<ReadingTaskQuestionAnswer> _readingTaskQuestionAnswerRepository,
ILogger<IRECIST1Point1CalculateService> _logger) : BaseService, ICriterionCalculateService
{
@ -432,6 +434,49 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
};
}
/// <summary>
/// 获取OCT-FCT模板
/// </summary>
/// <param name="inDto"></param>
/// <returns></returns>
[HttpPost]
public async Task<FileResult> GetOCTFCTTemplate(GetExportTemplateInDto inDto)
{
var taskinfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Include(x => x.Subject).FirstNotNullAsync();
var values = new
{
SubjectID = taskinfo.BlindSubjectCode.IsNullOrEmpty() ? taskinfo.Subject.Code : taskinfo.BlindSubjectCode,
TaskBlindName = taskinfo.TaskBlindName,
};
return await _visitTaskHelpeService.ExportTemplateAsync(new IRaCIS.Application.Contracts.ExportTemplateAsyncDto()
{
ExportFileName = "OCT_FCT_Template",
TemplateCode = StaticData.Export.OCT_FCT_Template,
Data = values
});
}
/// <summary>
/// 获取OCT-脂质角度模板
/// </summary>
/// <param name="inDto"></param>
/// <returns></returns>
[HttpPost]
public async Task<FileResult> GetOCTLipidAngleTemplate(GetExportTemplateInDto inDto)
{
var taskinfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Include(x => x.Subject).FirstNotNullAsync();
var values = new
{
SubjectID = taskinfo.BlindSubjectCode.IsNullOrEmpty() ? taskinfo.Subject.Code : taskinfo.BlindSubjectCode,
TaskBlindName = taskinfo.TaskBlindName,
};
return await _visitTaskHelpeService.ExportTemplateAsync(new IRaCIS.Application.Contracts.ExportTemplateAsyncDto()
{
ExportFileName = "OCT_LipidAngle_Template",
TemplateCode = StaticData.Export.OCT_LipidAngle_Template,
Data = values
});
}
/// <summary>
@ -446,20 +491,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},
@ -557,8 +601,199 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
}
/// <summary>
/// 计算斑块的统计数据
/// </summary>
/// <param name="inDto"></param>
/// <returns></returns>
public async Task CalculatePatchDataStatistics(ReadingCalculateDto inDto)
{
// 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>
/// 验证访视提交

View File

@ -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>
/// 脂质角度平均值

View File

@ -276,6 +276,10 @@ public static class StaticData
public const string IVUSTheMeasuredValueOfEachMatchedFragment = "IVUS_TheMeasuredValueOfEachMatchedFragment";
public const string OCT_FCT_Template = "OCT_FCT_Template";
public const string OCT_LipidAngle_Template = "OCT_LipidAngle_Template";
}