/** * Edits or adds a Procedure. * * @param bool|int $id * * @throws CHttpException */ public function actionEdit($id = false) { $admin = new Admin(FormularyDrugs::model(), $this); if ($id) { $admin->setModelId($id); } $admin->setModelDisplayName('Formulary Drugs'); $criteria = new CDbCriteria(); $admin->setEditFields(array('id' => 'label', 'name' => 'text', 'type_id' => array('widget' => 'DropDownList', 'options' => CHtml::listData(DrugType::model()->findAll(), 'id', 'name'), 'htmlOptions' => null, 'hidden' => false, 'layoutColumns' => null), 'aliases' => 'text', 'tallman' => 'text', 'form_id' => array('widget' => 'DropDownList', 'options' => CHtml::listData(DrugForm::model()->findAll(), 'id', 'name'), 'htmlOptions' => null, 'hidden' => false, 'layoutColumns' => null), 'dose_unit' => 'text', 'default_dose' => 'text', 'default_route_id' => array('widget' => 'DropDownList', 'options' => CHtml::listData(DrugRoute::model()->findAll(), 'id', 'name'), 'htmlOptions' => array('empty' => '-- Please select --'), 'hidden' => false, 'layoutColumns' => null), 'default_frequency_id' => array('widget' => 'DropDownList', 'options' => CHtml::listData(DrugFrequency::model()->findAll(), 'id', 'name'), 'htmlOptions' => array('empty' => '-- Please select --'), 'hidden' => false, 'layoutColumns' => null), 'default_duration_id' => array('widget' => 'DropDownList', 'options' => CHtml::listData(DrugDuration::model()->findAll(), 'id', 'name'), 'htmlOptions' => array('empty' => '-- Please select --'), 'hidden' => false, 'layoutColumns' => null), 'preservative_free' => 'checkbox', 'active' => 'checkbox', 'allergy_warnings' => array('widget' => 'MultiSelectList', 'relation_field_id' => 'id', 'label' => 'Allergy Warnings', 'options' => CHtml::encodeArray(CHtml::listData(Allergy::model()->findAll($criteria->condition = "name != 'Other'"), 'id', 'name'))))); $admin->editModel(); }
/** * @covers DrugType::search * @todo Implement testSearch(). */ public function testSearch() { $this->model->setAttributes($this->drugtypes('drugtype1')->getAttributes()); $results = $this->model->search(); $data = $results->getData(); $expectedKeys = array('drugtype1'); $expectedResults = array(); if (!empty($expectedKeys)) { foreach ($expectedKeys as $key) { $expectedResults[] = $this->drugtypes($key); } } $this->assertEquals(1, $results->getItemCount()); $this->assertEquals($expectedResults, $data); }
/** * Gets listdata for the drugtypes. * * @TODO: Should this be a static method on the DrugType model, rather than here? * * @return CHtml::listData */ public function drugTypes() { $drugTypes = CHtml::listData(DrugType::model()->active()->findAll(array('order' => 'name')), 'id', 'name'); natcasesort($drugTypes); return $drugTypes; }
public function listUnit() { return Response::json(array('unit' => Unit::all(), 'type' => DrugType::all())); }