/**
* @param Element_OphTrOperationbooking_Operation $element
* @param $action
*/
protected function setElementDefaultOptions_Element_OphTrOperationbooking_Operation($element, $action)
{
if ($action == 'create') {
// set the default eye
if ($this->episode && $this->episode->diagnosis) {
$element->eye_id = $this->episode->eye_id;
}
// set default anaesthetic based on whether patient is a child or not.
$key = $this->patient->isChild() ? 'ophtroperationbooking_default_anaesthetic_child' : 'ophtroperationbooking_default_anaesthetic';
if (isset(Yii::app()->params[$key])) {
if ($at = AnaestheticType::model()->find('code=?', array(Yii::app()->params[$key]))) {
$element->anaesthetic_type_id = $at->id;
}
}
if ($default_referral = $this->calculateDefaultReferral()) {
$element->referral_id = $default_referral->id;
}
$element->site_id = Yii::app()->session['selected_site_id'];
}
}