using IRaCIS.Core.Application.Contracts;
using IRaCIS.Core.Domain.Share;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ImageInfo = IRaCIS.Core.Domain.Models.ImageInfo;

namespace IRaCIS.Core.Application.Service.Reading.Dto
{

    public class IRConfirmMedicalReviewInDto
    {
        public Guid TaskMedicalReviewId { get; set; }

        /// <summary>
        /// 阅片人是否认同
        /// </summary>
        public MedicalReviewDoctorUserIdea DoctorUserIdeaEnum { get; set; }


        /// <summary>
		/// 不同意重阅原因
		/// </summary>
		public string DisagreeReason { get; set; } = string.Empty;


        /// <summary>
        /// 是否申请重阅
        /// </summary>
        public bool IsApplyHeavyReading { get; set; } = false;
    }

    public class GetIRMedicalFeedbackListInDto:PageInput
    {
        /// <summary>
        /// 项目Id
        /// </summary>
        [NotDefault]
        public Guid TrialId { get; set; }


        public bool? IsUrgent { get; set; }

        public MedicalReviewAuditState? AuditState { get; set; }

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

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

        public ReadingCategory? ReadingCategory { get; set; }

        /// <summary>
        /// 审核建议
        /// </summary>
        public AuditAdvice? AuditAdviceEnum { get; set; }
        /// <summary>
        /// 阅片人是否认同
        /// </summary>
        public MedicalReviewDoctorUserIdea? DoctorUserIdeaEnum { get; set; }
        /// <summary>
        /// 是否关闭对话
        /// </summary>
        public bool? IsClosedDialog { get; set; }
        /// <summary>
        /// 是否有问题
        /// </summary>
        public bool? IsHaveQuestion { get; set; }
        /// <summary>
        /// 医学审核对话关闭原因
        /// </summary>
        public MedicalDialogClose? MedicalDialogCloseEnum { get; set; }

        /// <summary>
        /// 无效的 为True无效
        /// </summary>
        public bool? IsInvalid { get; set; }

        public Guid? TrialReadingCriterionId { get; set; }
    }

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

        public bool IsUrgent { get; set; }

        /// <summary>
        /// 医学审核对话关闭原因
        /// </summary>
        public MedicalDialogClose MedicalDialogCloseEnum { get; set; }

        /// <summary>
        /// 审核 质询状态
        /// </summary>
        public MedicalReviewAuditState AuditState { get; set; }

        public string SubjectCode { get; set; }

        public string TaskBlindName { get; set; }

        /// <summary>
        /// 阅片类别
        /// </summary>
        public ReadingCategory ReadingCategory { get; set; }

        public DateTime? FirstReplyTime { get; set; }

        public DateTime? LastReplyTime { get; set; }

        /// <summary>
        /// 审核建议
        /// </summary>
        public AuditAdvice AuditAdviceEnum { get; set; }

        /// <summary>
        /// 阅片人是否认同
        /// </summary>
		public MedicalReviewDoctorUserIdea DoctorUserIdeaEnum { get; set; }


        /// <summary>
		/// 保存结论时间
		/// </summary>
		public DateTime? SaveConclusionTime { get; set; }

        /// <summary>
        /// 是否关闭对话
        /// </summary>
        public bool IsClosedDialog { get; set; }

        /// <summary>
        /// 是否有问题
        /// </summary>
        public bool IsHaveQuestion { get; set; } = false;


        public Guid VisitTaskId { get; set; }

        /// <summary>
        /// 无效的 为True无效
        /// </summary>
        public bool IsInvalid { get; set; }


        public TaskState TaskState { get; set; }


        public Guid SubjectId { get; set; }
        public Guid TrialReadingCriterionId { get; set; }
        public string TrialReadingCriterionName { get; set; }

        /// <summary>
        /// 阅片工具
        /// </summary>
        public ReadingTool? ReadingTool { get; set; }

        /// <summary>
        /// 任务展示检查批次 读片任务显示是否顺序
        /// </summary>
        public bool IsReadingTaskViewInOrder { get; set; } = true;


        /// <summary>
        /// 阅片是否显示患者信息
        /// </summary>
        public bool IsReadingShowSubjectInfo { get; set; } = false;

        /// <summary>
        /// IR阅片页面是否可以查看既往任务结果
        /// </summary>
        public bool IsReadingShowPreviousResults { get; set; } = false;

        public int? DigitPlaces { get; set; } = 2;

        public bool IseCRFShowInDicomReading { get; set; } = false;

        public CriterionType CriterionType { get; set; }
    }

    public class FinishMedicalReviewInDto
    {
        public Guid TaskMedicalReviewId { get; set; }
    }


    public class GetMedicalReviewDialogOutDto
    {
        /// <summary>
        /// 对话内容
        /// </summary>
        public string Content { get; set; }

        /// <summary>
        /// 用户角色
        /// </summary>
        public string UserTypeShortName { get; set; }

        /// <summary>
        /// 医学审核对话关闭原因
        /// </summary>
        public MedicalDialogClose? MedicalDialogCloseEnum { get; set; }

        /// <summary>
        /// 用户角色枚举
        /// </summary>
        public int UserTypeEnumInt { get; set; }

        /// <summary>
        /// 创建人
        /// </summary>
        public Guid CreateUserId { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTime { get; set; }

        /// <summary>
        /// 阅片人是否认同
        /// </summary>
        public MedicalReviewDoctorUserIdea DoctorUserIdeaEnum { get; set; } = MedicalReviewDoctorUserIdea.defalut;

        /// <summary>
        /// 是否有问题
        /// </summary>
        public bool IsHaveQuestion { get; set; } = false;

        /// <summary>
        /// 质询问题
        /// </summary>
        public string Questioning { get; set; } = string.Empty;

        /// <summary>
        /// 审核建议
        /// </summary>
        public AuditAdvice AuditAdviceEnum { get; set; } = AuditAdvice.None;

        /// <summary>
        /// 不同意重阅原因
        /// </summary>
        public string DisagreeReason { get; set; } = string.Empty;

        /// <summary>
        /// 是否申请重阅
        /// </summary>
        public bool? IsApplyHeavyReading { get; set; }


        /// <summary>
        /// 是否是当前用户
        /// </summary>
        public bool IsCurrentUser { get; set; }


        public string CreateUserName { get; set; }

        /// <summary>
		/// 图片路径
		/// </summary>
		public string ImagePath { get; set; } = string.Empty;


        public List<Domain.Models.ImageInfo> FileList { get; set; } = new List<ImageInfo>();


    }

 

    public class GetMedicalReviewDialogInDto
    {
        [NotDefault]
        public Guid TaskMedicalReviewId { get; set; }
    }

    public class IRSendMedicalReviewDialogInDto
    {

        public Guid TrialId { get; set; }

 

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


        public Guid TaskMedicalReviewId { get; set; }

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

        /// <summary>
		/// 阅片人是否认同
		/// </summary>
		public MedicalReviewDoctorUserIdea DoctorUserIdeaEnum { get; set; } = MedicalReviewDoctorUserIdea.defalut;


        /// <summary>
        /// 不同意重阅原因
        /// </summary>
        public string DisagreeReason { get; set; } = string.Empty;

        public bool? IsCopyOrigenalForms { get; set; } = false;
        public bool? IsCopyFollowForms { get; set; } = false;

        /// <summary>
        /// 是否申请重阅
        /// </summary>
        public bool? IsApplyHeavyReading { get; set; }



        public List<ImageInfo> FileList { get; set; } = new List<ImageInfo>();

       


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

    }

    public class SendMedicalReviewDialogInDto
    {
        public Guid TaskMedicalReviewId { get; set; }

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

      
        /// <summary>
        /// 是否有问题
        /// </summary>
        public bool IsHaveQuestion { get; set; } = false;

        /// <summary>
        /// 质询问题
        /// </summary>
        public string Questioning { get; set; } = string.Empty;

        /// <summary>
        /// 审核建议
        /// </summary>
        public AuditAdvice AuditAdviceEnum { get; set; } = AuditAdvice.None;

    }

    public class SaveMedicineQuestionInDto
    {
        public Guid TaskMedicalReviewId { get; set; }
        public Guid VisitTaskId { get; set; }

     

        public List<MedicineQuestionAnswer> QuestionAnswerList { get; set; }
    }

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


        public string Answer { get; set; }
    }

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

        public Guid TrialReadingCriterionId { get; set; }

        public Guid TaskMedicalReviewId { get; set; }
    }


    public class GetMedicalReviewReadingTaskOutDto
    {
        //阅片类型 
        public ReadingMethod ReadingType { get; set; }

        public string SubjectCode { get; set; }


        public string TaskBlindName { get; set; }


        public string ReadingUser { get; set; }


        public bool IsReadingTaskViewInOrder { get; set; }

        public Guid VisitTaskId { get; set; }

        public Arm ArmEnum { get; set; }


        public MedicalReviewAuditState AuditState { get; set; }

        public bool IsSendMessage { get; set; }


        public GetOncologyReadingInfoOutDto OncologyInfo { get; set; }


        public GetGlobalReadingInfoOutDto GlobalInfo { get; set; }


        public GetJudgeReadingInfoOutDto JudgeInfo { get; set; }

        /// <summary>
        /// 是否关闭
        /// </summary>
        public bool IsClosedDialog { get; set; }

   

        public List<TaskInfo> TaskList { get; set; } = new List<TaskInfo>();

 
        public List<ReadingMedicineQuestion> QuestionAnswerList { get; set; } = new List<ReadingMedicineQuestion>();


        public MedicalReviewInfo MedicalReviewInfo { get; set; }

    }

    public class ClosedMedicalReviewDialogInDto
    {
        public Guid TaskMedicalReviewId { get; set; }

        /// <summary>
        /// 是否关闭
        /// </summary>
        public bool IsClosedDialog { get; set; }

        /// <summary>
        /// 医学审核对话关闭原因
        /// </summary>
        public MedicalDialogClose MedicalDialogCloseEnum { get; set; }

        /// <summary>
        /// 对话关闭原因
        /// </summary>
        public string DialogCloseReason { get; set; } = string.Empty;
    }



    public class SaveMedicalReviewInfoInDto
    {
        public bool IsSendDialog { get; set; }

        public Guid TaskMedicalReviewId { get; set; }


        public List<ImageInfo> FileList { get; set; } = new List<ImageInfo>();


        /// <summary>
        /// 是否有问题
        /// </summary>
        public bool IsHaveQuestion { get; set; } = false;

        /// <summary>
        /// 质询问题
        /// </summary>
        public string Questioning { get; set; } = string.Empty;

        ///// <summary>
        ///// 图片路径
        ///// </summary>
        //public string ImagePath { get; set; } = string.Empty;


        ///// <summary>
        ///// 文件名称
        ///// </summary>
        //public string FileName { get; set; } = string.Empty;

        /// <summary>
        /// 审核建议
        /// </summary>
        public AuditAdvice AuditAdviceEnum { get; set; }
    }

    public class MedicalReviewInfo 
    {
        public Guid TaskMedicalReviewId { get; set; }

        public Guid VisitTaskId { get; set; }

        /// <summary>
        /// 是否有问题
        /// </summary>
        public bool IsHaveQuestion { get; set; } = false;

        /// <summary>
        /// 质询问题
        /// </summary>
        public string Questioning { get; set; } = string.Empty;


        public List<ImageInfo> FileList { get; set; } = new List<ImageInfo>();

        /// <summary>
        /// 审核建议
        /// </summary>
        public AuditAdvice AuditAdviceEnum { get; set; }

        public MedicalReviewAuditState AuditState { get; set; }

        /// <summary>
        /// 是否关闭
        /// </summary>
        public bool IsClosedDialog { get; set; }


        public bool IsSendMessage { get; set; }
    }

    public class ReadingMedicineQuestion 
    {
        /// <summary>
        /// 答案
        /// </summary>
        public string Answer { get; set; }

        public Guid Id { get; set; }

        /// <summary>
        /// 类型
        /// </summary>	
		public string Type { get; set; }

        /// <summary>
        /// 父问题触发值
        /// </summary>
        public string ParentTriggerValue { get; set; } = string.Empty;

        /// <summary>
        /// 问题名称
        /// </summary>
        public string QuestionName { get; set; }

        /// <summary>
        /// 类型值
        /// </summary>
        public string TypeValue { get; set; }

        /// <summary>
        /// 是否启用
        /// </summary>
        public bool IsEnable { get; set; }

        /// <summary>
        /// 是否必须
        /// </summary>
        public bool IsRequired { get; set; }

        /// <summary>
        /// 排序
        /// </summary>
        public int ShowOrder { get; set; }

        /// <summary>
        /// 父问题
        /// </summary>
        public Guid? ParentId { get; set; }

        /// <summary>
        /// 是否确认
        /// </summary>
        public bool? IsConfirm { get; set; }


        public List<ReadingMedicineQuestion> Childrens { get; set; }
    }

    public class TaskInfo
    {
        public Guid? TaskId { get; set; }


        public decimal VisitTaskNum { get; set; }
        /// <summary>
        /// 是否是当前任务
        /// </summary>
        public bool IsCurrentTask { get; set; } = false;

        /// <summary>
        /// 任务名称
        /// </summary>

        public string TaskName { get; set; }

        /// <summary>
        /// 是否有全局更新
        /// </summary>
        public bool IsGlobalChange { get; set; } = false;

        /// <summary>
        /// 盲态名称
        /// </summary>
        public string TaskBlindName { get; set; }

        public Arm ArmEnum { get; set; }


      

        /// <summary>
        /// 评估结果
        /// </summary>
        public string EvaluationResult { get; set; }

        public ReadingCategory ReadingCategory { get; set; }


        public Guid? SourceSubjectVisitId { get; set; }
        public Guid? SouceReadModuleId { get; set; }

        public Guid? OtherTaskId { get; set; }

        public Guid? GlobalTaskId { get; set; }
        public string? GlobalTaskName { get; set; }

        public Guid? JudgeTaskId { get; set; }

        public string? JudgeTaskName { get; set; }

        public Arm OtherArmEnum { get; set; }

        //public Guid? JudgeVisitTaskId { get; set; }

        //public Guid? JudgeResultTaskId { get; set; }


        public Arm? JudgeResultArm { get; set; }

        public Guid SubjectId { get; set; }

        /// <summary>
        /// 肿瘤学结果
        /// </summary>
        public string OncologyEvaluationResult { get; set; } = string.Empty;

        /// <summary>
        /// 肿瘤学原因
        /// </summary>
        public string OncologyEvaluationReason { get; set; } = string.Empty;

        public List<JudgeQuestionAnswerInfo> JudgeQuestionAnswerInfoList { get; set; }

    }

    public class JudgeQuestionAnswerInfo
    {

        public Guid VisitTaskId { get; set; }

        public string QuestionName { get; set; }

        public string Answer { get; set; }

        /// <summary>
        /// 排序
        /// </summary>
        public int ShowOrder { get; set; }

        /// <summary>
        /// 字典code
        /// </summary>
        public string DictionaryCode { get; set; } = string.Empty;

        /// <summary>
        /// 问题类型
        /// </summary>
        public TableQuestionType? QuestionGenre { get; set; }

    }

}
