Beispiel #1
0
 public function actionCount($id)
 {
     $physician = Physician::findOne($id);
     if ($physician !== null) {
         return json_encode($physician->getCountAvailableTimeByDates());
     }
 }
Beispiel #2
0
 public function import()
 {
     if ($this->validate()) {
         if ($handle = fopen($this->file->tempName, 'r')) {
             ini_set('max_execution_time', 6000);
             while ($data = fgetcsv($handle, 1000, ',')) {
                 $physician_snils = preg_replace('/[^0-9]/', '', $data[1]);
                 if (empty($physician_snils)) {
                     continue;
                 }
                 $physician = Physician::findOne(['snils' => $physician_snils]);
                 if ($physician === null) {
                     $physician = new Physician();
                     $physician->specialty_id = 1;
                     $physician->snils = $physician_snils;
                     $physician->last_name = 'Необходимо заполнить';
                     $physician->first_name = 'Необходимо заполнить';
                     $physician->patronymic = 'Необходимо заполнить';
                     $physician->save();
                 }
                 if (isset($physician->physician_id)) {
                     $last_name = mb_convert_case(trim($data[2]), MB_CASE_TITLE);
                     $first_name = mb_convert_case(trim($data[3]), MB_CASE_TITLE);
                     $patronymic = mb_convert_case(trim($data[4]), MB_CASE_TITLE);
                     $birth_date = trim($data[5]);
                     $policy = trim($data[6]);
                     $patient = Patient::findOne(['policy' => $policy]);
                     if ($patient === null) {
                         $patient = new Patient();
                         $patient->physician_id = $physician->physician_id;
                         $patient->policy = $policy;
                         $patient->last_name = $last_name;
                         $patient->first_name = $first_name;
                         $patient->patronymic = $patronymic;
                         $patient->birth_date = date('Y-m-d', strtotime($birth_date));
                         $patient->save();
                     }
                 }
             }
             fclose($handle);
             return true;
         }
     }
     return false;
 }
 /**
  * @param integer $physicianId
  * @return mixed
  */
 public function actionUpdate($physicianId)
 {
     $physician = Physician::findOne($physicianId);
     $receptions = Reception::findAll(['physician_id' => $physicianId]);
     if (Yii::$app->request->post('Reception') !== null) {
         Reception::deleteAll(['physician_id' => $physicianId]);
         foreach (Yii::$app->request->post('Reception') as $item) {
             $model = new Reception();
             $model->physician_id = $physicianId;
             $model->locality_id = $item['locality'];
             $model->weekday = $item['weekday'];
             $model->hour = (int) $item['hour'];
             $model->minute = (int) $item['minute'];
             $model->save();
         }
         return $this->redirect(['/appointment/physician/view', 'id' => $physicianId]);
     } else {
         $codes = [];
         foreach ($physician->receptions as $reception) {
             $codes[] = $reception->code;
         }
         return $this->render('update', ['model' => new Reception(), 'physician' => $physician, 'codes' => $codes]);
     }
 }
 /**
  * Finds the Physician model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Physician the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Physician::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }