protected function getPendingApplications()
{
$command = Yii::app()->db->createCommand();
return $command->select('patient.hos_num as HosNum,
event.id as EventID,
firm.name as FirmName,
CONCAT_WS(" ", user.first_name, user.last_name) as Username,
event.created_date as Created,
event.last_modified_date as Modified')->from('event')->join('episode', 'event.episode_id = episode.id')->join('patient', 'episode.patient_id = patient.id')->join('firm', 'episode.firm_id = firm.id')->join('user', 'event.created_user_id = user.id')->join('event_type', 'event.event_type_id = event_type.id AND event_type.name = "Therapy Application"')->leftJoin('ophcotherapya_email', 'event.id = ophcotherapya_email.event_id')->where('ophcotherapya_email.event_id IS NULL')->queryAll();
}