From 7a61ede3348a40476c25e6951a00b749b3dd97ca Mon Sep 17 00:00:00 2001
From: hang <872297557@qq.com>
Date: Wed, 29 Jun 2022 14:59:10 +0800
Subject: [PATCH] bug

---
 .../IRaCIS.Core.Application.xml               | 30 +++++++------
 .../DTO/TaskMedicalReviewRuleViewModel.cs     | 38 ++++++++++++++++
 .../ITaskMedicalReviewRuleService.cs          |  2 +-
 .../Allocation/TaskMedicalReviewService.cs    | 25 +++++++++--
 .../TaskTaskMedicalReviewRuleService.cs       | 18 ++++----
 .../Service/Allocation/_MapConfig.cs          | 43 ++++++++++++-------
 .../Allocation/TaskMedicalReview.cs           | 10 ++++-
 .../Allocation/TaskMedicalReviewRule.cs       | 20 ++++++---
 IRaCIS.Core.Domain/Allocation/VisitTask.cs    |  2 +
 .../Context/IRaCISDBContext.cs                |  4 ++
 10 files changed, 145 insertions(+), 47 deletions(-)

diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml
index b1ed4629e..351e54999 100644
--- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml
+++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml
@@ -79,6 +79,12 @@
             <param name="command"></param>
             <returns></returns>
         </member>
+        <member name="M:IRaCIS.Core.Application.Service.TaskMedicalReviewService.GetMIMUserList">
+            <summary>
+            获取医学经理列表
+            </summary>
+            <returns></returns>
+        </member>
         <member name="T:IRaCIS.Core.Application.Service.TaskMedicalReviewRuleService">
             <summary>
             医学审核生成规则
@@ -1123,6 +1129,16 @@
             获取访视列表
             </summary>
         </member>
+        <member name="P:IRaCIS.Core.Application.Service.Reading.Dto.GetReadingClinicalDataListIndto.IsVisit">
+            <summary>
+            是否是访视
+            </summary>
+        </member>
+        <member name="P:IRaCIS.Core.Application.Service.Reading.Dto.GetReadingClinicalDataListIndto.IsBaseLine">
+            <summary>
+            是否是基线
+            </summary>
+        </member>
         <member name="P:IRaCIS.Core.Application.Service.Reading.Dto.GetReadingClinicalDataPDFListOutDto.TrialId">
             <summary>
             项目ID
@@ -4706,20 +4722,6 @@
             </summary>
             <returns></returns>
         </member>
-        <member name="M:IRaCIS.Application.Services.ReadingQuestionService.VerifySystemQuestionIsSetJudgeAnswer(IRaCIS.Core.Application.Service.Reading.Dto.VerifySystemQuestionIsSetJudgeAnswerInDto)">
-            <summary>
-            验证系统问题是否设置裁片答案
-            </summary>
-            <param name="inDto"></param>
-            <returns></returns>
-        </member>
-        <member name="M:IRaCIS.Application.Services.ReadingQuestionService.VerifyTrialQuestionIsSetJudgeAnswer(IRaCIS.Core.Application.Service.Reading.Dto.VerifySystemQuestionIsSetJudgeAnswerInDto)">
-            <summary>
-            验证项目问题是否设置裁片答案
-            </summary>
-            <param name="inDto"></param>
-            <returns></returns>
-        </member>
         <member name="M:IRaCIS.Application.Services.ReadingQuestionService.SetSystemReadingQuestionCriterionIsCompleteConfig(IRaCIS.Core.Application.Service.Reading.Dto.SetSystemReadingQuestionCriterionIsIsCompleteConfig)">
             <summary>
             设置系统问题标准是否完成配置
diff --git a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskMedicalReviewRuleViewModel.cs b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskMedicalReviewRuleViewModel.cs
index 8948c7cc9..9dbae91ad 100644
--- a/IRaCIS.Core.Application/Service/Allocation/DTO/TaskMedicalReviewRuleViewModel.cs
+++ b/IRaCIS.Core.Application/Service/Allocation/DTO/TaskMedicalReviewRuleViewModel.cs
@@ -7,6 +7,7 @@ using System;
 using IRaCIS.Core.Domain.Share;
 using System.Collections.Generic;
 using System.ComponentModel.DataAnnotations;
+using Newtonsoft.Json;
 
 namespace IRaCIS.Core.Application.ViewModel
 {
@@ -20,6 +21,43 @@ namespace IRaCIS.Core.Application.ViewModel
 
         public UserSimpleInfo DoctorUser { get; set; }
 
+
+
+        [JsonIgnore]
+        public List<Guid> ActualVisitTaskIdList { get; set; }
+        [JsonIgnore]
+        public List<Guid> ActualJudgeTaskIdList { get; set; }
+        [JsonIgnore]
+        public List<Guid> ActualGlobalTaskIdList { get; set; }
+        [JsonIgnore]
+        public List<Guid> ActualTumorTaskIdList { get; set; }
+
+
+       
+
+        [JsonIgnore]
+        public List<Guid> GeneratedVisitTaskIdList { get; set; }
+        [JsonIgnore]
+        public List<Guid> GeneratedJudgeTaskIdList { get; set; }
+        [JsonIgnore]
+        public List<Guid> GeneratedGlobalTaskIdList { get; set; }
+        [JsonIgnore]
+        public List<Guid> GeneratedTumorTaskIdList { get; set; }
+
+
+        public int GeneratedVisitCount => GeneratedVisitTaskIdList.Count;
+        public int GeneratedJudgeCount => GeneratedJudgeTaskIdList.Count;
+        public int GeneratedGlobalCount => GeneratedGlobalTaskIdList.Count;
+        public int GeneratedTumorCount => GeneratedTumorTaskIdList.Count;
+
+
+
+
+        public int ActualVisitCount => ActualVisitTaskIdList.Count;
+        public int ActualJudgeCount => ActualJudgeTaskIdList.Count;
+        public int ActualGlobalCount => ActualGlobalTaskIdList.Count;
+        public int ActualTumorCount => ActualTumorTaskIdList.Count;
+
     }
 
     ///<summary>TaskTaskMedicalReviewRuleQuery  列表查询参数模型</summary>
diff --git a/IRaCIS.Core.Application/Service/Allocation/Interface/ITaskMedicalReviewRuleService.cs b/IRaCIS.Core.Application/Service/Allocation/Interface/ITaskMedicalReviewRuleService.cs
index 11a544392..e8063f134 100644
--- a/IRaCIS.Core.Application/Service/Allocation/Interface/ITaskMedicalReviewRuleService.cs
+++ b/IRaCIS.Core.Application/Service/Allocation/Interface/ITaskMedicalReviewRuleService.cs
@@ -14,7 +14,7 @@ namespace IRaCIS.Core.Application.Interfaces
     {
 
 
-        Task<List<TaskMedicalReviewRuleView>> GetTaskMedicalReviewRuleList(TaskMedicalReviewRuleQuery queryTaskTaskMedicalReviewRule);
+        //Task<List<TaskMedicalReviewRuleView>> GetTaskMedicalReviewRuleList(TaskMedicalReviewRuleQuery queryTaskTaskMedicalReviewRule);
 
         Task<IResponseOutput> AddOrUpdateTaskMedicalReviewRule(TaskMedicalReviewRuleAddOrEdit addOrEditTaskTaskMedicalReviewRule);
 
diff --git a/IRaCIS.Core.Application/Service/Allocation/TaskMedicalReviewService.cs b/IRaCIS.Core.Application/Service/Allocation/TaskMedicalReviewService.cs
index 7568aec40..26720db3d 100644
--- a/IRaCIS.Core.Application/Service/Allocation/TaskMedicalReviewService.cs
+++ b/IRaCIS.Core.Application/Service/Allocation/TaskMedicalReviewService.cs
@@ -20,9 +20,19 @@ namespace IRaCIS.Core.Application.Service
 
         private readonly IRepository<TaskMedicalReview> _taskMedicalReviewRepository;
 
-        public TaskMedicalReviewService(IRepository<TaskMedicalReview> taskMedicalReviewRepository)
+        private readonly IRepository<TrialUser> _trialUserRepository;
+
+        private readonly IRepository<TaskMedicalReviewRule> _taskMedicalReviewRuleRepository;
+
+        public TaskMedicalReviewService(IRepository<TaskMedicalReview> taskMedicalReviewRepository,IRepository<TrialUser> trialUserRepository, IRepository<TaskMedicalReviewRule> taskMedicalReviewRuleRepository)
         {
             _taskMedicalReviewRepository = taskMedicalReviewRepository;
+
+            _trialUserRepository = trialUserRepository;
+
+            _taskMedicalReviewRuleRepository = taskMedicalReviewRuleRepository;
+
+
         }
 
         /// <summary>
@@ -52,8 +62,6 @@ namespace IRaCIS.Core.Application.Service
 
 
 
-
-
         /// <summary>
         /// MIM  医学审核
         /// </summary>
@@ -108,5 +116,16 @@ namespace IRaCIS.Core.Application.Service
         }
 
 
+        /// <summary>
+        /// 获取医学经理列表
+        /// </summary>
+        /// <returns></returns>
+        public async  Task<List<UserSimpleInfo>> GetMIMUserList()
+        {
+            var query =  _trialUserRepository.Where(t => t.User.UserTypeEnum == Domain.Share.UserTypeEnum.MIM).Select(t => t.User).ProjectTo<UserSimpleInfo>(_mapper.ConfigurationProvider);
+
+            return  await query.ToListAsync();
+        }
+
     }
 }
diff --git a/IRaCIS.Core.Application/Service/Allocation/TaskTaskMedicalReviewRuleService.cs b/IRaCIS.Core.Application/Service/Allocation/TaskTaskMedicalReviewRuleService.cs
index 797c50d55..3c013881a 100644
--- a/IRaCIS.Core.Application/Service/Allocation/TaskTaskMedicalReviewRuleService.cs
+++ b/IRaCIS.Core.Application/Service/Allocation/TaskTaskMedicalReviewRuleService.cs
@@ -17,23 +17,25 @@ namespace IRaCIS.Core.Application.Service
     public class TaskMedicalReviewRuleService : BaseService, ITaskMedicalReviewRuleService
     {
 
-        private readonly IRepository<TaskMedicalReviewRule> _taskTaskMedicalReviewRuleRepository;
+        private readonly IRepository<TaskMedicalReviewRule> _taskMedicalReviewRuleRepository;
 
-        public TaskMedicalReviewRuleService(IRepository<TaskMedicalReviewRule> taskTaskMedicalReviewRuleRepository)
+        public TaskMedicalReviewRuleService(IRepository<TaskMedicalReviewRule> taskMedicalReviewRuleRepository)
         {
-            _taskTaskMedicalReviewRuleRepository = taskTaskMedicalReviewRuleRepository;
+            _taskMedicalReviewRuleRepository = taskMedicalReviewRuleRepository;
         }
 
 
         [HttpPost]
-        public async Task<List<TaskMedicalReviewRuleView>> GetTaskMedicalReviewRuleList(TaskMedicalReviewRuleQuery inQuery)
+        public async Task<(List<TaskMedicalReviewRuleView>,object)> GetTaskMedicalReviewRuleList(TaskMedicalReviewRuleQuery inQuery)
         {
 
 
-            var taskTaskMedicalReviewRuleQueryable = _taskTaskMedicalReviewRuleRepository.Where(t => t.TrialId == inQuery.TrialId)
+            var taskTaskMedicalReviewRuleQueryable = _taskMedicalReviewRuleRepository.Where(t => t.TrialId == inQuery.TrialId)
             .ProjectTo<TaskMedicalReviewRuleView>(_mapper.ConfigurationProvider);
 
-            return await taskTaskMedicalReviewRuleQueryable.ToListAsync();
+            var isHaveMIM = await _repository.AnyAsync<TrialUser>(t => t.User.UserTypeEnum == Domain.Share.UserTypeEnum.MIM);
+
+            return (await taskTaskMedicalReviewRuleQueryable.ToListAsync(),new {IsHaveMIM=isHaveMIM});
         }
 
         [HttpPost]
@@ -45,7 +47,7 @@ namespace IRaCIS.Core.Application.Service
                 VerifyMsg = "已有该医生配置,不允许继续增加"
             };
 
-            var entity = await _taskTaskMedicalReviewRuleRepository.InsertOrUpdateAsync(addOrEditTaskTaskMedicalReviewRule, true, verifyExp1);
+            var entity = await _taskMedicalReviewRuleRepository.InsertOrUpdateAsync(addOrEditTaskTaskMedicalReviewRule, true, verifyExp1);
 
             return ResponseOutput.Ok(entity.Id.ToString());
 
@@ -55,7 +57,7 @@ namespace IRaCIS.Core.Application.Service
         [HttpDelete("{taskMedicalReviewRuleId:guid}")]
         public async Task<IResponseOutput> DeleteTaskMedicalReviewRule(Guid taskMedicalReviewRuleId)
         {
-            var success = await _taskTaskMedicalReviewRuleRepository.DeleteFromQueryAsync(t => t.Id == taskMedicalReviewRuleId);
+            var success = await _taskMedicalReviewRuleRepository.DeleteFromQueryAsync(t => t.Id == taskMedicalReviewRuleId);
 
             return ResponseOutput.Ok();
         }
diff --git a/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs b/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs
index a6d1d8120..63dd4738b 100644
--- a/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs
+++ b/IRaCIS.Core.Application/Service/Allocation/_MapConfig.cs
@@ -18,7 +18,7 @@ namespace IRaCIS.Core.Application.Service
                  .ForMember(o => o.FullName, t => t.MapFrom(u => u.DoctorUser.FullName))
                  .ForMember(o => o.UserTypeShortName, t => t.MapFrom(u => u.DoctorUser.UserTypeRole.UserTypeShortName));
 
-            List<Guid> subjectIdList=new List<Guid> ();
+            List<Guid> subjectIdList = new List<Guid>();
             bool isJudgeDoctor = false;
 
 
@@ -34,8 +34,8 @@ namespace IRaCIS.Core.Application.Service
                  .ForMember(o => o.SelfApplyedTaskCount, t => t.MapFrom(u => u.Trial.VisitTaskList.Count(t => t.DoctorUserId == u.DoctorUserId)))
                  .ForMember(o => o.ApplyedTotalTaskCount, t => t.MapFrom(u => u.Trial.VisitTaskList.Count(t => t.DoctorUserId != null)))
 
-                 .ForMember(o => o.SelfApplyedSubjectCount, t => t.MapFrom(u => u.Trial.SubjectDoctorUserList.Where(t => t.DoctorUserId == u.DoctorUserId  && t.SubjectArmVisitTaskList.Any(c => c.DoctorUserId != null)).Count()))
-                 .ForMember(o => o.SelfSubjectCount, t => t.MapFrom(u => u.Trial.SubjectDoctorUserList.Where(t => t.DoctorUserId == u.DoctorUserId ).Count()))
+                 .ForMember(o => o.SelfApplyedSubjectCount, t => t.MapFrom(u => u.Trial.SubjectDoctorUserList.Where(t => t.DoctorUserId == u.DoctorUserId && t.SubjectArmVisitTaskList.Any(c => c.DoctorUserId != null)).Count()))
+                 .ForMember(o => o.SelfSubjectCount, t => t.MapFrom(u => u.Trial.SubjectDoctorUserList.Where(t => t.DoctorUserId == u.DoctorUserId).Count()))
 
                  .ForMember(o => o.ApplyedTotalSubjectCount, t => t.MapFrom(u => u.Trial.SubjectList.Count(c => c.SubjectVisitTaskList.Any(d => d.DoctorUserId != null))))
 
@@ -43,7 +43,7 @@ namespace IRaCIS.Core.Application.Service
 
                  //该医生未应用Subject 数量
                  .ForMember(o => o.WaitApplySelfSubjectCount, t => t.MapFrom(u =>
-                  subjectIdList.Count == 0 ? u.Trial.SubjectDoctorUserList.Where(t => t.DoctorUserId == u.DoctorUserId && t.SubjectArmVisitTaskList.Where(t=> isJudgeDoctor? t.ArmEnum==Arm.JudgeArm:t.ArmEnum!= Arm.JudgeArm).Any(c => c.DoctorUserId == null)).Count()
+                  subjectIdList.Count == 0 ? u.Trial.SubjectDoctorUserList.Where(t => t.DoctorUserId == u.DoctorUserId && t.SubjectArmVisitTaskList.Where(t => isJudgeDoctor ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Any(c => c.DoctorUserId == null)).Count()
                   : u.Trial.SubjectDoctorUserList.Where(t => t.DoctorUserId == u.DoctorUserId && subjectIdList.Contains(t.SubjectId) && t.SubjectArmVisitTaskList.Where(t => isJudgeDoctor ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Any(c => c.DoctorUserId == null)).Count()
                   ))
 
@@ -53,19 +53,19 @@ namespace IRaCIS.Core.Application.Service
                   : u.Trial.SubjectList.Where(t => subjectIdList.Contains(t.Id) && t.SubjectVisitTaskList.Where(t => isJudgeDoctor ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Any(c => c.DoctorUserId == null)).Count()
                  ))
 
-                 .ForMember(o => o.WaitApplySelfTaskCount, t => t.MapFrom(u => 
-                 subjectIdList.Count==0? u.Trial.SubjectDoctorUserList.Where(d => d.DoctorUserId == u.DoctorUserId).SelectMany(t => t.SubjectArmVisitTaskList.Where(t => isJudgeDoctor ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Where(t => t.DoctorUserId == null)).Count()
+                 .ForMember(o => o.WaitApplySelfTaskCount, t => t.MapFrom(u =>
+                 subjectIdList.Count == 0 ? u.Trial.SubjectDoctorUserList.Where(d => d.DoctorUserId == u.DoctorUserId).SelectMany(t => t.SubjectArmVisitTaskList.Where(t => isJudgeDoctor ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Where(t => t.DoctorUserId == null)).Count()
                  : u.Trial.SubjectDoctorUserList.Where(d => d.DoctorUserId == u.DoctorUserId && subjectIdList.Contains(d.SubjectId)).SelectMany(t => t.SubjectArmVisitTaskList.Where(t => isJudgeDoctor ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Where(t => t.DoctorUserId == null)).Count()
                                                                 ))
 
                   .ForMember(o => o.WaitApplyTotalTaskCount, t => t.MapFrom(u =>
                          subjectIdList.Count == 0 ? u.Trial.VisitTaskList.Where(t => isJudgeDoctor ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Where(t => t.DoctorUserId == null).Count()
-                 : u.Trial.VisitTaskList.Where(t => isJudgeDoctor ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Where(t => t.DoctorUserId == null && subjectIdList.Contains(t.SubjectId)).Count()  ))
+                 : u.Trial.VisitTaskList.Where(t => isJudgeDoctor ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Where(t => t.DoctorUserId == null && subjectIdList.Contains(t.SubjectId)).Count()))
+
+
+
 
-                                                    
 
-               
-               
                  ;
 
 
@@ -73,7 +73,7 @@ namespace IRaCIS.Core.Application.Service
 
 
             CreateMap<SubjectVisit, VisitGenerataTaskDTO>();
-            
+
 
             CreateMap<VisitTask, VisitTaskView>()
                  .ForMember(o => o.SiteId, t => t.MapFrom(u => u.Subject.SiteId))
@@ -107,7 +107,7 @@ namespace IRaCIS.Core.Application.Service
                  .ForMember(o => o.FullName, t => t.MapFrom(u => u.DoctorUser.FullName))
                  .ForMember(o => o.UserTypeShortName, t => t.MapFrom(u => u.DoctorUser.UserTypeRole.UserTypeShortName));
 
-            CreateMap<VisitTaskReReading, ReReadingTaskView>().IncludeMembers(t=>t.NewReReadingTask)
+            CreateMap<VisitTaskReReading, ReReadingTaskView>().IncludeMembers(t => t.NewReReadingTask)
                  .ForMember(o => o.ReReadingOriginalTaskCode, t => t.MapFrom(u => u.OriginalReReadingTask.TaskCode))
                  .ForMember(o => o.Id, t => t.MapFrom(u => u.Id))
 
@@ -144,7 +144,7 @@ namespace IRaCIS.Core.Application.Service
                  .ForMember(o => o.TrialSiteCode, t => t.MapFrom(u => u.TrialSite.TrialSiteCode))
                  .ForMember(o => o.SubjectCode, t => t.MapFrom(u => u.Code))
                  .ForMember(o => o.IsJudge, t => t.MapFrom(u => isJudgeDoctor))
-                 .ForMember(o => o.IsAssignedDoctorUser, t => t.MapFrom(u => u.SubjectDoctorList.Where(t=>isJudgeDoctor? t.ArmEnum == Arm.JudgeArm: t.ArmEnum != Arm.JudgeArm).Any()))
+                 .ForMember(o => o.IsAssignedDoctorUser, t => t.MapFrom(u => u.SubjectDoctorList.Where(t => isJudgeDoctor ? t.ArmEnum == Arm.JudgeArm : t.ArmEnum != Arm.JudgeArm).Any()))
 
 
                  .ForMember(o => o.TotalDoctorUserList, t => t.MapFrom(u => u.SubjectDoctorList.Where(t => isJudgeDoctor ? true : t.ArmEnum != Arm.JudgeArm).OrderBy(t => t.ArmEnum)));
@@ -178,12 +178,25 @@ namespace IRaCIS.Core.Application.Service
 
 
 
-            CreateMap<TaskMedicalReviewRule, TaskMedicalReviewRuleView>();
+            CreateMap<TaskMedicalReviewRule, TaskMedicalReviewRuleView>()
+              .ForMember(o => o.DoctorUser, t => t.MapFrom(u => u.DoctorUser))
+              .ForMember(o => o.ActualVisitTaskIdList, t => t.MapFrom(u => u.DoctorVisitTaskList.Where(t => t.ReadingCategory == ReadingCategory.Visit && t.TaskState == TaskState.Effect && t.ReadingTaskState==ReadingTaskState.HaveSigned).OrderBy(t=>t.SignTime).Select(t=>t.Id)))
+              .ForMember(o => o.ActualJudgeTaskIdList, t => t.MapFrom(u => u.DoctorVisitTaskList.Where(t => t.ReadingCategory == ReadingCategory.Judge && t.TaskState == TaskState.Effect && 
+              t.ReadingTaskState == ReadingTaskState.HaveSigned).OrderBy(t => t.SignTime).Select(t => t.Id)))
+              .ForMember(o => o.ActualGlobalTaskIdList, t => t.MapFrom(u => u.DoctorVisitTaskList.Where(t => t.ReadingCategory == ReadingCategory.Global && t.TaskState == TaskState.Effect &&
+              t.ReadingTaskState == ReadingTaskState.HaveSigned).OrderBy(t => t.SignTime).Select(t => t.Id)))
+              .ForMember(o => o.ActualTumorTaskIdList, t => t.MapFrom(u => u.DoctorVisitTaskList.Where(t => t.ReadingCategory == ReadingCategory.Oncology && t.TaskState == TaskState.Effect && 
+              t.ReadingTaskState == ReadingTaskState.HaveSigned).OrderBy(t => t.SignTime).Select(t => t.Id)))
+
+              .ForMember(o => o.GeneratedGlobalTaskIdList, t => t.MapFrom(u => u.TaskMedicalReviewList.Where(t => t.VisitTask.ReadingCategory == ReadingCategory.Global && t.VisitTask.TaskState == TaskState.Effect && t.VisitTask.ReadingTaskState == ReadingTaskState.HaveSigned).OrderBy(t => t.VisitTask.SignTime).Select(t=>t.VisitTaskId)))
+              .ForMember(o => o.GeneratedJudgeTaskIdList, t => t.MapFrom(u => u.TaskMedicalReviewList.Where(t => t.VisitTask.ReadingCategory == ReadingCategory.Judge && t.VisitTask.TaskState == TaskState.Effect && t.VisitTask.ReadingTaskState == ReadingTaskState.HaveSigned).OrderBy(t => t.VisitTask.SignTime).Select(t => t.VisitTaskId)))
+              .ForMember(o => o.GeneratedTumorTaskIdList, t => t.MapFrom(u => u.TaskMedicalReviewList.Where(t => t.VisitTask.ReadingCategory == ReadingCategory.Oncology && t.VisitTask.TaskState == TaskState.Effect && t.VisitTask.ReadingTaskState == ReadingTaskState.HaveSigned).OrderBy(t => t.VisitTask.SignTime).Select(t => t.VisitTaskId)))
+              .ForMember(o => o.GeneratedVisitTaskIdList, t => t.MapFrom(u => u.TaskMedicalReviewList.Where(t => t.VisitTask.ReadingCategory == ReadingCategory.Visit && t.VisitTask.TaskState == TaskState.Effect && t.VisitTask.ReadingTaskState == ReadingTaskState.HaveSigned).OrderBy(t => t.VisitTask.SignTime).Select(t => t.VisitTaskId)));
 
             CreateMap<TaskMedicalReviewRuleAddOrEdit, TaskMedicalReviewRule>();
 
 
-            
+
 
         }
     }
diff --git a/IRaCIS.Core.Domain/Allocation/TaskMedicalReview.cs b/IRaCIS.Core.Domain/Allocation/TaskMedicalReview.cs
index bfa6b6145..8e9088350 100644
--- a/IRaCIS.Core.Domain/Allocation/TaskMedicalReview.cs
+++ b/IRaCIS.Core.Domain/Allocation/TaskMedicalReview.cs
@@ -80,7 +80,15 @@ namespace IRaCIS.Core.Domain.Models
         [ForeignKey("VisitTaskId")]
 		public VisitTask  VisitTask { get; set; }
 
+		public Guid TrialId { get; set; }
 
-	 }
+		public Guid DoctorUserId { get; set; }
+
+
+		public TaskMedicalReviewRule TaskMedicalReviewRule { get; set; }
+
+
+
+	}
 
 }	 
diff --git a/IRaCIS.Core.Domain/Allocation/TaskMedicalReviewRule.cs b/IRaCIS.Core.Domain/Allocation/TaskMedicalReviewRule.cs
index 057a5e3ee..5dd76f410 100644
--- a/IRaCIS.Core.Domain/Allocation/TaskMedicalReviewRule.cs
+++ b/IRaCIS.Core.Domain/Allocation/TaskMedicalReviewRule.cs
@@ -7,6 +7,8 @@ using System;
 using IRaCIS.Core.Domain.Share;
 using System.ComponentModel.DataAnnotations;
 using System.ComponentModel.DataAnnotations.Schema;
+using System.Collections.Generic;
+
 namespace IRaCIS.Core.Domain.Models
 {
 	 ///<summary>
@@ -83,13 +85,21 @@ namespace IRaCIS.Core.Domain.Models
         /// </summary>
 		[Required]
 		public int PlanGlobalCount { get; set; }
-	
+
 		/// <summary>
-        /// PlanTumorCount
-        /// </summary>
+		/// PlanTumorCount
+		/// </summaryDoctorVisitTaskList
 		[Required]
 		public int PlanTumorCount { get; set; }
-	 
-	 }
+
+
+		public User DoctorUser { get; set; }
+
+
+		public List<VisitTask> DoctorVisitTaskList { get; set; }
+
+		public List<TaskMedicalReview> TaskMedicalReviewList { get; set; }
+
+	}
 
 }	 
diff --git a/IRaCIS.Core.Domain/Allocation/VisitTask.cs b/IRaCIS.Core.Domain/Allocation/VisitTask.cs
index 689ef8e85..f445a0f30 100644
--- a/IRaCIS.Core.Domain/Allocation/VisitTask.cs
+++ b/IRaCIS.Core.Domain/Allocation/VisitTask.cs
@@ -146,6 +146,8 @@ namespace IRaCIS.Core.Domain.Models
 
         public TaskAllocationRule DoctorTaskAllocationRule { get; set; }
 
+        public TaskMedicalReviewRule DoctorTaskMedicalReviewRule { get; set; }
+
 
 
 
diff --git a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs
index 0e89c3aa6..61efb57fe 100644
--- a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs
+++ b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs
@@ -90,6 +90,10 @@ namespace IRaCIS.Core.Infra.EFCore
 
             modelBuilder.Entity<TaskAllocationRule>().HasMany(t => t.DoctorVisitTaskList).WithOne(t => t.DoctorTaskAllocationRule).HasForeignKey(t=> new { t.DoctorUserId,t.TrialId } ).HasPrincipalKey(u=> new { u.DoctorUserId,u.TrialId });
 
+            modelBuilder.Entity<TaskMedicalReviewRule>().HasMany(t => t.DoctorVisitTaskList).WithOne(t => t.DoctorTaskMedicalReviewRule).HasForeignKey(t => new { t.DoctorUserId, t.TrialId }).HasPrincipalKey(u => new { u.DoctorUserId, u.TrialId });
+
+            modelBuilder.Entity<TaskMedicalReviewRule>().HasMany(t => t.TaskMedicalReviewList).WithOne(t => t.TaskMedicalReviewRule).HasForeignKey(t => new { t.DoctorUserId, t.TrialId }).HasPrincipalKey(u => new { u.DoctorUserId, u.TrialId });
+
             modelBuilder.Entity<SubjectUser>().HasMany(t => t.SubjectArmVisitTaskList).WithOne(t=>t.SujectArm).HasForeignKey(t => new { t.SubjectId,t.ArmEnum}).HasPrincipalKey(u => new { u.SubjectId,u.ArmEnum });
             modelBuilder.Entity<VisitTask>().HasMany(t => t.JudgeVisitList).WithOne(t=>t.JudgeVisitTask);
             modelBuilder.Entity<Dictionary>().HasMany(t => t.ChildList).WithOne(t => t.Parent);