(C) Moorfields Eye Hospital NHS Foundation Trust, 2008-2011 (C) OpenEyes Foundation, 2011-2013 This file is part of OpenEyes. OpenEyes is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenEyes is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenEyes in a file titled COPYING. If not, see .
Author: OpenEyes (info@openeyes.org.uk)
 /**
  * Carry out a search on the waiting list.
  */
 public function actionSearch()
 {
     Audit::add('waiting list', 'search');
     if (empty($_POST)) {
         $operations = array();
     } else {
         $subspecialty_id = !empty($_POST['subspecialty-id']) ? $_POST['subspecialty-id'] : null;
         $firm_id = !empty($_POST['firm-id']) ? $_POST['firm-id'] : null;
         $status = !empty($_POST['status']) ? $_POST['status'] : null;
         $patient_search = new PatientSearch();
         $hos_num = $patient_search->getHospitalNumber($_POST['hos_num']);
         $site_id = !empty($_POST['site_id']) ? $_POST['site_id'] : false;
         YiiSession::set('waitinglist_searchoptions', array('subspecialty-id' => $subspecialty_id, 'firm-id' => $firm_id, 'status' => $status, 'hos_num' => $hos_num, 'site_id' => $site_id));
         $operations = $this->getWaitingList($firm_id, $subspecialty_id, $status, $hos_num, $site_id);
     }
     $this->renderPartial('_list', array('operations' => $operations, 'assetPath' => $this->assetPath), false, true);
 }
Example #2
0
 /**
  * Omnibox search handler.
  */
 public function actionSearch()
 {
     if (isset($_POST['query']) && ($query = trim($_POST['query']))) {
         //empty string
         if (strlen($query) == 0) {
             Yii::app()->user->setFlash('warning.search_error', 'Please enter either a hospital number or a firstname and lastname.');
         } else {
             // Event ID
             if (preg_match('/^(E|Event)\\s*[:;]\\s*([0-9]+)$/i', $query, $matches)) {
                 $event_id = $matches[2];
                 if ($event = Event::model()->findByPk($event_id)) {
                     $event_class_name = $event->eventType->class_name;
                     $this->redirect(array($event_class_name . '/default/view/' . $event_id));
                 } else {
                     Yii::app()->user->setFlash('warning.search_error', 'Event ID not found');
                     $this->redirect('/');
                 }
                 return;
             } else {
                 $patientSearch = new PatientSearch();
                 // lets check if it is a NHS number, Hospital number or Patient name
                 if ($patientSearch->getNHSnumber($query) || $patientSearch->getHospitalNumber($query) || $patientSearch->getPatientName($query)) {
                     $this->redirect(array('patient/search', 'term' => $query));
                 } else {
                     // not a valid search
                     Yii::app()->user->setFlash('warning.search_error', '<strong>"' . CHtml::encode($query) . '"</strong> is not a valid search.');
                 }
             }
         }
     }
     /*
                 // NHS number (assume 10 digit number is an NHS number)
                 if(preg_match('/^(N|NHS)\s*[:;]\s*([0-9\- ]+)$/i',$query,$matches)
                         || preg_match('/^([0-9]{3}[- ]?[0-9]{3}[- ]?[0-9]{4})$/i',$query,$matches)) {
                     $nhs = (isset($matches[2])) ? $matches[2] : $matches[1];
                     $nhs = str_replace(array('-',' '),'',$nhs);
                     $this->redirect(array('patient/search', 'nhs_num' => $nhs));
                     return;
                 }
     
                 // Hospital number (assume a < 10 digit number is a hosnum)
                 if(preg_match('/^(H|Hosnum)\s*[:;]\s*([0-9a-zA-Z\-]+)$/i',$query,$matches)
                         || preg_match(Yii::app()->params['hos_num_regex'],$query,$matches)) {
                     $hosnum = (isset($matches[2])) ? $matches[2] : $matches[1];
                     $this->redirect(array('patient/search', 'hos_num' => $hosnum));
                     return;
                 }
     
                 // Patient name
                 if (preg_match('/^(?:P(?:atient)?[:;\s]*)?(.*[ ,].*)$/', $query, $m)) {
                     $name = $m[1];
     
                     if (strpos($name, ',') !== false) {
                         list ($surname, $firstname) = explode(',', $name, 2);
                     } else {
                         list ($firstname, $surname) = explode(' ', $name, 2);
                     }
     
                     $this->redirect(array('patient/search', 'first_name' => trim($firstname), 'last_name' => trim($surname)));
                 }
                     } */
     /*if (isset($query)) {
           if (strlen($query) == 0) {
               Yii::app()->user->setFlash('warning.search_error', "Please enter either a hospital number or a firstname and lastname.");
           } else {
               Yii::app()->user->setFlash('warning.search_error', '<strong>"'.CHtml::encode($query).'"</strong> is not a valid search.');
           }
       }*/
     $this->redirect('/');
 }
 public function actionSearch()
 {
     $term = trim(\Yii::app()->request->getParam('term', ''));
     $result = array();
     $patientSearch = new PatientSearch();
     if ($patientSearch->isValidSearchTerm($term)) {
         $dataProvider = $patientSearch->search($term);
         foreach ($dataProvider->getData() as $patient) {
             // check if the patient is already in the Request List
             $warning = '';
             $isInList = $this->isPatientInRequestList($patient->id);
             if ($isInList) {
                 $warning = "This patient is already requested for merge as {$isInList} patient.";
             }
             $result[] = array('id' => $patient->id, 'first_name' => $patient->first_name, 'last_name' => $patient->last_name, 'age' => $patient->isDeceased() ? 'Deceased' : $patient->getAge(), 'gender' => $patient->getGenderString(), 'genderletter' => $patient->gender, 'dob' => $patient->dob ? $patient->NHSDate('dob') : 'Unknown', 'hos_num' => $patient->hos_num, 'nhsnum' => $patient->nhsnum, 'all-episodes' => $this->getEpisodesHTML($patient), 'warning' => $warning);
         }
     }
     echo CJavaScript::jsonEncode($result);
     Yii::app()->end();
 }
Example #4
0
 /**
  * Ajax search.
  */
 public function actionAjaxSearch()
 {
     $term = trim(\Yii::app()->request->getParam('term', ''));
     $result = array();
     $patientSearch = new PatientSearch();
     if ($patientSearch->isValidSearchTerm($term)) {
         $dataProvider = $patientSearch->search($term);
         foreach ($dataProvider->getData() as $patient) {
             $result[] = array('id' => $patient->id, 'first_name' => $patient->first_name, 'last_name' => $patient->last_name, 'age' => $patient->isDeceased() ? 'Deceased' : $patient->getAge(), 'gender' => $patient->getGenderString(), 'genderletter' => $patient->gender, 'dob' => $patient->dob ? $patient->NHSDate('dob') : 'Unknown', 'hos_num' => $patient->hos_num, 'nhsnum' => $patient->nhsnum, 'label' => $patient->first_name . ' ' . $patient->last_name . ' (' . $patient->hos_num . ')');
         }
     }
     echo CJavaScript::jsonEncode($result);
     Yii::app()->end();
 }