/**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
    public function search($params)
    {
        $query = Procedures2::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([
            'id' => $this->id,
            'factor' => $this->factor,
            'factor_code' => $this->factor_code,
            'optional' => $this->optional,
        ]);

        $query->andFilterWhere(['ilike', 'name', $this->name]);

        return $dataProvider;
    }
 /**
  * Finds the Procedures2 model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Procedures2 the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Procedures2::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getProcedures()
 {
     return $this->hasMany(Procedures2::className(), ['factor' => 'id']);
 }
 /**
  * есть ли ретикулоциты
  * @param type $factors1
  * @param type $factors2
  * @return boolean
  */
 protected function defineProc($factors1, $factors2, $proc_cond_arr)
 {
     $proc_cond = "and name not like '%*%'";
     foreach ($proc_cond_arr as $el) {
         if (is_array($el)) {
             $el_str = implode("' or name like '", $el);
             $proc_cond .= " and ( name like '{$el_str}' )";
         } else {
             $proc_cond .= " and name like '{$el}'";
         }
     }
     foreach ($factors1 as $factor) {
         $factor_model = Factors1::find()->where(['code' => $factor])->one();
         if ($factor_model) {
             $proc = Procedures1::find()->where("factor={$factor_model->id}" . $proc_cond)->one();
             if ($proc) {
                 $procedure = Procedures::find()->where(['procedure' => $proc->name])->one();
                 if ($procedure && $procedure->place) {
                     return $procedure->place;
                 }
                 return 'каб.';
             }
         }
     }
     foreach ($factors2 as $factor) {
         $factor_model = Factors2::find()->where(['code' => $factor])->one();
         if ($factor_model) {
             $proc = Procedures2::find()->where("factor={$factor_model->id}" . $proc_cond)->one();
             if ($proc) {
                 $procedure = Procedures::find()->where(['procedure' => $proc->name])->one();
                 if ($procedure && $procedure->place) {
                     return $procedure->place;
                 }
                 return 'каб.';
             }
         }
     }
     return false;
 }