Fix profesional/especialidad: use MEDICO.CODIGO first, add config defaults
- SQL query now prioritizes MEDICO.CODIGO over RECEPCION.USUARIO as profesional (USUARIO is the billing clerk; MEDICO is the medical professional) - Add profesional_default and especialidad_default config keys for when Firebird data is empty or contains invalid values (e.g. especialidad = ".") - generar_rda_paciente accepts default_profesional and default_especialidad params - ensure_defaults in queries.py now updates existing query records on startup Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
fbdce1c790
commit
c70f0f1062
@@ -59,7 +59,7 @@ SELECT
|
||||
rel.PRECIO,
|
||||
rel.FECHA_REPORTADO,
|
||||
m.COD_ESPECIALIDAD,
|
||||
COALESCE(NULLIF(TRIM(r.USUARIO), ''), TRIM(m.CODIGO), '') AS profesional
|
||||
COALESCE(NULLIF(TRIM(m.CODIGO), ''), NULLIF(TRIM(r.USUARIO), ''), '') AS profesional
|
||||
FROM RECEPCION r
|
||||
JOIN RELACION rel ON rel.IDRECEPCION = r.IDRECEPCION
|
||||
LEFT JOIN MEDICO m ON m.CODIGO = r.COD_MEDICO
|
||||
@@ -229,10 +229,12 @@ async def run_automation(
|
||||
endpoint = f"{TNS_BASE}/v2/rda/RdaPaciente/Insertar"
|
||||
if api_sucursal:
|
||||
endpoint += f"?codigosucursal={api_sucursal}"
|
||||
prof_def = configs.get("profesional_default", "")
|
||||
esp_def = configs.get("especialidad_default", "")
|
||||
|
||||
async with httpx.AsyncClient(timeout=timeout) as client:
|
||||
for id_recepcion, grupo_rows in grupos.items():
|
||||
rda_json = generar_rda_paciente(grupo_rows)
|
||||
rda_json = generar_rda_paciente(grupo_rows, prof_def, esp_def)
|
||||
factura = str(grupo_rows[0].get("NUM_FACTURA", id_recepcion))
|
||||
try:
|
||||
resp = await client.post(endpoint, json=rda_json, headers=headers)
|
||||
|
||||
Reference in New Issue
Block a user