public function dataSelection($room, $block, $year, $month, $day, $atention, $medic)
 {
     $date = $year . "-" . $month . "-" . $day;
     $checkRoom = ReservationInfo::where('reservationDate', '=', $date)->where('block_id', '=', $block)->where('room', '=', $room)->count();
     if ($checkRoom == 0) {
         //revisar si el medico tiene ocupada esas horas
         $findMedicConflict = Reservation::where('medic_id', $medic)->where('reservationDate', $date)->get();
         $checkMedic = 0;
         foreach ($findMedicConflict as $register) {
             $checkMedic += $register->ReservationsInfo->where('block_id', $block)->count();
         }
         if ($checkMedic == 0) {
             //
             $atention = Atention::find($atention);
             $numberOfBlocks = $atention->block_numbers;
             for ($i = 1; $i < $numberOfBlocks; $i++) {
                 $nextBlock = $block + $i;
                 $checkRoom = ReservationInfo::where('reservationDate', '=', $date)->where('block_id', '=', $nextBlock)->where('room', '=', $room)->count();
                 if ($checkRoom > 0) {
                     //cortar con un return, ya que hay una hora tomada despues
                     //que impide hacer la reserva en el bloque seleccionado
                     return response()->json(['estado' => 'invalido', 'mensaje' => 'La sala esta ocupada']);
                 }
                 $checkMedic = 0;
                 foreach ($findMedicConflict as $register) {
                     $checkMedic += $register->ReservationsInfo->where('block_id', $nextBlock)->count();
                 }
                 if ($checkMedic > 0) {
                     //medico ocupado
                     return response()->json(['estado' => 'invalido', 'mensaje' => 'El medico esta ocupado en uno de los bloques']);
                 }
             }
             $initialBlock = Block::find($block);
             $lastBlockId = $block + $numberOfBlocks - 1;
             $encontro = false;
             $lastBlock;
             while ($encontro == false) {
                 if (!($lastBlock = Block::find($lastBlockId))) {
                     $lastBlockId--;
                 } else {
                     $encontro = true;
                 }
             }
             $respuesta = ['estado' => 'valido', 'inicio' => $initialBlock->startBlock, 'fin' => $lastBlock->finishBlock, 'bloques' => $numberOfBlocks, 'blolqueInicial' => $initialBlock->id, 'bloqueFinal' => $lastBlock->id];
             return response()->json($respuesta);
         } else {
             //el medico esta ocupado en ese bloque
             return response()->json(['estado' => 'invalido', 'mensaje' => 'El medico esta ocupado a esa hora']);
         }
     } else {
         //la sala esta ocupada en ese horario
         return response()->json(['estado' => 'invalido', 'mensaje' => 'La sala esta ocupada a esa hora']);
     }
 }
 public function listAllAtentions()
 {
     $atentions = Atention::orderBy('name')->get();
     return response()->json($atentions);
 }