using System;
using System.Collections.Generic;
using IRaCIS.Core.Domain.Share;
using IRaCIS.Core.Infrastructure.Extention;

namespace IRaCIS.Application.Contracts
{

    public class EnrollStatByReviewerDTO
    {
        public Guid Id { get; set; }
        public string Hospital { get; set; } = string.Empty;
        public string ChineseName { get; set; } = string.Empty;

        public string FirstName { get; set; } = string.Empty;
        public string LastName { get; set; } = string.Empty;

        public string FullName { get; set; } = string.Empty;
        public string ReviewerCode { get; set; } = string.Empty;

        public int Pending { get; set; }
        public int Approved { get; set; }
        public int Reading { get; set; }
        public int Finished { get; set; }
        public int Total { get; set; }
        public double EntryRate
        {
            get
            {
                if (Total == 0)
                {
                    return 0;
                }
                return Math.Round(((Reading + Finished) / (double)Total) * 100, 1, MidpointRounding.AwayFromZero);
                ;
            }
        }

    }


    public class EnrollStatByTrialDTO
    {
        public string TrialCode { get; set; } = string.Empty;
        public Guid TrialId { get; set; }
        public string Indication { get; set; } = string.Empty;
        //public Guid CroId { get; set; }
        public string Cro { get; set; } = string.Empty;

        public DateTime CreateTime { get; set; }

        public int Expedited { get; set; }

        public int EnrollCount { get; set; }

        public List<string> ReviewerNameCNList=new List<string>();

        public List<string> ReviewerNameList=new List<string>();
    }


    #region 参与项目统计


    public class ParticipateQueryDto:PageInput
    {
        public string UserInfo { get; set; } = string.Empty;
        public string OrganizationName { get; set; } = string.Empty;

    }

    public class UserParticipateTrialStat
    {
        public Guid UserId { get; set; }
        public string OrganizationName { get; set; } = string.Empty;

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

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

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

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

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

        public int TrialCount { get; set; }

    }

    public class UserParticipateTrialDetail
    {
        public Guid TrialId { get; set; }
        public string Code { get; set; } = string.Empty;
        public string Indication { get; set; } = string.Empty;

        public int Expedited { get; set; }

        public string CROName { get; set; } = string.Empty;
        public string UserType { get; set; } = string.Empty;
    }

    #endregion



    #region 统计 20200413 
    public class WorkloadByTrialAndReviewerDTO
    {
        public Guid Id { get; set; }
        public string TrialCode { get; set; } = string.Empty;
        public Guid TrialId { get; set; }
        public string Indication { get; set; } = string.Empty;
        public Guid? CroId { get; set; }
        public string Cro { get; set; } = string.Empty;
        public string ChineseName { get; set; } = string.Empty;

        public string FirstName { get; set; } = string.Empty;
        public string LastName { get; set; } = string.Empty;

        public string FullName { get; set; } = string.Empty;
        public string ReviewerCode { get; set; } = string.Empty;

        public int Training { get; set; }
        public int Downtime { get; set; }
        public int Timepoint { get; set; }
        public int TimepointIn24H { get; set; }
        public int TimepointIn48H { get; set; }
        public int Adjudication { get; set; }
        public int AdjudicationIn24H { get; set; }
        public int AdjudicationIn48H { get; set; }
        public int Global { get; set; }

        public int RefresherTraining { get; set; }
        
        public int PersonalTotal { get; set; }
    }


    public class StatisticsQueryDTO : PageInput
    {
        public Guid? CroId { get; set; } = Guid.Empty;
        public string TrialCode { get; set; } = string.Empty;
        public string Reviewer { get; set; } = string.Empty;
        public DateTime BeginDate { get; set; } = DateTime.Now;
        public DateTime EndDate { get; set; } = DateTime.Now;
        public int StatType { get; set; }

        //医生付费类型  CN  US
        public int? Nation { get; set; }
        public AttendedReviewerType? AttendedReviewerType { get; set; }
    }

    public class StatisticsWorkloadQueryParam : PageInput
    {
        public Guid? CroId { get; set; } 
        public string TrialCode { get; set; } = string.Empty;
        public string Reviewer { get; set; } = string.Empty;
        public DateTime BeginDate { get; set; } = DateTime.Now;
        public DateTime EndDate { get; set; } = DateTime.Now;
        public int StatType { get; set; }

        public Guid? HospitalId { get; set; } 
    }

    public class RevenuesStatQueryDTO : PageInput
    {
        public Guid CroId { get; set; } = Guid.Empty;

        public string Reviewer { get; set; } = string.Empty;
        public string TrialCode { get; set; } = string.Empty;
        public DateTime BeginDate { get; set; } = DateTime.Now;
        public DateTime EndDate { get; set; } = DateTime.Now;

        public int StatType { get; set; }
    }


    public class EnrollStatByReviewerQueryDTO : PageInput
    {
        public Guid? HospitalId { get; set; } = Guid.Empty;
        public string Reviewer { get; set; } = string.Empty;
        public DateTime BeginDate { get; set; } = DateTime.Now;
        public DateTime EndDate { get; set; } = DateTime.Now;
    }


    public class EnrollStatByTrialQueryDTO : PageInput
    {
        public string TrialCode { get; set; } = string.Empty;

        public string Indication { get; set; } = string.Empty;
        public DateTime? BeginDate { get; set; } = DateTime.Now;
        public DateTime? EndDate { get; set; } = DateTime.Now;

        public Guid? CROId { get; set; }

        public int? Expedited { get; set; }
    }
    #endregion

    #region  dashbord

    /// <summary>
    /// 读片数量分类统计
    /// </summary>
    public class ReadingDataDTO
    {
        public int Timepoint { get; set; }
        public int Adjudication { get; set; }
        public int Global { get; set; }
    }

    public class ReadingDataMonthDTO : ReadingDataDTO
    {
        public string Month { get; set; } = String.Empty;
    }

    public class ReadingDataRankDTO : ReadingDataDTO
    {
        public int TotalReadingCount { get; set; }
        public Guid ReviewerId { get; set; }
        public string ReviewerCode { get; set; } = String.Empty;
        public string FirstName { get; set; } = String.Empty;
        public string LastName { get; set; } = String.Empty;
        public string ChineseName { get; set; } = String.Empty;
    }

    public class RankReviewersDTO
    {
        public Guid? RankId { get; set; }
        public string RankName { get; set; } = String.Empty;
        public string RankNameAbbreviation
        {
            get
            {
                var arr = RankName.Split(' ');
                return arr[0];
            }
        }
        public int ReviewerCount { get; set; }
    }

    public class EnrollDataDTO
    {
        public int Year { get; set; }
        public int Month { get; set; }
        public string QuarterStr => Year + "-Q" + (Month / 3 + (Month % 3 == 0 ? 0 : 1));
        public string YearMonth => new DateTime(Year, Month, 1).ToString("yyyy-MM");
        public int EnrollCount { get; set; }
    }


    public class EnrollQuartDataDTO
    {
        //public int Year { get; set; }

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

        public int EnrollCount { get; set; }
    }

    public class LatestWorkLoadDTO : ReadingDataDTO
    {
        public int TotalReadingCount => Timepoint + Adjudication + Global;
        public Guid ReviewerId { get; set; }
        public string ReviewerCode { get; set; } = String.Empty;
        public string FirstName { get; set; } = String.Empty;
        public string LastName { get; set; } = String.Empty;
        public string ChineseName { get; set; } = String.Empty;
        public string TrialCode { get; set; } = String.Empty;
    }


    

    public class TrialDataRankDTO
    {
        public Guid ReviewerId { get; set; }
        public string ReviewerCode { get; set; } = String.Empty;
        public string FirstName { get; set; } = String.Empty;
        public string LastName { get; set; } = String.Empty;
        public string ChineseName { get; set; } = String.Empty;

        public int TrialCount { get; set; }
    }

    #endregion




}