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

namespace IRaCIS.Core.Domain.Models
{
    ///<summary>
    ///TaskMedicalReview
    ///</summary>
    [Table("TaskMedicalReview")]
    public class TaskMedicalReview : Entity, IAuditUpdate, IAuditAdd
    {


        /// <summary>
        /// CreateUserId
        /// </summary>
        [Required]
        public Guid CreateUserId { get; set; }

        /// <summary>
        /// CreateTime
        /// </summary>
        [Required]
        public DateTime CreateTime { get; set; }

        /// <summary>
        /// UpdateTime
        /// </summary>
        [Required]
        public DateTime UpdateTime { get; set; }

        /// <summary>
        /// UpdateUserId
        /// </summary>
        [Required]
        public Guid UpdateUserId { get; set; }

        /// <summary>
        /// 分配时间
        /// </summary>
        public DateTime? AllocateTime { get; set; }

        /// <summary>
        /// 审核状态
        /// </summary>
        [Required]
        public MedicalReviewAuditState AuditState { get; set; }



        /// <summary>
        /// 审核通过时间
        /// </summary>
        public DateTime? AuditSignTime { get; set; }

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

        /// <summary>
        /// MedicalManagerUserId
        /// </summary>
        public Guid? MedicalManagerUserId { get; set; }

        public User MedicalManagerUser { get; set; }

        public Guid VisitTaskId { get; set; }

        [ForeignKey("VisitTaskId")]
        public VisitTask VisitTask { get; set; }

        public Guid TrialId { get; set; }

        /// <summary>
        /// 冗余  废弃
        /// </summary>
        public Guid DoctorUserId { get; set; }

        [JsonIgnore]
        public TaskMedicalReviewRule TaskMedicalReviewRule { get; set; }


        /// <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 AuditAdvice AuditAdviceEnum { get; set; }

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

        /// <summary>
        /// 保存问题的时间
        /// </summary>
        public DateTime? SaveQuestionTime { get; set; }


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


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


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


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

        [JsonIgnore]
        public List<ReadingMedicalReviewDialog> ReadingMedicalReviewDialogList { get; set; }


        /// <summary>
        /// 是否发送消息
        /// </summary>
        public bool IsSendMessage { get; set; } = false;


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

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


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

        /// <summary>
        /// 文件
        /// </summary>
        [NotMapped]
        public List<ImageInfo> FileList
        {
            get
            {


                try
                {
                   var result= JsonConvert.DeserializeObject<List<ImageInfo>>(this.ImagePath);
                   return result==null?new List<ImageInfo>() : result;
                }
                catch (Exception)
                {

                    return new List<ImageInfo>();
                }

            }
        }


        public bool IsAutoGenerate { get; set; }

        //  | 分割
        public string PDRelationTaskIdListStr { get; set; }=string.Empty;

        [NotMapped]
        public List<Guid> PDRelationTaskIdList=> PDRelationTaskIdListStr.Split('|',StringSplitOptions.RemoveEmptyEntries).Select(t=> Guid.Parse(t) ).ToList();
    }

    #region 文件对象

    public class ImageInfo
    {
        public string FileName { get; set; }

        public string ImagePath { get; set; }
    }

    #endregion

}
