コード例 #1
0
ファイル: TicketController.php プロジェクト: andreyvaslv/crb
 public function actionEntry()
 {
     $this->layout = '//main';
     $session = Yii::$app->session;
     if ($session->has('patient_access_token')) {
         $accessToken = $session->get('patient_access_token');
         $session->remove('patient_access_token');
     } else {
         $accessToken = Yii::$app->request->post('access_token');
     }
     if ($accessToken === null) {
         $this->redirect(['login']);
     }
     $patient = Patient::find()->where(['access_token' => $accessToken])->one();
     if ($patient === null) {
         $this->redirect(['login']);
     }
     $ticket = new Ticket();
     if ($ticketForm = Yii::$app->request->post('TicketForm')) {
         $ticket->patient_id = $patient->patient_id;
         $ticket->physician_id = $ticketForm['physician_id'];
         $ticket->locality_id = $ticketForm['locality_id'];
         $time = explode(':', $ticketForm['time']);
         $ticket->hour = $time[0];
         $ticket->minute = $time[1];
         $ticket->date = date('Y-m-d', strtotime($ticketForm['date']));
         if ($ticket->save()) {
             return $this->redirect(['view', 'token' => $ticket->token]);
         }
     }
     return $this->render('entry', ['model' => new TicketForm(), 'patient' => $patient, 'accessToken' => $accessToken]);
 }
コード例 #2
0
ファイル: ImportForm.php プロジェクト: andreyvaslv/crb
 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;
 }
コード例 #3
0
ファイル: PatientSearch.php プロジェクト: andreyvaslv/crb
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Patient::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['patient_id' => $this->patient_id, 'locality_id' => $this->locality_id, 'blocked' => $this->blocked, 'birth_date' => $this->birth_date, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'policy', $this->policy])->andFilterWhere(['like', 'last_name', $this->last_name])->andFilterWhere(['like', 'first_name', $this->first_name])->andFilterWhere(['like', 'patronymic', $this->patronymic]);
     return $dataProvider;
 }
コード例 #4
0
ファイル: PatientController.php プロジェクト: andreyvaslv/crb
 /**
  * Finds the Patient model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Patient the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Patient::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #5
0
ファイル: EntryForm.php プロジェクト: andreyvaslv/crb
 public function getPatient()
 {
     $patient = Patient::findOne(['policy' => $this->policy, 'last_name' => $this->last_name]);
     return $patient;
 }
コード例 #6
0
ファイル: Review.php プロジェクト: andreyvaslv/crb
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPatient()
 {
     return $this->hasOne(Patient::className(), ['patient_id' => 'patient_id']);
 }
コード例 #7
0
ファイル: Physician.php プロジェクト: andreyvaslv/crb
 public function getAvailableTimeByDate($date)
 {
     $session = Yii::$app->session;
     if (($policy = $session->get('policy')) !== null && ($lastName = $session->get('last_name')) !== null) {
         $patient = Patient::findOne(['policy' => $policy, 'last_name' => $lastName]);
         $ticket = $patient->getTickets()->where(['physician_id' => $this->physician_id])->orderBy(['date' => SORT_DESC])->one();
         if ($ticket !== null) {
             $days = abs(ceil((strtotime($ticket->date) - strtotime($date)) / 86400));
             if ($days <= 7) {
                 return [];
             }
         }
     }
     $weekday = date('N', strtotime($date));
     $receptions = $this->getReceptions()->where(['weekday' => $weekday])->all();
     $reservedTimes = $this->getReservedTimeByDate($date);
     $localities = [];
     foreach ($receptions as $reception) {
         if (!in_array($reception->time, $reservedTimes)) {
             $localities[$reception->locality_id]['title'] = $reception->locality->title;
             $localities[$reception->locality_id]['times'][] = $reception->time;
         }
     }
     return $localities;
 }
コード例 #8
0
ファイル: Locality.php プロジェクト: andreyvaslv/crb
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPatients()
 {
     return $this->hasMany(Patient::className(), ['locality_id' => 'locality_id']);
 }