Exemplo n.º 1
0
 protected function __setData(stdClass $data)
 {
     try {
         $finalVisitTime = DateTime::create($data->final_visit_time);
         $visitEndTime = DateTime::create($data->visit_end_time);
     } catch (Exception $e) {
         throw new Exception('Время имеет неверный формат');
     }
     if ($finalVisitTime->getTimestamp() > $visitEndTime->getTimestamp()) {
         throw new Exception('Время приема не может быть позже времени окончания приема');
     }
     $timeChanged = false || $this->_entity->getFinalVisitTime() != $finalVisitTime->getTimestamp();
     $timeChanged = $timeChanged || $this->_entity->getVisitEndTime() != $visitEndTime->getTimestamp();
     if ($timeChanged) {
         $schedule = $this->_entity->getDoctor()->getSchedule($finalVisitTime);
         if (!$schedule->isAvailable($finalVisitTime, $visitEndTime, [(int) $this->_entity->getId()])) {
             throw new Exception('В это время доктор не принимает или занят');
         }
     }
     $this->_entity->setFinalVisitTime($finalVisitTime->getTimestamp());
     $this->_entity->setVisitEndTime($visitEndTime->getTimestamp());
     $serviceCollection = $this->_entity->getServiceCollection();
     $serviceCollection->resetItems();
     foreach ($data->id_services as $idService) {
         $service = Application_Model_Medical_Service::getById($idService);
         if ($service instanceof Application_Model_Medical_Service) {
             $serviceCollection->add($service);
         }
     }
     $this->_entity->setStatus($data->status);
 }
Exemplo n.º 2
0
 public function getNotProcessedCount()
 {
     $db = RM_Entity::getDb();
     /* @var Zend_Db_Select $select */
     $select = Application_Model_Medical_Reservation::_getSelect();
     $select->where('reservationStatus = ?', Application_Model_Medical_Reservation::STATUS_NEW);
     $select->columns(array('COUNT(*) as notProcessedCount'));
     if ($result = $db->fetchRow($select)) {
         return (int) $result->notProcessedCount;
     } else {
         return 0;
     }
 }
Exemplo n.º 3
0
 /**
  * @return Application_Model_Medical_Reservation|null
  */
 public function getFrom()
 {
     return Application_Model_Medical_Reservation::getById($this->getIdFrom());
 }
Exemplo n.º 4
0
 public function getStatus(Reservation $reservation)
 {
     return $this->getList()[$reservation->getStatus()];
 }
Exemplo n.º 5
0
 private function _save()
 {
     $this->_reservation->setLastSyncTime(DateTime::currentTimestamp());
     $this->_reservation->save();
 }
Exemplo n.º 6
0
 private function _buildReservation(Reservation $reservation)
 {
     $reservation->setDoctor($this->_doctor);
     $reservation->setDesiredVisitTime($this->_fromTime->getTimestamp());
     $reservation->setFinalVisitTime($this->_fromTime->getTimestamp());
     $reservation->setVisitEndTime($this->_toTime->getTimestamp());
     $reservation->setVisitorName($this->_data->visitorName);
     $reservation->setVisitorPhone($this->_data->visitorPhone);
     $serviceCollection = $reservation->getServiceCollection();
     foreach ($this->_services as $service) {
         $serviceCollection->add($service);
     }
     $reservation->setStatus($reservation::STATUS_NEW);
     $reservation->save();
     return $reservation;
 }
Exemplo n.º 7
0
 private function _getReservationDescription()
 {
     return join('; ', array('Клиент: ' . $this->_reservation->getVisitorName(), 'Телефон: ' . $this->_reservation->getVisitorPhone()));
 }