/** * Return the open referral choices for the patient. * * @return Referral[] */ public function getReferralChoices($element = null) { $criteria = new CdbCriteria(); $criteria->addCondition('patient_id = :pid'); $criteria->addCondition('closed_date is null'); $criteria->params = array('pid' => $this->patient->id); // if the referral has been closed but is the selected referral for the event, needs to be part of the list if ($element && $element->referral_id) { $criteria->addCondition('id = :crid', 'OR'); $criteria->params[':crid'] = $element->referral_id; } $criteria->order = 'received_date DESC'; return Referral::model()->findAll($criteria); }
public function insertRecords($data, $update = FALSE, $condition = FALSE) { $record = new self(); foreach ($data as $k => $v) { $v = str_replace(array("'", '"'), '', $v); $record->{$k} = $v; } if ($update) { $criteria = new CdbCriteria(); if (is_array($condition)) { foreach ($condition as $column => $value) { $criteria->addCondition("{$column}='{$value}'"); } } else { $criteria->where = $condition; } return $record->updateAll($data, $criteria); } else { return $record->save(); } }
public function getAllSamples() { $criteria = new CdbCriteria(); $criteria->join = "join dataset_sample ds on ds.sample_id = t.id"; $criteria->addCondition("ds.dataset_id = " . $this->id); return Sample::model()->findAll($criteria); }