/** * Ajax action to process a selected string request. * * @throws Exception */ public function actionGetString() { if (!($patient = Patient::model()->findByPk(@$_GET['patient_id']))) { throw new Exception('Patient not found: ' . @$_GET['patient_id']); } switch (@$_GET['string_type']) { case 'site': if (!($string = LetterString::model()->findByPk(@$_GET['string_id']))) { throw new Exception('Site letter string not found: ' . @$_GET['string_id']); } break; case 'subspecialty': if (!($string = SubspecialtyLetterString::model()->findByPk(@$_GET['string_id']))) { throw new Exception('Subspecialty letter string not found: ' . @$_GET['string_id']); } break; case 'firm': if (!($firm = FirmLetterString::model()->findByPk(@$_GET['string_id']))) { throw new Exception('Firm letter string not found: ' . @$_GET['string_id']); } break; case 'examination': echo $this->process_examination_findings($_GET['patient_id'], $_GET['string_id']); return; default: throw new Exception('Unknown letter string type: ' . @$_GET['string_type']); } $string->substitute($patient); echo $string->body; }
protected function beforeAction($action) { $this->admin = new Admin(LetterString::model(), $this); $this->admin->setModelDisplayName('Letter String'); return parent::beforeAction($action); }