using IRaCIS.Core.Domain.Share;
using System.Linq;

namespace IRaCIS.Core.Domain.Models;

[Comment("项目 - 临床数据适应标准配置")]
[Table("ClinicalDataTrialSet")]
public class ClinicalDataTrialSet : BaseAddAuditEntity
{
    #region 导航属性

    [JsonIgnore]
    public List<ReadingClinicalData> ReadingClinicalDataList { get; set; }

    [JsonIgnore]
    [ForeignKey("TrialId")]
    public Trial Trial { get; set; }

    [JsonIgnore]
    public List<TrialClinicalDataSetCriterion> TrialClinicalDataSetCriteriaList { get; set; }

    [JsonIgnore]
    public List<TrialClinicalQuestion> TrialClinicalQuestionList { get; set; }
    [JsonIgnore]
    [ForeignKey("SystemClinicalDataSetId")]
    public ClinicalDataSystemSet? ClinicalDataSystemSet { get; set; }
    #endregion

    [Comment("临床级别")]
    public ClinicalLevel ClinicalDataLevel { get; set; }

   
    public string ClinicalDataSetEnName { get; set; } = null!;

    public string ClinicalDataSetName { get; set; } = null!;

    [Comment("上传方式")]
    public ClinicalUploadType ClinicalUploadType { get; set; }

    [StringLength(1000)]
    public string CriterionEnumListStr { get; set; } = null!;

   
    public string FileName { get; set; } = null!;

    [Comment("是否应用")]
    public bool IsApply { get; set; }

    public bool IsConfirm { get; set; }

    [StringLength(1000)]
    public string Path { get; set; } = null!;

    public Guid? SystemClinicalDataSetId { get; set; }

    public Guid TrialId { get; set; }

    public UploadRole UploadRole { get; set; }

    [NotMapped]
    public List<int> CriterionEnumList => CriterionEnumListStr.Split('|', StringSplitOptions.RemoveEmptyEntries).Where(t => !string.IsNullOrEmpty(t) && int.TryParse(t.Trim(), out var s)).Select(t => int.Parse(t.Trim())).ToList();

}

