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

import com.ywt.mg.domain.models.ConstantDef;

/**
 * 终端类型
 */
public enum TerminalEnum {
    UNKNOWN("未知来源", -1),
    PatientWxApp("微信小程序患者版", 1),
    //  PatientWxOfficial("微信公众号患者版", 2), ——》 后台显示更改为： 南方医务通公众号
    PatientWxOfficial("南方医务通公众号", 2),
    DoctorAndroid("安卓医生版", 3),
    DoctorIOS("苹果医生版", 4),
    PatientAndroid("安卓患者版", 5),
    PatientIOS("苹果患者版", 6),
    DoctorWxOfficial("微信公众号医生版", 7),
    TaiheWxOfficial("南方医院太和分院公众号", 8),
    NfHealth("南方大健康", 9),
    TAI_HE_OFFICIAL("太和医院官网", 10),
    TAI_HE_INTERNET_HOSPITAL_PATIENT_MINI_PROGRAM("太和互联网医院患者端小程序版", 11),
    TAI_HE_INTERNET_HOSPITAL_PATIENT_WX_OFFICIAL("太和互联网医院患者端公众号版", 12),
    TAI_HE_INTERNET_HOSPITAL_DOCTOR_WX_OFFICIAL("太和互联网医院医生端公众号版", 13),
    GD_YWT_WX_OFFICIAL("广东医务通公众号", 14),
    PRESCRIPTION_SYSTEM_PC("处方系统PC端", 15),
    DOCTOR_MINI_PROGRAM("医生端小程序", 16),
    /**
     * 医生端小程序内嵌H5页面，
     * 接口路径前缀为：thnetdocexapi
     * 接口地址如：https://m-qa.ywtinfo.com/thnetdocexapi/account/doctor
     */
    DOCTOR_H5("医生端H5", 17),
    YWT_CLOUD_PLATFORM_PATIENT_MINI_PROGRAM("医务通云平台患者端小程序版", 18),
    ORDER_SERVICE_MINI_PROGRAM("下单服务助手小程序", 19),
    NF_HOSPITAL_BY_PATIENT_MINI_PROGRAM("南方医科大学南方医院白云分院微信小程序", 20),
    NF_HOSPITAL_BY_PATIENT_WX_OFFICIAL("南方医院白云分院公众号", 21),
    NF_HOSPITAL_BY_DOCTOR_WX_OFFICIAL("南方医院白云分院医生版公众号", 22),
    NF_HOSPITAL_BY_PATIENT_MINI_PROGRAM_ZFB("南方医科大学南方医院白云分院支付宝小程序", 24),
    NF_HOSPITAL_TH_PATIENT_MINI_PROGRAM_ZFB("南方医院太和分院支付宝小程序", 25);

    private final String displayName;

    private final int value;

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

    public static TerminalEnum getTerminalByHospitalId(int hospitalId) {
        if (hospitalId == ConstantDef.TAIHE_HOSPITAL_ID){
            return TAI_HE_INTERNET_HOSPITAL_PATIENT_MINI_PROGRAM;
        }
        if (hospitalId == ConstantDef.NFBY_HOSPITAL_ID){
            return NF_HOSPITAL_BY_PATIENT_MINI_PROGRAM;
        }
        if(hospitalId == ConstantDef.TAIHE_HOSPITAL_ID){
            return TaiheWxOfficial;
        }
        return YWT_CLOUD_PLATFORM_PATIENT_MINI_PROGRAM;
    }


    public  static TerminalEnum getTerminalByHospId (int hospitalId){
        if (hospitalId == ConstantDef.NFBY_HOSPITAL_ID){
            return NF_HOSPITAL_BY_PATIENT_MINI_PROGRAM;
        }
        if(hospitalId == ConstantDef.TAIHE_HOSPITAL_ID){
            return TaiheWxOfficial;
        }
        return YWT_CLOUD_PLATFORM_PATIENT_MINI_PROGRAM;
    }

    public String getDisplayName() {
        return displayName;
    }

    public int getValue() {
        return value;
    }


    public static boolean isDoctorTerminal(int terminal) {
        for (TerminalEnum terminalEnum : getDoctorTerminal()) {
            if (terminalEnum.getValue() == terminal) {
                return true;
            }
        }
        return false;
    }

    /**
     * 判断终端是否是患者版
     *
     * @param terminal 终端
     * @return ture or fasle
     */
    public static boolean isPatientTerminal(int terminal) {
        for (TerminalEnum terminalEnum : getPatientTerminals()) {
            if (terminalEnum.getValue() == terminal) {
                return true;
            }
        }
        return false;
    }

    /**
     * 患者版终端
     */
    public static TerminalEnum[] getPatientTerminals() {
        return new TerminalEnum[]{
                PatientAndroid,
                PatientIOS,
                PatientWxApp,
                PatientWxOfficial,
                TAI_HE_INTERNET_HOSPITAL_PATIENT_MINI_PROGRAM,
                TAI_HE_INTERNET_HOSPITAL_PATIENT_WX_OFFICIAL
        };
    }

    /**
     * 医生终端
     *
     * @return
     */
    public static TerminalEnum[] getDoctorTerminal() {
        return new TerminalEnum[]{
                DoctorAndroid,
                DoctorIOS,
                DoctorWxOfficial,
                TAI_HE_INTERNET_HOSPITAL_DOCTOR_WX_OFFICIAL
        };
    }


    public static TerminalEnum valueOf (int value){
        for(TerminalEnum terminalEnum : TerminalEnum.values()){
            if(terminalEnum.value == value){
                return terminalEnum;
            }
        }
        return UNKNOWN;
    }

    /**
     * 后台常用终端
     *
     * @return TerminalEnum[]
     */
    public static TerminalEnum[] getBackCommonTerminals() {
        return new TerminalEnum[]{
                TAI_HE_INTERNET_HOSPITAL_PATIENT_MINI_PROGRAM,
                TAI_HE_INTERNET_HOSPITAL_DOCTOR_WX_OFFICIAL,
                DOCTOR_MINI_PROGRAM,
                PatientWxOfficial,
                TaiheWxOfficial,
                NfHealth,
                PatientWxApp,
                PRESCRIPTION_SYSTEM_PC,
                DoctorWxOfficial
        };
    }

}
