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
@@ -14,6 +14,7 @@ from app.services.json_generator import (
|
||||
)
|
||||
from app.services.api_client import get_tns_token, TNS_BASE
|
||||
from app.services.whatsapp_sync import sync_paciente, sync_todos, guardar_sync_log
|
||||
from app.routes.contratos import load_contrato_map
|
||||
|
||||
router = APIRouter(prefix="/automation", tags=["automation"])
|
||||
|
||||
@@ -278,12 +279,13 @@ async def run_automation(
|
||||
esp_def = configs.get("especialidad_default", "")
|
||||
remis_def = configs.get("remisionante_default", "00")
|
||||
prefijo_def = configs.get("prefijo_tns_default", "00")
|
||||
contrato_map = load_contrato_map()
|
||||
|
||||
async with httpx.AsyncClient(timeout=timeout) as client:
|
||||
for id_recepcion, grupo_rows in grupos.items():
|
||||
num_fac = str(grupo_rows[0].get("NUM_FACTURA") or "").strip()
|
||||
num_override = num_fac
|
||||
rda_json = generar_rda_paciente(grupo_rows, prof_def, esp_def, remis_def, prefijo_def, num_override)
|
||||
rda_json = generar_rda_paciente(grupo_rows, prof_def, esp_def, remis_def, prefijo_def, num_override, contrato_map=contrato_map)
|
||||
factura = num_override or str(id_recepcion)
|
||||
try:
|
||||
resp = await client.post(endpoint, json=rda_json, headers=headers)
|
||||
|
||||
Reference in New Issue
Block a user