public function actionIcds() { $icd1 = new Icd(); $icd1->id = 7; $icd1->name = 'CLEFT MIDFACE HYPOPLASIA WITH CLASS III MALOCCLUSION'; $icd1->save(); var_dump($icd1); echo 'hr'; $icd2 = new Icd(); $icd2->id = 7; $icd2->name = 'OGS,LEFORT I OSTEOTOMY OF MAXILLA +BONE GRAFTING +BSSO OF MANDIBLE +INTER-MAXILLARY WIRING'; $icd2->save(); var_dump($icd2); }
public function actionCreate() { $model = new Icd(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Icd'])) { $model->attributes = $_POST['Icd']; if ($model->save()) { Yii::app()->user->setFlash('success', '儲存成功.'); $this->redirect(array('update', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
public function actionSeed() { $patients = new Patient(); $patients->attributes = array('name' => '鍾**', 'sex' => 1, 'birthday' => '1989-10-21', 'birth_weight' => 3000, 'telphone' => '08-735****', 'cellphone' => '0917******', 'address' => '屏東市**********', 'doctor_id' => 1, 'icd' => ''); $patients->save(); $patients = new Patient(); $patients->attributes = array('name' => '林**', 'sex' => 1, 'birthday' => '1989-08-12', 'birth_weight' => 3000, 'telphone' => '08-735****', 'cellphone' => '0917******', 'address' => '新北市*******', 'doctor_id' => 1, 'icd' => ''); $patients->save(); $icd = new Icd(); $icd->attributes = array('name' => '1號疾病', 'description' => ''); $icd->save(); $icd = new Icd(); $icd->attributes = array('name' => '2號疾病', 'description' => ''); $icd->save(); }
/** * 匯入ICD */ public function actionIcds() { $this->currentActive = 'ICD'; $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) { $icd = new Icd(); $icd->name = $row[1]; if (!$icd->save()) { $errorData = array('第' . ($i + 1) . '筆,' . $row[2] => $icd->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)); }