public function beforeSave() { if (!$this->hasMultiSelectValue('assessment', 'Other')) { $this->other = null; } return parent::beforeSave(); }
protected function beforeSave() { // Need to clear any "sided" fields if that side isn't active if ($this->eye->id != Eye::BOTH) { foreach ($this->sidedFields() as $field_suffix) { if ($this->eye->id == Eye::LEFT) { $this->{'right_' . $field_suffix} = null; } else { $this->{'left_' . $field_suffix} = null; } } } return parent::beforeSave(); }
protected function beforeValidate() { return parent::beforeValidate(); }
/** * Reset diagnosis data on the event based on the diagnosis set on this element. */ protected function afterSave() { if (!$this->event->episode->eye && !$this->event->episode->disorder_id) { $this->event->episode->setPrincipalDiagnosis($this->disorder_id, $this->eye_id); if ($sd = SecondaryDiagnosis::model()->find('patient_id=? and disorder_id=? and eye_id = ?', array($this->event->episode->patient_id, $this->disorder_id, 3))) { $this->event->episode->patient->removeDiagnosis($sd->id); if (in_array($this->eye_id, array(1, 2))) { $this->event->episode->patient->addDiagnosis($this->disorder_id, $this->eye_id == 1 ? 2 : 1); } } } else { if (!SecondaryDiagnosis::model()->find('patient_id=? and disorder_id=? and eye_id in (' . $this->eye_id . ',3)', array($this->event->episode->patient_id, $this->disorder_id))) { if (!Episode::model()->find('patient_id=? and disorder_id=? and eye_id in (' . $this->eye_id . ',3)', array($this->event->episode->patient_id, $this->disorder_id))) { $this->event->episode->patient->addDiagnosis($this->disorder_id, $this->eye_id); } } } return parent::afterSave(); }
public function afterValidate() { foreach (array('left', 'right') as $side) { foreach ($this->{$side . '_cvi_disorder_assignments'} as $ass) { // would prefer this to be just on the assignment validation, but having trouble // with scenario specification for different contexts (i.e. validating for errors to return // to the user versus actually saving (where the element id is requred) if ($ass->main_cause && !$ass->affected) { $this->addError('disorders', "{$side} disorder - '{$ass->ophcocvi_clinicinfo_disorder->name}'' cannot be main cause when eye not affected."); } } } parent::afterValidate(); }
/** * make sure the cached dates array is reset when patient_unavailables is updated. * * @param string $name * @param mixed $value * * @return mixed|void */ public function __set($name, $value) { if ($name == 'patient_unavailables') { $this->_unavailable_dates = null; } parent::__set($name, $value); }
/** * Returns the static model of the specified AR class. * * @return the static model class */ public static function model($className = __CLASS__) { return parent::model($className); }
/** * @param BaseEventTypeElement $element */ public function findAllByElement($element) { $element_type = $element->getElementType(); return $this->findAll('element_type_id = :element_type_id', array(':element_type_id' => $element_type->id)); }
protected function afterSave() { $existing_leaflet_ids = array(); foreach ($this->leaflets as $leaflet) { $existing_leaflet_ids[] = $leaflet->leaflet_id; } if (isset($_POST['OphTrConsent_Leaflet']) && is_array($_POST['OphTrConsent_Leaflet'])) { foreach ($_POST['OphTrConsent_Leaflet'] as $id) { if (!in_array($id, $existing_leaflet_ids)) { $leaflet = new OphTrConsent_Leaflets(); $leaflet->element_id = $this->id; $leaflet->leaflet_id = $id; if (!$leaflet->save()) { throw new Exception('Unable to save leaflet: ' . print_r($leaflet->getErrors(), true)); } } } } foreach ($existing_leaflet_ids as $id) { if (!isset($_POST['OphTrConsent_Leaflet']) || !in_array($id, $_POST['OphTrConsent_Leaflet'])) { $leaflet = OphTrConsent_Leaflets::model()->find('element_id=:element_id and leaflet_id=:leaflet_id', array(':element_id' => $this->id, ':leaflet_id' => $id)); if (!$leaflet->delete()) { throw new Exception('Unable to delete leaflet: ' . print_r($leaflet->getErrors(), true)); } } } return parent::afterSave(); }
public function beforeSave() { if (in_array(Yii::app()->getController()->getAction()->id, array('create', 'update'))) { if (!$this->draft) { $this->print = 1; } } return parent::beforeSave(); }
public function afterSave() { parent::afterSave(); $this->updateMeasurementReference($this->left_field_id, Eye::LEFT); $this->updateMeasurementReference($this->right_field_id, Eye::RIGHT); }
public function afterSave() { if (@$_POST['update_enclosures']) { foreach ($this->enclosures as $enclosure) { $enclosure->delete(); } if (is_array(@$_POST['EnclosureItems'])) { $i = 1; foreach (@$_POST['EnclosureItems'] as $key => $value) { if (strlen(trim($value)) > 0) { $enc = new LetterEnclosure(); $enc->element_letter_id = $this->id; $enc->display_order = $i++; $enc->content = $value; if (!$enc->save()) { throw new Exception('Unable to save EnclosureItem: ' . print_r($enc->getErrors(), true)); } } } } } return parent::afterSave(); }
protected function afterSave() { foreach ($_POST['Procedures_procedures'] as $procedure_id) { if (!EtOphtrconsentProcedureProceduresProcedures::model()->find('element_id=? and proc_id=?', array($this->id, $procedure_id))) { $p = new EtOphtrconsentProcedureProceduresProcedures(); $p->element_id = $this->id; $p->proc_id = $procedure_id; if (!$p->save()) { throw new Exception('Unable to save procedure item: ' . print_r($p->getErrors(), true)); } } } foreach (EtOphtrconsentProcedureProceduresProcedures::model()->findAll('element_id=?', array($this->id)) as $p) { if (!in_array($p->proc_id, $_POST['Procedures_procedures'])) { if (!$p->delete()) { throw new Exception('Unable to delete procedure item: ' . print_r($p->getErrors(), true)); } } } if (isset($_POST['Procedures_additional'])) { foreach ($_POST['Procedures_additional'] as $procedure_id) { if (!EtOphtrconsentProcedureAddProcsAddProcs::model()->find('element_id=? and proc_id=?', array($this->id, $procedure_id))) { $p = new EtOphtrconsentProcedureAddProcsAddProcs(); $p->element_id = $this->id; $p->proc_id = $procedure_id; if (!$p->save()) { throw new Exception('Unable to save additional procedure item: ' . print_r($p->getErrors(), true)); } } } foreach (EtOphtrconsentProcedureAddProcsAddProcs::model()->findAll('element_id=?', array($this->id)) as $p) { if (!in_array($p->proc_id, $_POST['Procedures_additional'])) { if (!$p->delete()) { throw new Exception('Unable to delete additional procedure item: ' . print_r($p->getErrors(), true)); } } } } else { foreach (EtOphtrconsentProcedureAddProcsAddProcs::model()->findAll('element_id=?', array($this->id)) as $p) { if (!$p->delete()) { throw new Exception('Unable to delete additional procedure item: ' . print_r($p->getErrors(), true)); } } } return parent::afterSave(); }
public function delete() { // Delete related records OphTrOperationbooking_Operation_Date_Letter_Sent::model()->deleteAll('element_id = ?', array($this->id)); OphTrOperationbooking_Operation_Procedures::model()->deleteAll('element_id = ?', array($this->id)); OphTrOperationbooking_Operation_Booking::model()->deleteAll('element_id = ?', array($this->id)); OphTrOperationbooking_Operation_EROD::model()->deleteAll('element_id = ?', array($this->id)); parent::delete(); }
public function loadFromExisting($element) { parent::loadFromExisting($element); $this->items = $element->items; }
protected function afterSave() { return parent::afterSave(); }
/** * Render the optional child elements for the given parent element type. * * @param BaseEventTypeElement $parent_element * @param string $action * @param BaseCActiveBaseEventTypeCActiveForm $form * @param array $data * * @throws Exception */ public function renderChildOptionalElements($parent_element, $action, $form = null, $data = null) { $this->setCurrentSet(); $elements = $this->getChildOptionalElements($parent_element->getElementType()); $this->filterElements($elements); foreach ($elements as $element) { $this->renderOptionalElement($element, $action, $form, $data); } }
/** * Ensure a principal diagnosis is set for the episode. * */ public function afterValidate() { if (count($this->diagnoses)) { $principal = false; foreach ($this->diagnoses as $diagnosis) { if ($diagnosis->principal) { $principal = true; } } if (!$principal) { $this->addError('diagnoses', 'Principal diagnosis required.'); } } // This isn't very nice but there isn't a clean alternative at the moment $controller = \Yii::app()->getController(); if ($controller instanceof \BaseEventTypeController) { $et_diagnoses = \ElementType::model()->find('class_name=?', array('OEModule\\OphCiExamination\\models\\Element_OphCiExamination_Diagnoses')); $children = $controller->getChildElements($et_diagnoses); $have_further_findings = false; foreach ($controller->getChildElements($et_diagnoses) as $element) { if (\CHtml::modelName($element) == 'OEModule_OphCiExamination_models_Element_OphCiExamination_FurtherFindings') { $have_further_findings = true; } } if (!$have_further_findings && !$this->diagnoses) { $this->addError('diagnoses', 'Please select at least one diagnosis.'); } } parent::afterValidate(); }
public function afterSave() { // Update Episode status when outcome is saved if ($this->status && $this->status->episode_status) { if ($this->event->isLatestOfTypeInEpisode()) { $this->event->episode->episode_status_id = $this->status->episode_status_id; if (!$this->event->episode->save()) { throw new Exception('Unable to save episode status: ' . print_r($this->event->episode->getErrors(), true)); } } } parent::afterSave(); }
public function afterValidate() { if ($this->further_findings_assignment) { foreach ($this->further_findings_assignment as $assignment) { if (!$assignment->validate()) { foreach ($assignment->errors as $field => $errors) { $this->addError($field, $errors[0]); } } } } else { $this->addError('further_findings_assignment', 'Please select at least one finding'); } parent::afterValidate(); }
/** * Validate prescription items. */ protected function afterValidate() { // Check that fields on prescription items are set foreach ($this->items as $i => $item) { if (!$item->validate()) { foreach ($item->getErrors() as $fld => $err) { $this->addError('items', 'Item (' . ($i + 1) . '): ' . implode(', ', $err)); } } } return parent::afterValidate(); }
/** * Render the optional child elements for the given parent element type * * @param BaseEventTypeElement $parent_element * @param string $action * @param BaseCActiveBaseEventTypeCActiveForm $form * @param array $data * @throws Exception */ public function renderChildOptionalElements($parent_element, $action, $form = null, $data = null) { foreach ($this->getChildOptionalElements($parent_element->getElementType()) as $element) { $this->renderOptionalElement($element, $action, $form, $data); } }
public function beforeSave() { !$this->witness_required && ($this->witness_name = ''); !$this->interpreter_required && ($this->interpreter_name = ''); return parent::beforeSave(); }