package com.ywt.mg.domain.models.enums;

public enum AttendingStatusEnum {

    /**
     * 外诊业务状态（位标识：1-拒绝，2-同意，4-已通知用户，8-已支付，16-已评价，32-已取消）
     */

    Refuse("外诊医生拒绝", 1),
    Accept("外诊医生同意", 2),
    InformPatient("已通知用户",4),
    AlreadyPay("患者已支付",8),
    PatientEvaluate("患者已评价",16),
    CancleOrder("已取消",32),
    UNKNOWN("待外诊医生回复",0);

    private final String displayName;

    private final int value;

    AttendingStatusEnum(String displayName, int value){
        this.displayName = displayName;
        this.value = value;
    }

    public String getDisplayName() {
        return displayName;
    }

    public int getValue() {
        return value;
    }

    public static AttendingStatusEnum getAttendingStatus(int value){
        value = getValue(value);

        switch (value){
            case 1:
                return Refuse;
            case 2:
                return Accept;
            case 4:
                return InformPatient;
            case 8:
                return AlreadyPay;
            case 16:
                return PatientEvaluate;
            case 32:
                return CancleOrder;
            default:
                return UNKNOWN;
        }
    }

    public static  int getValue(int status){
        if ( (status & CancleOrder.getValue()) >0   ){
            status = CancleOrder.getValue();
        }
        else if ( (status & PatientEvaluate.getValue()) >0   ){
            status = PatientEvaluate.getValue();
        }
        else if ( (status & AlreadyPay.getValue()) >0   ){
            status = AlreadyPay.getValue();
        }
        else if ( (status & InformPatient.getValue()) >0   ){
            status = InformPatient.getValue();
        }
        else if ( (status & Accept.getValue()) >0   ){
            status = Accept.getValue();
        }
        else if ( (status & Refuse.getValue()) >0   ){
            status = Refuse.getValue();
        }
        else{
            status = UNKNOWN.getValue();
        }

        return status;
    }



}
