package com.fs.his.enums.hsyy;

/**
 * @Author：peicj
 * @Description: 用药途径
 * @Date：2026/1/5 11:34
 */
public enum MedicationRoute {

    CHRONIC_DISEASE(1, "慢病用药"),
    GYNECOLOGY(2, "妇科用药"),
    DERMATOLOGY(3, "皮肤用药"),
    ONCOLOGY(4, "肿瘤用药"),
    CARDIOVASCULAR(5, "心脑血管"),
    PEDIATRIC(6, "儿童用药"),
    OTHER(7, "其他");

    private final int code;
    private final String description;

    MedicationRoute(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    // 根据code获取枚举
    public static MedicationRoute fromCode(int code) {
        for (MedicationRoute route : values()) {
            if (route.code == code) {
                return route;
            }
        }
        return OTHER; // 默认返回其他
    }

    // 根据code获取描述
    public static String getDescriptionByCode(int code) {
        return fromCode(code).getDescription();
    }
    // 根据描述获取code
    public static int getCodeByDescription(String description) {
        for (MedicationRoute route : values()) {
            if (route.description.equals(description)) {
                return route.code;
            }
        }
        return OTHER.code;
    }
}
