"""健康等级工具函数

根据评分获取健康等级及中文标签，供 scoring_service / geo_diagnosis 等模块复用。
"""


def get_health_level(score: float) -> str:
    """
    根据评分获取健康等级

    80+  -> excellent (优秀/绿)
    60-79 -> good (良好/黄)
    40-59 -> pass (及格/橙)
    <40  -> danger (危险/红)
    """
    if score >= 80:
        return "excellent"
    if score >= 60:
        return "good"
    if score >= 40:
        return "pass"
    return "danger"


def get_health_level_label(level: str) -> str:
    """获取健康等级中文标签"""
    labels = {
        "excellent": "优秀",
        "good": "良好",
        "pass": "及格",
        "danger": "危险",
    }
    return labels.get(level, "未知")
