OEModule\OphCiExamination\models\Element_OphCiExamination_InjectionManagementComplex::requiredIfSecondary PHP Method

requiredIfSecondary() public method

check a level 2 diagnosis is provided for level 1 diagnoses that require it (need to check the side as well though).
public requiredIfSecondary ( $attribute, $params )
    public function requiredIfSecondary($attribute, $params)
    {
        if ($params['side'] == 'left' && $this->eye_id != \Eye::RIGHT || $params['side'] == 'right' && $this->eye_id != \Eye::LEFT) {
            if ($this->{$params}['dependent'] && !$this->{$attribute}) {
                if ($api = Yii::app()->moduleAPI->get('OphCoTherapyapplication')) {
                    if (count($api->getLevel2Disorders($this->{$params}['dependent']))) {
                        $disorder = \Disorder::model()->findByPk($this->{$params}['dependent']);
                        $this->addError($attribute, $disorder->term . ' must be associated with another diagnosis');
                    }
                }
            }
        }
    }