model() public static method

Returns the static model of the specified AR class.
public static model ( $className = __CLASS__ ) : Procedure
return Procedure the static model class
 public function actionComplications($id)
 {
     if (!Procedure::model()->findByPk($id)) {
         throw new Exception("Unknown procedure: {$id}");
     }
     $complications = array();
     foreach (Yii::app()->db->createCommand()->select("b.name")->from("complication b")->join("procedure_complication pb", "pb.complication_id = b.id")->where("pb.proc_id = {$id} and b.active = 1")->order("b.name asc")->queryAll() as $row) {
         $complications[] = $row['name'];
     }
     echo json_encode($complications);
 }
 /**
  * Get any relevant warnings.
  *
  * @return array
  */
 public function getProcessWarnings()
 {
     $warnings = array();
     $el_diag = $this->getElement('Element_OphCoTherapyapplication_Therapydiagnosis');
     $sides = array();
     if ($el_diag->hasLeft()) {
         $sides[] = 'left';
     }
     if ($el_diag->hasRight()) {
         $sides[] = 'right';
     }
     if ($api = Yii::app()->moduleAPI->get('OphCiExamination')) {
         $missing_sides = array();
         foreach ($sides as $side) {
             if (!$api->getInjectionManagementComplexInEpisodeForDisorder($this->event->episode->patient, $this->event->episode, $side, $el_diag->{$side . '_diagnosis1_id'}, $el_diag->{$side . '_diagnosis2_id'})) {
                 $missing_sides[] = $side;
             }
         }
         foreach ($missing_sides as $missing) {
             $warnings[] = 'No Injection Management has been created for ' . $missing . ' diagnosis.';
         }
         // if the application doesn't have a given side, the VA value can be NR (e.g. eye missing etc)
         // but if it does, then we need an actual VA value.
         if (!$api->getLetterVisualAcuityForEpisodeLeft($this->event->episode, !$el_diag->hasLeft(), $this->event->event_date)) {
             $warnings[] = 'Visual acuity not found for left eye.';
         }
         if (!$api->getLetterVisualAcuityForEpisodeRight($this->event->episode, !$el_diag->hasRight(), $this->event->event_date)) {
             $warnings[] = 'Visual acuity not found for right eye.';
         }
     }
     if ($api = Yii::app()->moduleAPI->get('OphTrConsent')) {
         $procedures = Procedure::model()->findAll(array('condition' => 'snomed_code = :snomed or snomed_code = :snomed2 ', 'params' => array(':snomed' => $this::SNOMED_INTRAVITREAL_INJECTION, ':snomed2' => $this::SNOMED_PDT)));
         foreach ($sides as $side) {
             $sideHasConsent = false;
             foreach ($procedures as $procedure) {
                 if ($api->hasConsentForProcedure($this->event->episode, $procedure, $side)) {
                     $sideHasConsent = true;
                     break;
                 }
             }
             if (!$sideHasConsent) {
                 $warnings[] = 'Consent form is required for ' . $side . ' eye.';
             }
         }
     }
     return $warnings;
 }
Exemplo n.º 3
0
 /**
  * Sets Laser Procedures.
  *
  * @param BaseEventTypeElement $element
  * @param array                $data
  * @param null                 $index
  */
 protected function setElementComplexAttributesFromData($element, $data, $index = null)
 {
     if (get_class($element) == 'Element_OphTrLaser_Treatment') {
         $right_procedures = array();
         if (isset($data['treatment_right_procedures'])) {
             foreach ($data['treatment_right_procedures'] as $proc_id) {
                 $right_procedures[] = Procedure::model()->findByPk($proc_id);
             }
         }
         $element->right_procedures = $right_procedures;
         $left_procedures = array();
         if (isset($data['treatment_left_procedures'])) {
             foreach ($data['treatment_left_procedures'] as $proc_id) {
                 $left_procedures[] = Procedure::model()->findByPk($proc_id);
             }
         }
         $element->left_procedures = $left_procedures;
     }
 }
Exemplo n.º 4
0
 /**
  * AJAX method to check for any duplicate procedure bookings.
  */
 public function actionVerifyProcedures()
 {
     $this->setPatient($_REQUEST['patient_id']);
     $resp = array('previousProcedures' => false);
     $procs = array();
     $procs_by_id = array();
     if (isset($_POST['Procedures_procs'])) {
         foreach ($_POST['Procedures_procs'] as $proc_id) {
             if ($p = Procedure::model()->findByPk((int) $proc_id)) {
                 $procs[] = $p;
                 $procs_by_id[$p->id] = $p;
             }
         }
     }
     $eye = Eye::model()->findByPk((int) @$_POST['Element_OphTrOperationbooking_Operation']['eye_id']);
     if ($eye && count($procs)) {
         $matched_procedures = array();
         // get all the operation elements for this patient from booking events that have not been cancelled
         if (Yii::app()->params['OphTrOperationbooking_duplicate_proc_warn_all_eps']) {
             $episodes = $this->patient->episodes;
         } else {
             $episodes = array($this->getEpisode());
         }
         foreach ($episodes as $ep) {
             $events = $ep->getAllEventsByType($this->event_type->id);
             foreach ($events as $ev) {
                 if ($ev->id == @$_POST['event_id']) {
                     // if we're editing, then don't want to check against that event
                     continue;
                 }
                 $op = Element_OphTrOperationbooking_Operation::model()->findByAttributes(array('event_id' => $ev->id));
                 // check operation still valid, and that it is for a matching eye.
                 if (!$op->operation_cancellation_date && ($op->eye_id == Eye::BOTH || $eye->id == Eye::BOTH || $op->eye_id == $eye->id)) {
                     foreach ($op->procedures as $existing_proc) {
                         if (in_array($existing_proc->id, array_keys($procs_by_id))) {
                             if (!isset($matched_procedures[$existing_proc->id])) {
                                 $matched_procedures[$existing_proc->id] = array();
                             }
                             $matched_procedures[$existing_proc->id][] = $op;
                         }
                     }
                 }
             }
         }
         // if procedure matches
         if (count($matched_procedures)) {
             $resp['previousProcedures'] = true;
             $resp['message'] = $this->renderPartial('previous_procedures', array('matched_procedures' => $matched_procedures, 'eye' => $eye, 'procs_by_id' => $procs_by_id), true);
         }
     }
     echo \CJSON::encode($resp);
 }
 public function description()
 {
     $description = 'Operations';
     if ($this->surgeon_id) {
         $description .= ' by ' . User::model()->find($this->surgeon_id)->fullName;
     }
     $description .= ' between ' . date('j M Y', strtotime($this->date_from)) . ' and ' . date('j M Y', strtotime($this->date_to));
     if (!empty($this->Procedures_procs)) {
         $description .= "\nwith procedures: ";
         foreach ($this->Procedures_procs as $i => $proc_id) {
             if ($i) {
                 $description .= ', ';
             }
             $description .= Procedure::model()->findByPk($proc_id)->term;
         }
     }
     if (!empty($this->complications)) {
         $description .= "\nwith cataract complications: ";
         foreach ($this->complications as $i => $complication_id) {
             if ($i) {
                 $description .= ', ';
             }
             $description .= OphTrOperationnote_CataractComplications::model()->findByPk($complication_id)->name;
         }
     }
     return $description;
 }
Exemplo n.º 6
0
 public function run()
 {
     if (empty($_POST)) {
         if (!$this->selected_procedures && $this->element) {
             $this->selected_procedures = $this->element->{$this->relation};
             if ($this->durations) {
                 $this->total_duration = $this->element->total_duration;
             }
         }
     } else {
         $this->selected_procedures = array();
         if (isset($_POST['Procedures_' . $this->identifier]) && is_array($_POST['Procedures_' . $this->identifier])) {
             foreach ($_POST['Procedures_' . $this->identifier] as $proc_id) {
                 $proc = Procedure::model()->findByPk($proc_id);
                 $this->selected_procedures[] = $proc;
                 if ($this->durations) {
                     $this->total_duration += $proc->default_duration;
                 }
             }
         }
     }
     $firm = Firm::model()->findByPk(Yii::app()->session['selected_firm_id']);
     $subspecialty_id = $firm->serviceSubspecialtyAssignment ? $firm->serviceSubspecialtyAssignment->subspecialty_id : null;
     if ($this->restrict_common === 'unbooked') {
         $this->subsections = array();
     } else {
         $this->subsections = SubspecialtySubsection::model()->getList($subspecialty_id);
     }
     $this->procedures = array();
     $this->removed_stack = array();
     if (empty($this->subsections)) {
         foreach (Procedure::model()->getListBySubspecialty($subspecialty_id, $this->restrict_common) as $proc_id => $name) {
             if (empty($_POST)) {
                 $found = false;
                 if ($this->selected_procedures) {
                     foreach ($this->selected_procedures as $procedure) {
                         if ($procedure->id == $proc_id) {
                             $found = true;
                             break;
                         }
                     }
                 }
                 if (!$found) {
                     $this->procedures[$proc_id] = $name;
                 } else {
                     $this->removed_stack[] = "{id: {$proc_id}, name: '{$name}'}";
                 }
             } else {
                 if (!@$_POST['Procedures_' . $this->identifier] || !in_array($proc_id, $_POST['Procedures_' . $this->identifier])) {
                     $this->procedures[$proc_id] = $name;
                 } else {
                     $this->removed_stack[] = "{id: {$proc_id}, name: '{$name}'}";
                 }
             }
         }
     } else {
         // Doesn't matter if removed_stack contains non-common procedures as lists are reloaded using ajax on removal
         if (!empty($this->selected_procedures)) {
             foreach ($this->selected_procedures as $selected_procedure) {
                 $this->removed_stack[] = "{id: {$selected_procedure->id}, name: '{$selected_procedure->term}'}";
             }
         }
     }
     $this->class = get_class($this->element);
     if ($this->read_only) {
         $this->render(get_class($this) . '_readonly');
     } else {
         $this->render(get_class($this));
     }
 }
Exemplo n.º 7
0
 /**
  * Deletes rows for the model.
  */
 public function actionDelete()
 {
     $admin = new Admin(Procedure::model(), $this);
     $admin->deleteModel();
 }
Exemplo n.º 8
0
 /**
  * @param Element_OphTrOperationnote_ProcedureList $element
  * @param $data
  * @param $index
  */
 protected function setComplexAttributes_Element_OphTrOperationnote_ProcedureList($element, $data, $index)
 {
     $procs = array();
     if (isset($data['Procedures_procs'])) {
         foreach ($data['Procedures_procs'] as $proc_id) {
             $procs[] = Procedure::model()->findByPk($proc_id);
         }
     }
     $element->procedures = $procs;
 }