public function prepareInsights($id, $indicators) { $hospitalIndicators = Divisions::find()->where(['id' => $id])->one(); $whereArray = ['and']; foreach ($indicators as $key => $value) { array_push($whereArray, ['or', "{$key} = {$value}", "{$key} IS NULL"]); } if ($insights = InsightsDef::find()->where($whereArray)->orderBy('priority')->all()) { foreach ($insights as $insight) { foreach ($insight->content as $insightLine) { array_push($this->insightsArray, Insights::_evaluateIndicators($insightLine->content, $hospitalIndicators)); } } } else { $this->insightsArray = []; } }
/** * Generates insights for given hospital. * @param integer $id * @return mixed */ public function actionInsights($id) { $model = $this->findModel($id); $indicators = new Indicators(); $indicators->calculateIndicators($id); $insights = new Insights(); $insights->prepareInsights($indicators->getIndicatorsArray()); return $this->render('insights', ['model' => $model, 'insights' => $insights]); }