public function actionUpdate($id)
 {
     $patient = $this->loadModel($id);
     $doctors = Doctor::model()->findAll();
     $medicalRecords = new MedicalRecord('search');
     $medicalRecords->unsetAttributes();
     $surgeryRecords = new SurgeryRecord('search');
     $surgeryRecords->unsetAttributes();
     if (isset($_GET['MedicalRecord'])) {
         $medicalRecords->attributes = $_GET['MedicalRecord'];
     }
     if (isset($_GET['SurgeryRecord'])) {
         $surgeryRecords->attributes = $_GET['SurgeryRecord'];
     }
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($patient);
     if (isset($_POST['Patient'])) {
         $patient->attributes = $_POST['Patient'];
         if ($patient->save()) {
             Yii::app()->user->setFlash('success', '儲存成功.');
             $this->redirect(array('update', 'id' => $patient->id));
         }
     }
     $this->render('update', array('patient' => $patient, 'doctors' => $doctors, 'medicalRecords' => $medicalRecords, 'surgeryRecords' => $surgeryRecords));
 }
Example #2
0
 public function actionRecent()
 {
     $doctors = Doctor::model()->findAll();
     $recentOutpatients = new MedicalRecord('search');
     $recentOutpatients->unsetAttributes();
     if (isset($_GET['MedicalRecord'])) {
         $recentOutpatients->attributes = $_GET['MedicalRecord'];
     }
     $recentSurgeries = new SurgeryRecord('search');
     $recentSurgeries->unsetAttributes();
     if (isset($_GET['SurgeryRecord'])) {
         $recentSurgeries->attributes = $_GET['SurgeryRecord'];
     }
     $this->render('index', compact('recentOutpatients', 'recentSurgeries', 'doctors'));
 }
 public function loadModel($id)
 {
     $model = SurgeryRecord::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Example #4
0
 /**
  * 匯出手術記錄
  */
 public function actionSurgeryRecords()
 {
     $dataProvider = new SurgeryRecord('search');
     $dataProvider->unsetAttributes();
     if (isset($_GET['SurgeryRecord'])) {
         $dataProvider->attributes = $_GET['SurgeryRecord'];
         $surgeryRecords = SurgeryRecord::model()->findAll($dataProvider->search()->getCriteria());
         $fields = array('病歷號' => 'patientId', '姓名' => 'patientName', '手術日期' => 'date', '給付' => 'payType', '術前診斷' => 'icd', '術式' => 'surgical_methods', '3D' => 'three_dimensional', '矯正牙科醫師' => 'dentistName', '手術醫師' => 'plasticSurgeonName', '備註' => 'memo', '是否手術優先' => 'isSurgicalPriority', '是否院外牙科' => 'isOutsideDentist');
         $content = implode("\t", array_keys($fields)) . "\n";
         foreach ($surgeryRecords as $surgeryRecord) {
             foreach ($fields as $field) {
                 $content .= '"' . $surgeryRecord->{$field} . '"' . "\t";
             }
             $content .= "\n";
         }
         $this->_downloadExcel('手術記錄-' . date('Y-m-d-His'), $content);
     }
     exit;
 }
Example #5
0
 /**
  * 匯入手術記錄
  */
 public function actionSurgeryRecords()
 {
     $this->currentActive = '手術記錄';
     $excel = new ExcelUploadForm();
     $rows = array();
     $errors = array();
     if (isset($_POST['ExcelUploadForm'])) {
         $excel->attributes = $_POST['ExcelUploadForm'];
         $excel->file = CUploadedFile::getInstance($excel, 'file');
         $transaction = Yii::app()->db->beginTransaction();
         try {
             if ($excel->validate()) {
                 $rows = $excel->getContents();
                 foreach ($rows as $i => $row) {
                     if ($i != ExcelUploadForm::HEADER) {
                         $surgeryRecord = new SurgeryRecord();
                         $surgeryRecord->patient_id = $row[1];
                         $surgeryRecord->date = $row[3];
                         $surgeryRecord->pay_type = $this->_getCovertPayType($row[4]);
                         // 1=健保, 2=自費
                         $surgeryRecord->icd = $row[5];
                         $surgeryRecord->surgical_methods = $row[6];
                         $surgeryRecord->three_dimensional = $row[7];
                         $surgeryRecord->dentist_id = $row[8];
                         $surgeryRecord->plastic_surgeon_id = $row[10];
                         $surgeryRecord->memo = $row[12];
                         $surgeryRecord->is_surgical_priority = $this->_getConvertChecked($row[13]);
                         $surgeryRecord->is_outside_dentist = $this->_getConvertChecked($row[14]);
                         if (!$surgeryRecord->save()) {
                             $errorData = array('第' . ($i + 1) . '筆,' . $row[2] => $surgeryRecord->getErrors());
                             $errors[] = $errorData;
                         }
                     }
                 }
                 $transaction->commit();
             } else {
                 $errors[] = array('Excel' => $excel->getErrors());
             }
         } catch (Exception $e) {
             $transaction->rollBack();
             $errors = $e->getMessage();
         }
         $this->_setFlashMessage($errors);
         $this->redirect($this->createUrl("/excel/import/{$this->action->id}"));
     }
     $this->render('upload', array('excel' => $excel));
 }