From 62d93b2db40a6a55a20c6dcd38713e1364082ae2 Mon Sep 17 00:00:00 2001 From: he <109787524@qq.com> Date: Tue, 18 Nov 2025 17:25:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=A5=E5=91=8A=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IRaCIS.Core.Application.xml | 16 ++ .../Reading/Dto/ReadingImageTaskViewModel.cs | 12 + .../Service/Reading/_MapConfig.cs | 17 ++ .../General/GeneralCalculateService.cs | 181 ++++++++++++- .../IRECIST1Point1CalculateService.cs | 234 ++--------------- .../ReadingCalculate/IVUSCalculateService.cs | 234 ++--------------- .../Interface/IGeneralCalculateService.cs | 13 + .../LuganoCalculateService.cs | 224 ++-------------- .../LuganoWithoutPETCalculateService.cs | 224 ++-------------- .../MRECISTHCCCalculateService.cs | 224 ++-------------- .../MRIPDFFCalculateService.cs | 244 ++---------------- .../ReadingCalculate/OCTCalculateService.cs | 236 ++--------------- .../RECIST1Point1CalculateService.cs | 228 ++-------------- .../RECIST1Point1_BMCalculateService.cs | 224 ++-------------- .../SelfDefineCalculateService.cs | 244 ++---------------- 15 files changed, 422 insertions(+), 2133 deletions(-) diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index 7ce34bb53..434099b70 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -3505,6 +3505,22 @@ + + + 构造阅片报告问题 + + + + + + + + + + + + + 从上传文件中获取Datatable diff --git a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs index a3a050f72..8f0da5bb2 100644 --- a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs +++ b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs @@ -83,6 +83,8 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto public string QuestionName { get; set; } + public string QuestionEnName { get; set; } + public bool IsCanEditPosition { get; set; } = false; public string BlindName { get; set; } @@ -202,6 +204,16 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto } + public class Globalanswer + { + public Guid TaskId { get; set; } + + public string Answer { get; set; } + + public decimal VisitTaskNum { get; set; } + + public Guid? QuestionId { get; set; } + } public class LesionDto { diff --git a/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs b/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs index a56843f78..6169a4f52 100644 --- a/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/Reading/_MapConfig.cs @@ -15,6 +15,23 @@ namespace IRaCIS.Core.Application.Service //是否英文环境 var isEn_Us = false; + CreateMap() + .ForMember(d => d.QuestionId, u => u.MapFrom(s => s.Id)); + + CreateMap() + .ForMember(d => d.QuestionId, u => u.MapFrom(s => s.ReadingQuestionId)) + .ForMember(d => d.TableQuestionId, u => u.MapFrom(s => s.Id)); + + + + CreateMap(); + CreateMap().ReverseMap(); + + // 在此处拷贝automapper 映射 + + CreateMap(); + CreateMap().ReverseMap(); + //标准Id List CriterionIds = new List(); diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/General/GeneralCalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/General/GeneralCalculateService.cs index 465fe64e2..3a3c8e51c 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/General/GeneralCalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/General/GeneralCalculateService.cs @@ -4,6 +4,7 @@ using IRaCIS.Core.Domain.Models; using IRaCIS.Core.Domain.Share; using IRaCIS.Core.Infra.EFCore.Common; using MassTransit; +using MassTransit.Saga; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using MiniExcelLibs; @@ -27,7 +28,185 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate IOSSService oSSService, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer) : BaseService, IGeneralCalculateService { - + /// + /// 构造阅片报告问题 + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public async Task> GetReadingReportQuestion( + List? questionList, + List taskInfoList, + List? globalanswerList, + List? answers, + List? tableAnsweRowInfos, + List tableQuestionList, + List alltableAnsweRowInfos, + List tableAnswers, + List organInfos, + List needChangeType + ) + { + #region 构造问题 + List questions = _mapper.Map>(questionList.Where(x => x.Type == ReadingQestionType.Group).OrderBy(x => x.ShowOrder)); + + // 分组 + foreach (var item in questions) + { + item.QuestionName = item.QuestionName.LanguageName(item.QuestionEnName, _userInfo.IsEn_Us); + item.ReportLayType = ReportLayType.Group; + + item.Childrens = _mapper.Map>(questionList.Where(x => x.GroupId == item.QuestionId).OrderBy(x => x.ShowOrder)); + // 问题 + foreach (var question in item.Childrens) + { + question.QuestionName = question.QuestionName.LanguageName(question.QuestionEnName, _userInfo.IsEn_Us); + question.ReportLayType = ReportLayType.Question; + foreach (var task in taskInfoList) + { + var globalAnswer = globalanswerList.Where(x => x.TaskId == task.VisitTaskId && x.QuestionId == question.QuestionId).OrderByDescending(x => x.VisitTaskNum).FirstOrDefault(); + + var answer = answers.Where(x => x.VisitTaskId == task.VisitTaskId && x.ReadingQuestionTrialId == question.QuestionId).FirstOrDefault(); + question.Answer.Add(new TaskQuestionAnswer() + { + Answer = answer == null ? string.Empty : answer.Answer, + IsGlobalChange = globalAnswer == null ? false : true, + GlobalChangeAnswer = globalAnswer == null ? string.Empty : globalAnswer.Answer, + TaskName = task.TaskName, + VisitTaskId = task.VisitTaskId, + + }); + } + + // 构造表格行数据 + + + var rowlist = tableAnsweRowInfos.Where(x => x.QuestionId == question.QuestionId).OrderBy(x => x.RowIndex).ToList(); + + + question.Childrens = rowlist.Select(x => new ReadingReportDto() + { + QuestionName = question.OrderMark + x.RowIndex.GetLesionMark(), + SplitOrMergeLesionName = x.MergeName.IsNullOrEmpty() ? x.SplitName : x.MergeName, + SplitOrMergeType = x.SplitOrMergeType, + LesionType = question.LesionType, + IsShowInDicom = question.IsShowInDicom, + IsCanEditPosition = x.IsCanEditPosition, + RowIndex = x.RowIndex, + BlindName = x.BlindName, + ReportLayType = ReportLayType.Lesions, + }).ToList(); + + + foreach (var row in question.Childrens) + { + // tableQuestion + row.Childrens = _mapper.Map>(tableQuestionList.Where(x => x.ReadingQuestionId == question.QuestionId)); + + + + foreach (var tableQuestion in row.Childrens) + { + tableQuestion.QuestionName = tableQuestion.QuestionName.LanguageName(tableQuestion.QuestionEnName, _userInfo.IsEn_Us); + tableQuestion.LesionType = question.LesionType; + tableQuestion.RowId = row.RowId; + tableQuestion.IsShowInDicom = question.IsShowInDicom; + tableQuestion.RowIndex = row.RowIndex; + tableQuestion.ReportLayType = ReportLayType.TableQuestion; + foreach (var task in taskInfoList) + { + var rowinfo = alltableAnsweRowInfos.Where(x => x.VisitTaskId == task.VisitTaskId && x.QuestionId == tableQuestion.QuestionId && x.RowIndex == tableQuestion.RowIndex).FirstOrDefault(); + var taskQuestionAnswer = new TaskQuestionAnswer() + { + Answer = tableAnswers.Where(x => x.VisitTaskId == task.VisitTaskId && x.QuestionId == tableQuestion.QuestionId && x.RowIndex == tableQuestion.RowIndex && x.TableQuestionId == tableQuestion.TableQuestionId).Select(x => x.Answer).FirstIsNullReturnEmpty(), + TaskName = task.TaskName, + VisitTaskId = task.VisitTaskId, + }; + if (rowinfo != null && rowinfo.OrganInfoId != null) + { + var organInfo = organInfos.Where(x => x.Id == rowinfo.OrganInfoId).FirstOrDefault(); + + + if (organInfo != null && needChangeType.Contains(tableQuestion.QuestionMark)) + { + if (_userInfo.IsEn_Us) + { + switch (tableQuestion.QuestionMark) + { + case QuestionMark.Organ: + taskQuestionAnswer.Answer = organInfo.TULOCEN; + + break; + case QuestionMark.Location: + if (organInfo.IsCanEditPosition) + { + + } + else + { + taskQuestionAnswer.Answer = organInfo.TULATEN; + + } + break; + case QuestionMark.Part: + + taskQuestionAnswer.Answer = organInfo.PartEN; + + break; + + } + + } + else + { + switch (tableQuestion.QuestionMark) + { + case QuestionMark.Organ: + taskQuestionAnswer.Answer = organInfo.TULOC; + break; + case QuestionMark.Location: + if (organInfo.IsCanEditPosition) + { + + } + else + { + taskQuestionAnswer.Answer = organInfo.TULAT; + + } + break; + case QuestionMark.Part: + taskQuestionAnswer.Answer = organInfo.Part; + break; + + } + } + + } + } + tableQuestion.Answer.Add(taskQuestionAnswer); + } + } + + + } + + + } + ; + } + #endregion + + return questions; + } /// diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/IRECIST1Point1CalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/IRECIST1Point1CalculateService.cs index 913eb23f1..3c78334a2 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/IRECIST1Point1CalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/IRECIST1Point1CalculateService.cs @@ -146,12 +146,12 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate var answers = await _readingTaskQuestionAnswerRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync(); var tableAnswers = await _readingTableQuestionAnswerRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync(); - var globalanswerList = await _readingGlobalTaskInfoRepository.Where(x => visitTaskIds.Contains(x.TaskId) && x.GlobalVisitTask.TaskState == TaskState.Effect && x.Answer != string.Empty).Select(x => new + var globalanswerList = await _readingGlobalTaskInfoRepository.Where(x => visitTaskIds.Contains(x.TaskId) && x.GlobalVisitTask.TaskState == TaskState.Effect && x.Answer != string.Empty).Select(x => new Globalanswer() { - x.TaskId, - x.GlobalVisitTask.VisitTaskNum, - x.QuestionId, - x.Answer + TaskId= x.TaskId, + VisitTaskNum= x.GlobalVisitTask.VisitTaskNum, + QuestionId= x.QuestionId, + Answer= x.Answer }).ToListAsync(); var alltableAnsweRowInfos = await _readingTableAnswerRowInfoRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync(); var organIds = alltableAnsweRowInfos.Where(x => x.OrganInfoId != null).Select(x => x.OrganInfoId).Distinct().ToList(); @@ -165,217 +165,19 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate // 第一级 - #region 构造问题 - List questions = questionList.Where(x => x.Type == ReadingQestionType.Group).OrderBy(x => x.ShowOrder).Select(x => new ReadingReportDto() - { - QuestionId = x.Id, - GroupName = x.GroupName, - GroupEnName = x.GroupEnName, - IsShowInDicom = x.IsShowInDicom, - Type = x.Type, - GroupId = x.GroupId, - QuestionType = x.QuestionType, - LesionType = x.LesionType, - QuestionGenre = x.QuestionGenre, - DataSource = x.DataSource, - DictionaryCode = x.DictionaryCode, - TypeValue = x.TypeValue, - QuestionName = x.QuestionName.LanguageName(x.QuestionEnName, _userInfo.IsEn_Us), - ShowOrder = x.ShowOrder, - ValueType = x.ValueType, - Unit = x.Unit, - CustomUnit = x.CustomUnit, - ReportLayType = ReportLayType.Group, - HighlightAnswer = x.HighlightAnswer, - HighlightAnswerList = x.HighlightAnswerList, - }).ToList(); - - // 分组 - foreach (var item in questions) - { - item.Childrens = questionList.Where(x => x.GroupId == item.QuestionId).OrderBy(x => x.ShowOrder).Select(x => new ReadingReportDto() - { - GroupName = x.GroupName, - QuestionId = x.Id, - IsShowInDicom = x.IsShowInDicom, - GroupEnName = x.GroupEnName, - QuestionName = x.QuestionName.LanguageName(x.QuestionEnName, _userInfo.IsEn_Us), - LesionType = x.LesionType, - QuestionGenre = x.QuestionGenre, - DataSource = x.DataSource, - DictionaryCode = x.DictionaryCode, - Type = x.Type, - QuestionType = x.QuestionType, - TypeValue = x.TypeValue, - ShowOrder = x.ShowOrder, - OrderMark = x.OrderMark, - ValueType = x.ValueType, - Unit = x.Unit, - CustomUnit = x.CustomUnit, - ReportLayType = ReportLayType.Question, - HighlightAnswer = x.HighlightAnswer, - HighlightAnswerList = x.HighlightAnswerList, - }).ToList(); - - // 问题 - foreach (var question in item.Childrens) - { - - foreach (var task in taskInfoList) - { - var globalAnswer = globalanswerList.Where(x => x.TaskId == task.VisitTaskId && x.QuestionId == question.QuestionId).OrderByDescending(x => x.VisitTaskNum).FirstOrDefault(); - - var answer = answers.Where(x => x.VisitTaskId == task.VisitTaskId && x.ReadingQuestionTrialId == question.QuestionId).FirstOrDefault(); - question.Answer.Add(new TaskQuestionAnswer() - { - Answer = answer == null ? string.Empty : answer.Answer, - IsGlobalChange = globalAnswer == null ? false : true, - GlobalChangeAnswer = globalAnswer == null ? string.Empty : globalAnswer.Answer, - TaskName = task.TaskName, - VisitTaskId = task.VisitTaskId, - - }); - } - - // 构造表格行数据 - - - var rowlist = tableAnsweRowInfos.Where(x => x.QuestionId == question.QuestionId).OrderBy(x => x.RowIndex).ToList(); - - question.Childrens = new List(); - - var rowoindexs = lesionsIndexs.Where(x => x.QuestionId == question.QuestionId).Select(x => x.Rowindexs.OrderBy(y => y).ToList()).FirstOrDefault(); - rowoindexs = rowoindexs == null ? new List() : rowoindexs; - foreach (var rowoindex in rowoindexs) - { - var rowinfo = rowlist.Where(x => x.RowIndex == rowoindex).FirstOrDefault(); - question.Childrens.Add(new ReadingReportDto() - { - QuestionName = question.OrderMark + rowoindex.GetLesionMark(), - RowId = rowinfo?.Id, - IsShowInDicom = question.IsShowInDicom, - SplitOrMergeLesionName = rowinfo != null ? (rowinfo.MergeName.IsNullOrEmpty() ? rowinfo.SplitName : rowinfo.MergeName) : string.Empty, - SplitOrMergeType = rowinfo != null ? (rowinfo.SplitOrMergeType) : null, - LesionType = question.LesionType, - IsCanEditPosition = rowinfo != null ? (rowinfo.IsCanEditPosition) : false, - RowIndex = rowoindex, - BlindName = rowinfo != null ? rowinfo.BlindName : string.Empty, - ReportLayType = ReportLayType.Lesions, - ReportMark = rowinfo != null ? rowinfo.ReportMark : string.Empty, - - }); - } - - - foreach (var row in question.Childrens) - { - // tableQuestion - row.Childrens = tableQuestionList.Where(x => x.ReadingQuestionId == question.QuestionId).Select(x => new ReadingReportDto() - { - QuestionName = x.QuestionName.LanguageName(x.QuestionEnName, _userInfo.IsEn_Us), - QuestionId = x.ReadingQuestionId, - TableQuestionId = x.Id, - Type = x.Type, - LesionType = question.LesionType, - TableQuestionType = x.TableQuestionType, - RowId = row.RowId, - IsShowInDicom = question.IsShowInDicom, - DataSource = x.DataSource, - DictionaryCode = x.DictionaryCode, - QuestionMark = x.QuestionMark, - TypeValue = x.TypeValue, - RowIndex = row.RowIndex, - ShowOrder = x.ShowOrder, - ValueType = x.ValueType, - Unit = x.Unit, - ReportLayType = ReportLayType.TableQuestion, - }).ToList(); - - - foreach (var tableQuestion in row.Childrens) - { - foreach (var task in taskInfoList) - { - var rowinfo = alltableAnsweRowInfos.Where(x => x.VisitTaskId == task.VisitTaskId && x.QuestionId == tableQuestion.QuestionId && x.RowIndex == tableQuestion.RowIndex).FirstOrDefault(); - var taskQuestionAnswer = new TaskQuestionAnswer() - { - Answer = tableAnswers.Where(x => x.VisitTaskId == task.VisitTaskId && x.QuestionId == tableQuestion.QuestionId && x.RowIndex == tableQuestion.RowIndex && x.TableQuestionId == tableQuestion.TableQuestionId).Select(x => x.Answer).FirstIsNullReturnEmpty(), - TaskName = task.TaskName, - VisitTaskId = task.VisitTaskId, - }; - if (rowinfo != null && rowinfo.OrganInfoId != null) - { - var organInfo = organInfos.Where(x => x.Id == rowinfo.OrganInfoId).FirstOrDefault(); - - - if (organInfo != null && needChangeType.Contains(tableQuestion.QuestionMark)) - { - if (_userInfo.IsEn_Us) - { - switch (tableQuestion.QuestionMark) - { - case QuestionMark.Organ: - taskQuestionAnswer.Answer = organInfo.TULOCEN; - - break; - case QuestionMark.Location: - if (organInfo.IsCanEditPosition) - { - - } - else - { - taskQuestionAnswer.Answer = organInfo.TULATEN; - - } - break; - case QuestionMark.Part: - - taskQuestionAnswer.Answer = organInfo.PartEN; - - break; - - } - - } - else - { - switch (tableQuestion.QuestionMark) - { - case QuestionMark.Organ: - taskQuestionAnswer.Answer = organInfo.TULOC; - break; - case QuestionMark.Location: - if (organInfo.IsCanEditPosition) - { - - } - else - { - taskQuestionAnswer.Answer = organInfo.TULAT; - - } - break; - case QuestionMark.Part: - taskQuestionAnswer.Answer = organInfo.Part; - break; - - } - } - - } - } - tableQuestion.Answer.Add(taskQuestionAnswer); - } - } - - - } - - - }; - } - #endregion + List questions = await _generalCalculateService.GetReadingReportQuestion + ( + questionList, + taskInfoList, + globalanswerList, + answers, + tableAnsweRowInfos, + tableQuestionList, + alltableAnsweRowInfos, + tableAnswers, + organInfos, + needChangeType + ); diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/IVUSCalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/IVUSCalculateService.cs index 430bfdcf8..b320b1ac1 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/IVUSCalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/IVUSCalculateService.cs @@ -166,12 +166,12 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate var answers = await _readingTaskQuestionAnswerRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync(); var tableAnswers = await _readingTableQuestionAnswerRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync(); - var globalanswerList = await _readingGlobalTaskInfoRepository.Where(x => visitTaskIds.Contains(x.TaskId) && x.GlobalVisitTask.TaskState == TaskState.Effect && x.Answer != string.Empty).Select(x => new + var globalanswerList = await _readingGlobalTaskInfoRepository.Where(x => visitTaskIds.Contains(x.TaskId) && x.GlobalVisitTask.TaskState == TaskState.Effect && x.Answer != string.Empty).Select(x => new Globalanswer() { - x.TaskId, - x.GlobalVisitTask.VisitTaskNum, - x.QuestionId, - x.Answer + TaskId = x.TaskId, + VisitTaskNum = x.GlobalVisitTask.VisitTaskNum, + QuestionId = x.QuestionId, + Answer = x.Answer }).ToListAsync(); var alltableAnsweRowInfos = await _readingTableAnswerRowInfoRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync(); var organIds = alltableAnsweRowInfos.Where(x => x.OrganInfoId != null).Select(x => x.OrganInfoId).Distinct().ToList(); @@ -185,217 +185,19 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate // 第一级 - #region 构造问题 - List questions = questionList.Where(x => x.Type == ReadingQestionType.Group).OrderBy(x => x.ShowOrder).Select(x => new ReadingReportDto() - { - QuestionId = x.Id, - GroupName = x.GroupName, - GroupEnName = x.GroupEnName, - IsShowInDicom = x.IsShowInDicom, - Type = x.Type, - GroupId = x.GroupId, - QuestionType = x.QuestionType, - LesionType = x.LesionType, - QuestionGenre = x.QuestionGenre, - DataSource = x.DataSource, - DictionaryCode = x.DictionaryCode, - TypeValue = x.TypeValue, - QuestionName = x.QuestionName.LanguageName(x.QuestionEnName, _userInfo.IsEn_Us), - ShowOrder = x.ShowOrder, - ValueType = x.ValueType, - Unit = x.Unit, - CustomUnit = x.CustomUnit, - ReportLayType = ReportLayType.Group, - HighlightAnswer = x.HighlightAnswer, - HighlightAnswerList = x.HighlightAnswerList, - }).ToList(); - - // 分组 - foreach (var item in questions) - { - item.Childrens = questionList.Where(x => x.GroupId == item.QuestionId).OrderBy(x => x.ShowOrder).Select(x => new ReadingReportDto() - { - GroupName = x.GroupName, - QuestionId = x.Id, - IsShowInDicom = x.IsShowInDicom, - GroupEnName = x.GroupEnName, - QuestionName = x.QuestionName.LanguageName(x.QuestionEnName, _userInfo.IsEn_Us), - LesionType = x.LesionType, - QuestionGenre = x.QuestionGenre, - DataSource = x.DataSource, - DictionaryCode = x.DictionaryCode, - Type = x.Type, - QuestionType = x.QuestionType, - TypeValue = x.TypeValue, - ShowOrder = x.ShowOrder, - OrderMark = x.OrderMark, - ValueType = x.ValueType, - Unit = x.Unit, - CustomUnit = x.CustomUnit, - ReportLayType = ReportLayType.Question, - HighlightAnswer = x.HighlightAnswer, - HighlightAnswerList = x.HighlightAnswerList, - }).ToList(); - - // 问题 - foreach (var question in item.Childrens) - { - - foreach (var task in taskInfoList) - { - var globalAnswer = globalanswerList.Where(x => x.TaskId == task.VisitTaskId && x.QuestionId == question.QuestionId).OrderByDescending(x => x.VisitTaskNum).FirstOrDefault(); - - var answer = answers.Where(x => x.VisitTaskId == task.VisitTaskId && x.ReadingQuestionTrialId == question.QuestionId).FirstOrDefault(); - question.Answer.Add(new TaskQuestionAnswer() - { - Answer = answer == null ? string.Empty : answer.Answer, - IsGlobalChange = globalAnswer == null ? false : true, - GlobalChangeAnswer = globalAnswer == null ? string.Empty : globalAnswer.Answer, - TaskName = task.TaskName, - VisitTaskId = task.VisitTaskId, - - }); - } - - // 构造表格行数据 - - - var rowlist = tableAnsweRowInfos.Where(x => x.QuestionId == question.QuestionId).OrderBy(x => x.RowIndex).ToList(); - - question.Childrens = new List(); - - var rowoindexs = lesionsIndexs.Where(x => x.QuestionId == question.QuestionId).Select(x => x.Rowindexs.OrderBy(y => y).ToList()).FirstOrDefault(); - rowoindexs = rowoindexs == null ? new List() : rowoindexs; - foreach (var rowoindex in rowoindexs) - { - var rowinfo = rowlist.Where(x => x.RowIndex == rowoindex).FirstOrDefault(); - question.Childrens.Add(new ReadingReportDto() - { - QuestionName = question.OrderMark + rowoindex.GetLesionMark(), - RowId = rowinfo?.Id, - IsShowInDicom = question.IsShowInDicom, - SplitOrMergeLesionName = rowinfo != null ? (rowinfo.MergeName.IsNullOrEmpty() ? rowinfo.SplitName : rowinfo.MergeName) : string.Empty, - SplitOrMergeType = rowinfo != null ? (rowinfo.SplitOrMergeType) : null, - LesionType = question.LesionType, - IsCanEditPosition = rowinfo != null ? (rowinfo.IsCanEditPosition) : false, - RowIndex = rowoindex, - BlindName = rowinfo != null ? rowinfo.BlindName : string.Empty, - ReportLayType = ReportLayType.Lesions, - ReportMark = rowinfo != null ? rowinfo.ReportMark : string.Empty, - - }); - } - - - foreach (var row in question.Childrens) - { - // tableQuestion - row.Childrens = tableQuestionList.Where(x => x.ReadingQuestionId == question.QuestionId).Select(x => new ReadingReportDto() - { - QuestionName = x.QuestionName.LanguageName(x.QuestionEnName, _userInfo.IsEn_Us), - QuestionId = x.ReadingQuestionId, - TableQuestionId = x.Id, - Type = x.Type, - LesionType = question.LesionType, - TableQuestionType = x.TableQuestionType, - RowId = row.RowId, - IsShowInDicom = question.IsShowInDicom, - DataSource = x.DataSource, - DictionaryCode = x.DictionaryCode, - QuestionMark = x.QuestionMark, - TypeValue = x.TypeValue, - RowIndex = row.RowIndex, - ShowOrder = x.ShowOrder, - ValueType = x.ValueType, - Unit = x.Unit, - ReportLayType = ReportLayType.TableQuestion, - }).ToList(); - - - foreach (var tableQuestion in row.Childrens) - { - foreach (var task in taskInfoList) - { - var rowinfo = alltableAnsweRowInfos.Where(x => x.VisitTaskId == task.VisitTaskId && x.QuestionId == tableQuestion.QuestionId && x.RowIndex == tableQuestion.RowIndex).FirstOrDefault(); - var taskQuestionAnswer = new TaskQuestionAnswer() - { - Answer = tableAnswers.Where(x => x.VisitTaskId == task.VisitTaskId && x.QuestionId == tableQuestion.QuestionId && x.RowIndex == tableQuestion.RowIndex && x.TableQuestionId == tableQuestion.TableQuestionId).Select(x => x.Answer).FirstIsNullReturnEmpty(), - TaskName = task.TaskName, - VisitTaskId = task.VisitTaskId, - }; - if (rowinfo != null && rowinfo.OrganInfoId != null) - { - var organInfo = organInfos.Where(x => x.Id == rowinfo.OrganInfoId).FirstOrDefault(); - - - if (organInfo != null && needChangeType.Contains(tableQuestion.QuestionMark)) - { - if (_userInfo.IsEn_Us) - { - switch (tableQuestion.QuestionMark) - { - case QuestionMark.Organ: - taskQuestionAnswer.Answer = organInfo.TULOCEN; - - break; - case QuestionMark.Location: - if (organInfo.IsCanEditPosition) - { - - } - else - { - taskQuestionAnswer.Answer = organInfo.TULATEN; - - } - break; - case QuestionMark.Part: - - taskQuestionAnswer.Answer = organInfo.PartEN; - - break; - - } - - } - else - { - switch (tableQuestion.QuestionMark) - { - case QuestionMark.Organ: - taskQuestionAnswer.Answer = organInfo.TULOC; - break; - case QuestionMark.Location: - if (organInfo.IsCanEditPosition) - { - - } - else - { - taskQuestionAnswer.Answer = organInfo.TULAT; - - } - break; - case QuestionMark.Part: - taskQuestionAnswer.Answer = organInfo.Part; - break; - - } - } - - } - } - tableQuestion.Answer.Add(taskQuestionAnswer); - } - } - - - } - - - }; - } - #endregion + List questions = await _generalCalculateService.GetReadingReportQuestion + ( + questionList, + taskInfoList, + globalanswerList, + answers, + tableAnsweRowInfos, + tableQuestionList, + alltableAnsweRowInfos, + tableAnswers, + organInfos, + needChangeType + ); diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/Interface/IGeneralCalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/Interface/IGeneralCalculateService.cs index 9eaefec17..693033710 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/Interface/IGeneralCalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/Interface/IGeneralCalculateService.cs @@ -8,6 +8,19 @@ namespace IRaCIS.Core.Application.Service public interface IGeneralCalculateService { + Task> GetReadingReportQuestion( + List? questionList, + List taskInfoList, + List? globalanswerList, + List? answers, + List? tableAnsweRowInfos, + List tableQuestionList, + List alltableAnsweRowInfos, + List tableAnswers, + List organInfos, + List needChangeType + ); + /// /// 获取ReadingCalculateDto /// diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/LuganoCalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/LuganoCalculateService.cs index 1f79f7492..8ed02de45 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/LuganoCalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/LuganoCalculateService.cs @@ -133,12 +133,12 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate var answers = await _readingTaskQuestionAnswerRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync(); var tableAnswers = await _readingTableQuestionAnswerRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync(); - var globalanswerList = await _readingGlobalTaskInfoRepository.Where(x => visitTaskIds.Contains(x.TaskId) && x.GlobalVisitTask.TaskState == TaskState.Effect && x.Answer != string.Empty).Select(x => new + var globalanswerList = await _readingGlobalTaskInfoRepository.Where(x => visitTaskIds.Contains(x.TaskId) && x.GlobalVisitTask.TaskState == TaskState.Effect && x.Answer != string.Empty).Select(x => new Globalanswer() { - x.TaskId, - x.GlobalVisitTask.VisitTaskNum, - x.QuestionId, - x.Answer + TaskId = x.TaskId, + VisitTaskNum = x.GlobalVisitTask.VisitTaskNum, + QuestionId = x.QuestionId, + Answer = x.Answer }).ToListAsync(); var alltableAnsweRowInfos = await _readingTableAnswerRowInfoRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync(); @@ -153,207 +153,19 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate // 第一级 - #region 构造问题 - List questions = questionList.Where(x => x.Type == ReadingQestionType.Group).OrderBy(x => x.ShowOrder).Select(x => new ReadingReportDto() - { - QuestionId = x.Id, - GroupName = x.GroupName, - GroupEnName = x.GroupEnName, - IsShowInDicom = x.IsShowInDicom, - Type = x.Type, - GroupId = x.GroupId, - QuestionType = x.QuestionType, - LesionType = x.LesionType, - QuestionGenre = x.QuestionGenre, - DataSource = x.DataSource, - DictionaryCode = x.DictionaryCode, - TypeValue = x.TypeValue, - QuestionName = x.QuestionName.LanguageName(x.QuestionEnName, _userInfo.IsEn_Us), - ShowOrder = x.ShowOrder, - ValueType = x.ValueType, - Unit = x.Unit, - CustomUnit = x.CustomUnit, - ReportLayType = ReportLayType.Group, - HighlightAnswer = x.HighlightAnswer, - HighlightAnswerList = x.HighlightAnswerList, - }).ToList(); - - // 分组 - foreach (var item in questions) - { - item.Childrens = questionList.Where(x => x.GroupId == item.QuestionId).OrderBy(x => x.ShowOrder).Select(x => new ReadingReportDto() - { - GroupName = x.GroupName, - QuestionId = x.Id, - IsShowInDicom = x.IsShowInDicom, - GroupEnName = x.GroupEnName, - QuestionName = x.QuestionName.LanguageName(x.QuestionEnName, _userInfo.IsEn_Us), - LesionType = x.LesionType, - QuestionGenre = x.QuestionGenre, - DataSource = x.DataSource, - DictionaryCode = x.DictionaryCode, - Type = x.Type, - QuestionType = x.QuestionType, - TypeValue = x.TypeValue, - ShowOrder = x.ShowOrder, - OrderMark = x.OrderMark, - ValueType = x.ValueType, - Unit = x.Unit, - CustomUnit = x.CustomUnit, - ReportLayType = ReportLayType.Question, - HighlightAnswer = x.HighlightAnswer, - HighlightAnswerList = x.HighlightAnswerList, - }).ToList(); - - // 问题 - foreach (var question in item.Childrens) - { - - foreach (var task in taskInfoList) - { - - var globalAnswer = globalanswerList.Where(x => x.TaskId == task.VisitTaskId && x.QuestionId == question.QuestionId).OrderByDescending(x => x.VisitTaskNum).FirstOrDefault(); - var answer = answers.Where(x => x.VisitTaskId == task.VisitTaskId && x.ReadingQuestionTrialId == question.QuestionId).FirstOrDefault(); - question.Answer.Add(new TaskQuestionAnswer() - { - Answer = answer == null ? string.Empty : answer.Answer, - IsGlobalChange = globalAnswer == null ? false : true, - GlobalChangeAnswer = globalAnswer == null ? string.Empty : globalAnswer.Answer, - TaskName = task.TaskName, - VisitTaskId = task.VisitTaskId, - - }); - } - - // 构造表格行数据 - - - var rowlist = tableAnsweRowInfos.Where(x => x.QuestionId == question.QuestionId).OrderBy(x => x.RowIndex).ToList(); - - - question.Childrens = rowlist.Select(x => new ReadingReportDto() - { - QuestionName = question.OrderMark + x.RowIndex.GetLesionMark(), - SplitOrMergeLesionName = x.MergeName.IsNullOrEmpty() ? x.SplitName : x.MergeName, - SplitOrMergeType = x.SplitOrMergeType, - LesionType = question.LesionType, - IsShowInDicom = question.IsShowInDicom, - IsCanEditPosition = x.IsCanEditPosition, - RowIndex = x.RowIndex, - BlindName = x.BlindName, - ReportLayType = ReportLayType.Lesions, - }).ToList(); - - - foreach (var row in question.Childrens) - { - // tableQuestion - row.Childrens = tableQuestionList.Where(x => x.ReadingQuestionId == question.QuestionId).Select(x => new ReadingReportDto() - { - QuestionName = x.QuestionName.LanguageName(x.QuestionEnName, _userInfo.IsEn_Us), - QuestionId = x.ReadingQuestionId, - TableQuestionId = x.Id, - Type = x.Type, - LesionType = question.LesionType, - TableQuestionType = x.TableQuestionType, - RowId = row.RowId, - IsShowInDicom = question.IsShowInDicom, - DataSource = x.DataSource, - DictionaryCode = x.DictionaryCode, - QuestionMark = x.QuestionMark, - TypeValue = x.TypeValue, - RowIndex = row.RowIndex, - ShowOrder = x.ShowOrder, - ValueType = x.ValueType, - Unit = x.Unit, - ReportLayType = ReportLayType.TableQuestion, - }).ToList(); - - - foreach (var tableQuestion in row.Childrens) - { - foreach (var task in taskInfoList) - { - var rowinfo = alltableAnsweRowInfos.Where(x => x.VisitTaskId == task.VisitTaskId && x.QuestionId == tableQuestion.QuestionId && x.RowIndex == tableQuestion.RowIndex).FirstOrDefault(); - var taskQuestionAnswer = new TaskQuestionAnswer() - { - Answer = tableAnswers.Where(x => x.VisitTaskId == task.VisitTaskId && x.QuestionId == tableQuestion.QuestionId && x.RowIndex == tableQuestion.RowIndex && x.TableQuestionId == tableQuestion.TableQuestionId).Select(x => x.Answer).FirstIsNullReturnEmpty(), - TaskName = task.TaskName, - VisitTaskId = task.VisitTaskId, - }; - if (rowinfo != null && rowinfo.OrganInfoId != null) - { - var organInfo = organInfos.Where(x => x.Id == rowinfo.OrganInfoId).FirstOrDefault(); - - - if (organInfo != null && needChangeType.Contains(tableQuestion.QuestionMark)) - { - if (_userInfo.IsEn_Us) - { - switch (tableQuestion.QuestionMark) - { - case QuestionMark.Organ: - taskQuestionAnswer.Answer = organInfo.TULOCEN; - - break; - case QuestionMark.Location: - if (organInfo.IsCanEditPosition) - { - - } - else - { - taskQuestionAnswer.Answer = organInfo.TULATEN; - - } - break; - case QuestionMark.Part: - - taskQuestionAnswer.Answer = organInfo.PartEN; - - break; - - } - - } - else - { - switch (tableQuestion.QuestionMark) - { - case QuestionMark.Organ: - taskQuestionAnswer.Answer = organInfo.TULOC; - break; - case QuestionMark.Location: - if (organInfo.IsCanEditPosition) - { - - } - else - { - taskQuestionAnswer.Answer = organInfo.TULAT; - - } - break; - case QuestionMark.Part: - taskQuestionAnswer.Answer = organInfo.Part; - break; - - } - } - - } - } - tableQuestion.Answer.Add(taskQuestionAnswer); - } - } - - - } - - - }; - } - #endregion + List questions = await _generalCalculateService.GetReadingReportQuestion + ( + questionList, + taskInfoList, + globalanswerList, + answers, + tableAnsweRowInfos, + tableQuestionList, + alltableAnsweRowInfos, + tableAnswers, + organInfos, + needChangeType + ); diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/LuganoWithoutPETCalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/LuganoWithoutPETCalculateService.cs index 100debf1a..fee56e56b 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/LuganoWithoutPETCalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/LuganoWithoutPETCalculateService.cs @@ -134,12 +134,12 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate var answers = await _readingTaskQuestionAnswerRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync(); var tableAnswers = await _readingTableQuestionAnswerRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync(); - var globalanswerList = await _readingGlobalTaskInfoRepository.Where(x => visitTaskIds.Contains(x.TaskId) && x.GlobalVisitTask.TaskState == TaskState.Effect && x.Answer != string.Empty).Select(x => new + var globalanswerList = await _readingGlobalTaskInfoRepository.Where(x => visitTaskIds.Contains(x.TaskId) && x.GlobalVisitTask.TaskState == TaskState.Effect && x.Answer != string.Empty).Select(x => new Globalanswer() { - x.TaskId, - x.GlobalVisitTask.VisitTaskNum, - x.QuestionId, - x.Answer + TaskId = x.TaskId, + VisitTaskNum = x.GlobalVisitTask.VisitTaskNum, + QuestionId = x.QuestionId, + Answer = x.Answer }).ToListAsync(); var alltableAnsweRowInfos = await _readingTableAnswerRowInfoRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync(); @@ -154,207 +154,19 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate // 第一级 - #region 构造问题 - List questions = questionList.Where(x => x.Type == ReadingQestionType.Group).OrderBy(x => x.ShowOrder).Select(x => new ReadingReportDto() - { - QuestionId = x.Id, - GroupName = x.GroupName, - GroupEnName = x.GroupEnName, - IsShowInDicom = x.IsShowInDicom, - Type = x.Type, - GroupId = x.GroupId, - QuestionType = x.QuestionType, - LesionType = x.LesionType, - QuestionGenre = x.QuestionGenre, - DataSource = x.DataSource, - DictionaryCode = x.DictionaryCode, - TypeValue = x.TypeValue, - QuestionName = x.QuestionName.LanguageName(x.QuestionEnName, _userInfo.IsEn_Us), - ShowOrder = x.ShowOrder, - ValueType = x.ValueType, - Unit = x.Unit, - CustomUnit = x.CustomUnit, - ReportLayType = ReportLayType.Group, - HighlightAnswer = x.HighlightAnswer, - HighlightAnswerList = x.HighlightAnswerList, - }).ToList(); - - // 分组 - foreach (var item in questions) - { - item.Childrens = questionList.Where(x => x.GroupId == item.QuestionId).OrderBy(x => x.ShowOrder).Select(x => new ReadingReportDto() - { - GroupName = x.GroupName, - QuestionId = x.Id, - IsShowInDicom = x.IsShowInDicom, - GroupEnName = x.GroupEnName, - QuestionName = x.QuestionName.LanguageName(x.QuestionEnName, _userInfo.IsEn_Us), - LesionType = x.LesionType, - QuestionGenre = x.QuestionGenre, - DataSource = x.DataSource, - DictionaryCode = x.DictionaryCode, - Type = x.Type, - QuestionType = x.QuestionType, - TypeValue = x.TypeValue, - ShowOrder = x.ShowOrder, - OrderMark = x.OrderMark, - ValueType = x.ValueType, - Unit = x.Unit, - CustomUnit = x.CustomUnit, - ReportLayType = ReportLayType.Question, - HighlightAnswer = x.HighlightAnswer, - HighlightAnswerList = x.HighlightAnswerList, - }).ToList(); - - // 问题 - foreach (var question in item.Childrens) - { - - foreach (var task in taskInfoList) - { - - var globalAnswer = globalanswerList.Where(x => x.TaskId == task.VisitTaskId && x.QuestionId == question.QuestionId).OrderByDescending(x => x.VisitTaskNum).FirstOrDefault(); - var answer = answers.Where(x => x.VisitTaskId == task.VisitTaskId && x.ReadingQuestionTrialId == question.QuestionId).FirstOrDefault(); - question.Answer.Add(new TaskQuestionAnswer() - { - Answer = answer == null ? string.Empty : answer.Answer, - IsGlobalChange = globalAnswer == null ? false : true, - GlobalChangeAnswer = globalAnswer == null ? string.Empty : globalAnswer.Answer, - TaskName = task.TaskName, - VisitTaskId = task.VisitTaskId, - - }); - } - - // 构造表格行数据 - - - var rowlist = tableAnsweRowInfos.Where(x => x.QuestionId == question.QuestionId).OrderBy(x => x.RowIndex).ToList(); - - - question.Childrens = rowlist.Select(x => new ReadingReportDto() - { - QuestionName = question.OrderMark + x.RowIndex.GetLesionMark(), - SplitOrMergeLesionName = x.MergeName.IsNullOrEmpty() ? x.SplitName : x.MergeName, - SplitOrMergeType = x.SplitOrMergeType, - LesionType = question.LesionType, - IsShowInDicom = question.IsShowInDicom, - IsCanEditPosition = x.IsCanEditPosition, - RowIndex = x.RowIndex, - BlindName = x.BlindName, - ReportLayType = ReportLayType.Lesions, - }).ToList(); - - - foreach (var row in question.Childrens) - { - // tableQuestion - row.Childrens = tableQuestionList.Where(x => x.ReadingQuestionId == question.QuestionId).Select(x => new ReadingReportDto() - { - QuestionName = x.QuestionName.LanguageName(x.QuestionEnName, _userInfo.IsEn_Us), - QuestionId = x.ReadingQuestionId, - TableQuestionId = x.Id, - Type = x.Type, - LesionType = question.LesionType, - TableQuestionType = x.TableQuestionType, - RowId = row.RowId, - IsShowInDicom = question.IsShowInDicom, - DataSource = x.DataSource, - DictionaryCode = x.DictionaryCode, - QuestionMark = x.QuestionMark, - TypeValue = x.TypeValue, - RowIndex = row.RowIndex, - ShowOrder = x.ShowOrder, - ValueType = x.ValueType, - Unit = x.Unit, - ReportLayType = ReportLayType.TableQuestion, - }).ToList(); - - - foreach (var tableQuestion in row.Childrens) - { - foreach (var task in taskInfoList) - { - var rowinfo = alltableAnsweRowInfos.Where(x => x.VisitTaskId == task.VisitTaskId && x.QuestionId == tableQuestion.QuestionId && x.RowIndex == tableQuestion.RowIndex).FirstOrDefault(); - var taskQuestionAnswer = new TaskQuestionAnswer() - { - Answer = tableAnswers.Where(x => x.VisitTaskId == task.VisitTaskId && x.QuestionId == tableQuestion.QuestionId && x.RowIndex == tableQuestion.RowIndex && x.TableQuestionId == tableQuestion.TableQuestionId).Select(x => x.Answer).FirstIsNullReturnEmpty(), - TaskName = task.TaskName, - VisitTaskId = task.VisitTaskId, - }; - if (rowinfo != null && rowinfo.OrganInfoId != null) - { - var organInfo = organInfos.Where(x => x.Id == rowinfo.OrganInfoId).FirstOrDefault(); - - - if (organInfo != null && needChangeType.Contains(tableQuestion.QuestionMark)) - { - if (_userInfo.IsEn_Us) - { - switch (tableQuestion.QuestionMark) - { - case QuestionMark.Organ: - taskQuestionAnswer.Answer = organInfo.TULOCEN; - - break; - case QuestionMark.Location: - if (organInfo.IsCanEditPosition) - { - - } - else - { - taskQuestionAnswer.Answer = organInfo.TULATEN; - - } - break; - case QuestionMark.Part: - - taskQuestionAnswer.Answer = organInfo.PartEN; - - break; - - } - - } - else - { - switch (tableQuestion.QuestionMark) - { - case QuestionMark.Organ: - taskQuestionAnswer.Answer = organInfo.TULOC; - break; - case QuestionMark.Location: - if (organInfo.IsCanEditPosition) - { - - } - else - { - taskQuestionAnswer.Answer = organInfo.TULAT; - - } - break; - case QuestionMark.Part: - taskQuestionAnswer.Answer = organInfo.Part; - break; - - } - } - - } - } - tableQuestion.Answer.Add(taskQuestionAnswer); - } - } - - - } - - - }; - } - #endregion + List questions = await _generalCalculateService.GetReadingReportQuestion + ( + questionList, + taskInfoList, + globalanswerList, + answers, + tableAnsweRowInfos, + tableQuestionList, + alltableAnsweRowInfos, + tableAnswers, + organInfos, + needChangeType + ); diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/MRECISTHCCCalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/MRECISTHCCCalculateService.cs index 2f2ab5243..8bfa959a5 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/MRECISTHCCCalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/MRECISTHCCCalculateService.cs @@ -106,12 +106,12 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate }).ToList(); var answers = await _readingTaskQuestionAnswerRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync(); var tableAnswers = await _readingTableQuestionAnswerRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync(); - var globalanswerList = await _readingGlobalTaskInfoRepository.Where(x => visitTaskIds.Contains(x.TaskId) && x.GlobalVisitTask.TaskState == TaskState.Effect && x.Answer != string.Empty).Select(x => new + var globalanswerList = await _readingGlobalTaskInfoRepository.Where(x => visitTaskIds.Contains(x.TaskId) && x.GlobalVisitTask.TaskState == TaskState.Effect && x.Answer != string.Empty).Select(x => new Globalanswer() { - x.TaskId, - x.GlobalVisitTask.VisitTaskNum, - x.QuestionId, - x.Answer + TaskId = x.TaskId, + VisitTaskNum = x.GlobalVisitTask.VisitTaskNum, + QuestionId = x.QuestionId, + Answer = x.Answer }).ToListAsync(); var alltableAnsweRowInfos = await _readingTableAnswerRowInfoRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync(); var organIds = alltableAnsweRowInfos.Where(x => x.OrganInfoId != null).Select(x => x.OrganInfoId).Distinct().ToList(); @@ -125,207 +125,19 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate // 第一级 - #region 构造问题 - List questions = questionList.Where(x => x.Type == ReadingQestionType.Group).OrderBy(x => x.ShowOrder).Select(x => new ReadingReportDto() - { - QuestionId = x.Id, - GroupName = x.GroupName, - GroupEnName = x.GroupEnName, - IsShowInDicom = x.IsShowInDicom, - Type = x.Type, - GroupId = x.GroupId, - QuestionType = x.QuestionType, - LesionType = x.LesionType, - QuestionGenre = x.QuestionGenre, - DataSource = x.DataSource, - DictionaryCode = x.DictionaryCode, - TypeValue = x.TypeValue, - QuestionName = x.QuestionName.LanguageName(x.QuestionEnName, _userInfo.IsEn_Us), - ShowOrder = x.ShowOrder, - ValueType = x.ValueType, - Unit = x.Unit, - CustomUnit = x.CustomUnit, - ReportLayType = ReportLayType.Group, - HighlightAnswer = x.HighlightAnswer, - HighlightAnswerList = x.HighlightAnswerList, - }).ToList(); - - // 分组 - foreach (var item in questions) - { - item.Childrens = questionList.Where(x => x.GroupId == item.QuestionId).OrderBy(x => x.ShowOrder).Select(x => new ReadingReportDto() - { - GroupName = x.GroupName, - QuestionId = x.Id, - IsShowInDicom = x.IsShowInDicom, - GroupEnName = x.GroupEnName, - QuestionName = x.QuestionName.LanguageName(x.QuestionEnName, _userInfo.IsEn_Us), - LesionType = x.LesionType, - QuestionGenre = x.QuestionGenre, - DataSource = x.DataSource, - DictionaryCode = x.DictionaryCode, - Type = x.Type, - QuestionType = x.QuestionType, - TypeValue = x.TypeValue, - ShowOrder = x.ShowOrder, - OrderMark = x.OrderMark, - ValueType = x.ValueType, - Unit = x.Unit, - CustomUnit = x.CustomUnit, - ReportLayType = ReportLayType.Question, - HighlightAnswer = x.HighlightAnswer, - HighlightAnswerList = x.HighlightAnswerList, - }).ToList(); - - // 问题 - foreach (var question in item.Childrens) - { - - foreach (var task in taskInfoList) - { - var globalAnswer = globalanswerList.Where(x => x.TaskId == task.VisitTaskId && x.QuestionId == question.QuestionId).OrderByDescending(x => x.VisitTaskNum).FirstOrDefault(); - - var answer = answers.Where(x => x.VisitTaskId == task.VisitTaskId && x.ReadingQuestionTrialId == question.QuestionId).FirstOrDefault(); - question.Answer.Add(new TaskQuestionAnswer() - { - Answer = answer == null ? string.Empty : answer.Answer, - IsGlobalChange = globalAnswer == null ? false : true, - GlobalChangeAnswer = globalAnswer == null ? string.Empty : globalAnswer.Answer, - TaskName = task.TaskName, - VisitTaskId = task.VisitTaskId, - - }); - } - - // 构造表格行数据 - - - var rowlist = tableAnsweRowInfos.Where(x => x.QuestionId == question.QuestionId).OrderBy(x => x.RowIndex).ToList(); - - - question.Childrens = rowlist.Select(x => new ReadingReportDto() - { - QuestionName = question.OrderMark + x.RowIndex.GetLesionMark(), - SplitOrMergeLesionName = x.MergeName.IsNullOrEmpty() ? x.SplitName : x.MergeName, - SplitOrMergeType = x.SplitOrMergeType, - LesionType = question.LesionType, - IsShowInDicom = question.IsShowInDicom, - IsCanEditPosition = x.IsCanEditPosition, - RowIndex = x.RowIndex, - BlindName = x.BlindName, - ReportLayType = ReportLayType.Lesions, - }).ToList(); - - - foreach (var row in question.Childrens) - { - // tableQuestion - row.Childrens = tableQuestionList.Where(x => x.ReadingQuestionId == question.QuestionId).Select(x => new ReadingReportDto() - { - QuestionName = x.QuestionName.LanguageName(x.QuestionEnName, _userInfo.IsEn_Us), - QuestionId = x.ReadingQuestionId, - TableQuestionId = x.Id, - Type = x.Type, - LesionType = question.LesionType, - TableQuestionType = x.TableQuestionType, - RowId = row.RowId, - IsShowInDicom = question.IsShowInDicom, - DataSource = x.DataSource, - DictionaryCode = x.DictionaryCode, - QuestionMark = x.QuestionMark, - TypeValue = x.TypeValue, - RowIndex = row.RowIndex, - ShowOrder = x.ShowOrder, - ValueType = x.ValueType, - Unit = x.Unit, - ReportLayType = ReportLayType.TableQuestion, - }).ToList(); - - - foreach (var tableQuestion in row.Childrens) - { - foreach (var task in taskInfoList) - { - var rowinfo = alltableAnsweRowInfos.Where(x => x.VisitTaskId == task.VisitTaskId && x.QuestionId == tableQuestion.QuestionId && x.RowIndex == tableQuestion.RowIndex).FirstOrDefault(); - var taskQuestionAnswer = new TaskQuestionAnswer() - { - Answer = tableAnswers.Where(x => x.VisitTaskId == task.VisitTaskId && x.QuestionId == tableQuestion.QuestionId && x.RowIndex == tableQuestion.RowIndex && x.TableQuestionId == tableQuestion.TableQuestionId).Select(x => x.Answer).FirstIsNullReturnEmpty(), - TaskName = task.TaskName, - VisitTaskId = task.VisitTaskId, - }; - if (rowinfo != null && rowinfo.OrganInfoId != null) - { - var organInfo = organInfos.Where(x => x.Id == rowinfo.OrganInfoId).FirstOrDefault(); - - - if (organInfo != null && needChangeType.Contains(tableQuestion.QuestionMark)) - { - if (_userInfo.IsEn_Us) - { - switch (tableQuestion.QuestionMark) - { - case QuestionMark.Organ: - taskQuestionAnswer.Answer = organInfo.TULOCEN; - - break; - case QuestionMark.Location: - if (organInfo.IsCanEditPosition) - { - - } - else - { - taskQuestionAnswer.Answer = organInfo.TULATEN; - - } - break; - case QuestionMark.Part: - - taskQuestionAnswer.Answer = organInfo.PartEN; - - break; - - } - - } - else - { - switch (tableQuestion.QuestionMark) - { - case QuestionMark.Organ: - taskQuestionAnswer.Answer = organInfo.TULOC; - break; - case QuestionMark.Location: - if (organInfo.IsCanEditPosition) - { - - } - else - { - taskQuestionAnswer.Answer = organInfo.TULAT; - - } - break; - case QuestionMark.Part: - taskQuestionAnswer.Answer = organInfo.Part; - break; - - } - } - - } - } - tableQuestion.Answer.Add(taskQuestionAnswer); - } - } - - - } - - - }; - } - #endregion + List questions = await _generalCalculateService.GetReadingReportQuestion + ( + questionList, + taskInfoList, + globalanswerList, + answers, + tableAnsweRowInfos, + tableQuestionList, + alltableAnsweRowInfos, + tableAnswers, + organInfos, + needChangeType + ); diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/MRIPDFFCalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/MRIPDFFCalculateService.cs index c368029d9..0b564dfd5 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/MRIPDFFCalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/MRIPDFFCalculateService.cs @@ -108,12 +108,12 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate var answers = await _readingTaskQuestionAnswerRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync(); var tableAnswers = await _readingTableQuestionAnswerRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync(); - var globalanswerList = await _readingGlobalTaskInfoRepository.Where(x => visitTaskIds.Contains(x.TaskId) && x.GlobalVisitTask.TaskState == TaskState.Effect && x.Answer != string.Empty).Select(x => new + var globalanswerList = await _readingGlobalTaskInfoRepository.Where(x => visitTaskIds.Contains(x.TaskId) && x.GlobalVisitTask.TaskState == TaskState.Effect && x.Answer != string.Empty).Select(x => new Globalanswer() { - x.TaskId, - x.GlobalVisitTask.VisitTaskNum, - x.QuestionId, - x.Answer + TaskId = x.TaskId, + VisitTaskNum = x.GlobalVisitTask.VisitTaskNum, + QuestionId = x.QuestionId, + Answer = x.Answer }).ToListAsync(); var alltableAnsweRowInfos = await _readingTableAnswerRowInfoRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync(); var organIds = alltableAnsweRowInfos.Where(x => x.OrganInfoId != null).Select(x => x.OrganInfoId).Distinct().ToList(); @@ -127,227 +127,19 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate // 第一级 - #region 构造问题 - List questions = questionList.Where(x => x.Type == ReadingQestionType.Group).OrderBy(x => x.ShowOrder).Select(x => new ReadingReportDto() - { - QuestionId = x.Id, - GroupName = x.GroupName.LanguageName(x.GroupEnName, _userInfo.IsEn_Us), - IsShowInDicom = x.IsShowInDicom, - Type = x.Type, - GroupId = x.GroupId, - GroupEnName = x.GroupEnName, - QuestionType = x.QuestionType, - DataSource = x.DataSource, - LesionType = x.LesionType, - QuestionGenre = x.QuestionGenre, - DictionaryCode = x.DictionaryCode, - LimitEdit = x.LimitEdit, - MaxAnswerLength = x.MaxAnswerLength, - FileType = x.FileType, - TypeValue = x.TypeValue, - QuestionName = x.QuestionName.LanguageName(x.QuestionEnName, _userInfo.IsEn_Us), - ShowOrder = x.ShowOrder, - ValueType = x.ValueType, - Unit = x.Unit, - CustomUnit = x.CustomUnit, - ReportLayType = ReportLayType.Group, - HighlightAnswer = x.HighlightAnswer, - HighlightAnswerList = x.HighlightAnswerList, - }).ToList(); - - // 分组 - foreach (var item in questions) - { - item.Childrens = questionList.Where(x => x.GroupId == item.QuestionId).OrderBy(x => x.ShowOrder).Select(x => new ReadingReportDto() - { - GroupName = x.GroupName.LanguageName(x.GroupEnName, _userInfo.IsEn_Us), - QuestionId = x.Id, - IsShowInDicom = x.IsShowInDicom, - QuestionName = x.QuestionName.LanguageName(x.QuestionEnName, _userInfo.IsEn_Us), - LesionType = x.LesionType, - DataSource = x.DataSource, - QuestionGenre = x.QuestionGenre, - GroupEnName = x.GroupEnName, - LimitEdit = x.LimitEdit, - MaxAnswerLength = x.MaxAnswerLength, - FileType = x.FileType, - DictionaryCode = x.DictionaryCode, - Type = x.Type, - QuestionType = x.QuestionType, - TypeValue = x.TypeValue, - ShowOrder = x.ShowOrder, - OrderMark = x.OrderMark, - ValueType = x.ValueType, - Unit = x.Unit, - CustomUnit = x.CustomUnit, - ReportLayType = ReportLayType.Question, - HighlightAnswer = x.HighlightAnswer, - HighlightAnswerList = x.HighlightAnswerList, - }).ToList(); - - // 问题 - foreach (var question in item.Childrens) - { - - foreach (var task in taskInfoList) - { - var globalAnswer = globalanswerList.Where(x => x.TaskId == task.VisitTaskId && x.QuestionId == question.QuestionId).OrderByDescending(x => x.VisitTaskNum).FirstOrDefault(); - - var answer = answers.Where(x => x.VisitTaskId == task.VisitTaskId && x.ReadingQuestionTrialId == question.QuestionId).FirstOrDefault(); - question.Answer.Add(new TaskQuestionAnswer() - { - Answer = answer == null ? string.Empty : answer.Answer, - IsGlobalChange = globalAnswer == null ? false : true, - GlobalChangeAnswer = globalAnswer == null ? string.Empty : globalAnswer.Answer, - TaskName = task.TaskName, - VisitTaskId = task.VisitTaskId, - - }); - } - - // 构造表格行数据 - - - var rowlist = tableAnsweRowInfos.Where(x => x.QuestionId == question.QuestionId).OrderBy(x => x.RowIndex).ToList(); - - question.Childrens = new List(); - - var rowoindexs = lesionsIndexs.Where(x => x.QuestionId == question.QuestionId).Select(x => x.Rowindexs.OrderBy(y => y).ToList()).FirstOrDefault(); - rowoindexs = rowoindexs == null ? new List() : rowoindexs; - foreach (var rowoindex in rowoindexs) - { - var rowinfo = rowlist.Where(x => x.RowIndex == rowoindex).FirstOrDefault(); - question.Childrens.Add(new ReadingReportDto() - { - QuestionName = question.OrderMark + rowoindex.GetLesionMark(), - RowId = rowinfo?.Id, - IsShowInDicom = question.IsShowInDicom, - SplitOrMergeLesionName = rowinfo != null ? (rowinfo.MergeName.IsNullOrEmpty() ? rowinfo.SplitName : rowinfo.MergeName) : string.Empty, - SplitOrMergeType = rowinfo != null ? (rowinfo.SplitOrMergeType) : null, - LesionType = question.LesionType, - IsCanEditPosition = rowinfo != null ? (rowinfo.IsCanEditPosition) : false, - RowIndex = rowoindex, - BlindName = rowinfo != null ? rowinfo.BlindName : string.Empty, - ReportLayType = ReportLayType.Lesions, - }); - } - - - - - foreach (var row in question.Childrens) - { - // tableQuestion - row.Childrens = tableQuestionList.Where(x => x.ReadingQuestionId == question.QuestionId).Select(x => new ReadingReportDto() - { - QuestionName = x.QuestionName.LanguageName(x.QuestionEnName, _userInfo.IsEn_Us), - QuestionId = x.ReadingQuestionId, - TableQuestionId = x.Id, - Type = x.Type, - IsShowInDicom = question.IsShowInDicom, - DataSource = x.DataSource, - LimitEdit = x.LimitEdit, - MaxAnswerLength = x.MaxAnswerLength, - FileType = x.FileType, - LesionType = question.LesionType, - TableQuestionType = x.TableQuestionType, - DictionaryCode = x.DictionaryCode, - QuestionMark = x.QuestionMark, - TypeValue = x.TypeValue, - RowIndex = row.RowIndex, - RowId = row.RowId, - ShowOrder = x.ShowOrder, - ValueType = x.ValueType, - CustomUnit = x.CustomUnit, - Unit = x.Unit, - ReportLayType = ReportLayType.TableQuestion, - }).ToList(); - - - foreach (var tableQuestion in row.Childrens) - { - foreach (var task in taskInfoList) - { - var rowinfo = alltableAnsweRowInfos.Where(x => x.VisitTaskId == task.VisitTaskId && x.QuestionId == tableQuestion.QuestionId && x.RowIndex == tableQuestion.RowIndex).FirstOrDefault(); - var taskQuestionAnswer = new TaskQuestionAnswer() - { - Answer = tableAnswers.Where(x => x.VisitTaskId == task.VisitTaskId && x.QuestionId == tableQuestion.QuestionId && x.RowIndex == tableQuestion.RowIndex && x.TableQuestionId == tableQuestion.TableQuestionId).Select(x => x.Answer).FirstIsNullReturnEmpty(), - TaskName = task.TaskName, - VisitTaskId = task.VisitTaskId, - }; - if (rowinfo != null && rowinfo.OrganInfoId != null) - { - var organInfo = organInfos.Where(x => x.Id == rowinfo.OrganInfoId).FirstOrDefault(); - - - if (organInfo != null && needChangeType.Contains(tableQuestion.QuestionMark)) - { - if (_userInfo.IsEn_Us) - { - switch (tableQuestion.QuestionMark) - { - case QuestionMark.Organ: - taskQuestionAnswer.Answer = organInfo.TULOCEN; - - break; - case QuestionMark.Location: - if (organInfo.IsCanEditPosition) - { - - } - else - { - taskQuestionAnswer.Answer = organInfo.TULATEN; - - } - break; - case QuestionMark.Part: - - taskQuestionAnswer.Answer = organInfo.PartEN; - - break; - - } - - } - else - { - switch (tableQuestion.QuestionMark) - { - case QuestionMark.Organ: - taskQuestionAnswer.Answer = organInfo.TULOC; - break; - case QuestionMark.Location: - if (organInfo.IsCanEditPosition) - { - - } - else - { - taskQuestionAnswer.Answer = organInfo.TULAT; - - } - break; - case QuestionMark.Part: - taskQuestionAnswer.Answer = organInfo.Part; - break; - - } - } - - } - } - tableQuestion.Answer.Add(taskQuestionAnswer); - } - } - - - } - - - }; - } - #endregion + List questions = await _generalCalculateService.GetReadingReportQuestion + ( + questionList, + taskInfoList, + globalanswerList, + answers, + tableAnsweRowInfos, + tableQuestionList, + alltableAnsweRowInfos, + tableAnswers, + organInfos, + needChangeType + ); diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/OCTCalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/OCTCalculateService.cs index 7ea94488b..93206b459 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/OCTCalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/OCTCalculateService.cs @@ -161,12 +161,12 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate var answers = await _readingTaskQuestionAnswerRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync(); var tableAnswers = await _readingTableQuestionAnswerRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync(); - var globalanswerList = await _readingGlobalTaskInfoRepository.Where(x => visitTaskIds.Contains(x.TaskId) && x.GlobalVisitTask.TaskState == TaskState.Effect && x.Answer != string.Empty).Select(x => new + var globalanswerList = await _readingGlobalTaskInfoRepository.Where(x => visitTaskIds.Contains(x.TaskId) && x.GlobalVisitTask.TaskState == TaskState.Effect && x.Answer != string.Empty).Select(x => new Globalanswer() { - x.TaskId, - x.GlobalVisitTask.VisitTaskNum, - x.QuestionId, - x.Answer + TaskId = x.TaskId, + VisitTaskNum = x.GlobalVisitTask.VisitTaskNum, + QuestionId = x.QuestionId, + Answer = x.Answer }).ToListAsync(); var alltableAnsweRowInfos = await _readingTableAnswerRowInfoRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync(); var organIds = alltableAnsweRowInfos.Where(x => x.OrganInfoId != null).Select(x => x.OrganInfoId).Distinct().ToList(); @@ -178,219 +178,19 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate QuestionMark.Part, }; - // 第一级 - - #region 构造问题 - List questions = questionList.Where(x => x.Type == ReadingQestionType.Group).OrderBy(x => x.ShowOrder).Select(x => new ReadingReportDto() - { - QuestionId = x.Id, - GroupName = x.GroupName, - GroupEnName = x.GroupEnName, - IsShowInDicom = x.IsShowInDicom, - Type = x.Type, - GroupId = x.GroupId, - QuestionType = x.QuestionType, - LesionType = x.LesionType, - QuestionGenre = x.QuestionGenre, - DataSource = x.DataSource, - DictionaryCode = x.DictionaryCode, - TypeValue = x.TypeValue, - QuestionName = x.QuestionName.LanguageName(x.QuestionEnName, _userInfo.IsEn_Us), - ShowOrder = x.ShowOrder, - ValueType = x.ValueType, - Unit = x.Unit, - CustomUnit = x.CustomUnit, - ReportLayType = ReportLayType.Group, - HighlightAnswer = x.HighlightAnswer, - HighlightAnswerList = x.HighlightAnswerList, - }).ToList(); - - // 分组 - foreach (var item in questions) - { - item.Childrens = questionList.Where(x => x.GroupId == item.QuestionId).OrderBy(x => x.ShowOrder).Select(x => new ReadingReportDto() - { - GroupName = x.GroupName, - QuestionId = x.Id, - IsShowInDicom = x.IsShowInDicom, - GroupEnName = x.GroupEnName, - QuestionName = x.QuestionName.LanguageName(x.QuestionEnName, _userInfo.IsEn_Us), - LesionType = x.LesionType, - QuestionGenre = x.QuestionGenre, - DataSource = x.DataSource, - DictionaryCode = x.DictionaryCode, - Type = x.Type, - QuestionType = x.QuestionType, - TypeValue = x.TypeValue, - ShowOrder = x.ShowOrder, - OrderMark = x.OrderMark, - ValueType = x.ValueType, - Unit = x.Unit, - CustomUnit = x.CustomUnit, - ReportLayType = ReportLayType.Question, - HighlightAnswer = x.HighlightAnswer, - HighlightAnswerList = x.HighlightAnswerList, - }).ToList(); - - // 问题 - foreach (var question in item.Childrens) - { - - foreach (var task in taskInfoList) - { - var globalAnswer = globalanswerList.Where(x => x.TaskId == task.VisitTaskId && x.QuestionId == question.QuestionId).OrderByDescending(x => x.VisitTaskNum).FirstOrDefault(); - - var answer = answers.Where(x => x.VisitTaskId == task.VisitTaskId && x.ReadingQuestionTrialId == question.QuestionId).FirstOrDefault(); - question.Answer.Add(new TaskQuestionAnswer() - { - Answer = answer == null ? string.Empty : answer.Answer, - IsGlobalChange = globalAnswer == null ? false : true, - GlobalChangeAnswer = globalAnswer == null ? string.Empty : globalAnswer.Answer, - TaskName = task.TaskName, - VisitTaskId = task.VisitTaskId, - - }); - } - - // 构造表格行数据 - - - var rowlist = tableAnsweRowInfos.Where(x => x.QuestionId == question.QuestionId).OrderBy(x => x.RowIndex).ToList(); - - question.Childrens = new List(); - - var rowoindexs = lesionsIndexs.Where(x => x.QuestionId == question.QuestionId).Select(x => x.Rowindexs.OrderBy(y => y).ToList()).FirstOrDefault(); - rowoindexs = rowoindexs == null ? new List() : rowoindexs; - foreach (var rowoindex in rowoindexs) - { - var rowinfo = rowlist.Where(x => x.RowIndex == rowoindex).FirstOrDefault(); - question.Childrens.Add(new ReadingReportDto() - { - QuestionName = question.OrderMark + rowoindex.GetLesionMark(), - RowId = rowinfo?.Id, - IsShowInDicom = question.IsShowInDicom, - SplitOrMergeLesionName = rowinfo != null ? (rowinfo.MergeName.IsNullOrEmpty() ? rowinfo.SplitName : rowinfo.MergeName) : string.Empty, - SplitOrMergeType = rowinfo != null ? (rowinfo.SplitOrMergeType) : null, - LesionType = question.LesionType, - IsCanEditPosition = rowinfo != null ? (rowinfo.IsCanEditPosition) : false, - RowIndex = rowoindex, - BlindName = rowinfo != null ? rowinfo.BlindName : string.Empty, - ReportLayType = ReportLayType.Lesions, - ReportMark = rowinfo != null ? rowinfo.ReportMark : string.Empty, - - }); - } - - - foreach (var row in question.Childrens) - { - // tableQuestion - row.Childrens = tableQuestionList.Where(x => x.ReadingQuestionId == question.QuestionId).Select(x => new ReadingReportDto() - { - QuestionName = x.QuestionName.LanguageName(x.QuestionEnName, _userInfo.IsEn_Us), - QuestionId = x.ReadingQuestionId, - TableQuestionId = x.Id, - Type = x.Type, - LesionType = question.LesionType, - TableQuestionType = x.TableQuestionType, - RowId = row.RowId, - IsShowInDicom = question.IsShowInDicom, - DataSource = x.DataSource, - DictionaryCode = x.DictionaryCode, - QuestionMark = x.QuestionMark, - TypeValue = x.TypeValue, - RowIndex = row.RowIndex, - ShowOrder = x.ShowOrder, - ValueType = x.ValueType, - Unit = x.Unit, - ReportLayType = ReportLayType.TableQuestion, - }).ToList(); - - - foreach (var tableQuestion in row.Childrens) - { - foreach (var task in taskInfoList) - { - var rowinfo = alltableAnsweRowInfos.Where(x => x.VisitTaskId == task.VisitTaskId && x.QuestionId == tableQuestion.QuestionId && x.RowIndex == tableQuestion.RowIndex).FirstOrDefault(); - var taskQuestionAnswer = new TaskQuestionAnswer() - { - Answer = tableAnswers.Where(x => x.VisitTaskId == task.VisitTaskId && x.QuestionId == tableQuestion.QuestionId && x.RowIndex == tableQuestion.RowIndex && x.TableQuestionId == tableQuestion.TableQuestionId).Select(x => x.Answer).FirstIsNullReturnEmpty(), - TaskName = task.TaskName, - VisitTaskId = task.VisitTaskId, - }; - if (rowinfo != null && rowinfo.OrganInfoId != null) - { - var organInfo = organInfos.Where(x => x.Id == rowinfo.OrganInfoId).FirstOrDefault(); - - - if (organInfo != null && needChangeType.Contains(tableQuestion.QuestionMark)) - { - if (_userInfo.IsEn_Us) - { - switch (tableQuestion.QuestionMark) - { - case QuestionMark.Organ: - taskQuestionAnswer.Answer = organInfo.TULOCEN; - - break; - case QuestionMark.Location: - if (organInfo.IsCanEditPosition) - { - - } - else - { - taskQuestionAnswer.Answer = organInfo.TULATEN; - - } - break; - case QuestionMark.Part: - - taskQuestionAnswer.Answer = organInfo.PartEN; - - break; - - } - - } - else - { - switch (tableQuestion.QuestionMark) - { - case QuestionMark.Organ: - taskQuestionAnswer.Answer = organInfo.TULOC; - break; - case QuestionMark.Location: - if (organInfo.IsCanEditPosition) - { - - } - else - { - taskQuestionAnswer.Answer = organInfo.TULAT; - - } - break; - case QuestionMark.Part: - taskQuestionAnswer.Answer = organInfo.Part; - break; - - } - } - - } - } - tableQuestion.Answer.Add(taskQuestionAnswer); - } - } - - - } - - - }; - } - #endregion + List questions = await _generalCalculateService.GetReadingReportQuestion + ( + questionList, + taskInfoList, + globalanswerList, + answers, + tableAnsweRowInfos, + tableQuestionList, + alltableAnsweRowInfos, + tableAnswers, + organInfos, + needChangeType + ); diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/RECIST1Point1CalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/RECIST1Point1CalculateService.cs index 58244e6ad..030e9efdb 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/RECIST1Point1CalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/RECIST1Point1CalculateService.cs @@ -1,10 +1,13 @@ -using IRaCIS.Core.Application.Service.Reading.Dto; +using DocumentFormat.OpenXml.Drawing.Spreadsheet; +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; using MassTransit; using Microsoft.AspNetCore.Mvc; +using System.Collections.Generic; namespace IRaCIS.Core.Application.Service.ReadingCalculate { @@ -104,12 +107,12 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate }).ToList(); var answers = await _readingTaskQuestionAnswerRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync(); var tableAnswers = await _readingTableQuestionAnswerRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync(); - var globalanswerList = await _readingGlobalTaskInfoRepository.Where(x => visitTaskIds.Contains(x.TaskId) && x.GlobalVisitTask.TaskState == TaskState.Effect && x.Answer != string.Empty).Select(x => new + var globalanswerList = await _readingGlobalTaskInfoRepository.Where(x => visitTaskIds.Contains(x.TaskId) && x.GlobalVisitTask.TaskState == TaskState.Effect && x.Answer != string.Empty).Select(x => new Globalanswer() { - x.TaskId, - x.GlobalVisitTask.VisitTaskNum, - x.QuestionId, - x.Answer + TaskId = x.TaskId, + VisitTaskNum = x.GlobalVisitTask.VisitTaskNum, + QuestionId = x.QuestionId, + Answer = x.Answer }).ToListAsync(); var alltableAnsweRowInfos = await _readingTableAnswerRowInfoRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync(); var organIds = alltableAnsweRowInfos.Where(x => x.OrganInfoId != null).Select(x => x.OrganInfoId).Distinct().ToList(); @@ -123,207 +126,20 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate // 第一级 - #region 构造问题 - List questions = questionList.Where(x => x.Type == ReadingQestionType.Group).OrderBy(x => x.ShowOrder).Select(x => new ReadingReportDto() - { - QuestionId = x.Id, - GroupName = x.GroupName, - GroupEnName = x.GroupEnName, - IsShowInDicom = x.IsShowInDicom, - Type = x.Type, - GroupId = x.GroupId, - QuestionType = x.QuestionType, - LesionType = x.LesionType, - QuestionGenre = x.QuestionGenre, - DataSource = x.DataSource, - DictionaryCode = x.DictionaryCode, - TypeValue = x.TypeValue, - QuestionName = x.QuestionName.LanguageName(x.QuestionEnName, _userInfo.IsEn_Us), - ShowOrder = x.ShowOrder, - ValueType = x.ValueType, - Unit = x.Unit, - CustomUnit = x.CustomUnit, - ReportLayType = ReportLayType.Group, - HighlightAnswer = x.HighlightAnswer, - HighlightAnswerList = x.HighlightAnswerList, - }).ToList(); + List questions = await _generalCalculateService.GetReadingReportQuestion + ( + questionList, + taskInfoList, + globalanswerList, + answers, + tableAnsweRowInfos, + tableQuestionList, + alltableAnsweRowInfos, + tableAnswers, + organInfos, + needChangeType + ); - // 分组 - foreach (var item in questions) - { - item.Childrens = questionList.Where(x => x.GroupId == item.QuestionId).OrderBy(x => x.ShowOrder).Select(x => new ReadingReportDto() - { - GroupName = x.GroupName, - QuestionId = x.Id, - IsShowInDicom = x.IsShowInDicom, - GroupEnName = x.GroupEnName, - QuestionName = x.QuestionName.LanguageName(x.QuestionEnName, _userInfo.IsEn_Us), - LesionType = x.LesionType, - QuestionGenre = x.QuestionGenre, - DataSource = x.DataSource, - DictionaryCode = x.DictionaryCode, - Type = x.Type, - QuestionType = x.QuestionType, - TypeValue = x.TypeValue, - ShowOrder = x.ShowOrder, - OrderMark = x.OrderMark, - ValueType = x.ValueType, - Unit = x.Unit, - CustomUnit = x.CustomUnit, - ReportLayType = ReportLayType.Question, - HighlightAnswer = x.HighlightAnswer, - HighlightAnswerList = x.HighlightAnswerList, - }).ToList(); - - // 问题 - foreach (var question in item.Childrens) - { - - foreach (var task in taskInfoList) - { - var globalAnswer = globalanswerList.Where(x => x.TaskId == task.VisitTaskId && x.QuestionId == question.QuestionId).OrderByDescending(x => x.VisitTaskNum).FirstOrDefault(); - - var answer = answers.Where(x => x.VisitTaskId == task.VisitTaskId && x.ReadingQuestionTrialId == question.QuestionId).FirstOrDefault(); - question.Answer.Add(new TaskQuestionAnswer() - { - Answer = answer == null ? string.Empty : answer.Answer, - IsGlobalChange = globalAnswer == null ? false : true, - GlobalChangeAnswer = globalAnswer == null ? string.Empty : globalAnswer.Answer, - TaskName = task.TaskName, - VisitTaskId = task.VisitTaskId, - - }); - } - - // 构造表格行数据 - - - var rowlist = tableAnsweRowInfos.Where(x => x.QuestionId == question.QuestionId).OrderBy(x => x.RowIndex).ToList(); - - - question.Childrens = rowlist.Select(x => new ReadingReportDto() - { - QuestionName = question.OrderMark + x.RowIndex.GetLesionMark(), - SplitOrMergeLesionName = x.MergeName.IsNullOrEmpty() ? x.SplitName : x.MergeName, - SplitOrMergeType = x.SplitOrMergeType, - LesionType = question.LesionType, - IsShowInDicom = question.IsShowInDicom, - IsCanEditPosition = x.IsCanEditPosition, - RowIndex = x.RowIndex, - BlindName = x.BlindName, - ReportLayType = ReportLayType.Lesions, - }).ToList(); - - - foreach (var row in question.Childrens) - { - // tableQuestion - row.Childrens = tableQuestionList.Where(x => x.ReadingQuestionId == question.QuestionId).Select(x => new ReadingReportDto() - { - QuestionName = x.QuestionName.LanguageName(x.QuestionEnName, _userInfo.IsEn_Us), - QuestionId = x.ReadingQuestionId, - TableQuestionId = x.Id, - Type = x.Type, - LesionType = question.LesionType, - TableQuestionType = x.TableQuestionType, - RowId = row.RowId, - IsShowInDicom = question.IsShowInDicom, - DataSource = x.DataSource, - DictionaryCode = x.DictionaryCode, - QuestionMark = x.QuestionMark, - TypeValue = x.TypeValue, - RowIndex = row.RowIndex, - ShowOrder = x.ShowOrder, - ValueType = x.ValueType, - Unit = x.Unit, - ReportLayType = ReportLayType.TableQuestion, - }).ToList(); - - - foreach (var tableQuestion in row.Childrens) - { - foreach (var task in taskInfoList) - { - var rowinfo = alltableAnsweRowInfos.Where(x => x.VisitTaskId == task.VisitTaskId && x.QuestionId == tableQuestion.QuestionId && x.RowIndex == tableQuestion.RowIndex).FirstOrDefault(); - var taskQuestionAnswer = new TaskQuestionAnswer() - { - Answer = tableAnswers.Where(x => x.VisitTaskId == task.VisitTaskId && x.QuestionId == tableQuestion.QuestionId && x.RowIndex == tableQuestion.RowIndex && x.TableQuestionId == tableQuestion.TableQuestionId).Select(x => x.Answer).FirstIsNullReturnEmpty(), - TaskName = task.TaskName, - VisitTaskId = task.VisitTaskId, - }; - if (rowinfo != null && rowinfo.OrganInfoId != null) - { - var organInfo = organInfos.Where(x => x.Id == rowinfo.OrganInfoId).FirstOrDefault(); - - - if (organInfo != null && needChangeType.Contains(tableQuestion.QuestionMark)) - { - if (_userInfo.IsEn_Us) - { - switch (tableQuestion.QuestionMark) - { - case QuestionMark.Organ: - taskQuestionAnswer.Answer = organInfo.TULOCEN; - - break; - case QuestionMark.Location: - if (organInfo.IsCanEditPosition) - { - - } - else - { - taskQuestionAnswer.Answer = organInfo.TULATEN; - - } - break; - case QuestionMark.Part: - - taskQuestionAnswer.Answer = organInfo.PartEN; - - break; - - } - - } - else - { - switch (tableQuestion.QuestionMark) - { - case QuestionMark.Organ: - taskQuestionAnswer.Answer = organInfo.TULOC; - break; - case QuestionMark.Location: - if (organInfo.IsCanEditPosition) - { - - } - else - { - taskQuestionAnswer.Answer = organInfo.TULAT; - - } - break; - case QuestionMark.Part: - taskQuestionAnswer.Answer = organInfo.Part; - break; - - } - } - - } - } - tableQuestion.Answer.Add(taskQuestionAnswer); - } - } - - - } - - - }; - } - #endregion diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/RECIST1Point1_BMCalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/RECIST1Point1_BMCalculateService.cs index 669886a0c..c09c6f862 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/RECIST1Point1_BMCalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/RECIST1Point1_BMCalculateService.cs @@ -100,12 +100,12 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate var answers = await _readingTaskQuestionAnswerRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync(); var tableAnswers = await _readingTableQuestionAnswerRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync(); - var globalanswerList = await _readingGlobalTaskInfoRepository.Where(x => visitTaskIds.Contains(x.TaskId) && x.GlobalVisitTask.TaskState == TaskState.Effect && x.Answer != string.Empty).Select(x => new + var globalanswerList = await _readingGlobalTaskInfoRepository.Where(x => visitTaskIds.Contains(x.TaskId) && x.GlobalVisitTask.TaskState == TaskState.Effect && x.Answer != string.Empty).Select(x => new Globalanswer() { - x.TaskId, - x.GlobalVisitTask.VisitTaskNum, - x.QuestionId, - x.Answer + TaskId = x.TaskId, + VisitTaskNum = x.GlobalVisitTask.VisitTaskNum, + QuestionId = x.QuestionId, + Answer = x.Answer }).ToListAsync(); var alltableAnsweRowInfos = await _readingTableAnswerRowInfoRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync(); var organIds = alltableAnsweRowInfos.Where(x => x.OrganInfoId != null).Select(x => x.OrganInfoId).Distinct().ToList(); @@ -119,207 +119,19 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate // 第一级 - #region 构造问题 - List questions = questionList.Where(x => x.Type == ReadingQestionType.Group).OrderBy(x => x.ShowOrder).Select(x => new ReadingReportDto() - { - QuestionId = x.Id, - GroupName = x.GroupName, - GroupEnName = x.GroupEnName, - IsShowInDicom = x.IsShowInDicom, - Type = x.Type, - GroupId = x.GroupId, - QuestionType = x.QuestionType, - LesionType = x.LesionType, - QuestionGenre = x.QuestionGenre, - DataSource = x.DataSource, - DictionaryCode = x.DictionaryCode, - TypeValue = x.TypeValue, - QuestionName = x.QuestionName.LanguageName(x.QuestionEnName, _userInfo.IsEn_Us), - ShowOrder = x.ShowOrder, - ValueType = x.ValueType, - Unit = x.Unit, - CustomUnit = x.CustomUnit, - ReportLayType = ReportLayType.Group, - HighlightAnswer = x.HighlightAnswer, - HighlightAnswerList = x.HighlightAnswerList, - }).ToList(); - - // 分组 - foreach (var item in questions) - { - item.Childrens = questionList.Where(x => x.GroupId == item.QuestionId).OrderBy(x => x.ShowOrder).Select(x => new ReadingReportDto() - { - GroupName = x.GroupName, - QuestionId = x.Id, - IsShowInDicom = x.IsShowInDicom, - GroupEnName = x.GroupEnName, - QuestionName = x.QuestionName.LanguageName(x.QuestionEnName, _userInfo.IsEn_Us), - LesionType = x.LesionType, - QuestionGenre = x.QuestionGenre, - DataSource = x.DataSource, - DictionaryCode = x.DictionaryCode, - Type = x.Type, - QuestionType = x.QuestionType, - TypeValue = x.TypeValue, - ShowOrder = x.ShowOrder, - OrderMark = x.OrderMark, - ValueType = x.ValueType, - Unit = x.Unit, - CustomUnit = x.CustomUnit, - ReportLayType = ReportLayType.Question, - HighlightAnswer = x.HighlightAnswer, - HighlightAnswerList = x.HighlightAnswerList, - }).ToList(); - - // 问题 - foreach (var question in item.Childrens) - { - - foreach (var task in taskInfoList) - { - var globalAnswer = globalanswerList.Where(x => x.TaskId == task.VisitTaskId && x.QuestionId == question.QuestionId).OrderByDescending(x => x.VisitTaskNum).FirstOrDefault(); - - var answer = answers.Where(x => x.VisitTaskId == task.VisitTaskId && x.ReadingQuestionTrialId == question.QuestionId).FirstOrDefault(); - question.Answer.Add(new TaskQuestionAnswer() - { - Answer = answer == null ? string.Empty : answer.Answer, - IsGlobalChange = globalAnswer == null ? false : true, - GlobalChangeAnswer = globalAnswer == null ? string.Empty : globalAnswer.Answer, - TaskName = task.TaskName, - VisitTaskId = task.VisitTaskId, - - }); - } - - // 构造表格行数据 - - - var rowlist = tableAnsweRowInfos.Where(x => x.QuestionId == question.QuestionId).OrderBy(x => x.RowIndex).ToList(); - - - question.Childrens = rowlist.Select(x => new ReadingReportDto() - { - QuestionName = question.OrderMark + x.RowIndex.GetLesionMark(), - SplitOrMergeLesionName = x.MergeName.IsNullOrEmpty() ? x.SplitName : x.MergeName, - SplitOrMergeType = x.SplitOrMergeType, - LesionType = question.LesionType, - IsShowInDicom = question.IsShowInDicom, - IsCanEditPosition = x.IsCanEditPosition, - RowIndex = x.RowIndex, - BlindName = x.BlindName, - ReportLayType = ReportLayType.Lesions, - }).ToList(); - - - foreach (var row in question.Childrens) - { - // tableQuestion - row.Childrens = tableQuestionList.Where(x => x.ReadingQuestionId == question.QuestionId).Select(x => new ReadingReportDto() - { - QuestionName = x.QuestionName.LanguageName(x.QuestionEnName, _userInfo.IsEn_Us), - QuestionId = x.ReadingQuestionId, - TableQuestionId = x.Id, - Type = x.Type, - LesionType = question.LesionType, - TableQuestionType = x.TableQuestionType, - RowId = row.RowId, - IsShowInDicom = question.IsShowInDicom, - DataSource = x.DataSource, - DictionaryCode = x.DictionaryCode, - QuestionMark = x.QuestionMark, - TypeValue = x.TypeValue, - RowIndex = row.RowIndex, - ShowOrder = x.ShowOrder, - ValueType = x.ValueType, - Unit = x.Unit, - ReportLayType = ReportLayType.TableQuestion, - }).ToList(); - - - foreach (var tableQuestion in row.Childrens) - { - foreach (var task in taskInfoList) - { - var rowinfo = alltableAnsweRowInfos.Where(x => x.VisitTaskId == task.VisitTaskId && x.QuestionId == tableQuestion.QuestionId && x.RowIndex == tableQuestion.RowIndex).FirstOrDefault(); - var taskQuestionAnswer = new TaskQuestionAnswer() - { - Answer = tableAnswers.Where(x => x.VisitTaskId == task.VisitTaskId && x.QuestionId == tableQuestion.QuestionId && x.RowIndex == tableQuestion.RowIndex && x.TableQuestionId == tableQuestion.TableQuestionId).Select(x => x.Answer).FirstIsNullReturnEmpty(), - TaskName = task.TaskName, - VisitTaskId = task.VisitTaskId, - }; - if (rowinfo != null && rowinfo.OrganInfoId != null) - { - var organInfo = organInfos.Where(x => x.Id == rowinfo.OrganInfoId).FirstOrDefault(); - - - if (organInfo != null && needChangeType.Contains(tableQuestion.QuestionMark)) - { - if (_userInfo.IsEn_Us) - { - switch (tableQuestion.QuestionMark) - { - case QuestionMark.Organ: - taskQuestionAnswer.Answer = organInfo.TULOCEN; - - break; - case QuestionMark.Location: - if (organInfo.IsCanEditPosition) - { - - } - else - { - taskQuestionAnswer.Answer = organInfo.TULATEN; - - } - break; - case QuestionMark.Part: - - taskQuestionAnswer.Answer = organInfo.PartEN; - - break; - - } - - } - else - { - switch (tableQuestion.QuestionMark) - { - case QuestionMark.Organ: - taskQuestionAnswer.Answer = organInfo.TULOC; - break; - case QuestionMark.Location: - if (organInfo.IsCanEditPosition) - { - - } - else - { - taskQuestionAnswer.Answer = organInfo.TULAT; - - } - break; - case QuestionMark.Part: - taskQuestionAnswer.Answer = organInfo.Part; - break; - - } - } - - } - } - tableQuestion.Answer.Add(taskQuestionAnswer); - } - } - - - } - - - }; - } - #endregion + List questions = await _generalCalculateService.GetReadingReportQuestion + ( + questionList, + taskInfoList, + globalanswerList, + answers, + tableAnsweRowInfos, + tableQuestionList, + alltableAnsweRowInfos, + tableAnswers, + organInfos, + needChangeType + ); diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/SelfDefineCalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/SelfDefineCalculateService.cs index 97c93e6a2..eb270ec50 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/SelfDefineCalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/SelfDefineCalculateService.cs @@ -102,12 +102,12 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate var answers = await _readingTaskQuestionAnswerRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync(); var tableAnswers = await _readingTableQuestionAnswerRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync(); - var globalanswerList = await _readingGlobalTaskInfoRepository.Where(x => visitTaskIds.Contains(x.TaskId) && x.GlobalVisitTask.TaskState == TaskState.Effect && x.Answer != string.Empty).Select(x => new + var globalanswerList = await _readingGlobalTaskInfoRepository.Where(x => visitTaskIds.Contains(x.TaskId) && x.GlobalVisitTask.TaskState == TaskState.Effect && x.Answer != string.Empty).Select(x => new Globalanswer() { - x.TaskId, - x.GlobalVisitTask.VisitTaskNum, - x.QuestionId, - x.Answer + TaskId = x.TaskId, + VisitTaskNum = x.GlobalVisitTask.VisitTaskNum, + QuestionId = x.QuestionId, + Answer = x.Answer }).ToListAsync(); var alltableAnsweRowInfos = await _readingTableAnswerRowInfoRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync(); var organIds = alltableAnsweRowInfos.Where(x => x.OrganInfoId != null).Select(x => x.OrganInfoId).Distinct().ToList(); @@ -121,227 +121,19 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate // 第一级 - #region 构造问题 - List questions = questionList.Where(x => x.Type == ReadingQestionType.Group).OrderBy(x => x.ShowOrder).Select(x => new ReadingReportDto() - { - QuestionId = x.Id, - GroupName = x.GroupName.LanguageName(x.GroupEnName, _userInfo.IsEn_Us), - IsShowInDicom = x.IsShowInDicom, - Type = x.Type, - GroupId = x.GroupId, - GroupEnName = x.GroupEnName, - QuestionType = x.QuestionType, - DataSource = x.DataSource, - LesionType = x.LesionType, - QuestionGenre = x.QuestionGenre, - DictionaryCode = x.DictionaryCode, - LimitEdit = x.LimitEdit, - MaxAnswerLength = x.MaxAnswerLength, - FileType = x.FileType, - TypeValue = x.TypeValue, - QuestionName = x.QuestionName.LanguageName(x.QuestionEnName, _userInfo.IsEn_Us), - ShowOrder = x.ShowOrder, - ValueType = x.ValueType, - Unit = x.Unit, - CustomUnit = x.CustomUnit, - ReportLayType = ReportLayType.Group, - HighlightAnswer = x.HighlightAnswer, - HighlightAnswerList = x.HighlightAnswerList, - }).ToList(); - - // 分组 - foreach (var item in questions) - { - item.Childrens = questionList.Where(x => x.GroupId == item.QuestionId).OrderBy(x => x.ShowOrder).Select(x => new ReadingReportDto() - { - GroupName = x.GroupName.LanguageName(x.GroupEnName, _userInfo.IsEn_Us), - QuestionId = x.Id, - IsShowInDicom = x.IsShowInDicom, - QuestionName = x.QuestionName.LanguageName(x.QuestionEnName, _userInfo.IsEn_Us), - LesionType = x.LesionType, - DataSource = x.DataSource, - QuestionGenre = x.QuestionGenre, - GroupEnName = x.GroupEnName, - LimitEdit = x.LimitEdit, - MaxAnswerLength = x.MaxAnswerLength, - FileType = x.FileType, - DictionaryCode = x.DictionaryCode, - Type = x.Type, - QuestionType = x.QuestionType, - TypeValue = x.TypeValue, - ShowOrder = x.ShowOrder, - OrderMark = x.OrderMark, - ValueType = x.ValueType, - Unit = x.Unit, - CustomUnit = x.CustomUnit, - ReportLayType = ReportLayType.Question, - HighlightAnswer = x.HighlightAnswer, - HighlightAnswerList = x.HighlightAnswerList, - }).ToList(); - - // 问题 - foreach (var question in item.Childrens) - { - - foreach (var task in taskInfoList) - { - var globalAnswer = globalanswerList.Where(x => x.TaskId == task.VisitTaskId && x.QuestionId == question.QuestionId).OrderByDescending(x => x.VisitTaskNum).FirstOrDefault(); - - var answer = answers.Where(x => x.VisitTaskId == task.VisitTaskId && x.ReadingQuestionTrialId == question.QuestionId).FirstOrDefault(); - question.Answer.Add(new TaskQuestionAnswer() - { - Answer = answer == null ? string.Empty : answer.Answer, - IsGlobalChange = globalAnswer == null ? false : true, - GlobalChangeAnswer = globalAnswer == null ? string.Empty : globalAnswer.Answer, - TaskName = task.TaskName, - VisitTaskId = task.VisitTaskId, - - }); - } - - // 构造表格行数据 - - - var rowlist = tableAnsweRowInfos.Where(x => x.QuestionId == question.QuestionId).OrderBy(x => x.RowIndex).ToList(); - - question.Childrens = new List(); - - var rowoindexs = lesionsIndexs.Where(x => x.QuestionId == question.QuestionId).Select(x => x.Rowindexs.OrderBy(y => y).ToList()).FirstOrDefault(); - rowoindexs = rowoindexs == null ? new List() : rowoindexs; - foreach (var rowoindex in rowoindexs) - { - var rowinfo = rowlist.Where(x => x.RowIndex == rowoindex).FirstOrDefault(); - question.Childrens.Add(new ReadingReportDto() - { - QuestionName = question.OrderMark + rowoindex.GetLesionMark(), - RowId = rowinfo?.Id, - IsShowInDicom = question.IsShowInDicom, - SplitOrMergeLesionName = rowinfo != null ? (rowinfo.MergeName.IsNullOrEmpty() ? rowinfo.SplitName : rowinfo.MergeName) : string.Empty, - SplitOrMergeType = rowinfo != null ? (rowinfo.SplitOrMergeType) : null, - LesionType = question.LesionType, - IsCanEditPosition = rowinfo != null ? (rowinfo.IsCanEditPosition) : false, - RowIndex = rowoindex, - BlindName = rowinfo != null ? rowinfo.BlindName : string.Empty, - ReportLayType = ReportLayType.Lesions, - }); - } - - - - - foreach (var row in question.Childrens) - { - // tableQuestion - row.Childrens = tableQuestionList.Where(x => x.ReadingQuestionId == question.QuestionId).Select(x => new ReadingReportDto() - { - QuestionName = x.QuestionName.LanguageName(x.QuestionEnName, _userInfo.IsEn_Us), - QuestionId = x.ReadingQuestionId, - TableQuestionId = x.Id, - Type = x.Type, - IsShowInDicom = question.IsShowInDicom, - DataSource = x.DataSource, - LimitEdit = x.LimitEdit, - MaxAnswerLength = x.MaxAnswerLength, - FileType = x.FileType, - LesionType = question.LesionType, - TableQuestionType = x.TableQuestionType, - DictionaryCode = x.DictionaryCode, - QuestionMark = x.QuestionMark, - TypeValue = x.TypeValue, - RowIndex = row.RowIndex, - RowId = row.RowId, - ShowOrder = x.ShowOrder, - ValueType = x.ValueType, - CustomUnit = x.CustomUnit, - Unit = x.Unit, - ReportLayType = ReportLayType.TableQuestion, - }).ToList(); - - - foreach (var tableQuestion in row.Childrens) - { - foreach (var task in taskInfoList) - { - var rowinfo = alltableAnsweRowInfos.Where(x => x.VisitTaskId == task.VisitTaskId && x.QuestionId == tableQuestion.QuestionId && x.RowIndex == tableQuestion.RowIndex).FirstOrDefault(); - var taskQuestionAnswer = new TaskQuestionAnswer() - { - Answer = tableAnswers.Where(x => x.VisitTaskId == task.VisitTaskId && x.QuestionId == tableQuestion.QuestionId && x.RowIndex == tableQuestion.RowIndex && x.TableQuestionId == tableQuestion.TableQuestionId).Select(x => x.Answer).FirstIsNullReturnEmpty(), - TaskName = task.TaskName, - VisitTaskId = task.VisitTaskId, - }; - if (rowinfo != null && rowinfo.OrganInfoId != null) - { - var organInfo = organInfos.Where(x => x.Id == rowinfo.OrganInfoId).FirstOrDefault(); - - - if (organInfo != null && needChangeType.Contains(tableQuestion.QuestionMark)) - { - if (_userInfo.IsEn_Us) - { - switch (tableQuestion.QuestionMark) - { - case QuestionMark.Organ: - taskQuestionAnswer.Answer = organInfo.TULOCEN; - - break; - case QuestionMark.Location: - if (organInfo.IsCanEditPosition) - { - - } - else - { - taskQuestionAnswer.Answer = organInfo.TULATEN; - - } - break; - case QuestionMark.Part: - - taskQuestionAnswer.Answer = organInfo.PartEN; - - break; - - } - - } - else - { - switch (tableQuestion.QuestionMark) - { - case QuestionMark.Organ: - taskQuestionAnswer.Answer = organInfo.TULOC; - break; - case QuestionMark.Location: - if (organInfo.IsCanEditPosition) - { - - } - else - { - taskQuestionAnswer.Answer = organInfo.TULAT; - - } - break; - case QuestionMark.Part: - taskQuestionAnswer.Answer = organInfo.Part; - break; - - } - } - - } - } - tableQuestion.Answer.Add(taskQuestionAnswer); - } - } - - - } - - - }; - } - #endregion + List questions = await _generalCalculateService.GetReadingReportQuestion + ( + questionList, + taskInfoList, + globalanswerList, + answers, + tableAnsweRowInfos, + tableQuestionList, + alltableAnsweRowInfos, + tableAnswers, + organInfos, + needChangeType + );