fix: parsear d.data[] de la API de notas (no d.clinica/d.libres inexistentes)
This commit is contained in:
@@ -1641,11 +1641,14 @@ const notasManager = {
|
|||||||
async _cargar(domId) {
|
async _cargar(domId) {
|
||||||
const r = await fetch(`api/lab/get_notas_domicilio.php?domicilio_id=${domId}`);
|
const r = await fetch(`api/lab/get_notas_domicilio.php?domicilio_id=${domId}`);
|
||||||
const d = await r.json();
|
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
|
this._cache[domId] = d.success
|
||||||
? { clinica: d.clinica || null, libres: d.libres || [] }
|
? { clinica, libres }
|
||||||
: { clinica: null, libres: [] };
|
: { clinica: null, libres: [] };
|
||||||
// Actualizar badge
|
// 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}`);
|
const badge = document.getElementById(`nota-count-${domId}`);
|
||||||
if (badge) {
|
if (badge) {
|
||||||
badge.textContent = total;
|
badge.textContent = total;
|
||||||
|
|||||||
+6
-4
@@ -830,8 +830,9 @@ async function cargarNotasDetalle(domId) {
|
|||||||
const r = await fetch(`api/lab/get_notas_domicilio.php?domicilio_id=${domId}`);
|
const r = await fetch(`api/lab/get_notas_domicilio.php?domicilio_id=${domId}`);
|
||||||
const d = await r.json();
|
const d = await r.json();
|
||||||
if (!d.success) return;
|
if (!d.success) return;
|
||||||
const c = d.clinica || {};
|
const notas = d.data || [];
|
||||||
const libres = d.libres || [];
|
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 hayFicha = c.antecedentes || c.medicamentos || c.acudiente_nombre;
|
||||||
const hayLibres = libres.length > 0;
|
const hayLibres = libres.length > 0;
|
||||||
if (!hayFicha && !hayLibres) return;
|
if (!hayFicha && !hayLibres) return;
|
||||||
@@ -898,8 +899,9 @@ async function verInformeDom() {
|
|||||||
try {
|
try {
|
||||||
const r = await fetch(`api/lab/get_notas_domicilio.php?domicilio_id=${dom.id}`);
|
const r = await fetch(`api/lab/get_notas_domicilio.php?domicilio_id=${dom.id}`);
|
||||||
const d = await r.json();
|
const d = await r.json();
|
||||||
const c = d.success ? (d.clinica||{}) : {};
|
const notas = d.success ? (d.data || []) : [];
|
||||||
const libres = d.success ? (d.libres||[]) : [];
|
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-antecedentes').textContent = c.antecedentes || '—';
|
||||||
document.getElementById('inf-medicamentos').textContent = c.medicamentos || '—';
|
document.getElementById('inf-medicamentos').textContent = c.medicamentos || '—';
|
||||||
|
|||||||
Reference in New Issue
Block a user