diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/MRIPDFFCalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/MRIPDFFCalculateService.cs index 20000ea39..3662bb1c5 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/MRIPDFFCalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/MRIPDFFCalculateService.cs @@ -1,8 +1,10 @@ using DocumentFormat.OpenXml.EMMA; 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.Linq; @@ -620,7 +622,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate foreach (var item in questionInfo.TableRowInfoList) { var avg = item.TableQuestionList.Where(x => x.QuestionMark == QuestionMark.AverageValue).FirstOrDefault(); - var avgAnswer = string.Empty; + var avgAnswer = "NA"; List questionMarks = new List() { QuestionMark.FirstMeasurement, @@ -666,7 +668,31 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate public async Task VerifyVisitTaskQuestions(VerifyVisitTaskQuestionsInDto inDto) { + ReadingCalculateDto readingData = await _generalCalculateService.GetReadingCalculateDto(inDto.VisitTaskId); + + var markList = await _readingTaskQuestionMarkRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId).ToListAsync(); + var rowInfo = readingData.QuestionInfo.Where(x => x.LesionType == LesionType.FatFraction) + .SelectMany(x => x.TableRowInfoList).ToList(); + + var tableQuestionList = rowInfo.Where(x => x.TableQuestionList.Any(x => x.QuestionMark == QuestionMark.IsMeasurable && x.Answer.IsNotNullOrEmpty())).ToList(); + + if (tableQuestionList.Count() != 8) + { + throw new BusinessValidationFailedException(_localizer["MRIPDFF_AllNeedToBeMark"]); + } + + var notableQuestionList = rowInfo.Where(x => x.TableQuestionList.Any(x => x.QuestionMark == QuestionMark.IsMeasurable && x.Answer.EqEnum(YesOrNoOrNa.No))).ToList(); + + + foreach (var item in notableQuestionList) + { + if (markList.Any(x => x.RowId == item.RowId)) + { + throw new BusinessValidationFailedException(_localizer["MRIPDFF_NeedClearMark"]); + } + } + } } }