getMostRecentEventByType() public method

Get the most recent event by the given type in this episode.
public getMostRecentEventByType ( $event_type_id ) : Event
$event_type_id
return Event
Ejemplo n.º 1
0
 /**
  * gets the element of type $element for the given patient in the given episode
  *
  * @param Patient $patient - the patient
  * @param Episode $episode - the episode
  * @param string $element - the element class
  *
  * @return unknown - the element type requested, or null
  */
 public function getElementForLatestEventInEpisode($patient, $episode, $element)
 {
     $event_type = $this->getEventType();
     if ($event = $episode->getMostRecentEventByType($event_type->id)) {
         $criteria = new CDbCriteria();
         $criteria->compare('episode_id', $episode->id);
         $criteria->compare('event_id', $event->id);
         $criteria->order = 'event.created_date desc';
         return $element::model()->with('event')->find($criteria);
     }
 }