using System.ComponentModel.DataAnnotations;
using IRaCIS.Core.Infrastructure.Extention;
using IRaCIS.Core.Domain.Share;
using Magicodes.ExporterAndImporter.Core;
using MiniExcelLibs.Attributes;
using Newtonsoft.Json;
using IRaCIS.Core.Application.Contracts;
using IRaCIS.Core.Application.Helper;

namespace IRaCIS.Application.Contracts
{




    public class UserTrialDTO : UserTrialCommand
    {
        [JsonIgnore]
        public string State => IsDeleted ? "退出" : "加入";


        [DictionaryTranslateAttribute("IsUserExitTrial")]
        public bool IsDeleted { get; set; }

        [ExcelFormat("yyyy-MM-dd hh:mm:ss")]
        public DateTime? DeletedTime { get; set; }

        public Guid? SiteId { get; set; }
        public string Phone { get; set; } = String.Empty;
        public DateTime UpdateTime { get; set; }

        [ExcelFormat("yyyy-MM-dd hh:mm:ss")]
        public DateTime CreateTime { get; set; }


        public string UserType { get; set; } = String.Empty;
        public string UserRealName { get; set; } = String.Empty;

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

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

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

    }

    public class TrialUserSelct: UserTrialCommand
    {
        public string Phone { get; set; } = String.Empty;

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

        public string RealName { get; set; } = String.Empty;
        public string UserName { get; set; } = String.Empty;
    }

    public class TrialMaintenanceDTO : UserTrialCommand
    {
        //[JsonIgnore]
        //public int No { get; set; }
        //For MiniExcel  ExcelFormat
        public string State => IsDeleted ? "退出" : "加入";


        [ValueMapping(text: "退出", true)]
        [ValueMapping(text: "加入", false)]

        [DictionaryTranslateAttribute("IsUserExitTrial")]
        public bool IsDeleted { get; set; }

        [ExporterHeader(Format = "yyyy-mm-DD hh:mm:ss")]
        [ExcelFormat("yyyy-MM-dd hh:mm:ss")]
        public DateTime? DeletedTime { get; set; }


        [ExporterHeader(Format = "yyyy-mm-DD")]
        [ExcelFormat("yyyy-MM-dd")]
        public DateTime? RemoveTime { get; set; }


        [ExporterHeader(Format = "yyyy-mm-DD")]
        [ExcelFormat("yyyy-MM-dd")]
        public DateTime? JoinTime { get; set; }


        [ExporterHeader(Format = "yyyy-mm-DD hh:mm:ss")]
        [ExcelFormat("yyyy-MM-dd hh:mm:ss")]
        public DateTime CreateTime { get; set; }


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

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


        public DateTime UpdateTime { get; set; } = DateTime.Now;

        public Guid UserTypeId { get; set; }
        public string UserType { get; set; } = String.Empty;

        public UserTypeEnum UserTypeEnum { get; set; }

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

        public string UserRealName { get; set; } = String.Empty;
        public string UserName { get; set; } = String.Empty;


    }


    public class TrialCRCUploadImageList_Export: ExcelExportInfo
    {



    }

    public class ExcelExportInfo : TrialSelectDTO
    {
        public DateTime CurrentTime { get; set; } = DateTime.Now;

        public bool IsEn_US { get; set; }

        public object List { get; set; }

    }

    public class TrialUserExportDTO : ExcelExportInfo
    {

        public List<TrialMaintenanceDTO> TrialUserList { get; set; } = new List<TrialMaintenanceDTO>();
    }


    public class TrialSiteUserExportDto : ExcelExportInfo
    {

        public List<SiteUserExportDTO> TrialSiteUserList { get; set; } = new List<SiteUserExportDTO>();
    }
    public class SiteUserExportDTO : UserTrialDTO
    {

        public string TrialSiteCode { get; set; } = String.Empty;
        public string TrialSiteAliasName { get; set; } = String.Empty;
    }

    public class TrialSiteUserSummaryExportDto : ExcelExportInfo
    {

        public List<TrialSiteUserSummaryDto> TrialSiteUserList { get; set; } = new List<TrialSiteUserSummaryDto>();
        
    }

    public class TrialSiteUserSummaryDto: TrialSiteUserSurveyView
    {


        public string TrialSiteCode { get; set; } = String.Empty;
        public string TrialSiteAliasName { get; set; } = String.Empty;

        public string UserRealName => LastName + " / " + FirstName;


        //public string IsGenerateAccountStr => IsGenerateAccount ? "是" : "否";

        
        //public string StateStr => State.GetDescription();

    }



    public class SiteCRCCommand : UserTrialCommand
    {
        public Guid SiteId { get; set; }

        public Guid UserTypeId { get; set; }
        public string UserType { get; set; } = String.Empty;
        public string UserRealName { get; set; } = String.Empty;


        public UserTypeEnum UserTypeEnum { get; set; }


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

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



    public class UserTrialCommand
    {
        public Guid? Id { get; set; }
        public Guid UserId { get; set; }
        public Guid TrialId { get; set; }
    }





    public class SiteStatDTO : SiteStatSimpleDTO
    {



        public int? VisitCount { get; set; }
        public int? SubjectCount { get; set; }


    }

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

        public Guid SiteId { get; set; }

        public int? UserCount { get; set; }

        public string TrialSiteCode { get; set; } = String.Empty;
        public string TrialSiteAliasName { get; set; } = String.Empty;

        public bool IsDeleted { get; set; }

        public DateTime? DeletedTime { get; set; }

        public DateTime UpdateTime { get; set; }

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

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


        public string Hospital { get; set; } = String.Empty;
        public string City { get; set; } = String.Empty;
        public string Country { get; set; } = String.Empty;

        public string DirectorName { get; set; } = String.Empty;
        public string DirectorPhone { get; set; } = String.Empty;
        public string ContactName { get; set; } = String.Empty;
        public string ContactPhone { get; set; } = String.Empty;

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


        public List<string> UserNameList { get; set; } = new List<string>();
    }




    public class TrialMaintenanceExportQuery
    {
        public Guid TrialId { get; set; } = Guid.Empty;
        public string UserRealName { get; set; } = string.Empty;

        public Guid? UserTypeId { get; set; }

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

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

        public bool? IsDeleted { get; set; }
    }

    public class TrialMaintenanceQuery : PageInput
    {
        public Guid TrialId { get; set; } = Guid.Empty;
        public string UserRealName { get; set; } = string.Empty;

        public Guid? UserTypeId { get; set; }

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

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

        public bool? IsDeleted { get; set; }

    }

    public class SiteCRCQuery : TrialMaintenanceQuery
    {

        public Guid SiteId { get; set; }

    }



    public class TrialUserQuery : PageInput
    {
        public Guid TrialId { get; set; }
        public string UserName { get; set; } = string.Empty;

        public string UserRealName { get; set; } = string.Empty;
        public string OrganizationName { get; set; } = String.Empty;

        public UserTypeEnum? UserTypeEnum { get; set; }
    }

    public class TrialUserScreeningDTO : TrialUserAddCommand
    {

        public int Sex { get; set; } // 1-男  2-女

        public string Phone { get; set; } = string.Empty;
        public string EMail { get; set; } = string.Empty;

        public string DepartmentName { get; set; } = String.Empty;
        public string PositionName { get; set; } = String.Empty;

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

        public bool IsSelect { get; set; }



        public Guid UserTypeId { get; set; }
        public string UserType { get; set; } = string.Empty;
        public UserTypeEnum UserTypeEnum { get; set; }

        public string OrganizationName { get; set; } = string.Empty;
        public string UserRealName { get; set; } = string.Empty;


    }


    public class TrialUserAddCommand
    {
        public Guid UserId { get; set; }

        public Guid TrialId { get; set; }



    }


    public class UpdateTrialUserCommand
    {
        [NotDefault]
        public Guid Id { get; set; }

        public Guid TrialId { get; set; }

        public bool IsDeleted { get; set; }

        public DateTime? RemoveTime { get; set; }

        public DateTime? JoinTime { get; set; }
    }

}
