Inheritance: extends BaseActiveRecordVersioned
Exemplo n.º 1
0
 /**
  * @param $eyeIds
  * @param $eye
  * @param $iop
  * @param $eyeLabel
  * @throws \CDbException
  * @throws \Exception
  */
 protected function addIop($eyeIds, $eye, $iop, $eyeLabel)
 {
     $iopReading = $eye['reading'][0]['iop'];
     $iopValue = new \OEModule\OphCiExamination\models\OphCiExamination_IntraocularPressure_Value();
     $iopValue->element_id = $iop->id;
     $iopValue->eye_id = $eyeIds[$eyeLabel];
     $iopReadingValue = \OEModule\OphCiExamination\models\OphCiExamination_IntraocularPressure_Reading::model()->find('value = ?', array($iopReading['mm_hg']));
     $instrument = \OEModule\OphCiExamination\models\OphCiExamination_Instrument::model()->find('LOWER(name) = ?', array(strtolower($iopReading['instrument'])));
     $iopValue->reading_id = $iopReadingValue['id'];
     $iopValue->instrument_id = $instrument['id'];
     if (!$iopValue->save(true, null, true)) {
         throw new \CDbException('iop value failed: ' . print_r($iop->getErrors(), true));
     }
 }
 public function down()
 {
     $model = \OEModule\OphCiExamination\models\OphCiExamination_IntraocularPressure_Reading::model();
     $reading = $model->find('value = 17');
     $this->insert('setting_metadata', array('element_type_id' => $this->getIdOfElementTypeByClassName('OEModule\\OphCiExamination\\models\\Element_OphCiExamination_IntraocularPressure'), 'field_type_id' => 2, 'key' => 'default_reading_id', 'name' => 'Default reading', 'default_value' => $reading->id));
 }