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)); }
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 = MedicalRecord::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
/** * 匯出就醫記錄 */ public function actionMedicalRecords() { $dataProvider = new MedicalRecord('search'); $dataProvider->unsetAttributes(); if (isset($_GET['MedicalRecord'])) { $dataProvider->attributes = $_GET['MedicalRecord']; $medicalRecords = MedicalRecord::model()->findAll($dataProvider->search()->getCriteria()); $fields = array('流水號' => 'id', '病歷號' => 'patientId', '姓名' => 'patientName', '就醫時間' => 'date', '就醫目的' => 'purpose', '計畫' => 'plan', '看診結果' => 'result', '返診日期' => 'next_back_to_clinic_date', '返診事宜' => 'next_back_to_clinic_notes'); $content = implode("\t", array_keys($fields)) . "\n"; foreach ($medicalRecords as $medicalRecord) { foreach ($fields as $field) { $content .= '"' . $medicalRecord->{$field} . '"' . "\t"; } $content .= "\n"; } $this->_downloadExcel('就醫記錄-' . date('Y-m-d-His'), $content); } exit; }