Procedure::getList PHP Method

getList() public static method

Get a list of procedures.
public static getList ( string $term, string $restrict = null ) : array
$term string term to search by
$restrict string Set to 'booked' or 'unbooked' to restrict results to procedures of that type
return array
    public static function getList($term, $restrict = null)
    {
        $search = "%{$term}%";
        $select = 'term, short_format, id, default_duration';
        $where = '(term like :search or short_format like :search or snomed_term like :search or snomed_code = :term or aliases like :search)';
        if ($restrict == 'unbooked') {
            $where .= ' and unbooked = 1';
        } elseif ($restrict == 'booked') {
            $where .= ' and unbooked = 0';
        }
        $where .= ' and proc.active = 1';
        return Yii::app()->db->createCommand()->select('term')->from('proc')->where($where, array(':term' => $term, ':search' => $search))->order('term')->queryColumn();
    }

Usage Example

 /**
  * Lists all disorders for a given search term.
  */
 public function actionAutocomplete()
 {
     echo CJavaScript::jsonEncode(Procedure::getList($_GET['term'], @$_GET['restrict']));
 }
All Usage Examples Of Procedure::getList