from __future__ import annotations

from typing import Final


RIPS_TIPO_USUARIO_VERSION2: Final[dict[str, str]] = {
    "01": "Contributivo cotizante",
    "02": "Contributivo beneficiario",
    "03": "Contributivo adicional",
    "04": "Subsidiado",
    "05": "No afiliado",
    "06": "Especial o Excepcion cotizante",
    "07": "Especial o Excepcion beneficiario",
    "08": "Personas privadas de la libertad a cargo del Fondo Nacional de Salud",
    "09": "Tomador / Amparado ARL",
    "10": "Tomador / Amparado SOAT",
    "11": "Tomador / Amparado Planes voluntarios de salud",
    "12": "Particular",
    "13": "Especial o Excepcion no cotizante Ley 352 de 1997",
}

ZONA_VERSION2: Final[dict[str, str]] = {
    "01": "Rural",
    "02": "Urbano",
}

LST_SI_NO: Final[dict[str, str]] = {
    "SI": "SI",
    "NO": "NO",
}

CONCEPTO_RECAUDO: Final[dict[str, str]] = {
    "01": "COPAGO",
    "02": "CUOTA MODERADORA",
    "03": "PAGOS COMPARTIDOS EN PLANES VOLUNTARIOS DE SALUD",
    "04": "ANTICIPO",
    "05": "NO APLICA",
}

# The "TipoOtrosServicios" SISPRO table is referenced by the anexo tecnico.
# We encode the stable identifiers used by the ministerial examples and field
# descriptions so the application validates only supported categories.
TIPO_OTRO_SERVICIO: Final[dict[str, str]] = {
    "01": "DISPOSITIVOS MEDICOS E INSUMOS",
    "02": "TRASLADO Y TRANSPORTE",
    "03": "ESTANCIAS",
    "04": "SERVICIOS COMPLEMENTARIOS",
}

OTHER_SERVICE_SOURCE_SECTIONS: Final[set[str]] = {
    "examenes_laboratorio",
    "imagenologia",
    "hospitalizacion",
    "honorarios_medicos",
    "otros_servicios",
}

_LEGACY_LST_SI_NO_MAP: Final[dict[str, str]] = {
    "01": "SI",
    "02": "NO",
    "SI": "SI",
    "NO": "NO",
}


def normalize_catalog_code(value: str | None) -> str:
    return str(value or "").strip().upper()


def normalize_lst_si_no(value: str | None) -> str:
    normalized = normalize_catalog_code(value)
    return _LEGACY_LST_SI_NO_MAP.get(normalized, normalized)
