feat: enrich sync log with exams, diagnosis, EPS and valor per patient
- scheduler.py: after sync_todos(), inject diagnostico, nit_empresa, valor_total and examenes_det (cups/nombre/precio) into each detalle entry - whatsapp_sync.py: guardar_sync_log stores full enriched fields in detalle_json - envios_erp.html: expanded row shows per-patient card with Dx, EPS, valor and a CUPS/examen/precio table — scrollable, max-h-96 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
e044f21e3e
commit
cd63683869
@@ -167,6 +167,21 @@ async def sync_recientes(ventana_min: int = 2) -> dict:
|
||||
resultado = await sync_todos(recientes, ingest_url, wa_key, timeout,
|
||||
modo="upsert", examenes_map=examenes_map)
|
||||
|
||||
# Enriquecer detalle con exámenes, diagnóstico, empresa y valor para el log
|
||||
for entry in resultado.get("detalle", []):
|
||||
doc = entry.get("doc", "")
|
||||
exams = examenes_map.get(doc, [])
|
||||
if exams:
|
||||
first = exams[0]
|
||||
entry["diagnostico_cod"] = first.get("diagnostico_cod", "")
|
||||
entry["diagnostico_nombre"] = first.get("diagnostico_nombre", "")
|
||||
entry["nit_empresa"] = first.get("nit_empresa", "")
|
||||
entry["valor_total"] = first.get("valor_total")
|
||||
entry["examenes_det"] = [
|
||||
{"cups": e.get("cups", ""), "nombre": e.get("nombre", ""), "precio": e.get("precio")}
|
||||
for e in exams
|
||||
]
|
||||
|
||||
if resultado["total"] > 0:
|
||||
guardar_sync_log(resultado, None, origen="scheduler", modo="upsert")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user