Skip to content

Commit f46c216

Browse files
author
aldoEMatamala
committed
feat(RIP-354): sobreturnos solo con agenda completa
1 parent 9b24616 commit f46c216

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/app/modules/rup/components/ejecucion/puntoInicio.component.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -514,26 +514,24 @@ export class PuntoInicioComponent implements OnInit, OnDestroy {
514514
}
515515
});
516516
}
517-
518517
/**
519-
* Recorremos los bloques y los turnos de una agenda
520-
* y verifica si hay algun paciente agregado
518+
* Comprueba si la agenda tiene al menos paciente en al menos un turno en al menos un bloque
521519
*/
520+
agendaTienePaciente(agenda) {
521+
return agenda.bloques.some((bloque) => bloque.turnos.some((turno) => turno.paciente?.id));
522+
523+
}
522524
getCantidadPacientes(agenda) {
523525
let total = 0;
524-
525526
const lengthBloques = agenda.bloques.length;
526527
for (let indexBloque = 0; indexBloque < lengthBloques; indexBloque++) {
527-
528528
const _turnos = agenda.bloques[indexBloque].turnos.filter(t => {
529529
total += (t.paciente && t.paciente.id) ? 1 : 0;
530530
});
531531
}
532532
if (agenda.sobreturnos && agenda.sobreturnos.length > 0) {
533533
total = total + agenda.sobreturnos.length;
534534
}
535-
536-
537535
return total;
538536
}
539537

@@ -582,7 +580,7 @@ export class PuntoInicioComponent implements OnInit, OnDestroy {
582580
const esDeHoy = moment().isSame(agenda.horaInicio, 'day');
583581
const esNominalizadaNoDinamica = !agenda.dinamica && agenda.nominalizada;
584582
const esDelUsuario = agenda?.profesionales?.some(p => p.id === this.auth.profesional);
585-
this.puedeDarSobreturno = esDeHoy && esNominalizadaNoDinamica && esDelUsuario;
583+
this.puedeDarSobreturno = esDeHoy && esNominalizadaNoDinamica && esDelUsuario && !agenda?.turnosDisponibles && this.agendaTienePaciente(agenda);
586584
}
587585

588586
@Unsubscribe()
@@ -640,7 +638,7 @@ export class PuntoInicioComponent implements OnInit, OnDestroy {
640638
}
641639

642640
cargarPrestacionesTurnos(agenda) {
643-
// loopeamos agendas y vinculamos el turno si existe con alguna de las prestaciones
641+
// loopeamos agendas y vinculamos el turno si existe con alguna de las prestaciones
644642
agenda['cantidadTurnos'] = 0;
645643
agenda.bloques.forEach(bloques => {
646644
agenda['cantidadTurnos'] += bloques.turnos.length;

0 commit comments

Comments
 (0)