package thyyxxk.webserver.constants.sidicts;

import thyyxxk.webserver.utils.StringUtil;

/**
 * @description: 计划生育手术类别
 * @author: DingJie
 * @create: 2021/7/915:49
 */
public enum BirctrlType {

    INTRAUTERINE_DEVICE_PLACEMENT("1", "放置宫内节育器"),

    REMOVAL_OF_INTRAUTERINE_DEVICE("2", "取出宫内节育器"),

    ABORTION("3", "流产术"),

    INDUCED_LABOR("4", "引产术"),

    STERILIZATION("5", "绝育手术"),

    RECANALIZATION("6", "绝育复通手术"),

    STERILIZATION_VAS_DEFERENS("7", "绝育手术（输精管）"),

    RECANALIZATION_VAS_DEFERENS("8", "绝育复通手术（输精管）"),

    OTHERS("9", "其他");

    private final String code;
    private final String name;

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

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static BirctrlType get(String code) {
        if (StringUtil.isBlank(code)) {
            return null;
        }
        for (BirctrlType birctrlType : BirctrlType.values()) {
            if (code.trim().equals(birctrlType.getCode())) {
                return birctrlType;
            }
        }
        return null;
    }
}