//--------------------------------------------------------------------
//     此代码由T4模板自动生成  byzhouhang 20210918
//	   生成时间 2022-06-07 13:16:33 
//     对此文件的更改可能会导致不正确的行为，并且如果重新生成代码，这些更改将会丢失。
//--------------------------------------------------------------------
using System;
using IRaCIS.Core.Domain.Share;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using IRaCIS.Application.Contracts;
using Newtonsoft.Json;

namespace IRaCIS.Core.Application.ViewModel
{
    /// <summary> TaskAllocationRuleView  列表视图模型 </summary>
    public class TaskAllocationRuleView : TaskAllocationRuleAddOrEdit
    {
        public string UserCode { get; set; }
        public string UserName { get; set; }
        public string FullName { get; set; }

        public string UserTypeShortName { get; set; }

        public Guid CreateUserId { get; set; }
        public DateTime CreateTime { get; set; }
        public DateTime UpdateTime { get; set; }
        public Guid UpdateUserId { get; set; }

    }



    public class DoctorVisitTaskStatView : TaskAllocationRuleView
    {
        //该医生已经应用的 Subject数量
        public int? SelfApplyedSubjectCount { get; set; }

        //该医生已经分配Subject数量
        public int? SelfSubjectCount { get; set; }


        //该医生未应用Subject 数量    不是两者相减  跟批量勾选有关系
        public int? WaitApplySelfSubjectCount { get; set; }



        //该医生未应用的任务数
        public int? WaitApplySelfTaskCount { get; set; }

        //该医生已应用的任务数
        public int? SelfApplyedTaskCount { get; set; }



        //总共未应用的Subejct 数量
        public int? WaitApplyTotalSubjectCount { get; set; }

        public int? WaitApplyTotalTaskCount { get; set; }



        //已分配该医生但是未读片签名的数量
        public int? SelfUndoTaskCount { get; set; }



        //总共已应用 的Subject 数
        public int? ApplyedTotalSubjectCount { get; set; }


        //总共 已经应用的任务总数
        public int? ApplyedTotalTaskCount { get; set; }


        //系统  Subject数
        public int? TotalSubjectCount { get; set; }

        //总任务数
        public int? TotalTaskCount { get; set; }
    }






    ///<summary>TaskAllocationRuleQuery  列表查询参数模型</summary>
    public class TaskAllocationRuleQuery
    {
        [NotDefault]
        public Guid TrialId { get; set; }

        public bool IsJudgeDoctor { get; set; }
    }

    public class TaskAllocationRuleDTO : TaskAllocationRuleAddOrEdit
    {
        public Guid CreateUserId { get; set; }
        public DateTime CreateTime { get; set; }
        public DateTime UpdateTime { get; set; }
        public Guid UpdateUserId { get; set; }

        public UserSimpleInfo DoctorUser { get; set; }

        public List<ReadingCategory> ReadingCategoryList { get; set; }

        public List<TrialReadingCriterionDto> TrialReadingCriterionList { get; set; }

        [JsonIgnore]
        public List<TrialCriterionReadingCategory> CriterionReadingCategoryList { get; set; }

        public List<CriterionReadingCategory> CriterionCategoryList =>

            TrialReadingCriterionList.Select(t =>
            new CriterionReadingCategory() { 
                EnrollId = EnrollId, 
                TrialReadingCriterionId = t.TrialReadingCriterionId, 
                ReadingCategorys = CriterionReadingCategoryList.Where(c => c.TrialReadingCriterionId == t.TrialReadingCriterionId).Select(t => t.ReadingCategory).OrderBy(c => c).ToList()
            }).ToList();



            //CriterionReadingCategoryList.Count == 0 ? TrialReadingCriterionList.Select(t => new CriterionReadingCategory() { EnrollId = EnrollId, TrialReadingCriterionId = t.TrialReadingCriterionId }).ToList() :
            // CriterionReadingCategoryList
            //.GroupBy(t => new { t.TrialReadingCriterionId, t.EnrollId })
            //.Select(g => new CriterionReadingCategory() { EnrollId = g.Key.EnrollId, TrialReadingCriterionId = g.Key.TrialReadingCriterionId, ReadingCategorys = g.Select(t => t.ReadingCategory).OrderBy(t=>t).ToList() }).ToList();

    }


    public class DoctorSelectQuery
    {
        [NotDefault]
        public Guid TrialId { get; set; }

        public ReadingCategory? ReadingCategory { get; set; }

        public Guid? TrialReadingCriterionId { get; set; }
    }


    public class AssignDoctorStatView : TaskAllocationRuleDTO
    {
        public int? AssignedSubjectCount { get; set; }

        public int? WaitDealTrialTaskCount { get; set; }

        public int? WaitDealAllTaskCount { get; set; }
    }

    ///<summary> TaskAllocationRuleAddOrEdit  列表查询参数模型</summary>
    public class TaskAllocationRuleAddOrEdit
    {
        public Guid? Id { get; set; }
        public Guid TrialId { get; set; }

        public Guid EnrollId { get; set; }

        [NotDefault]
        public Guid DoctorUserId { get; set; }

        public int PlanSubjectCount { get; set; }

        public bool IsEnable { get; set; }

        public string Note { get; set; } = string.Empty;
    }

    public class CancelDoctorCommand
    {
        public Guid TrialId { get; set; }
        public Guid SubjectId { get; set; }

        public string Note { get; set; }

    }


    public class SubjectCancelDoctorView
    {
        public Guid SubjectId { get; set; }

        public string Note { get; set; }

        public DateTime CreateTime { get; set; }
    }

    public class TrialDoctorUserSelectView
    {
        public Guid TrialId { get; set; }

        //public ReadingMethod ReadingType { get; set; }

        public Guid? DoctorUserId { get; set; }

        public string UserCode { get; set; }

        public string UserName { get; set; }

        public string FullName { get; set; }

        public UserTypeEnum UserTypeEnum { get; set; }


        public List<ReadingCategory> ReadingCategoryList { get; set; }
    }

    public class GenerateTaskCommand
    {
        public Guid TrialId { get; set; }
     
        //针对检查批次产生任务的 有用
        public bool IsAssignSubjectToDoctor { get; set; }

        //检查批次任务产生的时候传递

        public List<VisitGenerataTaskDTO> VisitGenerataTaskList { get; set; } = new List<VisitGenerataTaskDTO>();



        public GenerateTaskCategory ReadingCategory { get; set; }

        /// <summary>
        /// 原任务的Id
        /// </summary>
        public Guid OriginalVisitId { get; set; }

        //裁判的时候传递
        public List<Guid> JudgeVisitTaskIdList { get; set; } = new List<Guid>();

        /// <summary>
        /// 阅片期
        /// </summary>
        public List<ReadingGenerataTaskDTO> ReadingGenerataTaskList = new List<ReadingGenerataTaskDTO>();


        //重阅 产生任务
        public VisitTask ReReadingTask { get; set; }

        public Action<VisitTask> Action;


        //自身一致性
        public List<VisitTaskSimpleDTO> GenerataConsistentTaskList { get; set; }

        //组间一致性

        public List<VisitTaskGroupSimpleDTO> GenerataGroupConsistentTaskList { get; set; }



    }

    //public class ReReadingApplyGenerateTaskCommand
    //{
    //    public RequestReReadingType RequestReReadingType { get; set; }

    //    public string RequestReReadingReason { get; set; }

    //    public List<VisitTask> ReReadingTaskList = new List<VisitTask>();
    //}


    public class ReadingGenerataTaskDTO
    {
        public Guid ReadModuleId { get; set; }

        public Guid SubjectId { get; set; }

        public decimal VisitNum { get; set; }

        public bool IsUrgent { get; set; }


        public string ReadingName { get; set; }

        public ReadingCategory ReadingCategory { get; set; }

    }

    public class VisitGenerataTaskDTO
    {
        public Guid Id { get; set; }

        public Guid SubjectId { get; set; }

        public bool IsUrgent { get; set; }

        public String VisitName { get; set; }

        public bool IsBaseLine { get; set; }

        public DateTime? CheckPassedTime { get; set; }

        public decimal VisitNum { get; set; }


    }


}


