using IRaCIS.Core.Domain.Share;

namespace IRaCIS.Core.Domain.Models;

[Comment("项目阅片标准")]
[Table("ReadingQuestionCriterionTrial")]
public class ReadingQuestionCriterionTrial : BaseAddAuditEntity
{
    #region 导航属性
    [ForeignKey("TrialId")]
    [JsonIgnore]
    public Trial Trial { get; set; }

    [JsonIgnore]

    public List<ReadingQuestionTrial> ReadingQuestionTrialList = new List<ReadingQuestionTrial>();

    [JsonIgnore]

    public List<TrialCriterionKeyFile> KeyFileList { get; set; } = new List<TrialCriterionKeyFile>();

    [JsonIgnore]

    public List<TrialCriterionAdditionalAssessmentType> TrialCriterionAdditionalAssessmentTypeList { get; set; } = new List<TrialCriterionAdditionalAssessmentType>();
    [JsonIgnore]

    public List<VisitTask> VisitTaskList { get; set; }

    [JsonIgnore]

    public List<TrialClinicalDataSetCriterion> TrialClinicalDataSetCriterionList { get; set; }

    #endregion
    [Comment("系统标准ID")]
    public Guid? ReadingQuestionCriterionSystemId { get; set; }

    [Comment("项目Id")]
    public Guid TrialId { get; set; }

    [Comment("标准")]
    public string CriterionName { get; set; } = string.Empty;

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

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

    [Comment("是否完成配置")]
    public bool IsCompleteConfig { get; set; }
    [Comment("描述")]
    public string Description { get; set; } = string.Empty;

    [Comment("是否确认")]
    public bool IsConfirm { get; set; }

    [Comment("表单类型")]

    public FormType FormType { get; set; } = FormType.SinglePage;
    [Comment("修约小数点")]
    public int? DigitPlaces { get; set; } = 1;

    [Comment("评估结果")]
    public string EvaluationResult { get; set; } = string.Empty;

    [Comment("全局阅片评估更新类型")]
    public string GlobalUpdateType { get; set; } = string.Empty;
    [Comment("评估原因")]
    public string EvaluationReason { get; set; } = I18n.T("CriterionTrial_EvaluationReason");
    [Comment("是否显示详情")]
    public bool IsShowDetail { get; set; } = true;

    [Comment("同步时间")]
    public DateTime SynchronizeTime { get; set; }
    [Comment("同步器官时间")]
    public DateTime? SynchronizeOriginalTime { get; set; }

    [Comment("标准类型")]
    public CriterionType CriterionType { get; set; }

    /// <summary>
    /// 标准分组
    /// </summary>
    public CriterionGroup CriterionGroup { get; set; }

    [Comment("是否加急")]
    public bool IsUrgent { get; set; } = false;

    [Comment("eCRF报告是否显示在图像页面")]
    public bool IseCRFShowInDicomReading { get; set; } = false;

    #region 阅片单元配置 新加
    public string CriterionModalitys { get; set; } = string.Empty;

    [Comment("阅片平台")]
    public ImagePlatform ImagePlatform { get; set; } = ImagePlatform.PACS;

    [Comment("阅片工具")]
    public ReadingTool? ReadingTool { get; set; }

    [Comment("任务组织级别")]
    public ReadingTaskViewMethod ReadingTaskViewEnum { get; set; }
    [Comment("阅片是否显示受试者信息")]
    public bool IsReadingShowSubjectInfo { get; set; } = true;

    [Comment("IR阅片页面是否可以查看既往任务结果")]
    public bool IsReadingShowPreviousResults { get; set; } = true;
    [Comment("是确认医学审核问题")]

    public bool IsConfirmMedicineQuestion { get; set; } = false;
    [Comment("仲裁对象")]
    public ArbitrationRule ArbitrationRule { get; set; } = ArbitrationRule.Reading;
    [Comment("阅片模式")]
    public ReadingMethod ReadingType { get; set; } = ReadingMethod.Double;
    [Comment("存在阅片期")]
    public bool IsReadingPeriod { get; set; } = true;

    [Comment("是否生成全局阅片任务")]
    public bool IsGlobalReading { get; set; } = false;

    [Comment("是否签名")]
    public bool IsSigned { get; set; } = false;

    /// <summary>
    /// 裁判
    /// </summary>
    [Comment("仲裁阅片")]
    
    public bool IsArbitrationReading { get; set; } = true;
    [Comment("肿瘤学阅片  原字段 IsClinicalReading")]
    public bool IsOncologyReading { get; set; }

    [Comment("是否系统设置了 肿瘤学")]
    public bool IsSystemSetOncology { get; set; } = true;

    [Comment("任务展示访视 读片任务显示是否顺序")]
    public ReadingOrder IsReadingTaskViewInOrder { get; set; } = ReadingOrder.InOrder;
    [Comment("任务分配对象")]
    public TaskAllocateObj TaskAllocateObjEnum { get; set; }
    [Comment("后续访视任务自动分配")]
    public bool IsFollowVisitAutoAssign { get; set; } = true;

    [Comment("后续全局自动分配")]
    public bool IsFollowGlobalVisitAutoAssign { get; set; } = true;

    public bool IsFollowJudgeTaskAutoAssign { get; set; } = true;

    public TaskAllocateDefaultState FollowJudgeTaskAutoAssignDefaultState { get; set; } = TaskAllocateDefaultState.Allocated;

    [Comment("后续访视自动分配默认状态")]
    public TaskAllocateDefaultState FollowVisitAutoAssignDefaultState { get; set; } = TaskAllocateDefaultState.Allocated;

    [Comment("后续全局自动分配默认状态")]
    public TaskAllocateDefaultState FollowGlobalVisitAutoAssignDefaultState { get; set; } = TaskAllocateDefaultState.Allocated;
    [Comment("阅片信息签名时间")]
    public DateTime? ReadingInfoSignTime { get; set; }

    [Comment("是否必须全局阅片")]
    public bool IsMustGlobalReading { get; set; } = false;
    [Comment("是否附加评估")]
    public bool IsAdditionalAssessment { get; set; }
    [Comment("自动  手动生成任务")]
    public bool IsAutoCreate { get; set; } = true;
    #endregion
    [Comment("阅片过程下载影像")]
    public ReadingImageDownload ImageDownloadEnum { get; set; }

    [Comment("阅片过程上传影像")]
    public ReadingImageUpload ImageUploadEnum { get; set; }

    [Comment("是否影像筛选")]
    public bool IsImageFilter { get; set; }

    /// <summary>
    /// 阅片版本
    /// </summary>
    public ReadingVersion ReadingVersionEnum { get; set; } = ReadingVersion.RT0;

    /// <summary>
    /// 阅片工具
    /// </summary>
    public List<string> ReadingToolList { get; set; } = new List<string>();

    /// <summary>
    /// 分割工具
    /// </summary>
    public List<string> SegmentToolList { get; set; } = new List<string>();

    /// <summary>
    /// 默认SegmentName
    /// </summary>
    [MaxLength]
    public DefaultSegmentNameDto DefaultSegmentName { get; set; } = new DefaultSegmentNameDto() { SegmentNameList = new List<string> { "Segment" } };

    /// <summary>
    /// 定圆工具默认半径
    /// </summary>
    public decimal CircleRadius { get; set; } = 10;

    /// <summary>
    /// 仲裁模式
    /// </summary>
    public JudgeMode JudgeModeEnum { get; set; } = JudgeMode.SelectOne;

    /// <summary>
    /// 裁判规则
    /// </summary>
    public JudgeRule JudgeRuleEnum { get; set; } = JudgeRule.Consistent;

    /// <summary>
    /// 裁判任务生成
    /// </summary>
    public JudgeGenerate JudgeGenerateEnum { get; set; } = JudgeGenerate.Instant;
}

/// <summary>
/// 裁判任务生成时间
/// </summary>
public enum JudgeGenerate
{
    /// <summary>
    /// 及时
    /// </summary>
    Instant = 0,

    /// <summary>
    /// 阶段性
    /// </summary>
    Phased = 1,

}


/// <summary>
/// 仲裁模式
/// </summary>
public enum JudgeMode
{
    /// <summary>
    /// 整体结果择一判定
    /// </summary>
    SelectOne = 0,

    /// <summary>
    /// 指标组合判定
    /// </summary>
    Combined = 1,

}

/// <summary>
/// 裁判规则
/// </summary>
public enum JudgeRule
{
    /// <summary>
    /// 跨访视一致规则
    /// </summary>
    Consistent = 0,

    /// <summary>
    /// 访视间差异规则
    /// </summary>
    Difference = 1,

}


/// <summary>
/// 阅片版本
/// </summary>
public enum ReadingVersion
{
    /// <summary>
    /// RT0
    /// </summary>
    RT0 = 0,

    /// <summary>
    /// RT1
    /// </summary>
    RT1 = 1,

}

public enum ReadingImageDownload
{
    None = 0,

    [Comment("按病例")]
    Subejct = 1,
    Visit = 2,
}

public enum ReadingImageUpload
{
    None = 0,

    [Comment("按病例")]
    IRReadingSubejctEnable = 1,

    IRReadingVisitEnable = 2,
}
public enum ReadingOrder
{
    Random = 0,

    InOrder = 1,

    SubjectRandom = 2,
}


public class DefaultSegmentNameDto
{
    public string SegmentationName { get; set; } = "Segmentation";

    public List<string> SegmentNameList { get; set; }
}