fix: parsear d.data[] de la API de notas (no d.clinica/d.libres inexistentes)

This commit is contained in:
Lizandro Guarnizo
2026-03-25 14:21:17 -05:00
parent 921c6abd8c
commit 7917f4852e
2 changed files with 11 additions and 6 deletions
+6 -4
View File
@@ -830,8 +830,9 @@ async function cargarNotasDetalle(domId) {
const r = await fetch(`api/lab/get_notas_domicilio.php?domicilio_id=${domId}`);
const d = await r.json();
if (!d.success) return;
const c = d.clinica || {};
const libres = d.libres || [];
const notas = d.data || [];
const c = notas.find(n => n.tipo === 'clinica') || {};
const libres = notas.filter(n => n.tipo === 'libre');
const hayFicha = c.antecedentes || c.medicamentos || c.acudiente_nombre;
const hayLibres = libres.length > 0;
if (!hayFicha && !hayLibres) return;
@@ -898,8 +899,9 @@ async function verInformeDom() {
try {
const r = await fetch(`api/lab/get_notas_domicilio.php?domicilio_id=${dom.id}`);
const d = await r.json();
const c = d.success ? (d.clinica||{}) : {};
const libres = d.success ? (d.libres||[]) : [];
const notas = d.success ? (d.data || []) : [];
const c = notas.find(n => n.tipo === 'clinica') || {};
const libres = notas.filter(n => n.tipo === 'libre');
document.getElementById('inf-antecedentes').textContent = c.antecedentes || '—';
document.getElementById('inf-medicamentos').textContent = c.medicamentos || '—';