using IRaCIS.Core.Domain.Share;

namespace IRaCIS.Core.Application.Service.Reading.Dto
{

    public class CRCSignClinicalDataInDto
    {
        public Guid ReadingClinicalDataId { get; set; }
    }


    public class DeleteStudyClinicalInDto
    {
        public Guid StudyId { get; set; }
    }

    public class AddStudyClinicalInDto
    {
        public Guid StudyId { get; set; }
    }

    public class AutoAddClinicalInDto
    {
        public Guid? SubjectId { get; set; }

        //public Guid? VisitId { get; set; }

        public Guid TrialId { get; set; }
    }


    public class GetCRCSubjectClinicalInDto : PageInput
    {
        public Guid TrialId { get; set; }

        public Guid? SubjectId { get; set; }

        public string? SubjectCode { get; set; }
    }


    public class GetCRCSubjectClinicalOutDto
    {
        public Guid SubjectId { get; set; }

        public Guid ReadingClinicalDataId { get; set; }

        /// <summary>
        /// 上传角色
        /// </summary>
        public UploadRole UploadRole { get; set; }
        public Guid TrialId { get; set; }

        /// <summary>
        /// 访视Id  或者模块Id
        /// </summary>
        public Guid ReadingId { get; set; }

        /// <summary>
        /// 临床级别
        /// </summary>
        public ClinicalLevel ClinicalDataLevel { get; set; }


        public Guid? BaseLineVisitId { get; set; }

        /// <summary>
        /// 上传方式
        /// </summary>
        public ClinicalUploadType ClinicalUploadType { get; set; }

        public string SubjectCode { get; set; }
        public Guid ClinicalDataTrialSetId { get; set; }

        public string ClinicalDataSetName { get; set; }

        public string ClinicalDataSetEnName { get; set; }

        public int ClinicalCount { get; set; } = 0;
    }


    public class GetCRCSubjectClinicalResultDto
    {
        public Guid SubjectId { get; set; }

        public string SubjectCode { get; set; }

        public List<GetCRCSubjectClinicalOutDto> ClinicalDataList { get; set; }
    }




    public class GetClinicalQuestionAnswerListInDto
    {
        public Guid SubjectId { get; set; }


        public Guid TrialId { get; set; }

        public Guid ClinicalDataTrialSetId { get; set; }
    }


    public class GetClinicalQuestionAnswerListOutDto
    {
        public List<TrialClinicalQuestionDto> QuestionList { get; set; }

        public List<Dictionary<string, string>> AnswerList { get; set; }
    }

    public class GetClinicalFormInfoInDto
    {
        public Guid ClinicalFormId { get; set; }
    }

    public class GetClinicalFormInfoOutDto
    {
        public List<ClinicalQuestionPreviewDto> Question { get; set; }
    }

    public class ClinicalFormQuestionAnswer
    {
        public Guid QuestionId { get; set; }

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

    public class ClinicalFormTableQuestionAnswer
    {
        public Guid TableQuestionId { get; set; }

        public int RowIndex { get; set; }

        public Guid QuestionId { get; set; }

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

    public class GetPMConfirmListInDto : PageInput
    {
        public Guid TrialId { get; set; }

        public Guid TrialReadingCriterionId { get; set; }
    }

    public class GetCRCConfirmListInDto : PageInput
    {

        public bool? IsCRCConfirm { get; set; }

        public bool? IsPMConfirm { get; set; }

        public Guid? TrialReadingCriterionId { get; set; }

        public Guid? SubjectId { get; set; }

        public DateTime? StartTime { get; set; }
        public DateTime? EndTime { get; set; }

        public Guid TrialId { get; set; }

        public Guid? ReadModuleId { get; set; }

        public string? SubjectCode { get; set; }
    }

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

        public Guid ReadModuleId { get; set; }
    }

    public class GetClinicalDateListOutDto
    {
        public string ClinicalDataSetName { get; set; }


        public List<GetCRCBeConfirmListOutDto> DateList { get; set; }
    }


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

        public Guid ReadModuleId { get; set; }
    }


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

        public Guid ReadModuleId { get; set; }
    }


    public class GetClinicalTableListOutDto : GetClinicalQuestionAnswerListOutDto
    {
        public string ClinicalDataSetName { get; set; }

        /// <summary>
        /// 模块名称
        /// </summary>
        public string ModuleName { get; set; }
    }


    public class GetCRCBeConfirm : GetCRCBeConfirmListOutDto
    {
        public Guid ReadModuleId { get; set; }
    }


    public class GetCRCBeConfirmListOutDto
    {
        public Guid ClinicalDataTrialSetId { get; set; }

        public Guid ClinicalFormId { get; set; }

        public string ClinicalDataSetName { get; set; }

        public string ClinicalDataSetEnName { get; set; }

        public DateTime CheckDate { get; set; }

        public bool IsHaveTableQuestion { get; set; }
    }

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

        public Guid SubjectId { get; set; }

        public Guid ReadModuleId { get; set; }

        /// <summary>
        /// 临床数据是否完整
        /// </summary>
        public bool? IsClinicalDataComplete { get; set; }

        /// <summary>
        /// 临床数据是否盲化
        /// </summary>
        public bool? IsClinicalDataBlind { get; set; }

        public bool IsConfirm { get; set; }

    }


    public class CRCClinicalForm
    {
        /// <summary>
        /// 受试者Id
        /// </summary>
        public Guid SubjectId { get; set; }
        public DateTime? CheckDate { get; set; }

        public Guid ClinicalFormId { get; set; }

        /// <summary>
        /// 临床级别
        /// </summary>
        public ClinicalLevel ClinicalDataLevel { get; set; }


        public Guid ClinicalDataTrialSetId { get; set; }

        public string ClinicalDataSetName { get; set; }

        public bool IsHaveTableQuestion { get; set; }

        public string ClinicalDataSetEnName { get; set; }
    }


    public class GetCRCConfirmListOutDto
    {

        /// <summary>
        /// 受试者ID
        /// </summary>
        public Guid SubjectId { get; set; }

        public bool IsNotNeedPMConfirm { get; set; } = false;
        public Guid ReadModuleId { get; set; }

        /// <summary>
        /// 模块名称
        /// </summary>
        public string ModuleName { get; set; }

        public string VisitBlindName { get; set; }

        public bool IsPMConfirm { get; set; }

        public ReadingSetType ReadingSetType { get; set; }

        public bool IsCRCConfirm { get; set; } = false;


        /// <summary>
        /// CRC是否正在申请撤回
        /// </summary>
        public bool IsCRCApplicationRevoke { get; set; } = false;

        public string SubjectCode { get; set; }

        public bool IsHaveTableQuestion
        {
            get
            {
                return ClinicalFormList.Any(x => x.IsHaveTableQuestion);
            }
        }
        /// <summary>
        /// 最晚拍片日期
        /// </summary>
        public DateTime? LatestScanDate { get; set; }

        public List<string> ClinicalNameList
        {
            get
            {
                return this.ClinicalFormList.Select(x => x.ClinicalDataSetName).Distinct().ToList();
            }
        }


        public List<GetCRCBeConfirmListOutDto> ClinicalFormList { get; set; }

        public int FormCount
        {
            get
            {
                return this.ClinicalFormList.Count();
            }
        }
    }

    public class DeleteClinicalFormInDto
    {
        public Guid ClinicalFormId { get; set; }
    }
    public class SubmitClinicalFormInDto
    {
        /// <summary>
        /// VisitId
        /// </summary>
        public Guid? ReadingId { get; set; }

        public Guid? ClinicalFormId { get; set; }

        public string? PicturePath { get; set; }

        public Guid SubjectId { get; set; }

        public Guid TrialId { get; set; }

        public Guid ClinicalDataTrialSetId { get; set; }


        public List<ClinicalFormQuestionAnswer> QuestionAnswers { get; set; }

        public List<ClinicalQuestionForm> TableQuestionAnswerList { get; set; }
    }


    public class ClinicalQuestionForm
    {
        public Guid QuestionId { get; set; }

        public List<List<ClinicalTableQuestionForm>> TableQuestionAnswers { get; set; }
    }


    public class ClinicalTableQuestionForm
    {
        public Guid TableQuestionId { get; set; }

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