feat(contratos): tabla de contratos con tipo_usuario por contrato
Agrega tabla `contratos` en SQLite sembrada con los 17 contratos del laboratorio. `generar_rda_paciente` consulta el mapa contrato→tipoUsuario como primera prioridad antes de derivar de TIPOUSU/TIPOUSUSISPRO. Incluye CRUD en /contratos con UI en sidebar. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
7d2a9df447
commit
0f3a760de4
@@ -134,7 +134,7 @@ def _calcular_descuento_pct(rows: list) -> int:
|
||||
|
||||
def generar_rda_paciente(rows: list, default_profesional: str = "", default_especialidad: str = "",
|
||||
default_remisionante: str = "00", default_prefijo: str = "00",
|
||||
numero_override: str = "") -> dict:
|
||||
numero_override: str = "", contrato_map: dict = None) -> dict:
|
||||
if not rows:
|
||||
return {}
|
||||
h = rows[0]
|
||||
@@ -191,15 +191,20 @@ def generar_rda_paciente(rows: list, default_profesional: str = "", default_espe
|
||||
cod_forma_pago = "CLIP" if es_particular else "INST"
|
||||
autorizacion = None if es_particular else (str(h.get("AUTORIZACION") or "").strip() or None)
|
||||
|
||||
# tipousuario: particular siempre "12"; para convenios usar TIPOUSUSISPRO o derivar
|
||||
# tipousuario: prioridad 1→tabla contratos, 2→particular, 3→TIPOUSUSISPRO/TIPOUSU
|
||||
_TIPOUSU_MAP = {"1": "11", "5": "07"} # EPS→11, Póliza→07
|
||||
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")
|
||||
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")
|
||||
|
||||
via_ingreso = "01"
|
||||
modalidad = "01"
|
||||
|
||||
Reference in New Issue
Block a user