diff --git a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs index e78bd3404..5940f1a61 100644 --- a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs +++ b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingImageTaskViewModel.cs @@ -281,6 +281,9 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto public Guid QuestionId { get; set; } + + public Guid RowId { get; set; } + /// /// 表格问题Id /// @@ -1011,7 +1014,7 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto { public Guid TableQuestionId { get; set; } - public string Answer { get; set; } + public string Answer { get; set; }=string.Empty; } public class GetTrialReadingQuestionInDto diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingCalculateService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingCalculateService.cs index a2a121d1b..baacda69d 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingCalculateService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingCalculateService.cs @@ -831,8 +831,8 @@ namespace IRaCIS.Core.Application.Service { if (visitTaskAnswerList == null) { - visitTaskAnswerList = await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTask.ReadingCategory == ReadingCategory.Visit - && x.SubjectId == inDto.SubjectId && x.VisitTask.ReadingTaskState == ReadingTaskState.HaveSigned &&x.VisitTask.ArmEnum==inDto.ArmEnum&& x.VisitTask.TaskState == TaskState.Effect && x.ReadingQuestionTrial.QuestionType == QuestionType.SOD) + visitTaskAnswerList = await _readingTaskQuestionAnswerRepository.Where(x =>x.VisitTaskId==inDto.VisitTaskId|| (x.VisitTask.ReadingCategory == ReadingCategory.Visit + && x.SubjectId == inDto.SubjectId && x.VisitTask.ReadingTaskState == ReadingTaskState.HaveSigned &&x.VisitTask.ArmEnum==inDto.ArmEnum&& x.VisitTask.TaskState == TaskState.Effect && x.ReadingQuestionTrial.QuestionType == QuestionType.SOD)) .Select(x => new VisitTaskAnswerInfo { VisitTaskId = x.VisitTaskId, diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs index 09b2a2ace..33e76d12b 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingImageTaskService.cs @@ -119,7 +119,7 @@ namespace IRaCIS.Application.Services await this.VerifyIsBaseLineTask(inDto.VisitTaskId); var rowAnswer = await _readingTableAnswerRowInfoRepository.Where(x =>x.Id==inDto.RowId).FirstNotNullAsync(); var tableAnswers = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.RowIndex == rowAnswer.RowIndex && x.QuestionId == inDto.QuestionId).ToListAsync(); - var maxRowIndex = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.QuestionId == inDto.QuestionId).OrderByDescending(x => x.RowIndex).Select(x => x.RowIndex).FirstOrDefaultAsync(); + var maxRowIndex = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.QuestionId == inDto.QuestionId&&x.RowIndex< Math.Floor(rowAnswer.RowIndex+1)).OrderByDescending(x => x.RowIndex).Select(x => x.RowIndex).FirstOrDefaultAsync(); var newRowIndex = maxRowIndex + (decimal)0.01; rowAnswer.RowIndex = newRowIndex; @@ -333,10 +333,6 @@ namespace IRaCIS.Application.Services if (!(await _readingTableQuestionAnswerRepository.AnyAsync(x => x.VisitTaskId == visitTaskId))) { - - - - var LastVisitTaskId = await _visitTaskRepository.Where(x => x.ReadingCategory == ReadingCategory.Visit&&x.SubjectId==taskinfo.SubjectId&&x.ReadingTaskState==ReadingTaskState.HaveSigned &&x.VisitTaskNum< taskinfo.VisitTaskNum&&x.TaskState==TaskState.Effect&&x.ArmEnum==taskinfo.ArmEnum ).OrderByDescending(x=>x.VisitTaskNum).Select(x => x.Id).FirstOrDefaultAsync(); @@ -345,6 +341,7 @@ namespace IRaCIS.Application.Services var copyTableAnswers = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == LastVisitTaskId).Select(x => new CopyTableAnswerDto() { Answer = x.Answer, QuestionId = x.QuestionId, + RowId=x.RowId, QuestionMark = x.ReadingTableQuestionTrial.QuestionMark, TableQuestionId = x.TableQuestionId, RowIndex = x.RowIndex, @@ -364,6 +361,7 @@ namespace IRaCIS.Application.Services { x.SplitRowId = tableRowAnswers.Where(y => y.OriginalId == x.SplitRowId).Select(y => y.Id).FirstOrDefault(); x.MergeRowId = tableRowAnswers.Where(y => y.OriginalId == x.MergeRowId).Select(y => y.Id).FirstOrDefault(); + }); List notNeedCopyMarks = new List() @@ -379,6 +377,7 @@ namespace IRaCIS.Application.Services Answer = notNeedCopyMarks.Contains(x.QuestionMark) ? string.Empty : x.Answer, QuestionId = x.QuestionId, RowIndex = x.RowIndex, + RowId= tableRowAnswers.Where(y=>y.OriginalId==x.RowId).Select(x=>x.Id).FirstOrDefault(), TableQuestionId = x.TableQuestionId, TrialId = x.TrialId, VisitTaskId = visitTaskId, @@ -2058,20 +2057,8 @@ namespace IRaCIS.Application.Services await _readingTableQuestionAnswerRepository.BatchDeleteNoTrackingAsync(x => x.VisitTaskId == inDto.VisitTaskId && x.QuestionId == inDto.QuestionId && x.TrialId == inDto.TrialId && x.RowIndex == inDto.RowIndex); await _readingTableAnswerRowInfoRepository.BatchDeleteNoTrackingAsync(x => x.VisitTaskId == inDto.VisitTaskId && x.QuestionId == inDto.QuestionId && x.TrialId == inDto.TrialId && x.RowIndex == inDto.RowIndex); - List answerList = inDto.AnswerList.Select(x => new ReadingTableQuestionAnswer() - { - Answer = x.Answer, - Id = NewId.NextGuid(), - TrialId = inDto.TrialId, - QuestionId = inDto.QuestionId, - TableQuestionId = x.TableQuestionId, - RowIndex = inDto.RowIndex, - VisitTaskId = inDto.VisitTaskId - }).ToList(); - - - await _readingTableAnswerRowInfoRepository.AddAsync(new ReadingTableAnswerRowInfo() + ReadingTableAnswerRowInfo rowInfo = new ReadingTableAnswerRowInfo() { Id = NewId.NextGuid(), TrialId = inDto.TrialId, @@ -2084,7 +2071,23 @@ namespace IRaCIS.Application.Services VisitTaskId = inDto.VisitTaskId, - }); + }; + + + List answerList = inDto.AnswerList.Select(x => new ReadingTableQuestionAnswer() + { + Answer = x.Answer, + Id = NewId.NextGuid(), + TrialId = inDto.TrialId, + QuestionId = inDto.QuestionId, + TableQuestionId = x.TableQuestionId, + RowIndex = inDto.RowIndex, + RowId= rowInfo.Id, + VisitTaskId = inDto.VisitTaskId + }).ToList(); + + + await _readingTableAnswerRowInfoRepository.AddAsync(rowInfo); await _readingTableQuestionAnswerRepository.AddRangeAsync(answerList); await _visitTaskRepository.UpdatePartialFromQueryAsync(inDto.VisitTaskId, x => new VisitTask() diff --git a/IRaCIS.Core.Domain/Reading/ReadingTableAnswerRowInfo.cs b/IRaCIS.Core.Domain/Reading/ReadingTableAnswerRowInfo.cs index ee0037c3e..957064082 100644 --- a/IRaCIS.Core.Domain/Reading/ReadingTableAnswerRowInfo.cs +++ b/IRaCIS.Core.Domain/Reading/ReadingTableAnswerRowInfo.cs @@ -80,6 +80,12 @@ namespace IRaCIS.Core.Domain.Models /// public Guid CreateUserId { get; set; } + [ForeignKey("SplitRowId")] + public ReadingTableAnswerRowInfo SplitRow { get; set; } + + [ForeignKey("MergeRowId")] + public ReadingTableAnswerRowInfo MergeRow { get; set; } + [ForeignKey("QuestionId")] public ReadingQuestionTrial ReadingQuestionTrial { get; set; } diff --git a/IRaCIS.Core.Domain/Reading/ReadingTableQuestionAnswer.cs b/IRaCIS.Core.Domain/Reading/ReadingTableQuestionAnswer.cs index 3792037ac..5156b254d 100644 --- a/IRaCIS.Core.Domain/Reading/ReadingTableQuestionAnswer.cs +++ b/IRaCIS.Core.Domain/Reading/ReadingTableQuestionAnswer.cs @@ -56,6 +56,13 @@ namespace IRaCIS.Core.Domain.Models /// public Guid CreateUserId { get; set; } + + /// + /// RowId + /// + public Guid RowId { get; set; } + + [ForeignKey("QuestionId")] public ReadingQuestionTrial ReadingQuestionTrial { get; set; }