Compare commits

..

No commits in common. "67fd739b0e5f857738ec327f55d6f95a4bc8e30f" and "bbcab237d41f038e105787746945ff635f5b1478" have entirely different histories.

10 changed files with 252 additions and 643 deletions

View File

@ -29,11 +29,11 @@ public class TrialGlobalLimitActionFilter(IFusionCache _fusionCache, IUserInfo _
var requestHost = context.HttpContext.Request.Host;
// 检查请求是否来自 localhost:6100
if (requestHost.Host == "localhost" && (requestHost.Port == 6100 || requestHost.Port == 3305))
{
await next();
return;
}
//if (requestHost.Host == "localhost" && (requestHost.Port == 6100 || requestHost.Port == 3305))
//{
// await next();
// return;
//}
#region 特殊用户类型拦截
// 用户类型检查

View File

@ -4407,27 +4407,6 @@
<param name="inDto"></param>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Service.ReadingCalculate.IVUSCalculateService.GetEmmSum(IRaCIS.Core.Application.Service.Reading.Dto.ReadingCalculateDto)">
<summary>
获取EMM求和
</summary>
<param name="inDto"></param>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Service.ReadingCalculate.IVUSCalculateService.GetEEMLumenSum(IRaCIS.Core.Application.Service.Reading.Dto.ReadingCalculateDto)">
<summary>
(EEM-Lumen)求和
</summary>
<param name="inDto"></param>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Service.ReadingCalculate.IVUSCalculateService.GetPAV(IRaCIS.Core.Application.Service.Reading.Dto.ReadingCalculateDto)">
<summary>
PAV冠状动脉粥样硬化体积百分比)
</summary>
<param name="inDto"></param>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Service.ReadingCalculate.IVUSCalculateService.AddTaskLesionAnswerFromLastTask(IRaCIS.Core.Application.ViewModel.AddTaskLesionAnswerFromLastTaskInDto)">
<summary>
将上一次的访视病灶添加到这一次
@ -6005,62 +5984,6 @@
<param name="inDto"></param>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Service.ReadingCalculate.OCTCalculateService.GetMinFCT(IRaCIS.Core.Application.Service.Reading.Dto.ReadingCalculateDto)">
<summary>
匹配动脉段最小FCT (平均值的最小值)
</summary>
<param name="inDto"></param>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Service.ReadingCalculate.OCTCalculateService.GetAvgFCT(IRaCIS.Core.Application.Service.Reading.Dto.ReadingCalculateDto)">
<summary>
平均最小FCT (平均值的平均值)
</summary>
<param name="inDto"></param>
<returns></returns>
</member>
<member name="M:IRaCIS.Core.Application.Service.ReadingCalculate.OCTCalculateService.GetAvgLipidAngle(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.GetMaxLipidAngle(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.GetMacrophageInfiltration(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.GetMacrophageExtensionAngle(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.GetMicrochannels(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.GetCholesterolCrystallization(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>
验证访视提交
@ -8729,6 +8652,11 @@
IVUS测量值导入
</summary>
</member>
<member name="P:IRaCIS.Core.Application.Service.Reading.Dto.IVUSMeasuredValue.PlaqueNum">
<summary>
斑块编号
</summary>
</member>
<member name="P:IRaCIS.Core.Application.Service.Reading.Dto.IVUSMeasuredValue.Emm">
<summary>
外弹力膜面积Emm
@ -8744,6 +8672,11 @@
外弹力膜面积- 管腔面积
</summary>
</member>
<member name="P:IRaCIS.Core.Application.Service.Reading.Dto.OCTFCTUploadData.PlaqueNum">
<summary>
斑块编号
</summary>
</member>
<member name="P:IRaCIS.Core.Application.Service.Reading.Dto.OCTFCTUploadData.FirstData">
<summary>
第一次
@ -8784,11 +8717,6 @@
官腔面积测量
</summary>
</member>
<member name="P:IRaCIS.Core.Application.Service.Reading.Dto.OCTFCTUploadData.LipidAngle">
<summary>
脂质角度
</summary>
</member>
<member name="P:IRaCIS.Core.Application.Service.Reading.Dto.OCTInfo.PlaqueNum">
<summary>
斑块编号
@ -16862,17 +16790,17 @@
</member>
<member name="F:IRaCIS.Core.Application.ViewModel.AccessToDialogueEnum.Question">
<summary>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
质疑
</summary>
</member>
<member name="F:IRaCIS.Core.Application.ViewModel.AccessToDialogueEnum.Consistency">
<summary>
һ<EFBFBD><EFBFBD><EFBFBD>Ժ˲<EFBFBD>
一致性核查
</summary>
</member>
<member name="T:IRaCIS.Core.Application.ViewModel.CopyFrontAuditConfigItemDto">
<summary>
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
复制
</summary>
</member>
<member name="T:IRaCIS.Core.Application.ViewModel.SystemNoticeView">

View File

@ -703,10 +703,6 @@ public class QCClaimTaskEventConsumer(
var userinfo = subjectVisit.CurrentActionUser;
if (userinfo == null)
{
return;
}
var messageToSend = new MimeMessage();
//发件地址

View File

@ -939,8 +939,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
//存在ivus 和oct 这两种的项目
if (_readingQuestionCriterionTrialRepository.Where(t => t.TrialId == info.TrialId &&
(t.CriterionType == CriterionType.IVUS || t.CriterionType == CriterionType.OCT)).Distinct().Count() == 2
&& _noneDicomStudyReposiotry.Where(t => t.SubjectId == inQuery.SubjectId && t.Modality == "IVUS").Count() != _dicomStudyRepository.Where(t => t.SubjectId == inQuery.SubjectId).Select(t => t.SubjectVisitId).Distinct().Count()
)
&& !_noneDicomStudyReposiotry.Any(t => t.SubjectId == inQuery.SubjectId && t.Modality == "IVUS"))
{
#region ivus 自动创建非dicom检查
@ -958,7 +957,6 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
}).ToListAsync();
var noneDicomStudyVisitIdList = _noneDicomStudyReposiotry.Where(t => t.SubjectId == inQuery.SubjectId && t.Modality == "IVUS").Select(t => t.SubjectVisitId).ToList();
var @lock = _distributedLockProvider.CreateLock($"NoneDicomCode");
@ -969,12 +967,10 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
//默认会是0
var code = await _noneDicomStudyReposiotry.Where(t => t.TrialId == trialId).Select(x => x.Code).DefaultIfEmpty().MaxAsync();
foreach (var g in addList.Where(t => !noneDicomStudyVisitIdList.Contains(t.SubjectVisitId)).GroupBy(t => t.SubjectVisitId))
foreach (var g in addList.GroupBy(t => t.SubjectVisitId))
{
var addOrEditNoneDicomStudy = g.First();
var optEntity = await _noneDicomStudyReposiotry.InsertFromDTOAsync(addOrEditNoneDicomStudy);
optEntity.Code = code + 1;

View File

@ -8,7 +8,6 @@ using IRaCIS.Core.Application.Filter;
using IRaCIS.Core.Application.Service.Reading.Dto;
using IRaCIS.Core.Domain.Models;
using IRaCIS.Core.Domain.Share;
using IRaCIS.Core.Infrastructure;
using Medallion.Threading;
using Microsoft.AspNetCore.Mvc;
using NPOI.SS.Formula.Functions;
@ -115,7 +114,7 @@ namespace IRaCIS.Core.Application.Contracts
var list = await noneDicomStudyQueryable.Where(t => isFilterIVUSNoneDicom ? t.Modality != "IVUS" : true)
.OrderBy(x => x.ImageDate).ThenBy(x => x.CreateTime).ToListAsync();
var config = await _subjectVisitRepository.Where(t => t.Id == subjectVisitId).Select(t => new { t.Trial.ImageFormatList, t.Trial.StudyNameList, t.Trial.IsShowStudyName, AuditState = qcAuditState, CriterionType = criterionType }).FirstOrDefaultAsync();
var config = await _subjectVisitRepository.Where(t => t.Id == subjectVisitId).Select(t => new { t.Trial.ImageFormatList, t.Trial.StudyNameList, t.Trial.IsShowStudyName, AuditState = qcAuditState, CriterionType=criterionType }).FirstOrDefaultAsync();
return ResponseOutput.Ok(list, config);
}
@ -155,13 +154,6 @@ namespace IRaCIS.Core.Application.Contracts
{
if (addOrEditNoneDicomStudy.Id == Guid.Empty || addOrEditNoneDicomStudy.Id == null)
{
if (_subjectVisitRepository.Where(t => t.Id == addOrEditNoneDicomStudy.SubjectVisitId).SelectMany(t => t.Trial.TrialReadingCriterionList)
.Where(t => (t.CriterionType == CriterionType.IVUS || t.CriterionType == CriterionType.OCT) && t.IsConfirm).Distinct().Count() == 2 && addOrEditNoneDicomStudy.Modality != "OCT")
{
throw new BusinessValidationFailedException(_localizer["NoneDicomStudy_OnlyNeedOCT"]);
}
//默认会是0
var code = await _noneDicomStudyRepository.Where(t => t.TrialId == addOrEditNoneDicomStudy.TrialId).Select(x => x.Code).DefaultIfEmpty().MaxAsync();

View File

@ -208,10 +208,10 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
/// </summary>
public class IVUSMeasuredValue
{
///// <summary>
///// 斑块编号
///// </summary>
//public int PlaqueNum { get; set; }
/// <summary>
/// 斑块编号
/// </summary>
public int PlaqueNum { get; set; }
/// <summary>
/// 外弹力膜面积Emm
@ -244,6 +244,11 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
public class OCTFCTUploadData
{
/// <summary>
/// 斑块编号
/// </summary>
public int PlaqueNum { get; set; }
/// <summary>
/// 第一次
/// </summary>
@ -285,10 +290,7 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
/// </summary>
public decimal? LumenAreaMeasurement { get; set; }
/// <summary>
/// 脂质角度
/// </summary>
public decimal? LipidAngle { get; set; }
public decimal Avg { get {

View File

@ -11,7 +11,6 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.IdentityModel.Tokens;
using MiniExcelLibs;
using System;
namespace IRaCIS.Core.Application.Service.ReadingCalculate
{
@ -45,7 +44,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
switch (readingImportType)
{
case ReadingImportType.ROI:
case ReadingImportType.IVUS_MatchingSegment:
await UploadIVUSTemplate();
break;
}
@ -274,7 +273,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
/// <returns></returns>
public async Task ReadingCalculate(ReadingCalculateDto inDto, List<QuestionType>? calculateType = null)
{
#region 计算 这里顺序非常重要 后面计算的值要依赖前面计算的结果
var needAddList = new List<ReadingTaskQuestionAnswer>();
@ -285,34 +284,23 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
ComputationTrigger.SaveEICRFQuestions,
};
//if (!computationTriggers.Contains(inDto.ComputationTrigger))
//{
// // 计算斑块统计数据
// await this.CalculatePatchDataStatisticsAndPVA(inDto);
// inDto = await _generalCalculateService.GetReadingCalculateDto(inDto.VisitTaskId);
//}
if (!computationTriggers.Contains(inDto.ComputationTrigger))
{
// 计算斑块统计数据
await this.CalculatePatchDataStatisticsAndPVA(inDto);
inDto = await _generalCalculateService.GetReadingCalculateDto(inDto.VisitTaskId);
}
List<ReadingCalculateData> calculateList = new List<ReadingCalculateData>()
{
//// 斑块1-PAV
//new ReadingCalculateData (){QuestionType=QuestionType.Plaque1PVA,GetDecimalNullFun=GetPlaque1PVA},
// // 斑块2-PAV
//new ReadingCalculateData (){QuestionType=QuestionType.Plaque2PVA,GetDecimalNullFun=GetPlaque2PVA},
// // 斑块3-PAV
//new ReadingCalculateData (){QuestionType=QuestionType.Plaque3PVA,GetDecimalNullFun=GetPlaque3PVA},
// (EEM-Lumen)求和
new ReadingCalculateData (){QuestionType=QuestionType.EEMSum,GetDecimalNullFun=GetEmmSum},
// 斑块1-PAV
new ReadingCalculateData (){QuestionType=QuestionType.Plaque1PVA,GetDecimalNullFun=GetPlaque1PVA},
// 斑块2-PAV
new ReadingCalculateData (){QuestionType=QuestionType.EEMSubLumenSum,GetDecimalNullFun=GetEEMLumenSum},
// PAV冠状动脉粥样硬化体积百分比)
new ReadingCalculateData (){QuestionType=QuestionType.PAV,GetDecimalNullFun=GetPAV},
new ReadingCalculateData (){QuestionType=QuestionType.Plaque2PVA,GetDecimalNullFun=GetPlaque2PVA},
// 斑块3-PAV
new ReadingCalculateData (){QuestionType=QuestionType.Plaque3PVA,GetDecimalNullFun=GetPlaque3PVA},
@ -483,9 +471,9 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
{
iVUSMeasuredValue = new IVUSMeasuredValue()
{
//PlaqueNum = int.Parse(dataTable.Rows[i]["A"].ToString()),
Emm = getdecimalData(dataTable.Rows[i]["A"].ToString()),
Lumen = getdecimalData(dataTable.Rows[i]["B"].ToString()),
PlaqueNum = int.Parse(dataTable.Rows[i]["A"].ToString()),
Emm = getdecimalData(dataTable.Rows[i]["B"].ToString()),
Lumen = getdecimalData(dataTable.Rows[i]["C"].ToString()),
};
}
catch (Exception)
@ -506,15 +494,15 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
var errorRows= string.Join(',', errorRow.Select(i => i.ToString()));
throw new BusinessValidationFailedException(_localizer["Service_TemplateException", errorRows]);
}
//List<int> nums = new List<int>() { 1, 2, 3 };
//if (measuredValueList.Any(x => !nums.Contains(x.PlaqueNum)))
//{
// throw new BusinessValidationFailedException(_localizer["IVUSOCT_PlaqueNum123"]);
//}
//measuredValueList = measuredValueList.OrderBy(x => x.PlaqueNum).ToList();
List<int> nums = new List<int>() { 1, 2, 3 };
if (measuredValueList.Any(x => !nums.Contains(x.PlaqueNum)))
{
throw new BusinessValidationFailedException(_localizer["IVUSOCT_PlaqueNum123"]);
}
measuredValueList = measuredValueList.OrderBy(x => x.PlaqueNum).ToList();
var questionInfo = await _readingQuestionTrialRepository.Where(x =>x.ReadingQuestionCriterionTrialId == taskinfo.TrialReadingCriterionId&& x.LesionType == LesionType.ROI).FirstNotNullAsync();
var questionInfo = await _readingQuestionTrialRepository.Where(x =>x.ReadingQuestionCriterionTrialId == taskinfo.TrialReadingCriterionId&& x.LesionType == LesionType.MatchValues).FirstNotNullAsync();
var tableQuestionList = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionId == questionInfo.Id).ToListAsync();
List<ReadingTableAnswerRowInfo> tableAnsweRowInfos = new List<ReadingTableAnswerRowInfo>();
List<ReadingTableQuestionAnswer> tableAnswers = new List<ReadingTableQuestionAnswer>();
@ -542,16 +530,16 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
});
// 编号
//tableAnswers.Add(new ReadingTableQuestionAnswer()
//{
// Answer = item.PlaqueNum.ToString(),
// QuestionId = questionInfo.Id,
// TrialId = taskinfo.TrialId,
// VisitTaskId = taskinfo.Id,
// RowId = newRowId,
// RowIndex = maxnum,
// TableQuestionId = tableQuestionList.Where(x => x.ReadingQuestionId == questionInfo.Id && x.QuestionMark == QuestionMark.PlaqueNumber).Select(x => x.Id).FirstOrDefault(),
//});
tableAnswers.Add(new ReadingTableQuestionAnswer()
{
Answer = item.PlaqueNum.ToString(),
QuestionId = questionInfo.Id,
TrialId = taskinfo.TrialId,
VisitTaskId = taskinfo.Id,
RowId = newRowId,
RowIndex = maxnum,
TableQuestionId = tableQuestionList.Where(x => x.ReadingQuestionId == questionInfo.Id && x.QuestionMark == QuestionMark.PlaqueNumber).Select(x => x.Id).FirstOrDefault(),
});
var emm = item.Emm.ToString();
var lumen=item.Lumen.ToString();
@ -645,7 +633,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
// 测量值集合
var matchValuesAnswerList = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.ROI).SelectMany(x => x.TableRowInfoList).ToList();
var matchValuesAnswerList = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.MatchValues).SelectMany(x => x.TableRowInfoList).ToList();
// 获取编号
var nums = matchValuesAnswerList.SelectMany(x => x.TableQuestionList).Where(x => x.QuestionMark == QuestionMark.PlaqueNumber).Select(x => int.Parse(x.Answer)).Distinct().OrderBy(x => x).ToList();
@ -663,7 +651,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
{
var newRowId = NewId.NextGuid();
var thisnumTableRows = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.ROI).SelectMany(x => x.TableRowInfoList).Where(x => x.TableQuestionList.Any(y => y.QuestionMark == QuestionMark.PlaqueNumber && y.Answer == item.ToString())).ToList();
var thisnumTableRows = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.MatchValues).SelectMany(x => x.TableRowInfoList).Where(x => x.TableQuestionList.Any(y => y.QuestionMark == QuestionMark.PlaqueNumber && y.Answer == item.ToString())).ToList();
// 斑块数据统计
tableAnsweRowInfos.Add(new ReadingTableAnswerRowInfo()
@ -846,7 +834,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
{
var taskinfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Include(x => x.Subject).Include(x => x.TrialReadingCriterion).FirstNotNullAsync();
var question = await _readingQuestionTrialRepository.Where(x => x.LesionType == LesionType.ROI && x.ReadingQuestionCriterionTrialId == taskinfo.TrialReadingCriterionId).FirstNotNullAsync();
var question = await _readingQuestionTrialRepository.Where(x => x.LesionType == LesionType.PAV && x.ReadingQuestionCriterionTrialId == taskinfo.TrialReadingCriterionId).FirstNotNullAsync();
var tableQuestions = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionId == question.Id)
@ -903,52 +891,6 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
.Where(x => x.QuestionMark == QuestionMark.PAV).Select(x => x.Answer).FirstIsNullReturnEmpty().IsNullOrEmptyReturnNull();
}
/// <summary>
/// 获取EMM求和
/// </summary>
/// <param name="inDto"></param>
/// <returns></returns>
public async Task<decimal?> GetEmmSum(ReadingCalculateDto inDto)
{
return inDto.QuestionInfo.Where(x => x.LesionType == LesionType.ROI).SelectMany(x => x.TableRowInfoList).SelectMany(x => x.TableQuestionList)
.Where(x => x.QuestionMark == QuestionMark.ElasticArea).Select(x => x.Answer.IsNullOrEmptyReturn0()).Sum();
}
/// <summary>
/// (EEM-Lumen)求和
/// </summary>
/// <param name="inDto"></param>
/// <returns></returns>
public async Task<decimal?> GetEEMLumenSum(ReadingCalculateDto inDto)
{
var emm = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.ROI).SelectMany(x => x.TableRowInfoList).SelectMany(x => x.TableQuestionList)
.Where(x => x.QuestionMark == QuestionMark.ElasticArea).Select(x => x.Answer.IsNullOrEmptyReturn0()).Sum();
var lumen = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.ROI).SelectMany(x => x.TableRowInfoList).SelectMany(x => x.TableQuestionList)
.Where(x => x.QuestionMark == QuestionMark.LumenArea).Select(x => x.Answer.IsNullOrEmptyReturn0()).Sum();
return emm - lumen;
}
/// <summary>
/// PAV冠状动脉粥样硬化体积百分比)
/// </summary>
/// <param name="inDto"></param>
/// <returns></returns>
public async Task<decimal?> GetPAV(ReadingCalculateDto inDto)
{
var eEMLumenSum = inDto.QuestionInfo.Where(x => x.QuestionType == QuestionType.EEMSubLumenSum).Select(x => x.Answer).FirstOrDefault().IsNullOrEmptyReturn0();
var eEMSum = inDto.QuestionInfo.Where(x => x.QuestionType == QuestionType.EEMSum).Select(x => x.Answer).FirstOrDefault().IsNullOrEmptyReturn0();
decimal pav = 0;
if (eEMSum != 0)
{
pav = eEMLumenSum * 100 / eEMSum;
}
return pav;
}
///// <summary>
///// 计算NTAV的EEM

View File

@ -1,10 +1,6 @@
using DocumentFormat.OpenXml.Drawing.Diagrams;
using DocumentFormat.OpenXml.Drawing.Spreadsheet;
using DocumentFormat.OpenXml.Office.SpreadSheetML.Y2023.MsForms;
using DocumentFormat.OpenXml.Office2010.Excel;
using IRaCIS.Core.Application.Service.Reading.Dto;
using IRaCIS.Core.Application.ViewModel;
using IRaCIS.Core.Domain.Models;
using IRaCIS.Core.Domain.Share;
using IRaCIS.Core.Infra.EFCore.Common;
using IRaCIS.Core.Infrastructure;
@ -44,7 +40,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
switch (readingImportType)
{
case ReadingImportType.ROI:
case ReadingImportType.OCT_FCT:
await UploadOCTFCTTemplate();
break;
@ -336,33 +332,21 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
List<OCTFCTUploadData> measuredValueList = new List<OCTFCTUploadData>();
var errorRow = new List<int> { };
string getNone(string value)
{
if (value == string.Empty || value == null)
{
return "无";
}
else
{
return value;
}
}
for (int i = 3; i < dataTable.Rows.Count; i++)
{
try
{
measuredValueList.Add(new OCTFCTUploadData()
{
//PlaqueNum = int.Parse(dataTable.Rows[i]["A"].ToString()),
FirstData = getdecimalData(dataTable.Rows[i]["A"].ToString()),
SecondData = getdecimalData(dataTable.Rows[i]["B"].ToString()),
ThirdData = getdecimalData(dataTable.Rows[i]["C"].ToString()),
MacrophageInfiltrationMeasurement = getNone(dataTable.Rows[i]["D"].ToString()),
MacrophageInfiltrationAngle = getdecimalEmptyData(dataTable.Rows[i]["E"].ToString() ?? string.Empty),
MicrochannelMeasurement = getNone(dataTable.Rows[i]["F"].ToString()),
CholesterolCrystalMeasurement = getNone(dataTable.Rows[i]["G"].ToString()),
LumenAreaMeasurement = getdecimalData(dataTable.Rows[i]["H"].ToString()),
LipidAngle = getdecimalEmptyData(dataTable.Rows[i]["I"].ToString() ?? string.Empty),
PlaqueNum = int.Parse(dataTable.Rows[i]["A"].ToString()),
FirstData = getdecimalData(dataTable.Rows[i]["B"].ToString()),
SecondData = getdecimalData(dataTable.Rows[i]["C"].ToString()),
ThirdData = getdecimalData(dataTable.Rows[i]["D"].ToString()),
MacrophageInfiltrationMeasurement = dataTable.Rows[i]["E"].ToString() ?? string.Empty,
MacrophageInfiltrationAngle = getdecimalEmptyData(dataTable.Rows[i]["F"].ToString() ?? string.Empty),
MicrochannelMeasurement =dataTable.Rows[i]["G"].ToString() ?? string.Empty,
CholesterolCrystalMeasurement = dataTable.Rows[i]["H"].ToString() ?? string.Empty,
LumenAreaMeasurement = getdecimalEmptyData(dataTable.Rows[i]["I"].ToString() ?? string.Empty),
});
}
catch (Exception)
@ -372,7 +356,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
}
}
measuredValueList = measuredValueList.OrderBy(x => x.PlaqueNum).ToList();
@ -382,6 +366,12 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
throw new BusinessValidationFailedException(_localizer["Service_TemplateException", errorRows]);
}
List<int> nums = new List<int>() { 1, 2, 3 };
if (measuredValueList.Any(x => !nums.Contains(x.PlaqueNum)))
{
throw new BusinessValidationFailedException(_localizer["IVUSOCT_PlaqueNum123"]);
}
Dictionary<string, string> isPresent = new Dictionary<string, string>()
{
{ "有","1"},
@ -423,7 +413,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
throw new BusinessValidationFailedException(_localizer["Service_TemplateException", errorRows]);
}
var questionInfo = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == taskinfo.TrialReadingCriterionId && x.LesionType == LesionType.ROI).FirstNotNullAsync();
var questionInfo = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == taskinfo.TrialReadingCriterionId && x.LesionType == LesionType.FCT).FirstNotNullAsync();
var tableQuestionList = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionId == questionInfo.Id).ToListAsync();
List<ReadingTableAnswerRowInfo> tableAnsweRowInfos = new List<ReadingTableAnswerRowInfo>();
List<ReadingTableQuestionAnswer> tableAnswers = new List<ReadingTableQuestionAnswer>();
@ -452,16 +442,16 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
});
// 编号
//tableAnswers.Add(new ReadingTableQuestionAnswer()
//{
// Answer = item.PlaqueNum.ToString(),
// QuestionId = questionInfo.Id,
// TrialId = taskinfo.TrialId,
// VisitTaskId = taskinfo.Id,
// RowId = newRowId,
// RowIndex = maxnum,
// TableQuestionId = tableQuestionList.Where(x => x.ReadingQuestionId == questionInfo.Id && x.QuestionMark == QuestionMark.PlaqueNumber).Select(x => x.Id).FirstOrDefault(),
//});
tableAnswers.Add(new ReadingTableQuestionAnswer()
{
Answer = item.PlaqueNum.ToString(),
QuestionId = questionInfo.Id,
TrialId = taskinfo.TrialId,
VisitTaskId = taskinfo.Id,
RowId = newRowId,
RowIndex = maxnum,
TableQuestionId = tableQuestionList.Where(x => x.ReadingQuestionId == questionInfo.Id && x.QuestionMark == QuestionMark.PlaqueNumber).Select(x => x.Id).FirstOrDefault(),
});
var avg = item.Avg.ToString();
@ -580,18 +570,6 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
TableQuestionId = tableQuestionList.Where(x => x.ReadingQuestionId == questionInfo.Id && x.QuestionMark == QuestionMark.LumenAreaMeasurement).Select(x => x.Id).FirstOrDefault(),
});
// 脂质角度
tableAnswers.Add(new ReadingTableQuestionAnswer()
{
Answer = item.LipidAngle.ToString(),
QuestionId = questionInfo.Id,
TrialId = taskinfo.TrialId,
VisitTaskId = taskinfo.Id,
RowId = newRowId,
RowIndex = maxnum,
TableQuestionId = tableQuestionList.Where(x => x.ReadingQuestionId == questionInfo.Id && x.QuestionMark == QuestionMark.LipidAngle).Select(x => x.Id).FirstOrDefault(),
});
}
catch (Exception)
{
@ -658,176 +636,173 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
[HttpPost]
public async Task UploadOCTLipidAngleTemplate()
{
#region 这个导入没有了 代码全部注释
//var request = httpContext.HttpContext!.Request;
//var file = request.Form.Files[0];
//Guid visitTaskId = Guid.Parse(request.Form["VisitTaskId"]);
//var taskinfo = await _visitTaskRepository.Where(x => x.Id == visitTaskId).Include(x => x.Subject).Include(x => x.TrialReadingCriterion).FirstNotNullAsync();
//var uploadInfo = await _generalCalculateService.GetDataTableFromUpload(file, "OCTLipidAngle", taskinfo.TrialId);
//List<string> sheetNames = new List<string>()
//{
// "脂质角度","LipidAngle"
//};
var request = httpContext.HttpContext!.Request;
var file = request.Form.Files[0];
Guid visitTaskId = Guid.Parse(request.Form["VisitTaskId"]);
var taskinfo = await _visitTaskRepository.Where(x => x.Id == visitTaskId).Include(x => x.Subject).Include(x => x.TrialReadingCriterion).FirstNotNullAsync();
var uploadInfo = await _generalCalculateService.GetDataTableFromUpload(file, "OCTLipidAngle", taskinfo.TrialId);
List<string> sheetNames = new List<string>()
{
"脂质角度","LipidAngle"
};
//if (sheetNames.Intersect(uploadInfo.SheetNames).Count() == 0)
//{
// throw new BusinessValidationFailedException(_localizer["IVUS_UplpadDataError"]);
//}
//var dataTable = uploadInfo.DataTable;
if (sheetNames.Intersect(uploadInfo.SheetNames).Count() == 0)
{
throw new BusinessValidationFailedException(_localizer["IVUS_UplpadDataError"]);
}
var dataTable = uploadInfo.DataTable;
//var values = new TemplateData()
//{
// SubjectID = taskinfo.BlindSubjectCode.IsNullOrEmpty() ? taskinfo.Subject.Code : taskinfo.BlindSubjectCode,
// TaskBlindName = taskinfo.TaskBlindName,
//};
var values = new TemplateData()
{
SubjectID = taskinfo.BlindSubjectCode.IsNullOrEmpty() ? taskinfo.Subject.Code : taskinfo.BlindSubjectCode,
TaskBlindName = taskinfo.TaskBlindName,
};
//if (values.SubjectID != dataTable.Rows[0]["B"].ToString() || values.TaskBlindName != dataTable.Rows[1]["B"].ToString())
//{
// throw new BusinessValidationFailedException(_localizer["IVUS_UploadVisitTaskError"]);
//}
if (values.SubjectID != dataTable.Rows[0]["B"].ToString() || values.TaskBlindName != dataTable.Rows[1]["B"].ToString())
{
throw new BusinessValidationFailedException(_localizer["IVUS_UploadVisitTaskError"]);
}
//var digitPlaces = taskinfo.TrialReadingCriterion.DigitPlaces ?? 0;
//decimal getdecimalData(string value)
//{
// return decimal.Parse(decimal.Round(decimal.Parse(value ?? "0"), digitPlaces, MidpointRounding.AwayFromZero).ToString("F" + digitPlaces.ToString()));
//}
//;
var digitPlaces = taskinfo.TrialReadingCriterion.DigitPlaces ?? 0;
decimal getdecimalData(string value)
{
return decimal.Parse(decimal.Round(decimal.Parse(value ?? "0"), digitPlaces, MidpointRounding.AwayFromZero).ToString("F" + digitPlaces.ToString()));
}
;
//List<OCTFCTUploadData> measuredValueList = new List<OCTFCTUploadData>();
//var errorRow = new List<int> { };
List<OCTFCTUploadData> measuredValueList = new List<OCTFCTUploadData>();
var errorRow = new List<int> { };
//for (int i = 3; i < dataTable.Rows.Count; i++)
//{
// try
// {
// measuredValueList.Add(new OCTFCTUploadData()
// {
// PlaqueNum = int.Parse(dataTable.Rows[i]["A"].ToString()),
// FirstData = getdecimalData(dataTable.Rows[i]["B"].ToString()),
for (int i = 3; i < dataTable.Rows.Count; i++)
{
try
{
measuredValueList.Add(new OCTFCTUploadData()
{
PlaqueNum = int.Parse(dataTable.Rows[i]["A"].ToString()),
FirstData = getdecimalData(dataTable.Rows[i]["B"].ToString()),
// });
// }
// catch (Exception)
// {
});
}
catch (Exception)
{
// errorRow.Add(i + 1);
// }
errorRow.Add(i+1);
}
//}
}
//measuredValueList = measuredValueList.OrderBy(x => x.PlaqueNum).ToList();
measuredValueList = measuredValueList.OrderBy(x => x.PlaqueNum).ToList();
//if (errorRow.Count() > 0)
//{
// var errorRows = string.Join(',', errorRow.Select(i => i.ToString()));
// throw new BusinessValidationFailedException(_localizer["Service_TemplateException", errorRows]);
//}
if (errorRow.Count() > 0)
{
var errorRows = string.Join(',', errorRow.Select(i => i.ToString()));
throw new BusinessValidationFailedException(_localizer["Service_TemplateException", errorRows]);
}
//List<int> nums = new List<int>() { 1, 2, 3 };
//if (measuredValueList.Any(x => !nums.Contains(x.PlaqueNum)))
//{
// throw new BusinessValidationFailedException(_localizer["IVUSOCT_PlaqueNum123"]);
//}
List<int> nums = new List<int>() { 1, 2, 3 };
if (measuredValueList.Any(x => !nums.Contains(x.PlaqueNum)))
{
throw new BusinessValidationFailedException(_localizer["IVUSOCT_PlaqueNum123"]);
}
//foreach (var item in measuredValueList)
//{
// if (item.FirstData > 360)
// {
// throw new BusinessValidationFailedException(_localizer["IVUS_LipidAngleLess360"]);
// }
//}
foreach (var item in measuredValueList)
{
if (item.FirstData > 360)
{
throw new BusinessValidationFailedException(_localizer["IVUS_LipidAngleLess360"]);
}
}
//var questionInfo = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == taskinfo.TrialReadingCriterionId && x.LesionType == LesionType.LipidAngle).FirstNotNullAsync();
//var tableQuestionList = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionId == questionInfo.Id).ToListAsync();
//List<ReadingTableAnswerRowInfo> tableAnsweRowInfos = new List<ReadingTableAnswerRowInfo>();
//List<ReadingTableQuestionAnswer> tableAnswers = new List<ReadingTableQuestionAnswer>();
var questionInfo = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == taskinfo.TrialReadingCriterionId && x.LesionType == LesionType.LipidAngle).FirstNotNullAsync();
var tableQuestionList = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionId == questionInfo.Id).ToListAsync();
List<ReadingTableAnswerRowInfo> tableAnsweRowInfos = new List<ReadingTableAnswerRowInfo>();
List<ReadingTableQuestionAnswer> tableAnswers = new List<ReadingTableQuestionAnswer>();
//var maxnum = 0;
var maxnum = 0;
//foreach (var item in measuredValueList)
//{
// maxnum = maxnum + 1;
// var newRowId = NewId.NextGuid();
// // 斑块数据统计
// tableAnsweRowInfos.Add(new ReadingTableAnswerRowInfo()
// {
// Id = newRowId,
// QuestionId = questionInfo.Id,
// VisitTaskId = taskinfo.Id,
// TrialId = taskinfo.TrialId,
// RowIndex = maxnum,
// IsCurrentTaskAdd = true,
// BlindName = taskinfo.TaskBlindName,
// OrderMark = questionInfo.OrderMark,
// FristAddTaskId = taskinfo.Id,
// RowMark = questionInfo.OrderMark + decimal.Parse(maxnum.ToString()).GetLesionMark()
// });
foreach (var item in measuredValueList)
{
maxnum = maxnum + 1;
var newRowId = NewId.NextGuid();
// 斑块数据统计
tableAnsweRowInfos.Add(new ReadingTableAnswerRowInfo()
{
Id = newRowId,
QuestionId = questionInfo.Id,
VisitTaskId = taskinfo.Id,
TrialId = taskinfo.TrialId,
RowIndex = maxnum,
IsCurrentTaskAdd = true,
BlindName = taskinfo.TaskBlindName,
OrderMark = questionInfo.OrderMark,
FristAddTaskId = taskinfo.Id,
RowMark = questionInfo.OrderMark + decimal.Parse(maxnum.ToString()).GetLesionMark()
});
// // 编号
// tableAnswers.Add(new ReadingTableQuestionAnswer()
// {
// Answer = item.PlaqueNum.ToString(),
// QuestionId = questionInfo.Id,
// TrialId = taskinfo.TrialId,
// VisitTaskId = taskinfo.Id,
// RowId = newRowId,
// RowIndex = maxnum,
// TableQuestionId = tableQuestionList.Where(x => x.ReadingQuestionId == questionInfo.Id && x.QuestionMark == QuestionMark.PlaqueNumber).Select(x => x.Id).FirstOrDefault(),
// });
// 编号
tableAnswers.Add(new ReadingTableQuestionAnswer()
{
Answer = item.PlaqueNum.ToString(),
QuestionId = questionInfo.Id,
TrialId = taskinfo.TrialId,
VisitTaskId = taskinfo.Id,
RowId = newRowId,
RowIndex = maxnum,
TableQuestionId = tableQuestionList.Where(x => x.ReadingQuestionId == questionInfo.Id && x.QuestionMark == QuestionMark.PlaqueNumber).Select(x => x.Id).FirstOrDefault(),
});
// var avg = item.Avg.ToString();
var avg = item.Avg.ToString();
// if (taskinfo.TrialReadingCriterion.DigitPlaces != -1)
// {
// avg = decimal.Round(decimal.Parse(avg ?? "0"), digitPlaces, MidpointRounding.AwayFromZero).ToString("F" + digitPlaces.ToString());
if (taskinfo.TrialReadingCriterion.DigitPlaces != -1)
{
avg = decimal.Round(decimal.Parse(avg ?? "0"), digitPlaces, MidpointRounding.AwayFromZero).ToString("F" + digitPlaces.ToString());
// }
}
// // 脂质角度
// tableAnswers.Add(new ReadingTableQuestionAnswer()
// {
// Answer = item.FirstData.ToString(),
// QuestionId = questionInfo.Id,
// TrialId = taskinfo.TrialId,
// VisitTaskId = taskinfo.Id,
// RowId = newRowId,
// RowIndex = maxnum,
// TableQuestionId = tableQuestionList.Where(x => x.ReadingQuestionId == questionInfo.Id && x.QuestionMark == QuestionMark.LipidAngle).Select(x => x.Id).FirstOrDefault(),
// });
// 脂质角度
tableAnswers.Add(new ReadingTableQuestionAnswer()
{
Answer = item.FirstData.ToString(),
QuestionId = questionInfo.Id,
TrialId = taskinfo.TrialId,
VisitTaskId = taskinfo.Id,
RowId = newRowId,
RowIndex = maxnum,
TableQuestionId = tableQuestionList.Where(x => x.ReadingQuestionId == questionInfo.Id && x.QuestionMark == QuestionMark.LipidAngle).Select(x => x.Id).FirstOrDefault(),
});
// // 添加其他问题答案
// foreach (var otherQuestion in tableQuestionList.Where(x => !tableAnswers.Any(y => y.TableQuestionId == x.Id && y.RowId == newRowId)))
// {
// tableAnswers.Add(new ReadingTableQuestionAnswer()
// {
// Answer = string.Empty,
// QuestionId = questionInfo.Id,
// TrialId = taskinfo.TrialId,
// VisitTaskId = taskinfo.Id,
// RowId = newRowId,
// RowIndex = maxnum,
// TableQuestionId = otherQuestion.Id,
// });
// }
//}
//await _readingTableAnswerRowInfoRepository.DeleteFromQueryAsync(x => x.QuestionId == questionInfo.Id && x.VisitTaskId == taskinfo.Id);
//await _readingTableQuestionAnswerRepository.DeleteFromQueryAsync(x => x.QuestionId == questionInfo.Id && x.VisitTaskId == taskinfo.Id);
//await _readingTableQuestionAnswerRepository.SaveChangesAsync();
//await _readingTableAnswerRowInfoRepository.AddRangeAsync(tableAnsweRowInfos);
//await _readingTableQuestionAnswerRepository.AddRangeAsync(tableAnswers);
//await _readingTableQuestionAnswerRepository.SaveChangesAsync();
// 添加其他问题答案
foreach (var otherQuestion in tableQuestionList.Where(x => !tableAnswers.Any(y => y.TableQuestionId == x.Id && y.RowId == newRowId)))
{
tableAnswers.Add(new ReadingTableQuestionAnswer()
{
Answer = string.Empty,
QuestionId = questionInfo.Id,
TrialId = taskinfo.TrialId,
VisitTaskId = taskinfo.Id,
RowId = newRowId,
RowIndex = maxnum,
TableQuestionId = otherQuestion.Id,
});
}
}
await _readingTableAnswerRowInfoRepository.DeleteFromQueryAsync(x => x.QuestionId == questionInfo.Id && x.VisitTaskId == taskinfo.Id);
await _readingTableQuestionAnswerRepository.DeleteFromQueryAsync(x => x.QuestionId == questionInfo.Id && x.VisitTaskId == taskinfo.Id);
await _readingTableQuestionAnswerRepository.SaveChangesAsync();
await _readingTableAnswerRowInfoRepository.AddRangeAsync(tableAnsweRowInfos);
await _readingTableQuestionAnswerRepository.AddRangeAsync(tableAnswers);
await _readingTableQuestionAnswerRepository.SaveChangesAsync();
//await this.CalculateTask(new CalculateTaskInDto()
//{
// VisitTaskId = taskinfo.Id,
//});
#endregion
await this.CalculateTask(new CalculateTaskInDto()
{
VisitTaskId = taskinfo.Id,
});
}
@ -849,48 +824,23 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
ComputationTrigger.SaveEICRFQuestions,
};
//if (!computationTriggers.Contains(inDto.ComputationTrigger))
//{
// // 计算斑块统计数据
// await this.CalculatePatchDataStatistics(inDto);
// inDto = await _generalCalculateService.GetReadingCalculateDto(inDto.VisitTaskId);
//}
if (!computationTriggers.Contains(inDto.ComputationTrigger))
{
// 计算斑块统计数据
await this.CalculatePatchDataStatistics(inDto);
inDto = await _generalCalculateService.GetReadingCalculateDto(inDto.VisitTaskId);
}
List<ReadingCalculateData> calculateList = new List<ReadingCalculateData>()
{
//// 斑块1-匹配动脉段最小FCT
//new ReadingCalculateData (){QuestionType=QuestionType.Plaque1MinFCT,GetDecimalNullFun=GetPlaque1MinFCT},
// 斑块1-匹配动脉段最小FCT
new ReadingCalculateData (){QuestionType=QuestionType.Plaque1MinFCT,GetDecimalNullFun=GetPlaque1MinFCT},
// // 斑块2-匹配动脉段最小FCT
//new ReadingCalculateData (){QuestionType=QuestionType.Plaque2MinFCT,GetDecimalNullFun=GetPlaque2MinFCT},
// 斑块2-匹配动脉段最小FCT
new ReadingCalculateData (){QuestionType=QuestionType.Plaque2MinFCT,GetDecimalNullFun=GetPlaque2MinFCT},
// // 斑块3-匹配动脉段最小FCT
//new ReadingCalculateData (){QuestionType=QuestionType.Plaque3MinFCT,GetDecimalNullFun=GetPlaque3MinFCT},
// 匹配动脉段最小FCT
new ReadingCalculateData (){QuestionType=QuestionType.MatchingTheMinimumFCT,GetDecimalNullFun=GetMinFCT},
// 平均最小FCT
new ReadingCalculateData (){QuestionType=QuestionType.AvgMinFCT,GetDecimalNullFun=GetAvgFCT},
// 脂质角度平均值
new ReadingCalculateData (){QuestionType=QuestionType.AvgLipidAngle,GetDecimalNullFun=GetAvgLipidAngle},
// 脂质角度最大值
new ReadingCalculateData (){QuestionType=QuestionType.MaxLipidAngle,GetDecimalNullFun=GetMaxLipidAngle},
//巨噬细胞浸润测量
new ReadingCalculateData (){QuestionType=QuestionType.MacrophageInfiltrationMeasurement,GetStringFun=GetMacrophageInfiltration},
//巨噬细胞浸润角度测量
new ReadingCalculateData (){QuestionType=QuestionType.MacrophageInfiltrationAngle,GetStringFun=GetMacrophageExtensionAngle},
//微通道测量
new ReadingCalculateData (){QuestionType=QuestionType.MicrochannelMeasurement,GetStringFun=GetMicrochannels},
//胆固醇结晶测量
new ReadingCalculateData (){QuestionType=QuestionType.CholesterolCrystalMeasurement,GetStringFun=GetCholesterolCrystallization},
// 斑块3-匹配动脉段最小FCT
new ReadingCalculateData (){QuestionType=QuestionType.Plaque3MinFCT,GetDecimalNullFun=GetPlaque3MinFCT},
};
@ -992,7 +942,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
public async Task CalculatePatchDataStatistics(ReadingCalculateDto inDto)
{
// FCT 问题信息
var fCTQuestionInfo = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.ROI).FirstOrDefault();
var fCTQuestionInfo = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.FCT).FirstOrDefault();
List<OCTInfo> oCTFCTInfos=new List<OCTInfo> ();
@ -1270,123 +1220,6 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
.Where(x => x.QuestionMark == QuestionMark.MiniMumFCT).Select(x => x.Answer).FirstIsNullReturnEmpty().IsNullOrEmptyReturnNull();
}
/// <summary>
/// 匹配动脉段最小FCT (平均值的最小值)
/// </summary>
/// <param name="inDto"></param>
/// <returns></returns>
public async Task<decimal?> GetMinFCT(ReadingCalculateDto inDto)
{
return inDto.QuestionInfo.Where(x => x.LesionType == LesionType.ROI).SelectMany(x => x.TableRowInfoList).SelectMany(x => x.TableQuestionList)
.Where(x => x.QuestionMark == QuestionMark.AvgFCT).Select(x => x.Answer.IsNullOrEmptyReturn0()).MinOrDefault();
}
/// <summary>
/// 平均最小FCT (平均值的平均值)
/// </summary>
/// <param name="inDto"></param>
/// <returns></returns>
public async Task<decimal?> GetAvgFCT(ReadingCalculateDto inDto)
{
return inDto.QuestionInfo.Where(x => x.LesionType == LesionType.ROI).SelectMany(x => x.TableRowInfoList).SelectMany(x => x.TableQuestionList)
.Where(x => x.QuestionMark == QuestionMark.AvgFCT).Select(x => x.Answer.IsNullOrEmptyReturn0()).DefaultIfEmpty(0).Average();
}
/// <summary>
/// 脂质角度平均值
/// </summary>
/// <param name="inDto"></param>
/// <returns></returns>
public async Task<decimal?> GetAvgLipidAngle(ReadingCalculateDto inDto)
{
return inDto.QuestionInfo.Where(x => x.LesionType == LesionType.ROI).SelectMany(x => x.TableRowInfoList).SelectMany(x => x.TableQuestionList)
.Where(x => x.QuestionMark == QuestionMark.LipidAngle).Select(x => x.Answer.IsNullOrEmptyReturn0()).DefaultIfEmpty(0).Average();
}
/// <summary>
/// 脂质角度最大
/// </summary>
/// <param name="inDto"></param>
/// <returns></returns>
public async Task<decimal?> GetMaxLipidAngle(ReadingCalculateDto inDto)
{
return inDto.QuestionInfo.Where(x => x.LesionType == LesionType.ROI).SelectMany(x => x.TableRowInfoList).SelectMany(x => x.TableQuestionList)
.Where(x => x.QuestionMark == QuestionMark.LipidAngle).Select(x => x.Answer.IsNullOrEmptyReturn0()).MaxOrDefault();
}
public async Task<List<OCTInfo>> GetOCTInfo(ReadingCalculateDto inDto)
{
var fCTQuestionInfo = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.ROI).FirstOrDefault();
List<OCTInfo> oCTFCTInfos = new List<OCTInfo>();
foreach (var item in fCTQuestionInfo!.TableRowInfoList)
{
oCTFCTInfos.Add(new OCTInfo()
{
// Data = item.TableQuestionList.Where(x => x.QuestionMark == QuestionMark.AvgFCT).Select(x => decimal.Parse(x.Answer)).FirstOrDefault(),
MacrophageInfiltrationMeasurement = item.TableQuestionList.Where(x => x.QuestionMark == QuestionMark.MacrophageInfiltrationMeasurement).Select(x => x.Answer).FirstOrDefault() ?? string.Empty,
MacrophageInfiltrationAngle = item.TableQuestionList.Where(x => x.QuestionMark == QuestionMark.MacrophageInfiltrationAngle).Select(x => x.Answer.IsNullOrEmptyReturnNull()).FirstOrDefault(),
MicrochannelMeasurement = item.TableQuestionList.Where(x => x.QuestionMark == QuestionMark.MicrochannelMeasurement).Select(x => x.Answer).FirstOrDefault() ?? string.Empty,
CholesterolCrystalMeasurement = item.TableQuestionList.Where(x => x.QuestionMark == QuestionMark.CholesterolCrystalMeasurement).Select(x => x.Answer).FirstOrDefault() ?? string.Empty,
});
}
return oCTFCTInfos;
}
/// <summary>
/// 获取巨噬细胞浸润测量
/// </summary>
/// <param name="inDto"></param>
/// <returns></returns>
public async Task<string> GetMacrophageInfiltration(ReadingCalculateDto inDto)
{
List<OCTInfo> oCTFCTInfos = await GetOCTInfo(inDto);
return oCTFCTInfos.Any(x => x.MacrophageInfiltrationMeasurement != string.Empty) ?
oCTFCTInfos.Any(x => x.MacrophageInfiltrationMeasurement.EqEnum(IsPresent.Existence)) ? IsPresent.Existence.GetEnumInt() : IsPresent.NonExistence.GetEnumInt()
: IsPresent.NonExistence.GetEnumInt();
}
/// <summary>
/// 巨噬细胞浸润角度测量
/// </summary>
/// <param name="inDto"></param>
/// <returns></returns>
public async Task<string> GetMacrophageExtensionAngle(ReadingCalculateDto inDto)
{
List<OCTInfo> oCTFCTInfos = await GetOCTInfo(inDto);
return oCTFCTInfos.Where(x =>x.MacrophageInfiltrationAngle != null).Count() == 0 ? string.Empty : oCTFCTInfos.Max(x => x.MacrophageInfiltrationAngle ?? 0).ToString();
}
/// <summary>
/// 获取微通道汇总
/// </summary>
/// <param name="inDto"></param>
/// <returns></returns>
public async Task<string> GetMicrochannels(ReadingCalculateDto inDto)
{
List<OCTInfo> oCTFCTInfos = await GetOCTInfo(inDto);
return oCTFCTInfos.Any(x => x.MicrochannelMeasurement != string.Empty) ?
oCTFCTInfos.Any(x => x.MicrochannelMeasurement.EqEnum(IsPresent.Existence)) ? IsPresent.Existence.GetEnumInt() : IsPresent.NonExistence.GetEnumInt()
: IsPresent.NonExistence.GetEnumInt();
}
/// <summary>
/// 获取胆固醇结晶汇总
/// </summary>
/// <param name="inDto"></param>
/// <returns></returns>
public async Task<string> GetCholesterolCrystallization(ReadingCalculateDto inDto)
{
List<OCTInfo> oCTFCTInfos = await GetOCTInfo(inDto);
return oCTFCTInfos.Any(x => x.CholesterolCrystalMeasurement != string.Empty) ?
oCTFCTInfos.Any(x => x.CholesterolCrystalMeasurement.EqEnum(IsPresent.Existence)) ? IsPresent.Existence.GetEnumInt() : IsPresent.NonExistence.GetEnumInt()
: IsPresent.NonExistence.GetEnumInt();
}
/// <summary>
/// 验证访视提交
/// </summary>
@ -1396,7 +1229,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
{
var taskinfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Include(x => x.Subject).Include(x => x.TrialReadingCriterion).FirstNotNullAsync();
var question = await _readingQuestionTrialRepository.Where(x => x.LesionType == LesionType.ROI && x.ReadingQuestionCriterionTrialId == taskinfo.TrialReadingCriterionId).FirstNotNullAsync();
var question = await _readingQuestionTrialRepository.Where(x => x.LesionType == LesionType.PatchDataStatistics && x.ReadingQuestionCriterionTrialId == taskinfo.TrialReadingCriterionId).FirstNotNullAsync();
var tableQuestions = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionId== question.Id)
@ -1428,7 +1261,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
public async Task<decimal?> GetAllMinFCT(ReadingCalculateDto inDto)
{
var allMinFCT = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.ROI).SelectMany(x => x.TableRowInfoList).SelectMany(x => x.TableQuestionList)
var allMinFCT = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.FCT).SelectMany(x => x.TableRowInfoList).SelectMany(x => x.TableQuestionList)
.Where(x => x.QuestionMark == QuestionMark.MinFCT).Select(x => x.Answer.IsNullOrEmptyReturn0()).MinOrDefault();
if (allMinFCT == 0)
{
@ -1444,7 +1277,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
/// <returns></returns>
public async Task<decimal?> GetAvgMinFCT(ReadingCalculateDto inDto)
{
var allMinFCT = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.ROI).SelectMany(x => x.TableRowInfoList).SelectMany(x => x.TableQuestionList)
var allMinFCT = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.FCT).SelectMany(x => x.TableRowInfoList).SelectMany(x => x.TableQuestionList)
.Where(x => x.QuestionMark == QuestionMark.MinFCT).Select(x => x.Answer.IsNullOrEmptyReturn0()).ToList();
if (allMinFCT.Count() == 0)
{

View File

@ -42,9 +42,9 @@ public class TrialStatService(
{
UploadedCount = t.SubjectVisitList.Where(t => inQuery.TrialSiteId != null ? t.TrialSiteId == inQuery.TrialSiteId : true)
.Where(t => t.SubmitState == SubmitStateEnum.Submitted).Count(),
QCFinishedCount = t.QCProcessEnum == TrialQCProcess.NotAudit ? null : t.SubjectVisitList.Where(t => inQuery.TrialSiteId != null ? t.TrialSiteId == inQuery.TrialSiteId : true)
QCFinishedCount = t.SubjectVisitList.Where(t => inQuery.TrialSiteId != null ? t.TrialSiteId == inQuery.TrialSiteId : true)
.Where(t => t.AuditState == AuditStateEnum.QCPassed || t.AuditState == AuditStateEnum.QCFailed).Count(),
CheckFinishedCount = t.IsImageConsistencyVerification == false ? null : t.SubjectVisitList.Where(t => inQuery.TrialSiteId != null ? t.TrialSiteId == inQuery.TrialSiteId : true)
CheckFinishedCount = t.SubjectVisitList.Where(t => inQuery.TrialSiteId != null ? t.TrialSiteId == inQuery.TrialSiteId : true)
.Where(t => t.CheckState == CheckStateEnum.CVPassed).Count(),
CriterionList = t.TrialReadingCriterionList.Where(t => inQuery.TrialReadingCriterionId != null ? t.Id == inQuery.TrialReadingCriterionId : true)

View File

@ -54,11 +54,6 @@ namespace IRaCIS.Core.Domain.Share
/// </summary>
OCT_LipidAngle = 2,
/// <summary>
/// ROI
/// </summary>
ROI = 3,
}
@ -2043,11 +2038,6 @@ namespace IRaCIS.Core.Domain.Share
/// </summary>
PAV = 103,
/// <summary>
/// ROI测量值
/// </summary>
ROI = 104,
/// <summary>
/// 脂质角度
/// </summary>
@ -2980,76 +2970,6 @@ namespace IRaCIS.Core.Domain.Share
/// </summary>
TargetSegmentRemarks = 1012,
/// <summary>
/// ROI起始回撤距离
/// </summary>
ROIStart = 1013,
/// <summary>
/// ROI终止回撤距离
/// </summary>
ROIEnd = 1014,
/// <summary>
/// ROI段落总长度
/// </summary>
ROIAllLength = 1015,
/// <summary>
/// PAV冠状动脉粥样硬化体积百分比)
/// </summary>
PAV =1019,
/// <summary>
/// EEM求和
/// </summary>
EEMSum = 1020,
/// <summary>
/// (EEM-Lumen)求和
/// </summary>
EEMSubLumenSum = 1021,
/// <summary>
/// 匹配动脉段最小FCT
/// </summary>
MatchingTheMinimumFCT = 1022,
/// <summary>
/// 平均最小FCT
/// </summary>
AvgMinFCT = 1023,
/// <summary>
/// 脂质角度平均值
/// </summary>
AvgLipidAngle = 1024,
/// <summary>
/// 脂质角度最大值
/// </summary>
MaxLipidAngle = 1025,
/// <summary>
/// 巨噬细胞浸润测量
/// </summary>
MacrophageInfiltrationMeasurement = 1026,
/// <summary>
/// 巨噬细胞浸润角度测量
/// </summary>
MacrophageInfiltrationAngle = 1027,
/// <summary>
/// 微通道测量
/// </summary>
MicrochannelMeasurement = 1028,
/// <summary>
/// 胆固醇结晶测量
/// </summary>
CholesterolCrystalMeasurement = 1029,
/// <summary>
/// 脂肪分数总平均值
/// </summary>