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

import org.omg.CORBA.UNKNOWN;

public enum TransferStatusEnum {

    /**
     * 转诊业务状态（位标识：1-无法安排床位，2-已安排床位，4-已通知用户，8-选择救护车，16-用户已确认，32-用户已评价,64-已取消）
     */

    Refuse("无法安排床位", 1),
    Accept("已安排床位", 2),
    InformPatient("已通知用户",4),
    SelectAmbulance("选择救护车",8),
    PatientAffirm("用户已确认",16),
    PatientEvaluate("用户已评价",32),
    CancleTrannsferOrder("已取消",64),
    UNKNOWN("等待处理",0);

    private final String displayName;

    private final int value;

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

    public String getDisplayName() {
        return displayName;
    }

    public int getValue() {
        return value;
    }

    public static TransferStatusEnum getTransferStatus(int value){
        value = getValue(value);
        switch (value){
            case 1:
                return Refuse;
            case 2:
                return Accept;
            case 4:
                return InformPatient;
            case 8:
                return SelectAmbulance;
            case 16:
                return PatientAffirm;
            case 32:
                return PatientEvaluate;
            case 64:
                return CancleTrannsferOrder;
            default:
                return UNKNOWN;
        }
    }

    public static  int getValue(int status){
        if ( (status & CancleTrannsferOrder.getValue()) > 0   ){
            status = CancleTrannsferOrder.getValue();
        }
        else if ( (status & PatientEvaluate.getValue()) >0  ){
            status = PatientEvaluate.getValue();
        }
        else if ( (status & PatientAffirm.getValue()) >0   ){
            status = PatientAffirm.getValue();
        }
        else if ( (status & SelectAmbulance.getValue()) >0   ){
            status = SelectAmbulance.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;
    }



}
