/** * @param $attribute * @param $params */ public function checkSelectedLensFormula($attribute, $params) { if (count(OphInBiometry_Imported_Events::model()->findAllByAttributes(array('event_id' => $this->event_id))) > 0) { $lensCount = count(Element_OphInBiometry_IolRefValues::model()->findAll(array('select' => 'lens_id', 'condition' => 'event_id=' . $this->event_id, 'distinct' => 'true'))); $formulaCount = count(Element_OphInBiometry_IolRefValues::model()->findAll(array('select' => 'formula_id', 'condition' => 'event_id=' . $this->event_id, 'distinct' => 'true'))); if ($params['selectData'] == 'left_lens' && $formulaCount > 1 && $lensCount > 1) { if (empty($this->formula_id_left) && !empty($this->lens_id_left) || !empty($this->formula_id_left) && empty($this->lens_id_left)) { if (empty($this->lens_id_left)) { $this->addError('lens_id_left', 'Lens and Formula must be selected or left blank (Left side).'); } } } elseif ($params['selectData'] == 'left_formula' && $lensCount > 1 && $formulaCount > 1) { if (empty($this->formula_id_left) && !empty($this->lens_id_left) || !empty($this->formula_id_left) && empty($this->lens_id_left)) { if (empty($this->formula_id_left)) { $this->addError('formula_id_left', 'Lens and Formula must be selected or left blank (Left side).'); } } } elseif ($params['selectData'] == 'right_lens' && $formulaCount > 1 && $lensCount > 1) { if (empty($this->formula_id_right) && !empty($this->lens_id_right) || !empty($this->formula_id_right) && empty($this->lens_id_right)) { if (empty($this->lens_id_right)) { $this->addError('lens_id_right', 'Lens and Formula must be selected or left blank (Right side).'); } } } elseif ($params['selectData'] == 'right_formula' && $lensCount > 1 && $formulaCount > 1) { if (empty($this->formula_id_right) && !empty($this->lens_id_right) || !empty($this->formula_id_right) && empty($this->lens_id_right)) { if (empty($this->lens_id_right)) { $this->addError('formula_id_right', 'Lens and Formula must be selected or left blank (Right side).'); } } } } }
/** * @return array validation rules for model attributes. */ public function rules() { // NOTE: you should only define rules for those attributes that // will receive user inputs. if (count(OphInBiometry_Imported_Events::model()->findAllByAttributes(array('event_id' => $this->event_id))) == 0) { return array(array('event_id, eye_id k1_left, k1_right, k2_left, k2_right, axis_k1_left, axis_k1_right, axial_length_left, axial_length_right, snr_left, snr_right, k2_axis_left, k2_axis_right, delta_k_left, delta_k_right, delta_k_axis_left, delta_k_axis_right, acd_left, acd_right, refraction_sphere_left, refraction_sphere_right, refraction_delta_left, refraction_delta_right, refraction_axis_left, refraction_axis_right, eye_status_left, eye_status_right, comments', 'safe'), array('k1_left, k1_right, k2_left, k2_right, axial_length_left, axial_length_right', 'match', 'pattern' => '/([0-9]*?)(\\.[0-9]{0,2})?/'), array('axis_k1_left, axis_k1_right, snr_left, snr_right', 'match', 'pattern' => '/([0-9]*?)(\\.[0-9]{0,1})?/'), array('snr_left, k1_left, k2_left, axis_k1_left, axial_length_left', 'requiredIfSide', 'side' => 'left'), array('snr_right, k1_right, k2_right, axis_k1_right, axial_length_right', 'requiredIfSide', 'side' => 'right'), array('snr_left', 'checkNumericRangeIfSide', 'side' => 'left', 'integerOnly' => true, 'max' => 2000, 'min' => 10), array('snr_right', 'checkNumericRangeIfSide', 'side' => 'right', 'integerOnly' => true, 'max' => 2000, 'min' => 10), array('k1_left, k2_left', 'checkNumericRangeIfSide', 'side' => 'left', 'max' => 60, 'min' => 30), array('k1_right, k2_right', 'checkNumericRangeIfSide', 'side' => 'right', 'max' => 60, 'min' => 30), array('axis_k1_left', 'checkNumericRangeIfSide', 'side' => 'left', 'max' => 180, 'min' => 0), array('axis_k1_right', 'checkNumericRangeIfSide', 'side' => 'right', 'max' => 180, 'min' => 0), array('axial_length_left', 'checkNumericRangeIfSide', 'side' => 'left', 'max' => 40, 'min' => 15), array('axial_length_right', 'checkNumericRangeIfSide', 'side' => 'right', 'max' => 40, 'min' => 15), array('id, event_id', 'safe', 'on' => 'search')); } else { return array(array('event_id, eye_id k1_left, k1_right, k2_left, k2_right, axis_k1_left, axis_k1_right, axial_length_left, axial_length_right, snr_left, snr_right, k2_axis_left, k2_axis_right, delta_k_left, delta_k_right, delta_k_axis_left, delta_k_axis_right, acd_left, acd_right, refraction_sphere_left, refraction_sphere_right, refraction_delta_left, refraction_delta_right, refraction_axis_left, refraction_axis_right, eye_status_left, eye_status_right, comments', 'safe')); } }
/** * Check for new imported biometry event. */ private function checkImportedBiometryEvent() { // we need to be sure that Biometry module is installed if (isset(Yii::app()->modules['OphInBiometry'])) { $criteria = new CDbCriteria(); $criteria->addCondition("is_linked=0 AND patient_id='" . $this->patient->id . "'"); $resultSet = OphInBiometry_Imported_Events::model()->findAll($criteria); if ($resultSet) { Yii::app()->user->setFlash('alert.unlinked_biometry_event', 'A new biometry report is available for this patient - please create a biometry event to view it '); } } }
/** * Get Auto Event data. * * @param $id * * @return mixed */ protected function getAutoBiometryEventData($id) { return OphInBiometry_Imported_Events::model()->findAllByAttributes(array('event_id' => $id)); }