/** * @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']; } }
/** * Determine if the witness field is required, and set various defaults from the patient and related booking. * * @param Element_OphTrOperationnote_Anaesthetic $element * @param string $action */ protected function setElementDefaultOptions_Element_OphTrOperationnote_Anaesthetic($element, $action) { if (Yii::app()->params['fife']) { $element->witness_required = true; } if ($action == 'create') { if ($this->booking_operation) { $element->anaesthetic_type_id = $this->booking_operation->anaesthetic_type_id; } else { $key = $this->patient->isChild() ? 'ophtroperationnote_default_anaesthetic_child' : 'ophtroperationnote_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; } } } $element->anaesthetic_agents = $this->getAnaestheticAgentsBySiteAndSubspecialty('siteSubspecialtyAssignmentDefaults'); } }
/** * @covers AnaestheticAgent::model */ public function testModel() { $this->assertEquals('AnaestheticType', get_class(AnaestheticType::model()), 'Class name should match model.'); }
protected function afterValidate() { if ($this->booking) { if ($this->consultant_required && !$this->booking->session->consultant) { $this->addError('consultant', 'The booked session does not have a consultant present, you must change the session or cancel the booking before making this change'); } if ($anaesthetic = AnaestheticType::model()->findByPk($this->anaesthetic_type_id)->name) { if (in_array($anaesthetic, array('LAC', 'LAS', 'GA')) && !$this->booking->session->anaesthetist) { $this->addError('anaesthetist', 'The booked session does not have an anaesthetist present, you must change the session or cancel the booking before making this change'); } if ($anaesthetic == 'GA' && !$this->booking->session->general_anaesthetic) { $this->addError('ga', 'General anaesthetic is not available for the booked session, you must change the session or cancel the booking before making this change'); } } } return parent::afterValidate(); }