fix: parsear d.data[] de la API de notas (no d.clinica/d.libres inexistentes)
This commit is contained in:
+6
-4
@@ -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 || '—';
|
||||
|
||||
Reference in New Issue
Block a user