Example #1
0
 /**
  * @return Appointment
  * @throws Exception
  */
 public function bookDITFollowUp()
 {
     if (!$this->isDIT(self::DIT_BOOKED)) {
         throw new Exception('cannot book DIT follow up for not DIT appointment');
     }
     $followUpApp = new self();
     $followUpApp->attributes = $this->attributes;
     $followUpApp->app_type = self::TYPE_VIEWING_FOLLOW_UP;
     $followUpApp->app_start = date("Y-m-d H:i:s", strtotime($this->app_start . ' + 1 day'));
     $followUpApp->app_end = date("Y-m-d H:i:s", strtotime($this->app_end . ' + 1 day'));
     $followUpApp->app_user = $this->app_user;
     $followUpApp->app_status = self::STATUS_ACTIVE;
     $followUpApp->app_bookedby = $this->app_bookedby;
     $followUpApp->followUpAppointmentId = $this->app_id;
     $instructions = [];
     foreach ($this->instructions as $instruction) {
         $instructions[] = $instruction->dea_id;
     }
     $clients = [];
     foreach ($this->clients as $client) {
         $clients[] = $client->cli_id;
     }
     $followUpApp->setInstructions($instructions);
     $followUpApp->setClients($clients);
     if ($followUpApp->save()) {
         $this->DIT = self::DIT_WITH_FOLLOW_UP;
         $this->save();
     }
     return $followUpApp;
 }