/**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
    public function search($params,$firm_id=false)
    {
        $query = Patients::find()->orderBy('surname');

        $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([
            'id' => $this->id,
            'birthday' => $this->birthday,
            'passport_series' => $this->passport_series,
            'passport_number' => $this->passport_number,
            'passport_given_date' => $this->passport_given_date,
            'passport_given_date' => $this->talon,
            'firm_id' => $firm_id?$firm_id:$this->firm_id,
        ]);

        $query->andFilterWhere(['ilike', 'surname', $this->surname])
            ->andFilterWhere(['ilike', 'name', $this->name])
            ->andFilterWhere(['ilike', 'patron', $this->patron])
            ->andFilterWhere(['ilike', 'snils', $this->snils])
            ->andFilterWhere(['ilike', 'sex', $this->sex])
            ->andFilterWhere(['ilike', 'spec', $this->spec])
            ->andFilterWhere(['ilike', 'phone', $this->phone])
            ->andFilterWhere(['ilike', 'factors1', $this->factors1])
            ->andFilterWhere(['ilike', 'factors2', $this->factors2])
            ->andFilterWhere(['ilike', 'seniority', $this->seniority])
            ->andFilterWhere(['ilike', 'dep', $this->dep])
            ->andFilterWhere(['ilike', 'prof', $this->prof])
            ->andFilterWhere(['ilike', 'addresse_reg', $this->addresse_reg])
            ->andFilterWhere(['ilike', 'addresse_fact', $this->addresse_fact])
            ->andFilterWhere(['ilike', 'disability', $this->disability])
            ->andFilterWhere(['ilike', 'passport_given_who', $this->passport_given_who])
            ->andFilterWhere(['ilike', 'insurance_company', $this->insurance_company])
            ->andFilterWhere(['ilike', 'insurance_number', $this->insurance_number])
            ->andFilterWhere(['ilike', 'living_lpu', $this->living_lpu])
            ->andFilterWhere(['ilike', 'firm', $this->firm])
            ->andFilterWhere(['ilike', 'descr', $this->descr])
            ->andFilterWhere(['ilike', 'file', $this->file]);

        return $dataProvider;
    }
 /**
  * dividing patients to groups to print
  * @param type $id
  * @return type
  */
 public function actionToprint($id)
 {
     $model = $this->findModel($id);
     $patients = Patients::find()->where(['firm_id' => $id])->orderBy('surname,name,patron')->all();
     $pat_groups = $group = $group_ids = [];
     $i = 0;
     foreach ($patients as $j => $patient) {
         $group[] = $patient;
         $group_ids[] = $patient['id'];
         ++$i;
         if ($i == 10 || $j == count($patients) - 1) {
             $pat_groups[] = [$group, $group_ids];
             $group = [];
             $group_ids = [];
             $i = 0;
         }
     }
     return $this->render('toprint', ['model' => $model, 'pat_groups' => $pat_groups]);
 }
Example #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPatients()
 {
     return $this->hasMany(Patients::className(), ['firm_id' => 'id']);
 }
Example #4
0
 /**
  * save data
  * @param array objects $data
  * @return type
  */
 protected static function saveData($data)
 {
     foreach ($data as $i=>$row) {
         $result=Patients::add($row);
         if($result) {
             return $result;
         }
     }
     return $data[0]['firm_id'];
 }
 /**
  * @param integer $id
  * @param integer $firm
  * @return boolean
  */
 public function actionPrint($id = false, $firm = false, array $ids = [])
 {
     if ($firm) {
         $condition = ['firm_id' => $firm];
     } elseif ($id) {
         $condition = ['id' => $id];
     } elseif ($ids) {
         $condition = ['id' => $ids];
     } else {
         return false;
     }
     $models = Patients::find()->where($condition)->all();
     if (!$models) {
         return false;
     }
     $this->_print($models);
 }
Example #6
0
 /**
  * 
  * @param type $data
  */
 public static function add($data)
 {
     $patient = new Patients();
     $patient->attributes=$data;
     if($patient->save()) {
         return false;
     }
     $patient_errors=[];
     foreach ($patient->errors as $error) {
         $patient_errors[]=implode(', ',$error);
     }
     $errors=implode('<br> ',$patient_errors);
     return 'При сохранении пациента '.$patient->surname.' '.$patient->name.' '.$patient->patron.' возникли ошибки: '.$errors;
 }
 /**
  * Finds the Patients model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Patients the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Patients::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }