package com.ruoyi.web.modules.diagnosis.support;

import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.web.modules.diagnosis.domain.BizMedicalResource;

/**
 * 在线问诊 — 兽医资源可问诊校验。
 */
public final class OnlineConsultVetSupport
{
    private OnlineConsultVetSupport()
    {
    }

    public static boolean hasOnlineConsultMode(String consultModesCsv)
    {
        if (StringUtils.isEmpty(consultModesCsv))
        {
            return false;
        }
        String target = String.valueOf(MedicalResourceRules.CONSULT_MODE_ONLINE);
        for (String part : consultModesCsv.split(","))
        {
            if (target.equals(part.trim()))
            {
                return true;
            }
        }
        return false;
    }

    public static boolean isConsultablePublishedVet(BizMedicalResource vet)
    {
        if (vet == null)
        {
            return false;
        }
        return MedicalResourceRules.RESOURCE_TYPE_VET.equals(vet.getResourceType())
                && MedicalResourceRules.DEL_FLAG_NORMAL.equals(vet.getDelFlag())
                && MedicalResourceRules.isPublished(vet.getPublishStatus())
                && hasOnlineConsultMode(vet.getConsultModes())
                && vet.getSysUserId() != null
                && vet.getAccountAssigned() != null
                && vet.getAccountAssigned() == MedicalResourceRules.ACCOUNT_ASSIGNED_YES;
    }
}
