feat: búsqueda de paciente en tiempo real + Enter selecciona el primero

- Búsqueda automática con debounce 300ms al escribir (sin necesidad de lupa)
- Enter: si ya hay resultados selecciona el primero, si no dispara la búsqueda

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-07-16 20:09:58 -05:00
co-authored by Claude Sonnet 4.6
parent 123ab0e034
commit 9df5f19c08
+13 -2
View File
@@ -1107,8 +1107,19 @@ document.addEventListener('DOMContentLoaded', () => {
cargarCola();
pollingColaId = setInterval(cargarCola, 3000);
document.getElementById('inp-buscar-pac')
.addEventListener('keydown', e => { if (e.key === 'Enter') buscarPaciente(); });
let _pacBusqTimer;
const _inpPac = document.getElementById('inp-buscar-pac');
_inpPac.addEventListener('input', () => {
clearTimeout(_pacBusqTimer);
_pacBusqTimer = setTimeout(buscarPaciente, 300);
});
_inpPac.addEventListener('keydown', e => {
if (e.key !== 'Enter') return;
e.preventDefault();
const first = document.querySelector('#lista-pacientes-res .pac-resultado');
if (first) { first.click(); return; }
buscarPaciente();
});
document.getElementById('sel-lugar')
.addEventListener('change', onLugarChange);
document.addEventListener('visibilitychange', () => {