OphCoTherapyapplication_Treatment::availableOrPk PHP Method

availableOrPk() public method

scope to only get treatments where the drug is available.
public availableOrPk ( $id )
    public function availableOrPk($id)
    {
        $alias = $this->getTableAlias(true);
        $criteria = new CDbCriteria();
        $criteria->compare('drug.active', true);
        $criteria->compare("{$alias}.active", true);
        $criteria->addCondition("{$alias}.decisiontree_id is not null");
        $criteria->compare("{$alias}." . $this->metadata->tableSchema->primaryKey, $id, false, 'OR');
        $this->dbCriteria->mergeWith($criteria);
        return $this;
    }