audit() public method

public audit ( $target, $action, $data = null, $log = false, $properties = [] )
Ejemplo n.º 1
0
 /**
  * add an episode to the patient for the given Firm
  *
  * @param $firm
  * @return Episode
  * @throws Exception
  */
 public function addEpisode($firm)
 {
     $episode = new Episode();
     $episode->patient_id = $this->id;
     if ($firm->getSubspecialtyID()) {
         $episode->firm_id = $firm->id;
     } else {
         $episode->support_services = true;
     }
     $episode->start_date = date("Y-m-d H:i:s");
     if (!$episode->save()) {
         OELog::log("Unable to create new episode for patient_id={$episode->patient_id}, firm_id={$episode->firm_id}, start_date='{$episode->start_date}'");
         throw new Exception('Unable to create create episode: ' . print_r($episode->getErrors(), true));
     }
     OELog::log("New episode created for patient_id={$episode->patient_id}, firm_id={$episode->firm_id}, start_date='{$episode->start_date}'");
     $episode->audit('episode', 'create');
     Yii::app()->event->dispatch('episode_after_create', array('episode' => $episode));
     return $episode;
 }