public static function defaultForSocialHistoryId(\SocialHistory $history) { if ($history->occupation_id !== null) { if ($default = self::model()->active()->findByAttributes(array('social_history_occupation_id' => $history->occupation_id))) { return $default->id; } } return null; }
/** * @param models\Element_OphCoCvi_ClericalInfo $element * @param $action */ protected function setElementDefaultOptions_Element_OphCoCvi_ClericalInfo(models\Element_OphCoCvi_ClericalInfo $element, $action) { if ($element->isNewRecord && $this->checkClinicalEditAccess()) { if ($this->patient->isChild()) { $element->employment_status_id = models\OphCoCvi_ClericalInfo_EmploymentStatus::defaultChildStatusId(); } elseif ($this->patient->socialhistory) { $element->employment_status_id = models\OphCoCvi_ClericalInfo_EmploymentStatus::defaultForSocialHistoryId($this->patient->socialhistory); } } }