package com.fs.his.enums.hsyy;

/**
 * @Author：peicj
 * @Description: 煎煮要求
 * @Date：2026/1/5 11:26
 */
public enum DecoctionRequirement {

    PRE_DECOCION(1, "先煎"),
    POST_ADDITION(2, "后下"),
    WRAPPED_DECOCION(3, "包煎"),
    SEPARATE_DECOCION(4, "另煎"),
    MELTING(5, "烊化"),
    FLUSHING(6, "冲服"),
    OTHER(99, "其他");

    private final int code;
    private final String description;

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

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

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

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