|
|
|
@ -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,113 @@ 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).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<IVUSMeasuredValue> measuredValueList = new List<IVUSMeasuredValue>();
|
|
|
|
|
|
|
|
|
|
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<ReadingTableAnswerRowInfo> tableAnsweRowInfos = new List<ReadingTableAnswerRowInfo>();
|
|
|
|
|
List<ReadingTableQuestionAnswer> tableAnswers = new List<ReadingTableQuestionAnswer>();
|
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// EMM
|
|
|
|
|
tableAnswers.Add(new ReadingTableQuestionAnswer()
|
|
|
|
|
{
|
|
|
|
|
Answer = item.Emm.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.ElasticArea).Select(x => x.Id).FirstOrDefault(),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
tableAnswers.Add(new ReadingTableQuestionAnswer()
|
|
|
|
|
{
|
|
|
|
|
Answer = item.Lumen.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.LumenArea).Select(x => x.Id).FirstOrDefault(),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
tableAnswers.Add(new ReadingTableQuestionAnswer()
|
|
|
|
|
{
|
|
|
|
|
Answer = item.EmmSubtractionLumen.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.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,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -621,6 +729,12 @@ 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();
|
|
|
|
|
|
|
|
|
|
// 斑块的表格问题集合
|
|
|
|
|
var tableQuestionList = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionId == questionInfo.QuestionId).ToListAsync();
|
|
|
|
|
|
|
|
|
|
// pAV表格问题
|
|
|
|
|
var pAvTableQuestionList = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionId == pAVquestionInfo.QuestionId).ToListAsync();
|
|
|
|
|
|
|
|
|
|
List <ReadingTableAnswerRowInfo> tableAnsweRowInfos = new List<ReadingTableAnswerRowInfo>();
|
|
|
|
|
List<ReadingTableQuestionAnswer> tableAnswers = new List<ReadingTableQuestionAnswer>();
|
|
|
|
|
|
|
|
|
@ -656,7 +770,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(),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -719,7 +833,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 +848,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 +863,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 +876,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(),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|