@@ -496,26 +496,27 @@ export class PuntoInicioComponent implements OnInit, OnDestroy {
496496 }
497497 } ) ;
498498 }
499-
500499 /**
501- * Recorremos los bloques y los turnos de una agenda
502- * y verifica si hay algun paciente agregado
500+ * Comprueba si el la agenda tiene al menos un turno con paciente en al menos un bloque
503501 */
502+ agendaTienePaciente ( agenda ) {
503+ return agenda . bloques . some ( ( bloque ) => {
504+ return bloque . turnos . some ( ( turno ) => {
505+ return turno . paciente ?. id ;
506+ } ) ;
507+ } ) ;
508+ }
504509 getCantidadPacientes ( agenda ) {
505510 let total = 0 ;
506-
507511 const lengthBloques = agenda . bloques . length ;
508512 for ( let indexBloque = 0 ; indexBloque < lengthBloques ; indexBloque ++ ) {
509-
510513 const _turnos = agenda . bloques [ indexBloque ] . turnos . filter ( t => {
511514 total += ( t . paciente && t . paciente . id ) ? 1 : 0 ;
512515 } ) ;
513516 }
514517 if ( agenda . sobreturnos && agenda . sobreturnos . length > 0 ) {
515518 total = total + agenda . sobreturnos . length ;
516519 }
517-
518-
519520 return total ;
520521 }
521522
@@ -564,7 +565,7 @@ export class PuntoInicioComponent implements OnInit, OnDestroy {
564565 const esDeHoy = moment ( ) . isSame ( agenda . horaInicio , 'day' ) ;
565566 const esNominalizadaNoDinamica = ! agenda . dinamica && agenda . nominalizada ;
566567 const esDelUsuario = agenda ?. profesionales ?. some ( p => p . id === this . auth . profesional ) ;
567- this . puedeDarSobreturno = esDeHoy && esNominalizadaNoDinamica && esDelUsuario ;
568+ this . puedeDarSobreturno = esDeHoy && esNominalizadaNoDinamica && esDelUsuario && ! agenda ?. turnosDisponibles && this . agendaTienePaciente ( agenda ) ;
568569 }
569570
570571 @Unsubscribe ( )
0 commit comments