package thyyxxk.webserver.entity.zhuyuanyisheng.emr;

import java.io.Serializable;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.Getter;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.util.Date;

@Data
@Accessors(chain = true)
@TableName("emr_audit_detail")
public class EmrAuditDetail implements Serializable {

    @Getter
    public enum ScoringCriteriaEnum {

        light(1, "轻"),

        middle(2, "中"),

        heavy(3, "重");


        private final Integer code;
        private final String name;

        ScoringCriteriaEnum(Integer code, String name) {
            this.code = code;
            this.name = name;
        }

        public static String getNameByCode(Integer code) {
            for (ScoringCriteriaEnum value : ScoringCriteriaEnum.values()) {
                if (value.getCode().equals(code)) {
                    return value.getName();
                }
            }
            return "";
        }

    }

    @Getter
    public enum RemediationStatusEnum {
        rectified(1, "已整改"),

        itIsKnownThatNoRectificationIsRequired(2, "已知无需整改");

        private final Integer code;
        private final String name;

        RemediationStatusEnum(Integer code, String name) {
            this.code = code;
            this.name = name;
        }

        public static String getNameByCode(Integer code) {
            for (RemediationStatusEnum value : RemediationStatusEnum.values()) {
                if (value.getCode().equals(code)) {
                    return value.getName();
                }
            }
            return "";
        }
    }

    @Getter
    public enum levelEnum {
        HOSP(0, "全院"),
        DEPT(1, "科室"),
        DOCTOR(2, "医生");

        private final Integer code;
        private final String name;

        levelEnum(Integer code, String name) {
            this.code = code;
            this.name = name;
        }

        public static String getNameByCode(Integer code) {
            for (levelEnum value : levelEnum.values()) {
                if (value.getCode().equals(code)) {
                    return value.getName();
                }
            }
            return "";
        }
    }


    private static final long serialVersionUID = 3711491177934905816L;

    @TableField(value = "pat_no")
    private String patNo;

    @TableField(value = "times")
    private Integer times;

    @TableField(exist = false)
    private String patName;

    /**
     * id
     */
    @TableId(type = IdType.AUTO, value = "id")
    private Integer id;

    /**
     * 审核人id
     */
    @TableField(value = "approver")
    private String approver;

    @TableField(exist = false)
    private String approverName;

    /**
     * 审核时间
     */
    @TableField(value = "review_time")
    private Date reviewTime;

    /**
     * 质控名称
     */
    @TableField(value = "name")
    private String name;

    /**
     * 1-轻度 2-中度 3-重度
     */
    @TableField(value = "scoring_criteria")
    private Integer scoringCriteria;

    /**
     * 备注
     */
    @TableField(value = "remark")
    private String remark;

    /**
     * 1-已整改 2-无需整改
     */
    @TableField(value = "remediation_status")
    private Integer remediationStatus;

    /**
     * 缺陷数
     */
    @TableField(value = "number_of_defects")
    private Integer numberOfDefects;

    /**
     * 修改人
     */
    @TableField(value = "modify_person")
    private String modifyPerson;

    @TableField(exist = false)
    private String modifyPersonName;

    /**
     * 修改时间
     */
    @TableField(value = "modification_time")
    private Date modificationTime;

    /**
     * 电子病历id
     */
    @TableField(value = "emr_id")
    private Integer emrId;

    /**
     * 0-最新 1-历史
     */
    @TableField(value = "history")
    private Integer history;

    /**
     * 电子病历中的名称
     */
    @TableField(exist = false)
    private String emrName;

    /**
     * 需要发送给那个医生
     */
    @TableField(value = "doctor")
    private String doctor;

    /**
     * 在查询的审核查看是否已经匹配上了
     */
    @TableField(exist = false)
    private Boolean matching = false;

    /**
     * 是否为终末质控
     */
    @TableField(value = "final_control")
    private Integer finalControl;

    @TableField(value = "level")
    private Integer level;

    @TableField(exist = false)
    private Integer sort;

    /**
     * 减分
     */
    @TableField(value = "minus_points")
    private BigDecimal minusPoints;

    public String getLevelName() {
        return levelEnum.getNameByCode(level);
    }

    public String getScoringCriteriaName() {
        return ScoringCriteriaEnum.getNameByCode(scoringCriteria);
    }

    public String getRemediationStatusName() {
        return RemediationStatusEnum.getNameByCode(remediationStatus);
    }

}
