package thyyxxk.webserver.constants.sidicts;

import lombok.Getter;
import thyyxxk.webserver.utils.StringUtil;

@Getter
public enum DrordDrProfttl {
    CHIEF_PHYSICIAN("231", "主任医师", "001"),

    DEPUTY_CHIEF_PHYSICIAN("232", "副主任医师", "002"),

    MAIN_PHYSICIAN("233", "主诊医师", "003"),

    NORMAN_PHYSICIAN("234", "医师", "004"),

    UNDER_PHYSICIAN("235", "医士", "005");

    private final String code;
    private final String name;
    private final String hisCode;

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

    public static DrordDrProfttl getByHisCode(String hisCode) {
        if (StringUtil.isBlank(hisCode)) {
            return NORMAN_PHYSICIAN;
        }
        for (DrordDrProfttl profttl : DrordDrProfttl.values()) {
            if (hisCode.trim().equals(profttl.getHisCode())) {
                return profttl;
            }
        }
        return NORMAN_PHYSICIAN;
    }

    public static String getCodeByHisCode(String hisCode) {
        if (StringUtil.isBlank(hisCode)) {
            return null;
        }
        for (DrordDrProfttl profttl : DrordDrProfttl.values()) {
            if (hisCode.trim().equals(profttl.getHisCode())) {
                return profttl.getCode();
            }
        }
        return null;
    }
}
