Пример #1
0
 /**
  * Updates an existing Hospitals model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdateData($id)
 {
     Yii::$app->dbTest->createCommand("CALL InsightsIndicatorsUpdate({$id}, 201501, 201509)")->execute();
     if ($rows = Yii::$app->dbTest->createCommand('select afr.*,o.nazwa from afr_indicators afr join oddzial o on o.id=afr.id_oddzial where afr.id_szpital = ' . $id)->queryAll()) {
         foreach ($rows as $line) {
             $division = new Divisions();
             foreach (array_keys($line) as $key) {
                 if ($key !== 'id') {
                     $division->{$key} = $line[$key];
                 }
             }
             $division->save();
         }
     }
     return $this->redirect(['divisions/index', 'id_hospitals' => $id]);
 }
Пример #2
0
 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 = [];
     }
 }
Пример #3
0
 public function calculateIndicators($id, $idSpec)
 {
     $hospitalIndicators = Divisions::find()->where(['id' => $id])->one();
     $indicatorDefinitions = IndicatorNames::find()->all();
     foreach ($indicatorDefinitions as $indicator) {
         $numeratorName = $indicator->basicNumerator->name;
         if ($indicator->denominator != 0) {
             $denominatorName = $indicator->basicDenominator->name;
         }
         if ($indicator->denominator != 0 && $hospitalIndicators->{$denominatorName} != 0) {
             $indicatorValue = ($hospitalIndicators->{$numeratorName} - $hospitalIndicators->{$denominatorName}) / $hospitalIndicators->{$denominatorName};
         } elseif ($indicator->denominator_dec != 0) {
             $indicatorValue = ($hospitalIndicators->{$numeratorName} - $indicator->denominator_dec) / $indicator->denominator_dec;
         } else {
             $indicatorValue = $hospitalIndicators->{$numeratorName};
         }
         $this->indicatorsArray[$indicator->indicator] = Indicators::_getRank($indicator->indicator, $indicatorValue, $id, $idSpec);
     }
 }
 /**
  * Deletes an existing BasicIndicators model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     if (\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $model = $this->findModel($id);
     // Yii::$app->db->createCommand()
     //     ->dropColumn(Hospitals::tableName(), $model->name)
     //     ->execute();
     Yii::$app->db->createCommand()->dropColumn(Divisions::tableName(), $model->name)->execute();
     $model->delete();
     return $this->redirect(['index']);
 }
Пример #5
0
 /**
  * Finds the Hospitals model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Hospitals the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Divisions::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }