package cn.hnthyy.thmz.enums;

import java.util.Arrays;
import java.util.List;

/**
 * 处方类型:1:西药;2:成药;3:草药;4:诊疗
 */
public enum GroupTypeEnum {
    WESTERN_MEDICINE("1","西药"),
    PATENT_MEDICINE("2","成药"),
    HERB("3","草药"),
    DIAGNOSIS("4","诊疗");
    public String code;
    public String name;

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

    /**
     * 根据编码查询对应的类型
     * @param code
     * @return
     */
    public static GroupTypeEnum getGroupTypeByCode(String code){
        List<GroupTypeEnum> groupTypeEnums= Arrays.asList(values());
        for (GroupTypeEnum groupTypeEnum:groupTypeEnums){
            if(groupTypeEnum.code.equals(code)){
                return groupTypeEnum;
            }
        }
        return null;
    }
}
