public function run() { if ($this->element) { $this->class = CHTML::modelName($this->element); } else { $this->class = get_class($this); } if (empty($_POST) || !array_key_exists($this->class, $_POST)) { if (empty($this->element->event_id)) { if ($this->default) { // It's a new event so fetch the most recent element_diagnosis $firmId = Yii::app()->session['selected_firm_id']; $firm = Firm::model()->findByPk($firmId); if (isset(Yii::app()->getController()->patient)) { $patientId = Yii::app()->getController()->patient->id; $episode = Episode::getCurrentEpisodeByFirm($patientId, $firm, true); if ($episode && ($disorder = $episode->diagnosis)) { // There is a diagnosis for this episode $this->value = $disorder->id; $this->label = $disorder->term; } } } } else { if (isset($this->element->disorder)) { $this->value = $this->element->disorder->id; $this->label = $this->element->disorder->term; } } } elseif (array_key_exists($this->field, $_POST[$this->class])) { if (preg_match('/[^\\d]/', $_POST[$this->class][$this->field])) { if ($disorder = Disorder::model()->find('term=? and specialty_id is not null', array($_POST[$this->class][$this->field]))) { $this->value = $disorder->id; $this->label = $disorder->term; } } else { $this->value = $_POST[$this->class][$this->field]; if ($disorder = Disorder::model()->findByPk($this->value)) { $this->label = $disorder->term; } } } parent::run(); }
/** * OpenEyes * * (C) Moorfields Eye Hospital NHS Foundation Trust, 2008-2011 * (C) OpenEyes Foundation, 2011-2013 * This file is part of OpenEyes. * OpenEyes is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * OpenEyes is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * You should have received a copy of the GNU General Public License along with OpenEyes in a file titled COPYING. If not, see <http://www.gnu.org/licenses/>. * * @package OpenEyes * @link http://www.openeyes.org.uk * @author OpenEyes <*****@*****.**> * @copyright Copyright (c) 2008-2011, Moorfields Eye Hospital NHS Foundation Trust * @copyright Copyright (c) 2011-2013, OpenEyes Foundation * @license http://www.gnu.org/licenses/gpl-3.0.html The GNU General Public License V3.0 */ ?> <div class="segmented"> <?php preg_match('/OphCiExamination_Refraction_(.*?)_Integer/', $model, $m); $type = strtolower($m[1]); echo CHtml::dropDownList(CHTML::modelName($element) . '_' . $side . '_' . $field . '_sign', $element->{$side . "_" . $field} > 0 ? 1 : -1, CHtml::listData(OEModule\OphCiExamination\models\OphCiExamination_Refraction_Sign::model()->findAll(), 'name', 'value'), array('class' => 'inline signField', 'data-type' => $type)); $model = 'OEModule\\OphCiExamination\\models\\' . $model; $sign_id = $element->{$side . "_" . $field} > 0 ? 1 : 2; echo CHtml::dropDownList(CHTML::modelName($element) . '_' . $side . '_' . $field . '_integer', abs((int) $element->{$side . "_" . $field}), CHtml::listData($model::model()->findAll('sign_id=' . $sign_id), 'value', 'value'), array('class' => 'inline')); echo CHtml::dropDownList(CHTML::modelName($element) . '_' . $side . '_' . $field . '_fraction', number_format(abs($element->{$side . "_" . $field}) - abs((int) $element->{$side . "_" . $field}), 2), CHtml::listData(OEModule\OphCiExamination\models\OphCiExamination_Refraction_Fraction::model()->findAll(), 'name', 'value'), array('class' => 'inline')); echo CHtml::activeHiddenField($element, $side . "_" . $field); ?> </div>