diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml
index b2eb320a5..226997618 100644
--- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml
+++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml
@@ -6450,6 +6450,31 @@
不等于
+
+
+ IVUS测量值导入
+
+
+
+
+ 斑块编号
+
+
+
+
+ 外弹力膜面积Emm
+
+
+
+
+ 管腔面积Lumen
+
+
+
+
+ 外弹力膜面积- 管腔面积
+
+
阅片计算Dto
diff --git a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingCalculateViewModel.cs b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingCalculateViewModel.cs
index a8ef9595c..3197db09d 100644
--- a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingCalculateViewModel.cs
+++ b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingCalculateViewModel.cs
@@ -201,6 +201,39 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto
{
public Guid VisitTaskId { get; set; }
}
+
+ ///
+ /// IVUS测量值导入
+ ///
+ public class IVUSMeasuredValue
+ {
+ ///
+ /// 斑块编号
+ ///
+ public int PlaqueNum { get; set; }
+
+ ///
+ /// 外弹力膜面积Emm
+ ///
+ public decimal Emm { get; set; }
+
+ ///
+ /// 管腔面积Lumen
+ ///
+ public decimal Lumen { get; set; }
+
+ ///
+ /// 外弹力膜面积- 管腔面积
+ ///
+ public decimal EmmSubtractionLumen
+ {
+ get
+ {
+ return this.Emm - this.Lumen;
+ }
+ }
+ }
+
///
/// 阅片计算Dto
///
diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/IVUSCalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/IVUSCalculateService.cs
index 86b407f42..7442ea160 100644
--- a/IRaCIS.Core.Application/Service/ReadingCalculate/IVUSCalculateService.cs
+++ b/IRaCIS.Core.Application/Service/ReadingCalculate/IVUSCalculateService.cs
@@ -1,8 +1,10 @@
-using DocumentFormat.OpenXml.Presentation;
+using DocumentFormat.OpenXml.EMMA;
+using DocumentFormat.OpenXml.Presentation;
using IRaCIS.Core.Application.Service.Reading.Dto;
using IRaCIS.Core.Application.ViewModel;
using IRaCIS.Core.Domain.Share;
using IRaCIS.Core.Infra.EFCore.Common;
+using IRaCIS.Core.Infrastructure;
using MassTransit;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
@@ -599,7 +601,137 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
var request = httpContext.HttpContext!.Request;
var file = request.Form.Files[0];
Guid visitTaskId = Guid.Parse(request.Form["VisitTaskId"]);
- var dataTable = _generalCalculateService.GetDataTableFromUpload(file);
+ var dataTable =await _generalCalculateService.GetDataTableFromUpload(file);
+
+ var taskinfo = await _visitTaskRepository.Where(x => x.Id == visitTaskId).Include(x => x.Subject).Include(x=>x.TrialReadingCriterion).FirstNotNullAsync();
+
+ var values = new
+ {
+ 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"]);
+ }
+
+ List measuredValueList = new List();
+
+ try
+ {
+ for (int i = 3; i < dataTable.Rows.Count; i++)
+ {
+ measuredValueList.Add(new IVUSMeasuredValue()
+ {
+ PlaqueNum = int.Parse(dataTable.Rows[i]["A"].ToString()),
+ Emm = decimal.Parse(dataTable.Rows[i]["B"].ToString()),
+ Lumen = decimal.Parse(dataTable.Rows[i]["C"].ToString()),
+ });
+ }
+ }
+ catch (Exception)
+ {
+ throw new BusinessValidationFailedException(_localizer["IVUS_UplpadDataError"]);
+ }
+
+ 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 tableAnsweRowInfos = new List();
+ List tableAnswers = new List();
+
+ var maxnum = _readingTableAnswerRowInfoRepository.Where(x => x.QuestionId == questionInfo.Id && x.VisitTaskId == taskinfo.Id).MaxOrDefault(x => x.RowIndex);
+
+
+ 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,
+ FristAddTaskNum = taskinfo.VisitTaskNum,
+ 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(),
+ });
+
+ var emm = item.Emm.ToString();
+ var lumen=item.Lumen.ToString();
+ var emmSubtractionLumen = item.EmmSubtractionLumen.ToString();
+
+ if (taskinfo.TrialReadingCriterion.DigitPlaces != -1)
+ {
+ var digitPlaces= taskinfo.TrialReadingCriterion.DigitPlaces??0;
+ emm = decimal.Round(decimal.Parse(emm ?? "0"), digitPlaces).ToString("F" + digitPlaces.ToString());
+ lumen = decimal.Round(decimal.Parse(lumen ?? "0"), digitPlaces).ToString("F" + digitPlaces.ToString());
+ emmSubtractionLumen = decimal.Round(decimal.Parse(emmSubtractionLumen ?? "0"), digitPlaces).ToString("F" + digitPlaces.ToString());
+ }
+
+ // EMM
+ tableAnswers.Add(new ReadingTableQuestionAnswer()
+ {
+ Answer = emm,
+ QuestionId = questionInfo.Id,
+ TrialId = taskinfo.TrialId,
+ VisitTaskId = taskinfo.Id,
+ RowId = newRowId,
+ RowIndex = maxnum,
+ TableQuestionId = tableQuestionList.Where(x => x.ReadingQuestionId == questionInfo.Id && x.QuestionMark == QuestionMark.ElasticArea).Select(x => x.Id).FirstOrDefault(),
+ });
+
+ tableAnswers.Add(new ReadingTableQuestionAnswer()
+ {
+ Answer = lumen,
+ QuestionId = questionInfo.Id,
+ TrialId = taskinfo.TrialId,
+ VisitTaskId = taskinfo.Id,
+ RowId = newRowId,
+ RowIndex = maxnum,
+ TableQuestionId = tableQuestionList.Where(x => x.ReadingQuestionId == questionInfo.Id && x.QuestionMark == QuestionMark.LumenArea).Select(x => x.Id).FirstOrDefault(),
+ });
+
+ tableAnswers.Add(new ReadingTableQuestionAnswer()
+ {
+ Answer = emmSubtractionLumen,
+ QuestionId = questionInfo.Id,
+ TrialId = taskinfo.TrialId,
+ VisitTaskId = taskinfo.Id,
+ RowId = newRowId,
+ RowIndex = maxnum,
+ TableQuestionId = tableQuestionList.Where(x => x.ReadingQuestionId == questionInfo.Id && x.QuestionMark == QuestionMark.ElasticAreaDiffValue).Select(x => x.Id).FirstOrDefault(),
+ });
+ }
+
+
+ await _readingTableAnswerRowInfoRepository.AddRangeAsync(tableAnsweRowInfos);
+ await _readingTableQuestionAnswerRepository.AddRangeAsync(tableAnswers);
+ await _readingTableQuestionAnswerRepository.SaveChangesAsync();
+
+ await this.CalculateTask(new CalculateTaskInDto()
+ {
+
+ VisitTaskId = taskinfo.Id,
+ });
}
///
@@ -621,7 +753,13 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
// 获取编号
var nums = matchValuesAnswerList.SelectMany(x => x.TableQuestionList).Where(x => x.QuestionMark == QuestionMark.PlaqueNumber).Select(x => int.Parse(x.Answer)).Distinct().OrderBy(x => x).ToList();
- List tableAnsweRowInfos = new List();
+ // 斑块的表格问题集合
+ var tableQuestionList = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionId == questionInfo.QuestionId).ToListAsync();
+
+ // pAV表格问题
+ var pAvTableQuestionList = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionId == pAVquestionInfo.QuestionId).ToListAsync();
+
+ List tableAnsweRowInfos = new List();
List tableAnswers = new List();
foreach (var item in nums)
@@ -656,7 +794,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
VisitTaskId = inDto.VisitTaskId,
RowId = newRowId,
RowIndex = item,
- TableQuestionId = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionId == questionInfo.QuestionId && x.QuestionMark == QuestionMark.PlaqueNumber).Select(x => x.Id).FirstOrDefaultAsync(),
+ TableQuestionId = tableQuestionList.Where(x => x.QuestionMark == QuestionMark.PlaqueNumber).Select(x => x.Id).FirstOrDefault(),
});
@@ -685,8 +823,6 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
emm = decimal.Round(decimal.Parse(emm ?? "0"), inDto.DigitPlaces).ToString("F" + inDto.DigitPlaces.ToString());
EEMLumen = decimal.Round(decimal.Parse(EEMLumen ?? "0"), inDto.DigitPlaces).ToString("F" + inDto.DigitPlaces.ToString());
pav = decimal.Round(decimal.Parse(pav ?? "0"), inDto.DigitPlaces).ToString("F" + inDto.DigitPlaces.ToString());
-
-
}
#endregion
@@ -719,7 +855,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
VisitTaskId = inDto.VisitTaskId,
RowId = newPAVRowId,
RowIndex = item,
- TableQuestionId = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionId == pAVquestionInfo.QuestionId && x.QuestionMark == QuestionMark.PlaqueNumber).Select(x => x.Id).FirstOrDefaultAsync(),
+ TableQuestionId = pAvTableQuestionList.Where(x => x.QuestionMark == QuestionMark.PlaqueNumber).Select(x => x.Id).FirstOrDefault(),
});
@@ -734,7 +870,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
VisitTaskId = inDto.VisitTaskId,
RowId = newPAVRowId,
RowIndex = item,
- TableQuestionId = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionId == pAVquestionInfo.QuestionId && x.QuestionMark == QuestionMark.PAV).Select(x => x.Id).FirstOrDefaultAsync(),
+ TableQuestionId = pAvTableQuestionList.Where(x => x.QuestionMark == QuestionMark.PAV).Select(x => x.Id).FirstOrDefault(),
});
#endregion
@@ -749,7 +885,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
VisitTaskId = inDto.VisitTaskId,
RowId = newRowId,
RowIndex = item,
- TableQuestionId = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionId == questionInfo.QuestionId && x.QuestionMark == QuestionMark.EEMSum).Select(x => x.Id).FirstOrDefaultAsync(),
+ TableQuestionId = tableQuestionList.Where(x => x.QuestionMark == QuestionMark.EEMSum).Select(x => x.Id).FirstOrDefault(),
});
// (EEM-Lumen)求和
@@ -762,7 +898,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate
VisitTaskId = inDto.VisitTaskId,
RowId = newRowId,
RowIndex = item,
- TableQuestionId = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionId == questionInfo.QuestionId && x.QuestionMark == QuestionMark.EEMSubtractLumenSum).Select(x => x.Id).FirstOrDefaultAsync(),
+ TableQuestionId = tableQuestionList.Where(x => x.QuestionMark == QuestionMark.EEMSubtractLumenSum).Select(x => x.Id).FirstOrDefault(),
});
}