model() public static method

Returns the static model of the specified AR class.
public static model ( $className = __CLASS__ ) : ElementOperation
return ElementOperation the static model class
 /**
  * Validate IOL data if IOL is part of the element.
  *
  * @return bool
  */
 public function beforeValidate()
 {
     $iol_position = OphTrOperationnote_IOLPosition::model()->findByPk($this->iol_position_id);
     if (!$iol_position || $iol_position->name != 'None') {
         if (!$this->iol_type_id) {
             $this->addError('iol_type_id', 'IOL type cannot be blank');
         }
         if (!isset($this->iol_power)) {
             $this->addError('iol_power', 'IOL power cannot be blank');
         }
         /* elseif (!is_numeric($this->iol_power) || strlen(substr(strrchr($this->iol_power, "."), 1)) > 2 || ((-999.99 > $this->iol_power) || ($this->iol_power > 999.99))) {
                $this->addError('iol_power', 'IOL power must be a number with an optional two decimal places between -999.99 and 999.99');
              }
              elseif (strlen(substr(strrchr($this->iol_power, "."), 1)) > 2) {
                $this->addError('iol_power', 'IOL power must be a number with an optional two decimal places between -999.99 and 999.99');
            } elseif ((-999.99 > $this->iol_power) || ($this->iol_power > 999.99)) {
                $this->addError('iol_power', 'IOL power must be a number with an optional two decimal places between -999.99 and 999.99');
              } */
     }
     return parent::beforeValidate();
 }
 protected function appendOpNoteValues(&$record, $event_id, $anaesthetic_type, $anaesthetic_delivery, $anaesthetic_comments, $anaesthetic_complications, $cataract_report, $incision_site, $cataract_complication_notes, $cataract_predicted_refraction, $cataract_iol_type, $cataract_iol_power, $tamponade_used, $surgeon, $surgeon_role, $assistant, $assistant_role, $supervising_surgeon, $supervising_surgeon_role, $opnote_comments)
 {
     $anaesthetic = Element_OphTrOperationnote_Anaesthetic::model()->find('event_id = :event_id', array(':event_id' => $event_id));
     if ($anaesthetic_type) {
         $record['anaesthetic_type'] = $anaesthetic->anaesthetic_type['name'];
     }
     if ($anaesthetic_delivery) {
         $record['anaesthetic_delivery'] = $anaesthetic->anaesthetic_delivery['name'];
     }
     if ($anaesthetic_comments) {
         $record['anaesthetic_comments'] = $anaesthetic['anaesthetic_comment'];
     }
     if ($anaesthetic_complications) {
         $complications = array();
         if (isset($anaesthetic->anaesthetic_complications)) {
             foreach ($anaesthetic->anaesthetic_complications as $complication) {
                 $complications[] = $complication['name'];
             }
             $record['anaesthetic_complications'] = implode(',', $complications);
         }
     }
     if ($cataract_report) {
         foreach (array('cataract_report', 'cataract_predicted_refraction', 'cataract_iol_type', 'cataract_iol_power') as $k) {
             $record[$k] = '';
         }
         if ($cataract_element = Element_OphTrOperationnote_Cataract::model()->find('event_id = :event_id', array(':event_id' => $event_id))) {
             $record['cataract_report'] = trim(preg_replace('/\\s\\s+/', ' ', $cataract_element['report']));
             $record['cataract_predicted_refraction'] = $cataract_element->predicted_refraction;
             if ($cataract_element->iol_type) {
                 $record['cataract_iol_type'] = $cataract_element->iol_type->name;
             } else {
                 $record['cataract_iol_type'] = 'None';
             }
             $record['cataract_iol_power'] = $cataract_element->iol_power;
         }
     }
     if ($incision_site) {
         $record['incision_site'] = 'Unknown';
         $record['length_of_incision'] = 'Unknown';
         $record['meridian'] = 'Unknown';
         $record['incision_type'] = 'Unknown';
         $record['iol_position'] = 'Unknown';
         $cataract_operation_details_element = Element_OphTrOperationnote_Cataract::model()->find('event_id = :event_id', array(':event_id' => $event_id));
         if ($cataract_operation_details_element) {
             $incisionSite = OphTrOperationnote_IncisionSite::model()->find('id = :id', array(':id' => $cataract_operation_details_element['incision_site_id']));
             if ($incisionSite) {
                 $record['incision_site'] = $incisionSite->name;
             }
             if ($cataract_operation_details_element['length']) {
                 $record['length_of_incision'] = $cataract_operation_details_element['length'];
             }
             if ($cataract_operation_details_element['meridian']) {
                 $record['meridian'] = $cataract_operation_details_element['meridian'];
             }
             $incision = OphTrOperationnote_IncisionType::model()->find('id = :id', array(':id' => $cataract_operation_details_element['incision_type_id']));
             if ($incision) {
                 $record['incision_type'] = $incision->name;
             }
             $iolPosition = OphTrOperationnote_IOLPosition::model()->find('id = :id', array(':id' => $cataract_operation_details_element['iol_position_id']));
             if ($iolPosition) {
                 $record['iol_position'] = $iolPosition->name;
             }
         }
     }
     if ($cataract_complication_notes) {
         $record['Cataract Complication Notes'] = 'Unknown';
         if ($cataract_complication_notes_element = Element_OphTrOperationnote_Cataract::model()->find('event_id = :event_id', array(':event_id' => $event_id))) {
             if ($cataract_complication_notes_element['complication_notes']) {
                 $record['Cataract Complication Notes'] = $cataract_complication_notes_element['complication_notes'];
             }
         }
     }
     if ($tamponade_used) {
         if ($tamponade_element = Element_OphTrOperationnote_Tamponade::model()->find('event_id = :event_id', array(':event_id' => $event_id))) {
             $record['tamponade_used'] = $tamponade_element->gas_type->name;
         } else {
             $record['tamponade_used'] = 'None';
         }
     }
     if ($surgeon || $surgeon_role || $assistant || $assistant_role || $supervising_surgeon || $supervising_surgeon_role) {
         $surgeon_element = Element_OphTrOperationnote_Surgeon::model()->findByAttributes(array('event_id' => $event_id));
         foreach (array('surgeon', 'assistant', 'supervising_surgeon') as $surgeon_type) {
             $role = $surgeon_type . '_role';
             if (${$surgeon_type} || ${$role}) {
                 $surgeon = $surgeon_element->{$surgeon_type};
                 if (${$surgeon_type}) {
                     $record[$surgeon_type] = $surgeon ? $surgeon->getFullName() : 'None';
                 }
                 if (${$role}) {
                     $record["{$surgeon_type}_role"] = $surgeon ? $surgeon->role : 'None';
                 }
             }
         }
     }
     if ($this->opnote_comments) {
         $comments = Element_OphTrOperationnote_Comments::model()->find('event_id = :event_id', array(':event_id' => $event_id));
         $record['opnote_comments'] = trim(preg_replace('/\\s\\s+/', ' ', $comments['comments']));
     }
 }