public function actionEditSocialHistory()
{
if (!($patient = Patient::model()->findByPk(@$_POST['patient_id']))) {
throw new Exception("Patient not found:" . @$_POST['patient_id']);
}
if (!($social_history = SocialHistory::model()->find('patient_id=?', array($patient->id)))) {
$social_history = new SocialHistory();
}
$social_history->patient_id = $patient->id;
$social_history->attributes = $_POST['SocialHistory'];
if (!$social_history->save()) {
throw new Exception("Unable to save social history: " . print_r($social_history->getErrors(), true));
} else {
$this->redirect(array('patient/view/' . $patient->id));
}
}