修改病情记录路由,用户id判断规则

This commit is contained in:
wucongxing 2023-12-14 13:12:33 +08:00
parent a8cef4ebd5
commit ec1a2fc134
2 changed files with 68 additions and 6 deletions

View File

@ -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();
}

View File

@ -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']);
});