using IRaCIS.Core.Domain.Share;

namespace IRaCIS.Core.Domain.Models;

[Comment("项目临床数据问题")]
[Table("TrialClinicalQuestion")]
public class TrialClinicalQuestion : BaseAddAuditEntity
{
    #region 导航属性
    [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>();
            }

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

    [Comment("项目临床数据Id")]
    public Guid TrialClinicalId { get; set; }

    [Comment("问题名称")]
    public string QuestionName { get; set; } = string.Empty;

    [Comment("问题英文名称")]
    public string QuestionEnName { get; set; } = string.Empty;

    [Comment("临床问题类型(分组，单选。)")]
    public string ClinicalQuestionType { get; set; } = string.Empty;

    [Comment("问题标识")]
    public ClinicalQuestionMark? ClinicalQuestionMarkEnum { get; set; }

    [Comment("最大长度")]
    public int? MaxAnswerLength { get; set; }

    [Comment("最大行数")]
    public int? MaxQuestionCount { get; set; }

    [Comment("临床数据选项类型(无，自定义)")]
    public ClinicalOptionType ClinicalOptionTypeEnum { get; set; }

    [Comment("分组Id")]
    public Guid? GroupId { get; set; }

    [Comment("自定义选项")]
    public string TypeValue { get; set; } = string.Empty;

    [Comment("字典Code")]
    public string DictionaryCode { get; set; } = string.Empty;

    [Comment("排序")]
    public int ShowOrder { get; set; } = 0;

    [Comment("是否必填")]
    public IsRequired IsRequired { get; set; }

    [Comment("关联Value")]
    public string RelevanceValue { get; set; } = string.Empty;

    [Comment("关联ID")]
    public Guid? RelevanceId { get; set; }

    [Comment("系统临床问题Id")]
    public Guid? SystemClinicalQuestionId { get; set; }
    [Comment("父问题Id")]
    public Guid? ParentId { get; set; }

    [Comment("父问题触发值")]
    public string ParentTriggerValue { get; set; } = string.Empty;

    [Comment("显示类型")]
    public ClinicalQuestionShow ClinicalQuestionShowEnum { get; set; } = ClinicalQuestionShow.Show;

    [Comment("是否是检查日期")]
    public bool IsCheckDate { get; set; }

    [Comment("自定义计算标记")]
    public ClinicalCalculateMark? CustomCalculateMark { get; set; }

    [Comment("分组")]
    [JsonIgnore]
    [ForeignKey("GroupId")]
    public TrialClinicalQuestion GroupQuestin { get; set; }

    [Comment("自定义计算问题")]
    [MaxLength]
    public string CalculateQuestions { get; set; } = "[]";
    [Comment("小数点位数")]
    public int? DigitPlaces { get; set; }

    [Comment("单位")]
    public string Unit { get; set; } = string.Empty;
}
