diff --git a/enfermero_portal.php b/enfermero_portal.php index 306586a..f83c8d3 100644 --- a/enfermero_portal.php +++ b/enfermero_portal.php @@ -1641,11 +1641,14 @@ const notasManager = { async _cargar(domId) { const r = await fetch(`api/lab/get_notas_domicilio.php?domicilio_id=${domId}`); const d = await r.json(); + const notas = d.success ? (d.data || []) : []; + const clinica = notas.find(n => n.tipo === 'clinica') || null; + const libres = notas.filter(n => n.tipo === 'libre'); this._cache[domId] = d.success - ? { clinica: d.clinica || null, libres: d.libres || [] } + ? { clinica, libres } : { clinica: null, libres: [] }; // Actualizar badge - const total = (d.libres || []).length + (d.clinica ? 1 : 0); + const total = libres.length + (clinica ? 1 : 0); const badge = document.getElementById(`nota-count-${domId}`); if (badge) { badge.textContent = total; diff --git a/lab_domicilios.php b/lab_domicilios.php index 2cc51ce..a60ba90 100644 --- a/lab_domicilios.php +++ b/lab_domicilios.php @@ -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 || '—';