diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/LuganoCalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/LuganoCalculateService.cs index e0500170a..188472752 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/LuganoCalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/LuganoCalculateService.cs @@ -30,7 +30,8 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate private readonly IRepository _readingTableQuestionTrialRepository; private readonly IRepository _readingTaskQuestionMarkRepository; private readonly IRepository _readingTableAnswerRowInfoRepository; - private readonly IRepository _readingQuestionTrialRepository; + private readonly IRepository _readingGlobalTaskInfoRepository; + private readonly IRepository _readingQuestionTrialRepository; private readonly IRepository _organInfoRepository; private readonly IRepository _subjectVisitRepository; private readonly IRepository _dicomStudyRepository; @@ -46,7 +47,8 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate IRepository readingTableQuestionTrialRepository, IRepository readingTaskQuestionMarkRepository, IRepository readingTableAnswerRowInfoRepository, - IRepository readingQuestionTrialRepository, + IRepository readingGlobalTaskInfoRepository, + IRepository readingQuestionTrialRepository, IRepository organInfoRepository, IRepository subjectVisitRepository, IRepository dicomStudyRepository, @@ -62,7 +64,8 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate this._readingTableQuestionTrialRepository = readingTableQuestionTrialRepository; this._readingTaskQuestionMarkRepository = readingTaskQuestionMarkRepository; this._readingTableAnswerRowInfoRepository = readingTableAnswerRowInfoRepository; - this._readingQuestionTrialRepository = readingQuestionTrialRepository; + this._readingGlobalTaskInfoRepository = readingGlobalTaskInfoRepository; + this._readingQuestionTrialRepository = readingQuestionTrialRepository; this._organInfoRepository = organInfoRepository; this._subjectVisitRepository = subjectVisitRepository; this._dicomStudyRepository = dicomStudyRepository; @@ -160,7 +163,15 @@ 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 alltableAnsweRowInfos = await _readingTableAnswerRowInfoRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync(); + var globalanswerList = await _readingGlobalTaskInfoRepository.Where(x => visitTaskIds.Contains(x.TaskId)&&x.GlobalVisitTask.TaskState== TaskState.Effect).Select(x => new + { + x.TaskId, + x.GlobalVisitTask.VisitTaskNum, + x.QuestionId, + 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(); var organInfos = await _organInfoRepository.Where(x => organIds.Contains(x.Id)).ToListAsync(); @@ -227,12 +238,13 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate 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 = answer == null ? false : answer.IsGlobalChange, - GlobalChangeAnswer = answer == null ? string.Empty : answer.GlobalChangeAnswer, + IsGlobalChange = globalAnswer == null ? false : true, + GlobalChangeAnswer = globalAnswer == null ? string.Empty : globalAnswer.Answer, TaskName = task.TaskName, VisitTaskId = task.VisitTaskId,