diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index fb4e96eb4..cfff70b9f 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -1444,6 +1444,61 @@ 答案 + + + 答案 + + + + + 类型 + + + + + 父问题触发值 + + + + + 问题名称 + + + + + 类型值 + + + + + 是否启用 + + + + + 是否必须 + + + + + 排序 + + + + + 父问题 + + + + + 是否确认 + + + + + 是否是当前任务 + + 任务名称 @@ -2161,7 +2216,7 @@ - 获取 + 获取医学审核任务信息 diff --git a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingMedicalReviewDto.cs b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingMedicalReviewDto.cs index ff8409445..0abe6d5f1 100644 --- a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingMedicalReviewDto.cs +++ b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingMedicalReviewDto.cs @@ -29,12 +29,79 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto public List TaskList { get; set; } = new List(); public List OtherDoctorTaskList { get; set; } = new List(); + + + public List QuestionAnswerList { get; set; } = new List(); + + } + + public class ReadingMedicineQuestion + { + /// + /// 答案 + /// + public string Answer { get; set; } + + public Guid MedicineQuestionId { get; set; } + + /// + /// 类型 + /// + public string Type { get; set; } + + /// + /// 父问题触发值 + /// + public string ParentTriggerValue { get; set; } = string.Empty; + + /// + /// 问题名称 + /// + public string QuestionName { get; set; } + + /// + /// 类型值 + /// + public string TypeValue { get; set; } + + /// + /// 是否启用 + /// + public bool IsEnable { get; set; } + + /// + /// 是否必须 + /// + public bool IsRequired { get; set; } + + /// + /// 排序 + /// + public int ShowOrder { get; set; } + + /// + /// 父问题 + /// + public Guid? ParentId { get; set; } + + /// + /// 是否确认 + /// + public bool? IsConfirm { get; set; } + + + public List Childrens { get; set; } } public class TaskInfo { public Guid Id { get; set; } + /// + /// 是否是当前任务 + /// + public bool IsCurrentTask { get; set; } = false; + /// /// 任务名称 /// @@ -44,7 +111,9 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto /// /// 盲态名称 /// - public string TaskBlindName { get; set; } + public string TaskBlindName { get; set; } + + public Arm ArmEnum { get; set; } /// /// 评估结果 diff --git a/IRaCIS.Core.Application/Service/Reading/ReadModuleService.cs b/IRaCIS.Core.Application/Service/Reading/ReadModuleService.cs index 594434864..9a6ba001a 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadModuleService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadModuleService.cs @@ -157,8 +157,8 @@ namespace IRaCIS.Application.Services dto.SortField = dto.Asc ? dto.SortField : dto.SortField + " desc"; var subjectQuery = _readModuleViewRepository.WhereIf(dto.TrialId != null, x => x.TrialId == dto.TrialId) .WhereIf(dto.SubjectId != null, x => x.SubjectId == dto.SubjectId) - .WhereIf(dto.TrialSiteCode != null && dto.TrialSiteCode != String.Empty, x => x.TrialSiteCode == dto.TrialSiteCode) - .WhereIf(dto.SubjectCode != null && dto.SubjectCode != String.Empty, x => x.SubjectCode == dto.SubjectCode) + .WhereIf(dto.TrialSiteCode != null && dto.TrialSiteCode != string.Empty, x => x.TrialSiteCode == dto.TrialSiteCode) + .WhereIf(dto.SubjectCode != null && dto.SubjectCode != string.Empty, x => x.SubjectCode == dto.SubjectCode) .WhereIf(dto.ModuleType != null, x => x.ModuleType == dto.ModuleType) .WhereIf(dto.ReadingStatus != null, x => x.ReadingStatus == dto.ReadingStatus) .WhereIf(dto.Name != null, x => x.Name.Contains(dto.Name)).OrderBy(x => x.SiteCode); @@ -336,7 +336,7 @@ namespace IRaCIS.Application.Services } else { - return ResponseOutput.NotOk("No qualified visit was found "); + return ResponseOutput.NotOk("未找到符合要求的访视"); } diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingMedicalReviewService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingMedicalReviewService.cs index ed5e05f00..be3ec8b8f 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingMedicalReviewService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingMedicalReviewService.cs @@ -21,64 +21,161 @@ namespace IRaCIS.Core.Application.Service private readonly IRepository _readingMedicineTrialQuestionRepository; private readonly IRepository _trialRepository; private readonly IRepository _visitTaskRepository; + private readonly IRepository _taskMedicalReviewRepository; + private readonly IRepository _readingMedicineQuestionAnswerRepository; private readonly IRepository _readingMedicineSystemQuestionRepository; public ReadingMedicalReviewService( IRepository readingMedicineTrialQuestionRepository, IRepository trialRepository, IRepository visitTaskRepository, - IRepository readingMedicineSystemQuestionRepository + IRepository taskMedicalReviewRepository, + IRepository readingMedicineQuestionAnswerRepository, + IRepository readingMedicineSystemQuestionRepository ) { this._readingMedicineTrialQuestionRepository = readingMedicineTrialQuestionRepository; this._trialRepository = trialRepository; this._visitTaskRepository = visitTaskRepository; + this._taskMedicalReviewRepository = taskMedicalReviewRepository; + this._readingMedicineQuestionAnswerRepository = readingMedicineQuestionAnswerRepository; this._readingMedicineSystemQuestionRepository = readingMedicineSystemQuestionRepository; } /// - /// 获取 + /// 获取医学审核任务信息 /// /// /// + [HttpPost] public async Task GetMedicalReviewReadingTask(GetMedicalReviewReadingTaskInDto inDto) { var medicalReviewInfo = await _trialRepository.Where(x => x.Id == inDto.TrialId).Select(x => new GetMedicalReviewReadingTaskOutDto() { ReadingType=x.ReadingType, IsReadingTaskViewInOrder=x.IsReadingTaskViewInOrder - }).FirstOrDefaultAsync(); + }).FirstNotNullAsync(); - var taskInfo = await _visitTaskRepository.Where(x => x.Id == inDto.TrialId).FirstOrDefaultAsync(); + var taskMedicalReview = await _taskMedicalReviewRepository.Where(x => x.Id == inDto.TaskMedicalReviewId).FirstNotNullAsync(); + var taskInfo = await _visitTaskRepository.Where(x => x.Id == taskMedicalReview.VisitTaskId).FirstNotNullAsync(); - // 单审有序 + #region 取任务 if (medicalReviewInfo.IsReadingTaskViewInOrder) { - medicalReviewInfo.TaskList = await _visitTaskRepository.Where(x => x.SouceReadModuleId == taskInfo.SouceReadModuleId && x.SourceSubjectVisitId == taskInfo.SourceSubjectVisitId + medicalReviewInfo.TaskList = await _visitTaskRepository + .WhereIf(taskInfo.ArmEnum == Arm.JudgeArm, x => x.ArmEnum == Arm.JudgeArm) + .WhereIf(taskInfo.ArmEnum != Arm.JudgeArm, x => x.ArmEnum != Arm.JudgeArm) + .Where(x => x.SubjectId == taskInfo.SubjectId && x.DoctorUserId == taskInfo.DoctorUserId && x.ReadingTaskState == ReadingTaskState.HaveSigned && x.ReReadingApplyState != ReReadingApplyState.Agree ).OrderBy(x => x.VisitTaskNum).Select(x => new TaskInfo() + { + Id = x.Id, + IsCurrentTask = x.Id == taskInfo.Id, + ReadingCategory = x.ReadingCategory, + TaskBlindName = x.TaskBlindName, + ArmEnum=x.ArmEnum, + TaskName = x.TaskName + }).ToListAsync(); + if (medicalReviewInfo.ReadingType == ReadingMethod.Double) + { + if (taskInfo.ArmEnum != Arm.JudgeArm) + { + medicalReviewInfo.OtherDoctorTaskList = await _visitTaskRepository.Where(x => x.ArmEnum != Arm.JudgeArm && x.SubjectId == taskInfo.SubjectId + && x.DoctorUserId != taskInfo.DoctorUserId && x.ReadingTaskState == ReadingTaskState.HaveSigned && x.ReReadingApplyState != ReReadingApplyState.Agree + ).OrderBy(x => x.VisitTaskNum).Select(x => new TaskInfo() { Id = x.Id, ReadingCategory = x.ReadingCategory, TaskBlindName = x.TaskBlindName, + ArmEnum=x.ArmEnum, TaskName = x.TaskName }).ToListAsync(); - if (medicalReviewInfo.ReadingType == ReadingMethod.Double) - { - //medicalReviewInfo.OtherDoctorTaskList= + } } } + else + { + medicalReviewInfo.TaskList = await _visitTaskRepository.Where(x => x.Id == taskInfo.Id).Select(x => new TaskInfo() + { + Id = x.Id, + IsCurrentTask = x.Id == taskInfo.Id, + ReadingCategory = x.ReadingCategory, + TaskBlindName = x.TaskBlindName, + ArmEnum=x.ArmEnum, + TaskName = x.TaskName + }).ToListAsync(); - - + if (medicalReviewInfo.ReadingType == ReadingMethod.Double) + { + if (taskInfo.ArmEnum != Arm.JudgeArm) + { + medicalReviewInfo.OtherDoctorTaskList = await _visitTaskRepository.Where(x => x.ArmEnum != Arm.JudgeArm && x.SouceReadModuleId == taskInfo.SouceReadModuleId && x.SourceSubjectVisitId == taskInfo.SourceSubjectVisitId + && x.DoctorUserId != taskInfo.DoctorUserId && x.ReadingTaskState == ReadingTaskState.HaveSigned && x.ReReadingApplyState != ReReadingApplyState.Agree + ).OrderBy(x => x.VisitTaskNum).Select(x => new TaskInfo() + { + Id = x.Id, + ReadingCategory = x.ReadingCategory, + TaskBlindName = x.TaskBlindName, + TaskName = x.TaskName, + ArmEnum=x.ArmEnum, + }).ToListAsync(); + } + } + } + #endregion + medicalReviewInfo.QuestionAnswerList = await this.GetMedicalQuestionAnswer(inDto); return medicalReviewInfo; } + private async Task> GetMedicalQuestionAnswer(GetMedicalReviewReadingTaskInDto inDto) + { + var questionQuery = from data in _readingMedicineTrialQuestionRepository.Where(x => x.TrialId == inDto.TrialId&&x.IsConfirm&&x.IsEnable) + join questionAnswer in _readingMedicineQuestionAnswerRepository.Where(x => x.TaskMedicalReviewId == inDto.TaskMedicalReviewId) on data.Id equals questionAnswer.ReadingMedicineQuestionId into questionAnswerTemp + from leftquestionAnswer in questionAnswerTemp.DefaultIfEmpty() + select new ReadingMedicineQuestion() + { + MedicineQuestionId = data.Id, + Type = data.Type, + ParentTriggerValue = data.ParentTriggerValue, + IsEnable=data.IsEnable, + IsConfirm=data.IsConfirm, + QuestionName = data.QuestionName, + IsRequired = data.IsRequired, + ShowOrder = data.ShowOrder, + ParentId = data.ParentId, + TypeValue = data.TypeValue, + Answer = leftquestionAnswer.Answer + }; - } + var questionList = await questionQuery.ToListAsync(); + + List < ReadingMedicineQuestion > medicineQuestionList = questionList.Where(x => x.ParentId == null).ToList(); + medicineQuestionList.ForEach(x => + { + FindChildQuestion(x, questionList); + }); + + return medicineQuestionList; + } + + + private void FindChildQuestion(ReadingMedicineQuestion medicineQuestionList, List questionlists) + { + medicineQuestionList.Childrens = questionlists.Where(x => x.ParentId == medicineQuestionList.MedicineQuestionId).ToList(); + if (medicineQuestionList.Childrens != null && medicineQuestionList.Childrens.Count != 0) + { + medicineQuestionList.Childrens.ForEach(x => + { + this.FindChildQuestion(x, questionlists); + }); + } + } + + + } } diff --git a/IRaCIS.Core.Domain/Reading/ReadingMedicineQuestionAnswer.cs b/IRaCIS.Core.Domain/Reading/ReadingMedicineQuestionAnswer.cs index ea9ae408f..e750b513c 100644 --- a/IRaCIS.Core.Domain/Reading/ReadingMedicineQuestionAnswer.cs +++ b/IRaCIS.Core.Domain/Reading/ReadingMedicineQuestionAnswer.cs @@ -11,13 +11,17 @@ namespace IRaCIS.Core.Domain.Models [Table("ReadingMedicineQuestionAnswer")] public class ReadingMedicineQuestionAnswer : Entity, IAuditUpdate, IAuditAdd { - - - + + /// - /// 医学审核Id - /// + /// 医学审核问题Id + /// + public Guid ReadingMedicineQuestionId { get; set; } + /// + /// 医学审核Id + /// + public Guid TaskMedicalReviewId { get; set; } /// diff --git a/IRaCIS.Core.Domain/Reading/ReadingMedicineTrialQuestion.cs b/IRaCIS.Core.Domain/Reading/ReadingMedicineTrialQuestion.cs index 7e37c0585..bac3e30e7 100644 --- a/IRaCIS.Core.Domain/Reading/ReadingMedicineTrialQuestion.cs +++ b/IRaCIS.Core.Domain/Reading/ReadingMedicineTrialQuestion.cs @@ -84,7 +84,7 @@ namespace IRaCIS.Core.Domain.Models /// /// 是否确认 /// - public bool? IsConfirm { get; set; } + public bool IsConfirm { get; set; } [ForeignKey("ParentId")] public ReadingMedicineTrialQuestion ParentQuestion { get; set; } diff --git a/IRaCIS.Core.Infrastructure/_IRaCIS/IQueryableExtensions.cs b/IRaCIS.Core.Infrastructure/_IRaCIS/IQueryableExtensions.cs new file mode 100644 index 000000000..e3f2e219a --- /dev/null +++ b/IRaCIS.Core.Infrastructure/_IRaCIS/IQueryableExtensions.cs @@ -0,0 +1,34 @@ +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using System.Linq.Dynamic.Core; + +namespace IRaCIS.Core.Infrastructure.Extention +{ + public static class IQueryableExtensions + { + /// + /// 获取第一条 null提示 + /// + /// + /// + /// + /// + public static async Task FirstNotNullAsync(this IQueryable source) + { + var result =await source.FirstOrDefaultAsync(); + + if (result == null) + { + throw new QueryBusinessObjectNotExistException($"The query object does not exist in database, Please check the query parameters"); + } + else + { + return result; + } + } + + + } +}