package com.diagbot.enums.data;

import lombok.Setter;

public enum LeaveHospitalTypeEnum implements AKeyedNamed{
    LEAVE_HOSPTAIL("1", "医院离院"),
    TRANSFER_MEDICAL("2", "医嘱转院"),
    TRANSFER_COMMUNITY("3", "医嘱转社区卫生服务机构/乡镇卫生院"),
    NO_TRANSFER_MEDICAL("4", "非医嘱离院"),
    DEATH("5", "死亡"),
    OTHER("9", "其他");

    @Setter
    private String key;

    @Setter
    private String name;

    LeaveHospitalTypeEnum(String key, String name) {
        this.key = key;
        this.name = name;
    }

    public static LeaveHospitalTypeEnum getEnum(String key) {
        for (LeaveHospitalTypeEnum item : LeaveHospitalTypeEnum.values()) {
            if (key.equals(item.getKey())) {
                return item;
            }
        }
        return null;
    }

    public static String getName(String key) {
        LeaveHospitalTypeEnum item = getEnum(key);
        return item != null ? item.name : null;
    }

    @Override
    public String getKey() {
        return key;
    }

    @Override
    public String getName() {
        return name;
    }
}
