From ec1a2fc13488c3882642efe868bd0c9472903c4b Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Thu, 14 Dec 2023 13:12:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=97=85=E6=83=85=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E8=B7=AF=E7=94=B1=EF=BC=8C=E7=94=A8=E6=88=B7id?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/PatientPathographyService.php | 56 +++++++++++++++++++--- config/routes.php | 18 +++++++ 2 files changed, 68 insertions(+), 6 deletions(-) diff --git a/app/Services/PatientPathographyService.php b/app/Services/PatientPathographyService.php index 8b5c46f..49e0468 100644 --- a/app/Services/PatientPathographyService.php +++ b/app/Services/PatientPathographyService.php @@ -28,13 +28,27 @@ class PatientPathographyService extends BaseService $user_info = $this->request->getAttribute("userInfo") ?? []; $family_id = $this->request->input('family_id'); + // 获取家庭成员数据 + $params = array(); + $params['family_id'] = $family_id; + $patient_family = PatientFamily::getOne($params); + if (empty($patient_family)){ + return fail(); + } + + if ($user_info['user_type'] == 1){ + // 患者情况下 用户id需相同 + if ($patient_family['patient_id'] != $user_info['client_user_id']){ + return fail(); + } + } + $result = array(); $result['is_exist'] = 0; // 获取病情记录 $params = array(); - $params['user_id'] = $user_info['user_id']; - $params['patient_id'] = $user_info['client_user_id']; + $params['patient_id'] = $patient_family['patient_id']; $params['family_id'] = $family_id; $params['status'] = 1; $patient_pathography = PatientPathography::getLastOne($params); @@ -51,6 +65,7 @@ class PatientPathographyService extends BaseService */ public function getFamilyPathographyPage(): array { + $user_info = $this->request->getAttribute("userInfo") ?? []; $family_id = $this->request->input('family_id'); $page = $this->request->input('page', 1); $per_page = $this->request->input('per_page', 10); @@ -63,6 +78,13 @@ class PatientPathographyService extends BaseService return fail(); } + if ($user_info['user_type'] == 1){ + // 患者情况下 用户id需相同 + if ($patient_family['patient_id'] != $user_info['client_user_id']){ + return fail(); + } + } + // 获取病情记录列表 $fields = [ "pathography_id", @@ -103,8 +125,6 @@ class PatientPathographyService extends BaseService $pathography_id = $this->request->route('pathography_id'); $params = array(); - $params['user_id'] = $user_info['user_id']; - $params['patient_id'] = $user_info['client_user_id']; $params['pathography_id'] = $pathography_id; $params['status'] = 1; $patient_pathography = PatientPathography::getOne($params); @@ -112,6 +132,17 @@ class PatientPathographyService extends BaseService return success(null); } + if ($user_info['user_type'] == 1){ + // 患者情况下 用户id需相同 + if ($patient_pathography['patient_id'] != $user_info['client_user_id']){ + return fail(); + } + + if ($patient_pathography['user_id'] != $user_info['user_id']){ + return fail(); + } + } + $result = $patient_pathography->toArray(); $result['order_prescription'] = null; // 处方数据 $result['patient_pathography_product'] = array(); // 用药意向 @@ -231,14 +262,27 @@ class PatientPathographyService extends BaseService // 获取病情记录 $params = array(); - $params['user_id'] = $user_info['user_id']; - $params['patient_id'] = $user_info['client_user_id']; $params['pathography_id'] = $pathography_id; $patient_pathography = PatientPathography::getOne($params); if (empty($patient_pathography)){ return fail(HttpEnumCode::HTTP_ERROR,"无该病例"); } + if ($user_info['user_type'] == 2){ + return fail(); + } + + if ($user_info['user_type'] == 1){ + // 患者情况下 用户id需相同 + if ($patient_pathography['patient_id'] != $user_info['client_user_id']){ + return fail(); + } + + if ($patient_pathography['user_id'] != $user_info['user_id']){ + return fail(); + } + } + if ($patient_pathography['status'] == 2){ return success(); } diff --git a/config/routes.php b/config/routes.php index e9a1eea..43edbc2 100644 --- a/config/routes.php +++ b/config/routes.php @@ -797,3 +797,21 @@ Router::addGroup('/inquiry', function () { // 获取弹窗数据 Router::get('/popup', [UserController::class, 'getUserPopup']); + +// 病情记录 +Router::addGroup('/pathography', function () { + // 检测家庭成员是否存在病情记录 + Router::get('/exist', [PatientPathographyController::class, 'existFamilyPathography']); + + // 获取家庭成员病情记录列表-分页 + Router::get('', [PatientPathographyController::class, 'getFamilyPathographyPage']); + + // 获取家庭成员病情记录详情 + Router::get('/{pathography_id:\d+}', [PatientPathographyController::class, 'getFamilyPathographyInfo']); + + // 获取家庭成员病情记录分组 + Router::get('/group', [PatientPathographyController::class, 'getFamilyPathographyGroup']); + + // 删除家庭成员病情记录 + Router::delete('/{pathography_id:\d+}', [PatientPathographyController::class, 'deleteFamilyPathography']); +}); \ No newline at end of file