package com.fs.his.enums.hsyy;

/**
 * @Author：peicj
 * @Description: 给药途径
 * @Date：2026/1/5 11:23
 */
public enum AdministrationRoute {

    // 基础给药途径
    ORAL(1, "口服"),
    RECTAL(2, "直肠给药"),
    SUBLINGUAL(3, "舌下给药"),
    INJECTION(4, "注射给药"),
    INHALATION(5, "吸入给药"),
    LOCAL_APPLICATION(6, "局部用药"),
    OTHER_ROUTE(9, "其他给药途径"),

    // 注射给药子类型
    SUBCUTANEOUS_INJECTION(401, "皮下注射"),
    INTRADERMAL_INJECTION(402, "皮内注射"),
    INTRAMUSCULAR_INJECTION(403, "肌肉注射"),
    INTRAVENOUS_INJECTION(404, "静脉注射或静脉滴注"),

    // 局部用药子类型
    INTRATHECAL_USE(601, "椎管内用药"),
    INTRA_ARTICULAR_USE(602, "关节腔内用药"),
    PLEURAL_CAVITY_USE(603, "胸膜腔用药"),
    PERITONEAL_CAVITY_USE(604, "腹腔用药"),
    VAGINAL_USE(605, "阴道用药"),
    TRACHEAL_USE(606, "气管内用药"),
    EYE_DROPS(607, "滴眼"),
    NASAL_DROPS(608, "滴鼻"),
    THROAT_SPRAY(609, "喷喉"),
    SUBLINGUAL_USE(610, "含化"),
    WOUND_DRESSING(611, "敷伤口"),
    SKIN_APPLICATION(612, "擦皮肤"),
    OTHER_LOCAL_ROUTE(699, "其他局部给药途径");

    private final int code;
    private final String description;

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

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    // 根据code获取枚举
    public static AdministrationRoute fromCode(int code) {
        for (AdministrationRoute route : values()) {
            if (route.code == code) {
                return route;
            }
        }
        return OTHER_ROUTE; // 默认返回其他给药途径
    }

    // 根据code获取描述
    public static String getDescriptionByCode(int code) {
        return fromCode(code).getDescription();
    }

    // 根据描述获取code
    public static int getCodeByDescription(String description) {
        for (AdministrationRoute route : values()) {
            if (route.description.equals(description)) {
                return route.code;
            }
        }
        return OTHER_ROUTE.code;
    }
}
