
//--------------------------------------------------------------------
//     此代码由T4模板自动生成  byzhouhang 20210918
//	   生成时间 2023-06-16 13:37:24 
//     对此文件的更改可能会导致不正确的行为，并且如果重新生成代码，这些更改将会丢失。
using System;
using IRaCIS.Core.Domain.Share;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using IRaCIS.Core.Domain.Models;
using System.Collections.Generic;

namespace IRaCIS.Core.Domain.Models
{
    ///<summary>
    ///项目临床数据问题
    ///</summary>
    [Table("TrialClinicalQuestion")]
    public class TrialClinicalQuestion : Entity, IAuditAdd
    {
        /// <summary>
        /// 项目临床数据Id
        /// </summary>
        public Guid TrialClinicalId { get; set; }

        /// <summary>
        /// 问题名称
        /// </summary>
        public string QuestionName { get; set; } = string.Empty;

        /// <summary>
        /// 问题英文名称
        /// </summary>
        public string QuestionEnName { get; set; } = string.Empty;

        /// <summary>
        /// 临床问题类型(分组，单选。)
        /// </summary>
        public string ClinicalQuestionType { get; set; }

        /// <summary>
        /// 问题标识
        /// </summary>
        public ClinicalQuestionMark? ClinicalQuestionMarkEnum { get; set; }

        /// <summary>
        /// 最大长度
        /// </summary>
        public int? MaxAnswerLength { get; set; }
        
        /// <summary>
        /// 最大行数
        /// </summary>
        public int? MaxQuestionCount { get; set; }

        /// <summary>
        /// 临床数据选项类型(无，自定义)
        /// </summary>
        public ClinicalOptionType ClinicalOptionTypeEnum { get; set; }

        /// <summary>
        /// 分组Id
        /// </summary>
        public Guid? GroupId { get; set; }

        /// <summary>
        /// 自定义选项
        /// </summary>
        public string TypeValue { get; set; } = string.Empty;

        /// <summary>
        /// 字典Code
        /// </summary>
        public string DictionaryCode { get; set; } = string.Empty;

        /// <summary>
        /// 排序
        /// </summary>
        public int ShowOrder { get; set; } = 0;

        /// <summary>
        /// 是否必填
        /// </summary>
        public IsRequired IsRequired { get; set; }

		/// <summary>
		/// 关联Value
		/// </summary>
		public string RelevanceValue { get; set; } = string.Empty;

		/// <summary>
		/// 关联ID
		/// </summary>
		public Guid? RelevanceId { get; set; }

		/// <summary>
		/// 系统临床问题Id
		/// </summary>
		public Guid? SystemClinicalQuestionId { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTime { get; set; }

        /// <summary>
        /// 创建人
        /// </summary>
        public Guid CreateUserId { get; set; }

        /// <summary>
        /// 父问题Id
        /// </summary>
        public Guid? ParentId { get; set; }

        /// <summary>
        /// 父问题触发值
        /// </summary>
        public string ParentTriggerValue { get; set; } = string.Empty;

        /// <summary>
        /// 显示类型
        /// </summary>
        public ClinicalQuestionShow ClinicalQuestionShowEnum { get; set; } = ClinicalQuestionShow.Show;

        /// <summary>
        /// 是否是检查日期
        /// </summary>
        public bool IsCheckDate { get; set; }

        /// <summary>
        /// 自定义计算标记
        /// </summary>
        public  ClinicalCalculateMark? CustomCalculateMark { get; set; }

        /// <summary>
        /// 分组
        /// </summary>
        [JsonIgnore]
        [ForeignKey("GroupId")]
        public TrialClinicalQuestion GroupQuestin { get; set; }

        /// <summary>
        /// 自定义计算问题
        /// </summary>
        public string CalculateQuestions { get; set; } = "[]";

		[NotMapped]
		public List<CalculateInfo> CalculateQuestionList
		{
			get
			{

				try
				{
					var result = JsonConvert.DeserializeObject<List<CalculateInfo>>(this.CalculateQuestions);
					return result == null ? new List<CalculateInfo>() : result;
				}
				catch (Exception)
				{

					return new List<CalculateInfo>();
				}

			}
		}

		/// <summary>
		/// 小数点位数
		/// </summary>
		public int? DigitPlaces { get; set; }

        /// <summary>
        /// 单位
        /// </summary>
        public string Unit { get; set; } = string.Empty;

		[JsonIgnore]
		[ForeignKey("TrialClinicalId")]
		public ClinicalDataTrialSet ClinicalDataTrialSet { get; set; }
	}


}
