using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using IRaCIS.Core.Domain.Share;
using Newtonsoft.Json;

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

        [JsonIgnore]
        public List<SubjectVisit> SubjectVisitList { get; set; } = new List<SubjectVisit>();
        [JsonIgnore]
        public List<VisitTask> SubjectVisitTaskList { get; set; } = new List<VisitTask>();
        [JsonIgnore]
        public List<ReadModule> ReadModuleList { get; set; }

        [JsonIgnore]
        public List<ReadingClinicalData> ClinicalDataList { get; set; }



        [JsonIgnore]

        public List<SubjectAdditionalEvaluationResult> SubjectAdditionalEvaluationResult { get; set; }


        [JsonIgnore]
        public List<ReadingTaskQuestionAnswer> ReadingTaskQuestionAnswerList { get; set; }

        [JsonIgnore]
        [ForeignKey("FinalSubjectVisitId")]
        public SubjectVisit FinalSubjectVisit { get; set; }
        public Guid? FinalSubjectVisitId { get; set; }


        //需要配置是两个键连接
        [JsonIgnore]
        public TrialSite TrialSite { get; set; }

        [JsonIgnore]
        [ForeignKey("TrialId")]
        public Trial Trial { get; set; }

        [JsonIgnore]
        [ForeignKey("SiteId")]
        public Site Site { get; set; }
        [JsonIgnore]
        public List<DicomStudy> StudyList { get; set; } = new List<DicomStudy>();

        public string Code { get; set; }
        public string FirstName { get; set; } = string.Empty;
        public string LastName { get; set; } = string.Empty;
        public int? Age { get; set; }
        public string Sex { get; set; } = string.Empty;
        public Guid SiteId { get; set; } = Guid.Empty;

        [JsonIgnore]
        [ForeignKey("LatestSubjectVisitId")]
        public SubjectVisit LatestSubjectVisit { get; set; }
        public Guid? LatestSubjectVisitId { get; set; }

        //public bool IsMissingImages { get; set; } = false;


        public Guid TrialId { get; set; } = Guid.Empty;
        public string MedicalNo { get; set; } = string.Empty;

        public SubjectStatus Status { get; set; } = SubjectStatus.OnVisit;//1 访视中，2 出组  3 访视结束
        public string Reason { get; set; } = string.Empty;
        public bool IsEnrollment { get; set; }


        public DateTime? OutEnrollmentTime { get; set; }

        public DateTime? VisitOverTime { get; set; }



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


        public string ShortName { get; set; } = String.Empty;

        public string Height { get; set; } = String.Empty;

        public string Weight { get; set; } = String.Empty;

        public DateTime? BirthDate { get; set; }
        public DateTime? SignDate { get; set; }

        public int StudyCount { get; set; } = 0;
        public string Modalities { get; set; } = string.Empty;

        public DateTime? FirstGiveMedicineTime { get; set; }

        public bool IsUrgent { get; set; }


        public bool IsDeleted { get; set; }
        public DateTime? DeletedTime { get; set; }

        public Guid? DeleteUserId { get; set; }

        public bool IsReReadingOrBackInfluenceAnalysis { get; set; }
        [JsonIgnore]
        public List<ClinicalForm> ClinicalFormList { get; set; }


        //是否分配了读片医生
        //public bool IsAssignDoctorUser{get;set;}
    }
}
