The followings are the available columns in table 'medication_drug':
Inheritance: extends BaseActiveRecordVersioned
 public function actionSearch()
 {
     if (Yii::app()->request->isAjaxRequest) {
         $criteria = new CDbCriteria();
         if (isset($_GET['term']) && strlen($term = $_GET['term']) > 0) {
             $criteria->addCondition(array('LOWER(name) LIKE :term'), 'OR');
             $params[':term'] = '%' . strtolower(strtr($term, array('%' => '\\%'))) . '%';
         }
         $criteria->order = 'name';
         $criteria->select = 'id, name';
         $criteria->params = $params;
         $drugs = MedicationDrug::model()->findAll($criteria);
         $return = array();
         foreach ($drugs as $drug) {
             $return[] = array('label' => $drug->name, 'value' => $drug->name, 'id' => $drug->id);
         }
         echo CJSON::encode($return);
     }
 }
 /**
  * Searches across MedicationDrug and Drug models for the given term. If the term only matches
  * on an alias, the alias will be included in the returned label for that entry.
  *
  * Distinguishes between the data types to ensure relationship defined correctly.
  */
 public function actionFindDrug()
 {
     $return = array();
     if (isset($_GET['term']) && ($term = strtolower($_GET['term']))) {
         $criteria = new CDbCriteria();
         $criteria->compare('LOWER(name)', $term, true, 'OR');
         $criteria->compare('LOWER(aliases)', $term, true, 'OR');
         foreach (MedicationDrug::model()->findAll($criteria) as $md) {
             $label = $md->name;
             if (strpos(strtolower($md->name), $term) === false) {
                 $label .= " (" . $md->aliases . ")";
             }
             $return[] = array('name' => $md->name, 'label' => $label, 'value' => $md->id, 'type' => 'md');
         }
         foreach (Drug::model()->active()->findAll($criteria) as $drug) {
             $label = $drug->tallmanlabel;
             if (strpos(strtolower($drug->name), $term) === false) {
                 $label .= " (" . $drug->aliases . ")";
             }
             $return[] = array('name' => $drug->tallmanlabel, 'label' => $label, 'value' => $drug->id, 'type' => 'd');
         }
     }
     echo json_encode($return);
 }
Exemplo n.º 3
0
 public static function getList($firm)
 {
     return CHtml::listData(MedicationDrug::model()->findAll(array('join' => 'JOIN medication_drug md ON md.id = t.medication_id', 'order' => 'term')), 'id', 'term');
 }
 /**
  * Deletes rows for the model
  */
 public function actionDelete()
 {
     $admin = new Admin(MedicationDrug::model(), $this);
     $admin->deleteModel();
 }