fix: clearCache en TomSelect para aplicar filtro de género correctamente

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-07-17 16:51:29 -05:00
co-authored by Claude Sonnet 4.6
parent 3eaade80ff
commit 67f6e23ffd
+3 -2
View File
@@ -1630,14 +1630,15 @@ function filtrarExamenesPorGenero() {
if (!examTS) return;
const genero = (pacienteActivo?.genero || '').toUpperCase();
const bloqueados = [];
Object.values(examTS.options).forEach(opt => {
Object.entries(examTS.options).forEach(([val, opt]) => {
const gp = (opt['data-genero'] || '').toUpperCase();
const incompatible = !!(gp && genero && gp !== genero);
opt.disabled = incompatible;
if (incompatible && examTS.items.includes(String(opt.value))) bloqueados.push(String(opt.value));
if (incompatible && examTS.items.includes(String(val))) bloqueados.push(String(val));
});
bloqueados.forEach(id => examTS.removeItem(id, true));
if (bloqueados.length) recalcularPrecios();
examTS.clearCache();
examTS.refreshOptions(false);
}