diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/PCWG3CalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/PCWG3CalculateService.cs index 04de656be..cbd67de47 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/PCWG3CalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/PCWG3CalculateService.cs @@ -1,14 +1,149 @@ using IRaCIS.Core.Application.Service.Reading.Dto; using IRaCIS.Core.Application.ViewModel; - +using IRaCIS.Core.Domain.Share; +using MassTransit; namespace IRaCIS.Core.Application.Service.ReadingCalculate { public class PCWG3CalculateService : BaseService, ICriterionCalculateService { + private readonly IRepository _readingTableQuestionAnswerRepository; + private readonly IRepository _visitTaskRepository; + private readonly IRepository _readingQuestionCriterionTrialRepository; + private readonly IRepository _readingTableQuestionTrialRepository; + private readonly IRepository _readingTableAnswerRowInfoRepository; + private readonly IRepository _readingQuestionTrialRepository; + private readonly IRepository _subjectVisitRepository; + private readonly IRepository _tumorAssessmentRepository; + private readonly IGeneralCalculateService _generalCalculateService; + private readonly IRepository _readingTaskQuestionAnswerRepository; + + public PCWG3CalculateService( + IRepository readingTableQuestionAnswerRepository, + IRepository visitTaskRepository, + IRepository readingQuestionCriterionTrialRepository, + IRepository readingTableQuestionTrialRepository, + IRepository readingTableAnswerRowInfoRepository, + IRepository readingQuestionTrialRepository, + IRepository subjectVisitRepository, + IRepository tumorAssessmentRepository, + IGeneralCalculateService generalCalculateService, + IRepository readingTaskQuestionAnswerRepository + ) + { + this._readingTableQuestionAnswerRepository = readingTableQuestionAnswerRepository; + this._visitTaskRepository = visitTaskRepository; + this._readingQuestionCriterionTrialRepository = readingQuestionCriterionTrialRepository; + this._readingTableQuestionTrialRepository = readingTableQuestionTrialRepository; + this._readingTableAnswerRowInfoRepository = readingTableAnswerRowInfoRepository; + this._readingQuestionTrialRepository = readingQuestionTrialRepository; + this._subjectVisitRepository = subjectVisitRepository; + this._tumorAssessmentRepository = tumorAssessmentRepository; + this._generalCalculateService = generalCalculateService; + this._readingTaskQuestionAnswerRepository = readingTaskQuestionAnswerRepository; + } + + /// + /// 将上一次的病灶信息添加到这一次 + /// + /// + /// public async Task AddTaskLesionAnswerFromLastTask(AddTaskLesionAnswerFromLastTaskInDto inDto) { return new AddTaskLesionAnswerFromLastTaskOutDto(); + //var visitTaskId = inDto.VisitTaskId; + + //var taskinfo = await _visitTaskRepository.Where(x => x.Id == visitTaskId).FirstNotNullAsync(); + + //var baseLineVisitId = await _subjectVisitRepository.Where(x => x.SubjectId == taskinfo.SubjectId && x.IsBaseLine).Select(x => x.Id).FirstOrDefaultAsync(); + + //// 判断当前任务是否是基线 + //if (taskinfo.SourceSubjectVisitId != baseLineVisitId) + //{ + // // 判断当前任务是是否有表格问题答案 + // if (!(await _readingTableQuestionAnswerRepository.AnyAsync(x => x.VisitTaskId == visitTaskId))) + // { + // var LastVisitTaskId = await _visitTaskRepository.Where(x => x.ReadingCategory == ReadingCategory.Visit && + // x.TrialReadingCriterionId == taskinfo.TrialReadingCriterionId && + // 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(); + + // 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, + // TrialId = x.TrialId + // }).ToListAsync(); + + // var tableRowAnswers = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == LastVisitTaskId).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); + + // tableRowAnswers.ForEach(x => + // { + // x.VisitTaskId = visitTaskId; + // x.IsCurrentTaskAdd = false; + // x.Id = NewId.NextGuid(); + // x.SeriesId = null; + // x.InstanceId = null; + // x.MeasureData = string.Empty; + // }); + + // tableRowAnswers.ForEach(x => + // { + // 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() + // { + // QuestionMark.State, + // }; + + // var tableAnswers = copyTableAnswers.Select(x => new ReadingTableQuestionAnswer + // { + // Id = NewId.NextGuid(), + // 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, + // }); + + + // await _visitTaskRepository.UpdatePartialFromQueryAsync(visitTaskId, x => new VisitTask() + // { + // ReadingTaskState = ReadingTaskState.Reading, + + // }); + + // tableRowAnswers.ForEach(x => + // { + // x.MergeRow = null; + // x.SplitRow = null; + // }); + + + + + + // await _readingTableAnswerRowInfoRepository.AddRangeAsync(tableRowAnswers); + // await _readingTableQuestionAnswerRepository.AddRangeAsync(tableAnswers); + // await _readingTableQuestionAnswerRepository.SaveChangesAsync(); + + // } + //} + + //return new AddTaskLesionAnswerFromLastTaskOutDto() + //{ + + // IsBaseLine = taskinfo.SourceSubjectVisitId == baseLineVisitId, + //}; } public async Task CalculateTask(CalculateTaskInDto inDto) diff --git a/IRaCIS.Core.Domain.Share/Reading/ReadEnum.cs b/IRaCIS.Core.Domain.Share/Reading/ReadEnum.cs index 52f3eb1b2..ea16fef55 100644 --- a/IRaCIS.Core.Domain.Share/Reading/ReadEnum.cs +++ b/IRaCIS.Core.Domain.Share/Reading/ReadEnum.cs @@ -678,6 +678,16 @@ namespace IRaCIS.Core.Domain.Share /// NewLesions = 2, + /// + /// 既往新病灶 + /// + AlwaysNewLesions = 3, + + /// + /// 基线病灶 + /// + BaselineLesions=4, + }