Skip to content

Commit 0f45a4a

Browse files
author
aldoEMatamala
committed
feat(RIP-354): sobreturnos solo con agenda completa
1 parent 417f16b commit 0f45a4a

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -496,26 +496,33 @@ export class PuntoInicioComponent implements OnInit, OnDestroy {
496496
}
497497
});
498498
}
499-
499+
agendaTienePaciente(agenda) {
500+
let existePaciente = false;
501+
const lengthBloques = agenda.bloques.length;
502+
let indexBloque = 0;
503+
while (indexBloque < lengthBloques && !existePaciente) {
504+
const _turnos = agenda.bloques[indexBloque].turnos.filter(t => {
505+
existePaciente = (t.paciente && t.paciente.id) ? true : false;
506+
});
507+
indexBloque++;
508+
}
509+
return existePaciente;
510+
}
500511
/**
501512
* Recorremos los bloques y los turnos de una agenda
502513
* y verifica si hay algun paciente agregado
503514
*/
504515
getCantidadPacientes(agenda) {
505516
let total = 0;
506-
507517
const lengthBloques = agenda.bloques.length;
508518
for (let indexBloque = 0; indexBloque < lengthBloques; indexBloque++) {
509-
510519
const _turnos = agenda.bloques[indexBloque].turnos.filter(t => {
511520
total += (t.paciente && t.paciente.id) ? 1 : 0;
512521
});
513522
}
514523
if (agenda.sobreturnos && agenda.sobreturnos.length > 0) {
515524
total = total + agenda.sobreturnos.length;
516525
}
517-
518-
519526
return total;
520527
}
521528

@@ -564,7 +571,7 @@ export class PuntoInicioComponent implements OnInit, OnDestroy {
564571
const esDeHoy = moment().isSame(agenda.horaInicio, 'day');
565572
const esNominalizadaNoDinamica = !agenda.dinamica && agenda.nominalizada;
566573
const esDelUsuario = agenda?.profesionales?.some(p => p.id === this.auth.profesional);
567-
this.puedeDarSobreturno = esDeHoy && esNominalizadaNoDinamica && esDelUsuario;
574+
this.puedeDarSobreturno = esDeHoy && esNominalizadaNoDinamica && esDelUsuario && !agenda?.turnosDisponibles && this.agendaTienePaciente(agenda);
568575
}
569576

570577
@Unsubscribe()

0 commit comments

Comments
 (0)