surat/frontend/modules/hospital/controllers/ReportController.php

72 lines
1.8 KiB
PHP
Raw Normal View History

2024-12-25 03:04:59 +00:00
<?php
2025-03-26 13:08:00 +00:00
namespace frontend\modules\api\controllers;
2024-12-25 03:04:59 +00:00
use common\models\CaseDish;
use common\models\CaseNonGyn;
use common\models\CasePap;
2025-03-26 13:08:00 +00:00
use common\models\CaseSurgical;
use common\models\ConstServiceCharge;
2024-12-25 03:04:59 +00:00
use common\models\FinanceServiceCharge;
2025-03-26 13:08:00 +00:00
use common\models\HospitalCaseOpen;
use common\models\HospitalImport;
2024-12-25 03:04:59 +00:00
use Yii;
2025-03-26 13:08:00 +00:00
use yii\rest\Controller;
use common\models\HospitalImportServiceCharge;
use common\models\HospitalImportServiceChargeMapping;
use common\models\PatientCase;
use yii\db\Expression;
use yii\helpers\Json;
use common\models\User;
use common\models\CaseAutopsy;
use common\models\CaseFrozen;
use common\models\CaseHpv;
use Exception;
2024-12-25 03:04:59 +00:00
use yii\data\ActiveDataProvider;
2025-03-26 13:08:00 +00:00
use yii\web\NotFoundHttpException;
2024-12-25 03:04:59 +00:00
class ReportController extends Controller
{
2025-03-26 13:08:00 +00:00
2024-12-25 03:04:59 +00:00
/**
2025-03-26 13:08:00 +00:00
* View Report
*
* @param [type] $report_key
* @param [type] $hn
* @return void
2024-12-25 03:04:59 +00:00
*/
2025-03-26 13:08:00 +00:00
public function actionView($report_key, $hn)
2024-12-25 03:04:59 +00:00
{
2025-03-26 13:08:00 +00:00
$this->layout = 'hospital';
2024-12-25 03:04:59 +00:00
2025-03-26 13:08:00 +00:00
if (empty($hn) || empty($report_key)) {
throw new NotFoundHttpException('Invalid request');
2024-12-25 03:04:59 +00:00
}
2025-03-26 13:08:00 +00:00
if ($report_key != Yii::$app->params['report_key']) {
throw new NotFoundHttpException('Wrong report key');
2024-12-25 03:04:59 +00:00
}
2025-03-26 13:08:00 +00:00
$user = User::findIdentityByAccessToken('7vq04fPZbLJGiXK2TrMKnZ0b8cuQGq6r');
if ($user) {
Yii::$app->user->login($user, 60);
$case = PatientCase::find()->where(['h_n' => $hn])->one();
2024-12-25 03:04:59 +00:00
2025-03-26 13:08:00 +00:00
if (!$case || empty($case->id_case)) {
throw new NotFoundHttpException('Patient not found');
2024-12-25 03:04:59 +00:00
}
}
2025-03-26 13:08:00 +00:00
$dataProvider = new ActiveDataProvider([
'query' => PatientCase::find()->where(['h_n' => $hn]),
2024-12-25 03:04:59 +00:00
]);
2025-03-26 13:08:00 +00:00
return $this->render('view', [
'case' => $case,
'dataProvider' => $dataProvider,
2024-12-25 03:04:59 +00:00
]);
}
2025-03-26 13:08:00 +00:00
}