public function isAvailable(DateTime $from, DateTime $to = null, array $excludeReservations = array()) { if (!$to) { $to = clone $from; $to->addSeconds($this->_doctor->getMinReceptionDuration()->getTimestamp()); } if (!$this->isWorkingAt($from) || !$this->isWorkingAt($to)) { return false; } return !$this->_reservationService->hasReservationsBetween($from, $to, $excludeReservations); }
private function _prepareVisitTime(array $excludedReservations = array()) { $this->_fromTime = MedOptima_DateTime::create($this->_data->visitDate . ' ' . $this->_data->visitTime); if ($this->_fromTime->isToday()) { throw new Exception('Can not make reservation for today'); } $this->_toTime = clone $this->_fromTime; $this->_toTime->addSeconds($this->_doctor->getMinReceptionDuration()->getTimestamp()); if (!$this->_doctor->getSchedule($this->_fromTime)->isAvailable($this->_fromTime, $this->_toTime, $excludedReservations)) { throw new Exception('Doctor is not available at this time (' . $this->_fromTime->getGostDatetime() . ')'); } }