diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs index a6c1ab1dd..a300b9826 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs @@ -133,12 +133,12 @@ namespace IRaCIS.Application.Services /// /// [HttpPost] - public async Task<(List,bool)> GetTaskAdditionalQuestion(GetTaskAdditionalQuestionInDto inDto) + public async Task<(List, bool)> GetTaskAdditionalQuestion(GetTaskAdditionalQuestionInDto inDto) { var answerList = await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId).IgnoreAutoIncludes().ToListAsync(); var taskInfo = await _visitTaskRepository.Where(x => inDto.VisitTaskId == x.Id).FirstNotNullAsync(); - var result= await _readingQuestionTrialRepository.Where(x => x.IsAdditional && x.ReadingQuestionCriterionTrialId == taskInfo.TrialReadingCriterionId).IgnoreAutoIncludes().IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).OrderBy(x => x.ShowOrder).ToListAsync(); + var result = await _readingQuestionTrialRepository.Where(x => x.IsAdditional && x.ReadingQuestionCriterionTrialId == taskInfo.TrialReadingCriterionId).IgnoreAutoIncludes().IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).OrderBy(x => x.ShowOrder).ToListAsync(); result.ForEach(x => { @@ -223,7 +223,7 @@ namespace IRaCIS.Application.Services try { - relatedIds = JsonConvert.DeserializeObject>(item.RelatedVisitTaskIds)?? new List(); + relatedIds = JsonConvert.DeserializeObject>(item.RelatedVisitTaskIds) ?? new List(); } catch (Exception) { @@ -270,7 +270,7 @@ namespace IRaCIS.Application.Services var questionAnswerList = await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId).ToListAsync(); - var tableQuestionAnswerList= await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId).ToListAsync(); + var tableQuestionAnswerList = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId).ToListAsync(); var rowInfoList = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId).ToListAsync(); @@ -284,25 +284,26 @@ namespace IRaCIS.Application.Services Answer = item.Answer, }); } - else + else { - await _readingTaskQuestionAnswerRepository.AddAsync(new ReadingTaskQuestionAnswer() { - Answer=item.Answer, - ReadingQuestionCriterionTrialId= visitTask.TrialReadingCriterionId, - ReadingQuestionTrialId= item.QuestionId, - SubjectId= visitTask.SubjectId, - VisitTaskId=inDto.VisitTaskId, - TrialId= visitTask.TrialId + await _readingTaskQuestionAnswerRepository.AddAsync(new ReadingTaskQuestionAnswer() + { + Answer = item.Answer, + ReadingQuestionCriterionTrialId = visitTask.TrialReadingCriterionId, + ReadingQuestionTrialId = item.QuestionId, + SubjectId = visitTask.SubjectId, + VisitTaskId = inDto.VisitTaskId, + TrialId = visitTask.TrialId }); } - + } foreach (var item in inDto.TableQuestionAnswer) { - if (tableQuestionAnswerList.Any(x => x.QuestionId == item.QuestionId&&x.RowId==item.RowId&&x.TableQuestionId==item.TableQuestionId)) + if (tableQuestionAnswerList.Any(x => x.QuestionId == item.QuestionId && x.RowId == item.RowId && x.TableQuestionId == item.TableQuestionId)) { await _readingTableQuestionAnswerRepository.UpdatePartialFromQueryAsync(x => x.VisitTaskId == inDto.VisitTaskId && x.RowId == item.RowId && x.TableQuestionId == item.TableQuestionId, x => new ReadingTableQuestionAnswer() { @@ -312,21 +313,21 @@ namespace IRaCIS.Application.Services else { - var rowInfo = rowInfoList.Where(x => x.Id == item.RowId).FirstOrDefault()??new ReadingTableAnswerRowInfo (); + var rowInfo = rowInfoList.Where(x => x.Id == item.RowId).FirstOrDefault() ?? new ReadingTableAnswerRowInfo(); await _readingTableQuestionAnswerRepository.AddAsync(new ReadingTableQuestionAnswer() { Answer = item.Answer, - QuestionId=item.QuestionId, - TableQuestionId=item.TableQuestionId, - RowIndex= rowInfo.RowIndex, - RowId=rowInfo.Id, + QuestionId = item.QuestionId, + TableQuestionId = item.TableQuestionId, + RowIndex = rowInfo.RowIndex, + RowId = rowInfo.Id, VisitTaskId = inDto.VisitTaskId, TrialId = visitTask.TrialId }); } - + } await _readingTableQuestionAnswerRepository.SaveChangesAsync(); @@ -417,21 +418,21 @@ namespace IRaCIS.Application.Services var baselineVisitId = await _subjectVisitRepository.Where(x => x.SubjectId == taskInfo.SubjectId && x.IsBaseLine && !x.IsLostVisit).Select(x => x.Id).FirstNotNullAsync(); - var taskQuery = _visitTaskRepository.Where(x => - (x.TrialId == taskInfo.TrialId && - x.SubjectId == taskInfo.SubjectId && - x.ArmEnum == taskInfo.ArmEnum && - x.DoctorUserId == taskInfo.DoctorUserId && - x.ReadingTaskState == ReadingTaskState.HaveSigned && - x.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId && - x.TaskState == TaskState.Effect && - x.VisitTaskNum <= taskInfo.VisitTaskNum && - x.IsAnalysisCreate == taskInfo.IsAnalysisCreate && - x.ReadingCategory == ReadingCategory.Visit) || x.Id == inDto.VisitTaskId); + var taskQuery = _visitTaskRepository.Where(x => + (x.TrialId == taskInfo.TrialId && + x.SubjectId == taskInfo.SubjectId && + x.ArmEnum == taskInfo.ArmEnum && + x.DoctorUserId == taskInfo.DoctorUserId && + x.ReadingTaskState == ReadingTaskState.HaveSigned && + x.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId && + x.TaskState == TaskState.Effect && + x.VisitTaskNum <= taskInfo.VisitTaskNum && + x.IsAnalysisCreate == taskInfo.IsAnalysisCreate && + x.ReadingCategory == ReadingCategory.Visit) || x.Id == inDto.VisitTaskId); if (taskInfo.ReadingTaskState == ReadingTaskState.HaveSigned) { - taskQuery = _visitTaskRepository.Where(x => taskInfo.RelatedVisitTaskIdList.Contains(x.Id)||x.Id== taskInfo.Id); + taskQuery = _visitTaskRepository.Where(x => taskInfo.RelatedVisitTaskIdList.Contains(x.Id) || x.Id == taskInfo.Id); } var result = await taskQuery @@ -489,12 +490,13 @@ namespace IRaCIS.Application.Services taskQuery = _visitTaskRepository.Where(x => taskInfo.PastResultTaskIdList.Contains(x.Id)); } - var readingPastResultList = await taskQuery.Select(x => new GetReadingPastResultListOutDto() { + var readingPastResultList = await taskQuery.Select(x => new GetReadingPastResultListOutDto() + { VisitTaskId = x.Id, TaskBlindName = x.TaskBlindName, TaskName = x.TaskName, VisitTaskNum = x.VisitTaskNum, - JudgeResultArm = x.JudgeResultTask == null?null:x.JudgeResultTask.ArmEnum, + JudgeResultArm = x.JudgeResultTask == null ? null : x.JudgeResultTask.ArmEnum, }).OrderBy(x => x.VisitTaskNum).ToListAsync(); return readingPastResultList; @@ -623,8 +625,9 @@ namespace IRaCIS.Application.Services .WhereIf(criterionIdInfo.IseCRFShowInDicomReading, x => x.ReadingQuestionCriterionTrialId == trialReadingCriterionId && x.Type != ReadingQestionType.Table) .WhereIf(!criterionIdInfo.IseCRFShowInDicomReading, x => x.IsShowInDicom && x.ReadingQuestionCriterionTrialId == trialReadingCriterionId && x.Type != ReadingQestionType.Table) - .ProjectTo(_mapper.ConfigurationProvider,new{ - isEn_Us=_userInfo.IsEn_Us + .ProjectTo(_mapper.ConfigurationProvider, new + { + isEn_Us = _userInfo.IsEn_Us }).OrderBy(x => x.ShowOrder).ToListAsync(); @@ -643,7 +646,7 @@ namespace IRaCIS.Application.Services } else { - var crterionDictionaryGroup= new List() { CrterionDictionaryGroup.General, CrterionDictionaryGroup.BeforeConvert }; + var crterionDictionaryGroup = new List() { CrterionDictionaryGroup.General, CrterionDictionaryGroup.BeforeConvert }; questions.ForEach(x => { x.CrterionDictionaryGroup = crterionDictionaryGroup; @@ -666,11 +669,11 @@ namespace IRaCIS.Application.Services private void GetDicomReadingAnswer(DicomReadingQuestionAnswer item, List questions, List answers) { - var answer= answers.Where(x => x.ReadingQuestionTrialId == item.Id).Select(x => x.Answer).FirstIsNullReturnEmpty(); + var answer = answers.Where(x => x.ReadingQuestionTrialId == item.Id).Select(x => x.Answer).FirstIsNullReturnEmpty(); item.Answer = answer.IsNullOrEmpty() ? item.DefaultValue : answer; - item.Childrens = questions.Where(x => x.ParentId == item.Id || (x.GroupId==item.Id&&x.ParentId==null)).ToList(); + item.Childrens = questions.Where(x => x.ParentId == item.Id || (x.GroupId == item.Id && x.ParentId == null)).ToList(); if (item.Childrens != null && item.Childrens.Count > 0) { foreach (var question in item.Childrens) @@ -733,7 +736,7 @@ namespace IRaCIS.Application.Services }); } - + result.ForEach(x => { @@ -776,17 +779,18 @@ namespace IRaCIS.Application.Services var organList = await _organInfoRepository.Where(x => organIds.Contains(x.Id)).ToListAsync(); var questionPage = await GetReadingTableQuestion( - new GetReadingTableQuestionOrAnswerInDto() { + new GetReadingTableQuestionOrAnswerInDto() + { TrialReadingCriterionId = taskinfo.TrialReadingCriterionId, TaskId = inDto.VisitTaskId, TableAnswers = tableAnswers, TableAnsweRowInfos = tableAnsweRowInfos, - OrganInfos= organList, + OrganInfos = organList, } - ); + ); result.SinglePage = questionPage.SinglePage; result.MultiPage = questionPage.MultiPage; @@ -815,7 +819,7 @@ namespace IRaCIS.Application.Services //await _readingCalculateService.AddTaskLesionAnswerFromLastTask(new AddTaskLesionAnswerFromLastTaskInDto() { //VisitTaskId=inDto.VisitTaskId //}); - var taskInfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Include(x=>x.SourceSubjectVisit).FirstNotNullAsync(); + var taskInfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Include(x => x.SourceSubjectVisit).FirstNotNullAsync(); var tableAnswers = await _readingTableQuestionAnswerRepository .ProjectTo(_mapper.ConfigurationProvider) @@ -834,12 +838,13 @@ namespace IRaCIS.Application.Services TableAnswers = tableAnswers, TableAnsweRowInfos = tableAnsweRowInfos, IsGetallQuestion = true, - OrganInfos= organList + OrganInfos = organList } - ),new { - IsBaseline= taskInfo.SourceSubjectVisit!=null&&taskInfo.SourceSubjectVisit.IsBaseLine, - ReadingTaskState= taskInfo.ReadingTaskState + ), new + { + IsBaseline = taskInfo.SourceSubjectVisit != null && taskInfo.SourceSubjectVisit.IsBaseLine, + ReadingTaskState = taskInfo.ReadingTaskState }); } @@ -854,15 +859,16 @@ namespace IRaCIS.Application.Services { var criterionInfo = await _readingQuestionCriterionTrialRepository.Where(x => x.Id == inDto.TrialReadingCriterionId).FirstNotNullAsync(); - var qusetionList = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == inDto.TrialReadingCriterionId).ProjectTo(_mapper.ConfigurationProvider,new { + var qusetionList = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == inDto.TrialReadingCriterionId).ProjectTo(_mapper.ConfigurationProvider, new + { - isEn_Us=_userInfo.IsEn_Us + isEn_Us = _userInfo.IsEn_Us }).OrderBy(x => x.ShowOrder).ToListAsync(); var taskInfo = new VisitTask(); if (inDto.TaskId != null) { - taskInfo = await _visitTaskRepository.Where(x => x.Id == inDto.TaskId).FirstNotNullAsync(); + taskInfo = await _visitTaskRepository.Where(x => x.Id == inDto.TaskId).FirstNotNullAsync(); qusetionList.ForEach(x => { @@ -879,7 +885,7 @@ namespace IRaCIS.Application.Services }); } - //是否是预览 + //是否是预览 if (inDto.IsGetPreview == false) { // 是否获取所有问题 @@ -898,13 +904,13 @@ namespace IRaCIS.Application.Services } - if (inDto.TaskId != null&& !taskInfo.IsConvertedTask) + if (inDto.TaskId != null && !taskInfo.IsConvertedTask) { - qusetionList= qusetionList.Where(x=>x.QuestionType!=QuestionType.IsConverted).OrderBy(x => x.ShowOrder).ToList(); + qusetionList = qusetionList.Where(x => x.QuestionType != QuestionType.IsConverted).OrderBy(x => x.ShowOrder).ToList(); } var usedGuropIds = qusetionList.Where(x => x.Type == ReadingQestionType.Table).Select(x => x.GroupId).ToList(); - qusetionList = qusetionList.Where(x => usedGuropIds.Contains(x.Id)|| usedGuropIds.Contains(x.GroupId)).ToList(); + qusetionList = qusetionList.Where(x => usedGuropIds.Contains(x.Id) || usedGuropIds.Contains(x.GroupId)).ToList(); } } @@ -923,9 +929,10 @@ namespace IRaCIS.Application.Services var qusetionIds = qusetionList.Select(x => x.Id).ToList(); var tableQuestionList = await _readingTableQuestionTrialRepository.Where(x => qusetionIds.Contains(x.ReadingQuestionId)) - .ProjectTo(_mapper.ConfigurationProvider,new { + .ProjectTo(_mapper.ConfigurationProvider, new + { - isEn_Us=_userInfo.IsEn_Us + isEn_Us = _userInfo.IsEn_Us }) .OrderBy(x => x.ShowOrder).ToListAsync(); @@ -934,7 +941,9 @@ namespace IRaCIS.Application.Services List baseLineTableAnswer = new List(); - if(inDto.TaskId!=null) + bool isFirstChangeTask = false; + + if (inDto.TaskId != null) { taskInfo = await _visitTaskRepository.Where(x => x.Id == inDto.TaskId).FirstNotNullAsync(); // 取基线 @@ -945,11 +954,28 @@ namespace IRaCIS.Application.Services && x.DoctorUserId == taskInfo.DoctorUserId && x.IsAnalysisCreate == taskInfo.IsAnalysisCreate && x.TaskState == TaskState.Effect - &&x.TrialReadingCriterionId== taskInfo.TrialReadingCriterionId + && x.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId ).Select(x => x.Id).FirstNotNullAsync(); - baseLineTableAnswer = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == baselineTaskId).Include(x=>x.ReadingTableQuestionTrial).ToListAsync(); + baseLineTableAnswer = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == baselineTaskId).Include(x => x.ReadingTableQuestionTrial).ToListAsync(); + + if (taskInfo.IsConvertedTask && + !(await _visitTaskRepository.AnyAsync(x => x.IsAnalysisCreate == taskInfo.IsAnalysisCreate + && x.IsSelfAnalysis == taskInfo.IsSelfAnalysis + && x.VisitTaskNum < taskInfo.VisitTaskNum + && x.DoctorUserId == taskInfo.DoctorUserId + && x.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId + && !x.IsConvertedTask + && x.SubjectId == taskInfo.SubjectId + && x.ArmEnum == taskInfo.ArmEnum && + x.TaskState == TaskState.Effect)) + ) + { + isFirstChangeTask = true; + + + } } if (criterionInfo.FormType == FormType.MultiplePage) { @@ -969,7 +995,7 @@ namespace IRaCIS.Application.Services var pageGroupList = newPageQusetionList.Where(x => x.Type == ReadingQestionType.Group).ToList(); pageGroupList.ForEach(x => { - this.FindChildQuestion(x, newPageQusetionList, tableQuestionList, inDto.TableAnswers, inDto.TableAnsweRowInfos,inDto.OrganInfos, baseLineTableAnswer); + this.FindChildQuestion(x, newPageQusetionList, tableQuestionList, inDto.TableAnswers, inDto.TableAnsweRowInfos, inDto.OrganInfos, baseLineTableAnswer, isFirstChangeTask); }); page.Childrens = pageGroupList.Where(x => !(x.Type == ReadingQestionType.Group && x.Childrens.Count() == 0)).ToList(); @@ -986,7 +1012,7 @@ namespace IRaCIS.Application.Services groupList = qusetionList.Where(x => x.Type == ReadingQestionType.Group).ToList(); groupList.ForEach(x => { - this.FindChildQuestion(x, qusetionList, tableQuestionList, inDto.TableAnswers, inDto.TableAnsweRowInfos, inDto.OrganInfos, baseLineTableAnswer); + this.FindChildQuestion(x, qusetionList, tableQuestionList, inDto.TableAnswers, inDto.TableAnsweRowInfos, inDto.OrganInfos, baseLineTableAnswer, isFirstChangeTask); }); groupList = groupList.Where(x => !(x.Type == ReadingQestionType.Group && x.Childrens.Count() == 0)).ToList(); @@ -1006,9 +1032,9 @@ namespace IRaCIS.Application.Services /// /// /// - private async void FindChildQuestion(TrialReadQuestionData item, List questionlists, List tableQuestionLists, List tableAnswers, List tableAnsweRowInfos,List organInfos, List baseLineTableAnswer) + private async void FindChildQuestion(TrialReadQuestionData item, List questionlists, List tableQuestionLists, List tableAnswers, List tableAnsweRowInfos, List organInfos, List baseLineTableAnswer,bool isFirstChangeTask) { - item.Childrens = questionlists.Where(x => x.ParentId == item.Id ||x.GroupId==item.Id).ToList(); + item.Childrens = questionlists.Where(x => x.ParentId == item.Id || x.GroupId == item.Id).ToList(); item.TableQuestions = new TrialReadTableQuestion(); item.TableQuestions.Questions = tableQuestionLists.Where(x => x.ReadingQuestionId == item.Id).OrderBy(x => x.ShowOrder).ToList(); @@ -1053,14 +1079,14 @@ namespace IRaCIS.Application.Services QuestionMark.Location, QuestionMark.Part, }; - + orders.ForEach(x => { Dictionary answers = new Dictionary(); var rowInfo = tableAnsweRowInfos.Where(y => y.RowIndex == x && y.QuestionId == item.Id).FirstOrDefault(); var rowAnswer = thisAnswer.Where(y => y.RowId == rowInfo.Id).OrderBy(y => y.ShowOrder).ToList(); - var organInfo = organInfos.Where(x=>x.Id== rowInfo.OrganInfoId).FirstOrDefault(); + var organInfo = organInfos.Where(x => x.Id == rowInfo.OrganInfoId).FirstOrDefault(); rowAnswer.ForEach(z => { @@ -1123,12 +1149,13 @@ namespace IRaCIS.Application.Services { answers.Add(z.TableQuestionId.ToString(), z.Answer); } - + }); answers.Add("BlindName", rowInfo.BlindName); + answers.Add("IsFirstChangeTask", isFirstChangeTask.ToString()); answers.Add("FromMark", rowInfo.FromMark); answers.Add("IsDicomReading", rowInfo.IsDicomReading.ToString()); answers.Add("MeasureData", rowInfo == null ? string.Empty : rowInfo.MeasureData); @@ -1144,7 +1171,7 @@ namespace IRaCIS.Application.Services answers.Add("SplitOrMergeType", rowInfo.SplitOrMergeType == null ? string.Empty : ((int)rowInfo.SplitOrMergeType).ToString()); if (rowInfo.LesionType == LesionType.BaselineLesions) { - answers.Add("BaseLineLesionNumber", baseLineTableAnswer.Where(n=>n.ReadingTableQuestionTrial.QuestionMark==QuestionMark.LesionNumber&&n.RowIndex==rowInfo.RowIndex).Select(x=>x.Answer).FirstIsNullReturnEmpty()); + answers.Add("BaseLineLesionNumber", baseLineTableAnswer.Where(n => n.ReadingTableQuestionTrial.QuestionMark == QuestionMark.LesionNumber && n.RowIndex == rowInfo.RowIndex).Select(x => x.Answer).FirstIsNullReturnEmpty()); } @@ -1155,7 +1182,7 @@ namespace IRaCIS.Application.Services { item.Childrens.ForEach(x => { - this.FindChildQuestion(x, questionlists, tableQuestionLists, tableAnswers, tableAnsweRowInfos, organInfos, baseLineTableAnswer); + this.FindChildQuestion(x, questionlists, tableQuestionLists, tableAnswers, tableAnsweRowInfos, organInfos, baseLineTableAnswer, isFirstChangeTask); }); } } @@ -1368,19 +1395,20 @@ namespace IRaCIS.Application.Services { IsDeleted = true - }); - await _readingTableAnswerRowInfoRepository.UpdatePartialFromQueryAsync(x => x.Id == inDto.RowId,x=>new ReadingTableAnswerRowInfo() { - - IsDeleted=true + }); + await _readingTableAnswerRowInfoRepository.UpdatePartialFromQueryAsync(x => x.Id == inDto.RowId, x => new ReadingTableAnswerRowInfo() + { + + IsDeleted = true }); await _readingTableAnswerRowInfoRepository.SaveChangesAsync(); - var rowInfoList = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.QuestionId == inDto.QuestionId,true).Include(x => x.ReadingQuestionTrial).OrderBy(x => x.RowIndex).ToListAsync(); + var rowInfoList = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.QuestionId == inDto.QuestionId, true).Include(x => x.ReadingQuestionTrial).OrderBy(x => x.RowIndex).ToListAsync(); + + var answerlist = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.QuestionId == inDto.QuestionId, true).ToListAsync(); - var answerlist = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.QuestionId == inDto.QuestionId,true).ToListAsync(); - foreach (var item in rowInfoList.Where(x => x.RowIndex % 1 == 0)) { @@ -1392,13 +1420,13 @@ namespace IRaCIS.Application.Services measureDataStr = JsonConvert.SerializeObject(measureData); } - - foreach (var answerItem in answerlist.Where(x=>x.RowIndex== item.RowIndex)) + + foreach (var answerItem in answerlist.Where(x => x.RowIndex == item.RowIndex)) { answerItem.RowIndex = index; - + } @@ -1407,7 +1435,7 @@ namespace IRaCIS.Application.Services rowAnswerItem.RowIndex = index; rowAnswerItem.MeasureData = measureDataStr; - + } //await _readingTableQuestionAnswerRepository.UpdatePartialFromQueryAsync(x => x.VisitTaskId == inDto.VisitTaskId && x.RowIndex == item.RowIndex && x.QuestionId == inDto.QuestionId, x => new ReadingTableQuestionAnswer() @@ -1436,7 +1464,7 @@ namespace IRaCIS.Application.Services foreach (var answerItem in answerlist.Where(x => x.RowIndex == spiltitem.RowIndex)) { answerItem.RowIndex = index + spiltindex; - + } @@ -1446,7 +1474,7 @@ namespace IRaCIS.Application.Services rowAnswerItem.RowIndex = index + spiltindex; rowAnswerItem.MeasureData = spiltmeasureDataStr; - + } @@ -1489,7 +1517,7 @@ namespace IRaCIS.Application.Services await VerifyTaskIsSign(inDto.VisitTaskId); - if (inDto.InstanceId != null&&inDto.IsDicomReading) + if (inDto.InstanceId != null && inDto.IsDicomReading) { if (!(await _dicomInstanceRepository.AnyAsync(x => x.Id == inDto.InstanceId && x.SeriesId == inDto.SeriesId))) { @@ -1510,19 +1538,19 @@ namespace IRaCIS.Application.Services case CriterionType.RECIST1Point1: var lastTaskinfo = await _visitTaskRepository .Where(x => x.IsAnalysisCreate == taskinfo.IsAnalysisCreate && - x.SubjectId==taskinfo.SubjectId&& + x.SubjectId == taskinfo.SubjectId && x.ReadingCategory == taskinfo.ReadingCategory && x.DoctorUserId == taskinfo.DoctorUserId && x.ArmEnum == taskinfo.ArmEnum && - x.TrialReadingCriterionId==taskinfo.TrialReadingCriterionId&& - x.ReadingTaskState==ReadingTaskState.HaveSigned&& + x.TrialReadingCriterionId == taskinfo.TrialReadingCriterionId && + x.ReadingTaskState == ReadingTaskState.HaveSigned && x.TaskState == TaskState.Effect && x.IsSelfAnalysis == taskinfo.IsSelfAnalysis && x.VisitTaskNum < taskinfo.VisitTaskNum ).OrderByDescending(x => x.VisitTaskNum).FirstOrDefaultAsync(); if (lastTaskinfo != null) { - var tablequestionList = await _readingTableQuestionTrialRepository.Where(x => x.TrialCriterionId == taskinfo.TrialReadingCriterionId&&x.ReadingQuestionTrial.LesionType==LesionType.NonTargetLesions).ToListAsync(); + var tablequestionList = await _readingTableQuestionTrialRepository.Where(x => x.TrialCriterionId == taskinfo.TrialReadingCriterionId && x.ReadingQuestionTrial.LesionType == LesionType.NonTargetLesions).ToListAsync(); @@ -1535,7 +1563,7 @@ namespace IRaCIS.Application.Services if (stateQuestion != null) { // 判断是否为非靶病灶 - if (inDto.QuestionId == tablequestionList[0].ReadingQuestionId && inDto.AnswerList.Any(x => x.TableQuestionId== stateQuestion.Id&&x.Answer.EqEnum(NoTargetState.Increase))) + if (inDto.QuestionId == tablequestionList[0].ReadingQuestionId && inDto.AnswerList.Any(x => x.TableQuestionId == stateQuestion.Id && x.Answer.EqEnum(NoTargetState.Increase))) { var lymphQuestion = tablequestionList.Where(x => x.QuestionMark == QuestionMark.IsLymph).FirstOrDefault(); if (lymphQuestion != null) @@ -1574,7 +1602,7 @@ namespace IRaCIS.Application.Services throw new BusinessValidationFailedException(_localizer["ReadingImage_IsLymphNotbigger"]); } - + } } } @@ -1595,21 +1623,21 @@ namespace IRaCIS.Application.Services var thisvalue = 0m; try { - lastvalue = decimal.Parse(lastAnswer); - thisvalue = decimal.Parse(thisAnswer); + lastvalue = decimal.Parse(lastAnswer); + thisvalue = decimal.Parse(thisAnswer); } catch (Exception) { - + } - + if (lastvalue >= thisvalue) { throw new BusinessValidationFailedException(_localizer["ReadingImage_NotLymphNotbigger"]); } - + } } } @@ -1618,7 +1646,7 @@ namespace IRaCIS.Application.Services } } - + } } @@ -1644,8 +1672,8 @@ namespace IRaCIS.Application.Services if (inDto.RowIndex % 1 == 0) { - - if (questionInfo.MaxQuestionCount != null && questionInfo.MaxQuestionCount != 0&& inDto.RowId==null) + + if (questionInfo.MaxQuestionCount != null && questionInfo.MaxQuestionCount != 0 && inDto.RowId == null) { if (questionInfo.MaxQuestionCount < ( @@ -1664,14 +1692,14 @@ namespace IRaCIS.Application.Services { QuestionMark.Part, QuestionMark.Organ, - + }; - + string msg = string.Empty; foreach (var item in tableQuestions) { - + var answer = inDto.AnswerList.Where(x => x.TableQuestionId == item.Id).Select(x => x.Answer).FirstOrDefault(); if (!answer.IsNullOrEmpty()) { @@ -1682,9 +1710,9 @@ namespace IRaCIS.Application.Services {CriterionType.PCWG3, _localizer["ReadingImage_PCWGMaximum", item.MaxRowCount.Value]}, }; var rowCount = 0; - if ((item.QuestionMark == QuestionMark.Part|| item.QuestionMark == QuestionMark.Organ) &&inDto.OrganInfoId!=null) + if ((item.QuestionMark == QuestionMark.Part || item.QuestionMark == QuestionMark.Organ) && inDto.OrganInfoId != null) { - var organIds= await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.QuestionId == inDto.QuestionId && ((x.RowIndex % 1) == 0) && x.OrganInfoId != null && x.RowIndex != inDto.RowIndex).Select(x=>x.OrganInfoId).ToListAsync(); + var organIds = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.QuestionId == inDto.QuestionId && ((x.RowIndex % 1) == 0) && x.OrganInfoId != null && x.RowIndex != inDto.RowIndex).Select(x => x.OrganInfoId).ToListAsync(); organIds.Add(inDto.OrganInfoId); var orginInfos = await _organInfoRepository.Where(x => organIds.Contains(x.Id)).ToListAsync(); @@ -1692,14 +1720,14 @@ namespace IRaCIS.Application.Services List orginInfoList = new List(); foreach (var organId in organIds) { - orginInfoList.Add(orginInfos.Where(x=>x.Id==organId).FirstOrDefault()); + orginInfoList.Add(orginInfos.Where(x => x.Id == organId).FirstOrDefault()); } - var currentOrginInfo = orginInfos.Where(x => x.Id == inDto.OrganInfoId).FirstOrDefault()??new OrganInfo (); + var currentOrginInfo = orginInfos.Where(x => x.Id == inDto.OrganInfoId).FirstOrDefault() ?? new OrganInfo(); if (item.QuestionMark == QuestionMark.Part) { - rowCount = orginInfoList.Where(x=>x.Part== currentOrginInfo.Part).Count(); + rowCount = orginInfoList.Where(x => x.Part == currentOrginInfo.Part).Count(); } else { @@ -1708,7 +1736,7 @@ namespace IRaCIS.Application.Services if (rowCount > item.MaxRowCount.Value) { - if (rowCount > item.MaxRowCount.Value ) + if (rowCount > item.MaxRowCount.Value) { @@ -1727,7 +1755,7 @@ namespace IRaCIS.Application.Services } } - + else { rowCount = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.TableQuestionId == item.Id && ((x.RowIndex % 1) == 0) && x.Answer == answer && x.RowIndex != inDto.RowIndex).CountAsync(); @@ -1735,7 +1763,7 @@ namespace IRaCIS.Application.Services if (rowCount > item.MaxRowCount.Value - 1) { - + try { msg = errorMsgDic[criterionInfo.CriterionType]; @@ -1749,9 +1777,9 @@ namespace IRaCIS.Application.Services throw new BusinessValidationFailedException(msg); } } - - + + } } } @@ -1792,8 +1820,8 @@ namespace IRaCIS.Application.Services rowInfo.IsCanEditPosition = inDto.IsCanEditPosition; rowInfo.WL = inDto.WL; rowInfo.WW = inDto.WW; - result.RowId = rowInfo.Id; - + result.RowId = rowInfo.Id; + if (inDto.RowId == null) { @@ -1814,7 +1842,7 @@ namespace IRaCIS.Application.Services await _readingTableAnswerRowInfoRepository.AddAsync(rowInfo); await _readingTableQuestionAnswerRepository.AddRangeAsync(answerList); - + } else @@ -1838,7 +1866,7 @@ namespace IRaCIS.Application.Services VisitTaskId = rowInfo.VisitTaskId, StudyId = rowInfo.StudyId, IsCanEditPosition = rowInfo.IsCanEditPosition, - }) ; + }); foreach (var item in inDto.AnswerList) @@ -1865,10 +1893,10 @@ namespace IRaCIS.Application.Services VisitTaskId = inDto.VisitTaskId, }); } - + } - + } await _visitTaskRepository.UpdatePartialFromQueryAsync(inDto.VisitTaskId, x => new VisitTask() @@ -1976,20 +2004,20 @@ namespace IRaCIS.Application.Services [HttpPost] public async Task VerifyDefaultQuestionBeAnswer(VerifyVisitTaskQuestionsInDto inDto) { - - var taskInfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Include(x=>x.TrialReadingCriterion).Include(x=>x.SourceSubjectVisit).FirstNotNullAsync(); + + var taskInfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Include(x => x.TrialReadingCriterion).Include(x => x.SourceSubjectVisit).FirstNotNullAsync(); var criterion = await _readingQuestionCriterionTrialRepository.Where(x => x.Id == taskInfo.TrialReadingCriterionId).FirstNotNullAsync(); var readingQuestionList = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == taskInfo.TrialReadingCriterionId) - .WhereIf(taskInfo.SourceSubjectVisit.IsBaseLine,x=> ((x.IsRequired == IsRequired.Required && x.ShowQuestion == ShowQuestion.Show)&&(x.LimitEdit==LimitEdit.None||x.LimitEdit==LimitEdit.OnlyBaseLine))) + .WhereIf(taskInfo.SourceSubjectVisit.IsBaseLine, x => ((x.IsRequired == IsRequired.Required && x.ShowQuestion == ShowQuestion.Show) && (x.LimitEdit == LimitEdit.None || x.LimitEdit == LimitEdit.OnlyBaseLine))) .WhereIf(!taskInfo.SourceSubjectVisit.IsBaseLine, x => ((x.IsRequired == IsRequired.Required && x.ShowQuestion == ShowQuestion.Show) && (x.LimitEdit == LimitEdit.None || x.LimitEdit == LimitEdit.OnlyVisit))) - .WhereIf(taskInfo.TrialReadingCriterion.CriterionType==CriterionType.PCWG3, x => x.QuestionType != QuestionType.SiteVisitForTumorEvaluation) + .WhereIf(taskInfo.TrialReadingCriterion.CriterionType == CriterionType.PCWG3, x => x.QuestionType != QuestionType.SiteVisitForTumorEvaluation) //.WhereIf(!criterion.IseCRFShowInDicomReading,x=>x.IsShowInDicom) .ToListAsync(); - var answerQuestionIds = await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId&&x.Answer!=string.Empty).Select(x => x.ReadingQuestionTrialId).ToListAsync(); + var answerQuestionIds = await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.Answer != string.Empty).Select(x => x.ReadingQuestionTrialId).ToListAsync(); readingQuestionList = readingQuestionList.Where(x => !answerQuestionIds.Contains(x.Id)).ToList(); @@ -2120,9 +2148,10 @@ namespace IRaCIS.Application.Services { TrialId = inDto.TrialId, TrialReadingCriterionId = trialReadingCriterionId.Value, - Page=new PageInput() { - PageIndex=1, - PageSize=99999, + Page = new PageInput() + { + PageIndex = 1, + PageSize = 99999, } })).Item2; @@ -2165,7 +2194,7 @@ namespace IRaCIS.Application.Services && x.TaskState == TaskState.Effect).Select(x => new GetReadingTaskDto() { VisitTaskId = x.Id, - ArmEnum= x.ArmEnum, + ArmEnum = x.ArmEnum, TaskBlindName = x.TaskBlindName, ReadingCategory = x.ReadingCategory, VisistId = x.SourceSubjectVisitId != null ? x.SourceSubjectVisitId.Value : x.ReadModule == null ? default(Guid) : x.ReadModule.SubjectVisitId, @@ -2174,7 +2203,7 @@ namespace IRaCIS.Application.Services SubjectCode = x.Subject.Code, TrialReadingCriterionId = x.TrialReadingCriterionId, }).FirstOrDefaultAsync(); - + } if (task == null) @@ -2270,7 +2299,7 @@ namespace IRaCIS.Application.Services int timespanMin = (DateTime.Now - cacheDate).Minutes; if (timespanMin > 120 && timespanMin < 140) { - throw new BusinessValidationFailedException(_localizer["ReadingImage_NeedRest",2,20]); + throw new BusinessValidationFailedException(_localizer["ReadingImage_NeedRest", 2, 20]); } else if (timespanMin > 140) { @@ -2329,7 +2358,7 @@ namespace IRaCIS.Application.Services // 完成阅片修改状态 //await this.FinishReadUpdateState(visitTaskId); - + await _visitTaskRepository.SaveChangesAsync(); @@ -2406,7 +2435,7 @@ namespace IRaCIS.Application.Services await _visitTaskRepository.UpdatePartialFromQueryAsync(taskInfo.Id, x => new VisitTask() { - + PastResultTaskIds = JsonConvert.SerializeObject(pastResultTaskIdList), RelatedVisitTaskIds = JsonConvert.SerializeObject(relatedVisitTaskIdList), @@ -2438,7 +2467,7 @@ namespace IRaCIS.Application.Services /// [HttpPost] [TypeFilter(typeof(TrialResourceFilter), Arguments = new object[] { "AfterStopCannNotOpt" })] - public async Task AddReadingTask(Guid visitTaskId,Guid? trialId=null) + public async Task AddReadingTask(Guid visitTaskId, Guid? trialId = null) { // ****** 先生成阅片期 阅片期任务阅片完成之后生成肿瘤学的 如果没有阅片期 直接生成肿瘤学 *********//// #region 建立关系