feat: use ITEM.CUPS_DETALLE as codigoMaterial in RDA

LEFT JOIN ITEM on COD_EXAMEN to get CUPS_DETALLE. Falls back to
COD_EXAMEN if CUPS is empty. Applied to automation, test_rda, and
saved queries in SQLite.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-07-01 12:20:22 -05:00
co-authored by Claude Sonnet 4.6
parent ebd45446a4
commit ff08c1b3a8
3 changed files with 7 additions and 2 deletions
+1 -1
View File
@@ -149,7 +149,7 @@ def generar_rda_paciente(rows: list, default_profesional: str = "", default_espe
_doc = str(row.get("DOCIDMEDICO") or "").strip()
cedula_medico = _re.sub(r"[^0-9]", "", _doc)
detalle_pedido.append({
"codigoMaterial": str(row.get("COD_EXAMEN") or "").strip(),
"codigoMaterial": str(row.get("CUPS") or row.get("COD_EXAMEN") or "").strip(),
"codigoBodega": "00",
"cantidad": 1,
"tipoUnidad": "D",