fix(Internaciones): Ordenar tabla por orden de camas en lugar de fecha de ingreso
This commit is contained in:
@@ -137,6 +137,14 @@ export function Internaciones({
|
||||
}
|
||||
};
|
||||
|
||||
const sortedCamas = sortCamas(camas);
|
||||
|
||||
const getCamaIndex = (camaId?: string) => {
|
||||
if (!camaId) return 999999;
|
||||
const index = sortedCamas.findIndex(c => c.id === camaId);
|
||||
return index !== -1 ? index : 999999;
|
||||
};
|
||||
|
||||
const internacionesFiltradas = internaciones.filter(i => {
|
||||
const paciente = getPacienteById(i.pacienteId);
|
||||
const cumpleBusqueda = !busqueda ||
|
||||
@@ -151,15 +159,20 @@ export function Internaciones({
|
||||
(filtroEstado === 'finalizadas' && !i.activa);
|
||||
|
||||
return cumpleBusqueda && cumpleEstado;
|
||||
}).sort((a, b) => new Date(b.fechaIngresoClinica || '').getTime() - new Date(a.fechaIngresoClinica || '').getTime());
|
||||
}).sort((a, b) => {
|
||||
const indexA = getCamaIndex(a.camaId);
|
||||
const indexB = getCamaIndex(b.camaId);
|
||||
if (indexA !== indexB) {
|
||||
return indexA - indexB;
|
||||
}
|
||||
return new Date(b.fechaIngresoClinica || '').getTime() - new Date(a.fechaIngresoClinica || '').getTime();
|
||||
});
|
||||
|
||||
const pacientesSinInternar = pacientes.filter(p => {
|
||||
const internacionActiva = internaciones.find(i => i.pacienteId === p.id && i.activa);
|
||||
return !internacionActiva;
|
||||
});
|
||||
|
||||
const sortedCamas = sortCamas(camas);
|
||||
|
||||
const getGrupoName = (grupoId?: string) => grupos.find(a => a.id === grupoId)?.nombre;
|
||||
|
||||
const calcularEdad = (fechaNacimiento?: string) => {
|
||||
|
||||
Reference in New Issue
Block a user