The followings are the available columns in table 'drug_route_option':
Inheritance: extends BaseActiveRecordVersioned
コード例 #1
0
ファイル: DrugRoute.php プロジェクト: openeyes/openeyes
 /**
  * Get active options for this route.
  *
  * @param int $id Also retrieve the option matching this id if passed
  *
  * @return DrugRouteOption[]
  */
 public function getOptions($id = null)
 {
     $crit = new CDbCriteria();
     $crit->compare('active', true);
     $crit->compare('id', $id, false, 'OR');
     $crit->compare('drug_route_id', $this->id);
     return DrugRouteOption::model()->findAll($crit);
 }
コード例 #2
0
 /**
  * @covers DrugForm::tableName
  */
 public function testTableName()
 {
     $this->assertEquals('drug_route_option', $this->model->tableName());
 }
コード例 #3
0
 /**
  * Render the form for a OphDrPrescription_Item, DrugSetItem or Drug (by id).
  *
  * @param $key
  * @param OphDrPrescription_Item|DrugSetItem|int $source
  *
  * @throws CException
  */
 public function renderPrescriptionItem($key, $source)
 {
     $item = new OphDrPrescription_Item();
     if (is_a($source, 'OphDrPrescription_Item')) {
         // Source is a prescription item, so we should clone it
         foreach (array('drug_id', 'duration_id', 'frequency_id', 'dose', 'route_option_id', 'route_id', 'continue_by_gp') as $field) {
             $item->{$field} = $source->{$field};
         }
         if ($source->tapers) {
             $tapers = array();
             foreach ($source->tapers as $taper) {
                 $taper_model = new OphDrPrescription_ItemTaper();
                 $taper_model->dose = $taper->dose;
                 $taper_model->frequency_id = $taper->frequency_id;
                 $taper_model->duration_id = $taper->duration_id;
                 $tapers[] = $taper_model;
             }
             $item->tapers = $tapers;
         }
     } else {
         if (is_a($source, 'DrugSetItem')) {
             // Source is an drug set item which contains frequency and duration data
             $item->drug_id = $source->drug_id;
             $item->loadDefaults();
             foreach (array('duration_id', 'frequency_id', 'dose') as $field) {
                 if ($source->{$field}) {
                     $item->{$field} = $source->{$field};
                 }
             }
             if ($source->tapers) {
                 $tapers = array();
                 foreach ($source->tapers as $taper) {
                     $taper_model = new OphDrPrescription_ItemTaper();
                     foreach (array('duration_id', 'frequency_id', 'dose') as $field) {
                         if ($taper->{$field}) {
                             $taper_model->{$field} = $taper->{$field};
                         } else {
                             $taper_model->{$field} = $item->{$field};
                         }
                     }
                     $tapers[] = $taper_model;
                 }
                 $item->tapers = $tapers;
             }
         } elseif (is_int($source) || (int) $source) {
             // Source is an integer, so we use it as a drug_id
             $item->drug_id = $source;
             $item->loadDefaults();
         } else {
             throw new CException('Invalid prescription item source: ' . print_r($source));
         }
         // Populate route option from episode for Eye
         if ($episode = $this->episode) {
             if ($principal_eye = $episode->eye) {
                 $route_option_id = DrugRouteOption::model()->find('name = :eye_name', array(':eye_name' => $principal_eye->name));
                 $item->route_option_id = $route_option_id ? $route_option_id : null;
             }
             //check operation note eye and use instead of original diagnosis
             if ($api = Yii::app()->moduleAPI->get('OphTrOperationnote')) {
                 if ($apieye = $api->getLastEye($this->patient)) {
                     $item->route_option_id = $apieye;
                 }
             }
         }
     }
     if (isset($this->patient)) {
         $this->renderPartial('/default/form_Element_OphDrPrescription_Details_Item', array('key' => $key, 'item' => $item, 'patient' => $this->patient));
     } else {
         $output = $this->renderPartial('/default/form_Element_OphDrPrescription_Details_Item', array('key' => $key, 'item' => $item), true);
         return $output;
     }
 }