recepcion: quitar botón duplicar del historial (va en sección formatos)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
78e71d5926
commit
a0979e31e7
@@ -447,13 +447,6 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
<button class="hist-toggle-btn" id="btn-hist-toggle" onclick="toggleHistorialPaciente()">
|
||||
<i class="fas fa-history" style="color:#6366f1"></i>
|
||||
Historial del paciente
|
||||
<span id="btn-duplicar-wrap" class="ms-auto d-none">
|
||||
<span class="btn btn-outline-indigo btn-sm py-0 px-2"
|
||||
style="font-size:.7rem;border-color:#6366f1;color:#6366f1;background:#fff;border-radius:6px"
|
||||
onmousedown="event.stopPropagation();duplicarUltimaVisita()">
|
||||
<i class="fas fa-copy me-1"></i>Duplicar
|
||||
</span>
|
||||
</span>
|
||||
<i class="fas fa-chevron-down hist-chev"></i>
|
||||
</button>
|
||||
<div id="hist-pac-body" class="hist-pac-body d-none">
|
||||
@@ -1185,7 +1178,6 @@ function seleccionarPaciente(pac) {
|
||||
// Resetear estado colapsado
|
||||
document.getElementById('hist-pac-body').classList.add('d-none');
|
||||
document.getElementById('btn-hist-toggle').classList.remove('open');
|
||||
document.getElementById('btn-duplicar-wrap').classList.remove('d-none');
|
||||
// Precargar en background (usuario decide si abre)
|
||||
_historialPacienteCargado = false;
|
||||
_historialPacienteId = pac.id;
|
||||
@@ -1222,7 +1214,6 @@ function desvincularPaciente() {
|
||||
document.getElementById('sec-historial-pac').classList.add('d-none');
|
||||
document.getElementById('hist-pac-body').classList.add('d-none');
|
||||
document.getElementById('btn-hist-toggle').classList.remove('open');
|
||||
document.getElementById('btn-duplicar-wrap').classList.add('d-none');
|
||||
document.getElementById('lista-pacientes-res').innerHTML = '';
|
||||
document.getElementById('inp-buscar-pac').value = '';
|
||||
document.getElementById('chk-embarazada').checked = false;
|
||||
@@ -1761,45 +1752,6 @@ function resetMedico() {
|
||||
quitarMedico();
|
||||
}
|
||||
|
||||
async function duplicarUltimaVisita() {
|
||||
if (!_historialPacienteId) { mostrarError('No hay paciente seleccionado.'); return; }
|
||||
mostrarToast('Buscando última visita…', 'info', 1500);
|
||||
try {
|
||||
// 1. Obtener el turno más reciente del paciente
|
||||
const rH = await fetch(`${API}get_historial.php?paciente_id=${_historialPacienteId}&per_page=1&page=1`);
|
||||
const jH = await rH.json();
|
||||
if (!jH.ok || !jH.turnos?.length) { mostrarError('Sin visitas anteriores para duplicar.'); return; }
|
||||
const ultimoTurnoId = jH.turnos[0].id;
|
||||
|
||||
// 2. Obtener solicitud + exámenes de esa visita
|
||||
const rS = await fetch(`${API}get_consentimientos.php?turno_id=${ultimoTurnoId}&incluir_solicitud=1`);
|
||||
const jS = await rS.json();
|
||||
if (!jS.ok || !jS.examenes?.length) { mostrarError('La última visita no tiene exámenes registrados.'); return; }
|
||||
|
||||
// 3. Pre-marcar checkboxes con los exam_tipo_ids
|
||||
const ids = new Set(jS.examenes.map(e => String(e.id)));
|
||||
let marcados = 0;
|
||||
document.querySelectorAll('.exam-chk').forEach(c => {
|
||||
const match = ids.has(c.value);
|
||||
c.checked = match;
|
||||
if (match) marcados++;
|
||||
});
|
||||
|
||||
// 4. Pre-llenar pago si viene
|
||||
if (jS.solicitud?.metodo_pago) {
|
||||
document.getElementById('sel-pago').value = jS.solicitud.metodo_pago;
|
||||
togglePagoCombinado();
|
||||
}
|
||||
if (jS.solicitud?.total_cobrado) {
|
||||
document.getElementById('inp-total').value = jS.solicitud.total_cobrado;
|
||||
}
|
||||
|
||||
mostrarToast(`Duplicado: ${marcados} exámen${marcados !== 1 ? 'es' : ''} copiado${marcados !== 1 ? 's' : ''}.`, 'success', 3000);
|
||||
} catch (e) {
|
||||
mostrarError('Error al duplicar: ' + e.message);
|
||||
}
|
||||
}
|
||||
|
||||
function escJs(s) { return String(s||'').replace(/\\/g,'\\\\').replace(/'/g,"\\'"); }
|
||||
|
||||
function toggleSoloMuestras() {
|
||||
|
||||
Reference in New Issue
Block a user