fix(tipousuario): contrato 012 no debe ser tratado como particular
El check `"012".lstrip("0") == "12"` causaba false positive marcando
contratos EPS como particulares. Ahora la heurística solo aplica si el
contrato no está en la tabla contratos; si está, el tipo_usuario del mapa
tiene precedencia y también controla es_particular.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
0f3a760de4
commit
d3a6ab7ab6
@@ -182,29 +182,34 @@ def generar_rda_paciente(rows: list, default_profesional: str = "", default_espe
|
||||
|
||||
nit_empresa = str(h.get("NIT_EMPRESA") or "").strip()
|
||||
cod_contrato_raw = str(h.get("CODCONTRATO") or "").strip()
|
||||
# Particular: por NIT_EMPRESA "PART" o por contrato "12"/"012"
|
||||
|
||||
# Resolver tipo desde contrato_map primero (tiene prioridad sobre heurísticas)
|
||||
_TIPOUSU_MAP = {"1": "11", "5": "07"} # EPS→11, Póliza→07
|
||||
_nc_s = cod_contrato_raw.lstrip("0") or cod_contrato_raw
|
||||
_map_tipo = ""
|
||||
if contrato_map and cod_contrato_raw:
|
||||
_map_tipo = contrato_map.get(cod_contrato_raw) or contrato_map.get(_nc_s) or ""
|
||||
|
||||
# es_particular: NIT "PART", o mapa dice "12", o heurística solo si no está en el mapa
|
||||
es_particular = (
|
||||
nit_empresa.upper() in ("PART", "PARTICULAR", "", "0")
|
||||
or cod_contrato_raw.lstrip("0") == "12"
|
||||
or (_map_tipo == "12")
|
||||
or (not _map_tipo and cod_contrato_raw.lstrip("0") == "12")
|
||||
)
|
||||
cod_contrato = cod_contrato_raw or ("012" if es_particular else None)
|
||||
cod_forma_pago = "CLIP" if es_particular else "INST"
|
||||
autorizacion = None if es_particular else (str(h.get("AUTORIZACION") or "").strip() or None)
|
||||
|
||||
# tipousuario: prioridad 1→tabla contratos, 2→particular, 3→TIPOUSUSISPRO/TIPOUSU
|
||||
_TIPOUSU_MAP = {"1": "11", "5": "07"} # EPS→11, Póliza→07
|
||||
tipoususispro = ""
|
||||
if contrato_map and cod_contrato_raw:
|
||||
_nc_s = cod_contrato_raw.lstrip("0") or cod_contrato_raw
|
||||
tipoususispro = contrato_map.get(cod_contrato_raw) or contrato_map.get(_nc_s) or ""
|
||||
if not tipoususispro:
|
||||
if es_particular:
|
||||
tipoususispro = "12"
|
||||
else:
|
||||
tipoususispro = str(h.get("TIPOUSUSISPRO") or "").strip()
|
||||
if not tipoususispro:
|
||||
tipousu = str(h.get("TIPOUSU") or "").strip()
|
||||
tipoususispro = _TIPOUSU_MAP.get(tipousu, "11")
|
||||
# tipousuario: prioridad 1→mapa contratos, 2→particular, 3→TIPOUSUSISPRO/TIPOUSU
|
||||
if _map_tipo:
|
||||
tipoususispro = _map_tipo
|
||||
elif es_particular:
|
||||
tipoususispro = "12"
|
||||
else:
|
||||
tipoususispro = str(h.get("TIPOUSUSISPRO") or "").strip()
|
||||
if not tipoususispro:
|
||||
tipousu = str(h.get("TIPOUSU") or "").strip()
|
||||
tipoususispro = _TIPOUSU_MAP.get(tipousu, "11")
|
||||
|
||||
via_ingreso = "01"
|
||||
modalidad = "01"
|
||||
|
||||
Reference in New Issue
Block a user