using IRaCIS.Core.Application.Contracts;
using IRaCIS.Core.Application.Helper;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IRaCIS.Core.Application.ViewModel
{
    public class VisitFinishedStatQuery
    {
        public Guid TrialId { get; set; }

        public Guid? TrialSiteId { get; set; }

        public Guid? TrialReadingCriterionId { get; set; }
    }


    public class VisitFinishedStatViewModel
    {
        public int? UploadedCount { get; set; }

        public int? QCFinishedCount { get; set; }

        public int? CheckFinishedCount { get; set; }

        public List<VisitReadingCriterionInfo> CriterionList { get; set; }
    }

    public class VisitReadingCriterionInfo
    {
        public Guid TrialReadingCriterionId { get; set; }

        public string TrialReadingCriterionName { get; set; }

        public int? ReadingFinishedCount { get; set; }
    }


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

        public Guid? TrialSiteId { get; set; }

        public Guid? TrialReadingCriterionId { get; set; }

    }

    public class VisitQuestionViewModel
    {

        public int? QCQuestion_IngCount { get; set; }

        public int? QCQuestion_ClosedCount { get; set; }

        public int? CheckQuestion_ClosedCount { get; set; }

        public int? CheckQuestion_IngCount { get; set; }

        public int? MedicalReviewQuestion_ClosedCount { get; set; }

        public int? MedicalReviewQuestion_IngCount { get; set; }


        //public List<MedicalReviewQuestionInfo> CriterionList { get; set; }

    }


    public class MedicalReviewQuestionInfo
    {
        public Guid TrialReadingCriterionId { get; set; }

        public string TrialReadingCriterionName { get; set; }


        public int? MedicalReviewQuestion_ClosedCount { get; set; }

        public int? MedicalReviewQuestion_IngCount { get; set; }
    }

    public class EfficacyEvaluationQuery
    {
        [NotDefault]
        public Guid TrialId { get; set; }
        [NotDefault]
        public Guid TrialReadingCriterionId { get; set; }

        public Guid? TrialSiteId { get; set; }
    }

    public class FirstPdInfo
    {
        public string SubjectCode { get; set; }

        public DateTime? EarliestScanDate { get; set; }

        public DateTime? BaseLineLatestScanDate { get; set; }


        // 新增属性：天数差
        public double? DaysDiff
        {
            get
            {
                if (BaseLineLatestScanDate.HasValue && EarliestScanDate.HasValue)
                {
                    return (EarliestScanDate.Value - BaseLineLatestScanDate.Value).TotalDays;
                }
                return null;
            }
        }

        public double? MonthsDiff
        {
            get
            {
                if (DaysDiff.HasValue)
                {
                    return Math.Round(DaysDiff.Value / 30.44, 2, MidpointRounding.AwayFromZero);
                }
                return null;
            }
        }
    }

    public class EfficacyEvaluationStatViewModel
    {
        public string? DictionaryCode { get; set; }

        public string Code { get; set; }
        public string OverallTumorEvaluation { get; set; }

        public int SubjectCount => SubjectCodeList.Count();

        public List<EfficacyEvaluationSubjectInfo> SubjectCodeList { get; set; }
    }


    public class EfficacyEvaluationSubjectInfo
    {
        public string TrialSiteCode { get; set; }

        public string SubjectCode { get; set; }
    }

    public class TrialSiteOrrStat
    {
        public string TrialSiteCode { get; set; }
        public int SiteSubjectCount { get; set; }
        public int SiteCrPrSubjectCount { get; set; }
        public string OrrPercent { get; set; }
    }

    public class EfficacyEvaluationExport
    {

        public DateTime? EarliestScanDate { get; set; }

        public DateTime? LatestScanDate { get; set; }


        public Guid Id { get; set; }

        public Guid SubjectId { get; set; }

        public string TrialSiteCode { get; set; }

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

        public decimal VisitTaskNum { get; set; }

        public string TaskName { get; set; }
        public string TaskBlindName { get; set; }


        public ReadingTaskState ReadingTaskState { get; set; }

        public ReadingCategory ReadingCategory { get; set; }

        public bool? IsBaseline { get; set; }


        [DictionaryTranslateAttribute("ArmEnum")]
        public Arm ArmEnum { get; set; }

        //裁判结果选择的访视或者全局任务Id
        public Arm? JudgeArmEnum { get; set; }

        //裁判选择标记
        //根据裁判的任务结果 设置访视任务的这个字段  该字段表示  裁判认同该任务的结果
        [DictionaryTranslateAttribute("YesOrNoAudit")]
        public bool? IsJudgeSelect { get; set; }


        //在当前访视触发裁判，或者在截止日期小于等于当前访视的阅片期触发裁判
        [DictionaryTranslateAttribute("YesOrNoAudit")]
        public bool? IsTrigerJudge { get; set; }

        //（如果是访视点裁判，则仅在所选阅片人对应访视 显示；如果是阅片期裁判，则在所选阅片人 阅片期内的所有访视 显示此原因）
        public string JudgeNote { get; set; } = string.Empty;



        public List<decimal> SubjectCriterionReadingPeriodVisitNumList { get; set; }


        public string? DictionaryCode { get; set; }

        public string OverallTumorEvaluation { get; set; }





        //public string VisitNote { get; set; }

        //public Guid? DoctorUserId { get; set; }
        //public string UserName { get; set; }
        //public List<CommonQuesionInfo> QuestionAnswerList { get; set; }

        //public String TrialSiteCode { get; set; } = String.Empty;
    }
}
