public function actionAddFamilyHistory() { if (!($patient = Patient::model()->findByPk(@$_POST['patient_id']))) { throw new Exception("Patient not found:" . @$_POST['patient_id']); } if (!($relative = FamilyHistoryRelative::model()->findByPk(@$_POST['relative_id']))) { throw new Exception("Unknown relative: " . @$_POST['relative_id']); } if (!($side = FamilyHistorySide::model()->findByPk(@$_POST['side_id']))) { throw new Exception("Unknown side: " . @$_POST['side_id']); } if (!($condition = FamilyHistoryCondition::model()->findByPk(@$_POST['condition_id']))) { throw new Exception("Unknown condition: " . @$_POST['condition_id']); } if (@$_POST['edit_family_history_id']) { if (!($fh = FamilyHistory::model()->findByPk(@$_POST['edit_family_history_id']))) { throw new Exception("Family history not found: " . @$_POST['edit_family_history_id']); } $fh->relative_id = $relative->id; $fh->side_id = $side->id; $fh->condition_id = $condition->id; $fh->comments = @$_POST['comments']; if (!$fh->save()) { throw new Exception("Unable to save family history: " . print_r($fh->getErrors(), true)); } } else { $patient->addFamilyHistory($relative->id, $side->id, $condition->id, @$_POST['comments']); } $this->redirect(array('patient/view/' . $patient->id)); }
</div> </div> <div class="field-row row"> <div class="<?php echo $form->columns('label'); ?> "> <label for="side_id">Side:</label> </div> <div class="<?php echo $form->columns('field'); ?> "> <?php echo CHtml::dropDownList('side_id', '', CHtml::listData(FamilyHistorySide::model()->findAll(array('order' => 'display_order')), 'id', 'name')); ?> </div> </div> <div class="field-row row"> <div class="<?php echo $form->columns('label'); ?> "> <label for="condition_id">Condition:</label> </div> <div class="<?php echo $form->columns('field'); ?> ">