From 8207d73fead752512e0ab842fd476563dd55e15f Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Wed, 22 Nov 2023 12:03:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=AE=B6=E5=BA=AD=E6=88=90=E5=91=98=E7=97=85=E6=83=85=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E5=88=86=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PatientPathographyController.php | 11 ++++++ app/Model/PatientPathography.php | 9 +++++ app/Request/PatientPathographyRequest.php | 3 ++ app/Services/PatientPathographyService.php | 35 +++++++++++++++++++ config/routes.php | 23 ++++++------ 5 files changed, 71 insertions(+), 10 deletions(-) diff --git a/app/Controller/PatientPathographyController.php b/app/Controller/PatientPathographyController.php index a885951..64e1496 100644 --- a/app/Controller/PatientPathographyController.php +++ b/app/Controller/PatientPathographyController.php @@ -58,4 +58,15 @@ class PatientPathographyController extends AbstractController $data = $PatientPathographyService->getFamilyPathographyInfo(); return $this->response->json($data); } + + /** + * 获取家庭成员病情记录分组 + * @return ResponseInterface + */ + public function getFamilyPathographyGroup(): ResponseInterface + { + $PatientPathographyService = new PatientPathographyService(); + $data = $PatientPathographyService->getFamilyPathographyGroup(); + return $this->response->json($data); + } } \ No newline at end of file diff --git a/app/Model/PatientPathography.php b/app/Model/PatientPathography.php index a4caffe..00c1b2b 100644 --- a/app/Model/PatientPathography.php +++ b/app/Model/PatientPathography.php @@ -7,6 +7,7 @@ namespace App\Model; use Hyperf\Database\Model\Collection; +use Hyperf\DbConnection\Db; use Hyperf\Snowflake\Concern\Snowflake; /** @@ -144,4 +145,12 @@ class PatientPathography extends Model return $data; } + + // 获取信息-分组 + public static function getFamilyPathographyGroup(array $params, array $fields = ['*']): object|null + { + return self::where($params) + ->groupBy(["family_id"]) + ->get($fields); + } } diff --git a/app/Request/PatientPathographyRequest.php b/app/Request/PatientPathographyRequest.php index 5688039..b7045f5 100644 --- a/app/Request/PatientPathographyRequest.php +++ b/app/Request/PatientPathographyRequest.php @@ -14,6 +14,9 @@ class PatientPathographyRequest extends FormRequest 'getFamilyPathographyPage' => [ // 获取家庭成员病情记录列表-分页 'family_id', ], + 'getFamilyPathographyGroup' => [ // 获取家庭成员病情记录分组 + 'family_id', + ], ]; /** diff --git a/app/Services/PatientPathographyService.php b/app/Services/PatientPathographyService.php index a610c81..3b825de 100644 --- a/app/Services/PatientPathographyService.php +++ b/app/Services/PatientPathographyService.php @@ -11,6 +11,7 @@ use App\Model\PatientPathography; use App\Model\PatientPathographyProduct; use App\Model\Product; use App\Utils\PcreMatch; +use Hyperf\DbConnection\Db; /** * 家庭成员病情记录 @@ -34,6 +35,7 @@ class PatientPathographyService extends BaseService $params['user_id'] = $user_info['user_id']; $params['patient_id'] = $user_info['client_user_id']; $params['family_id'] = $family_id; + $params['status'] = 1; $patient_pathography = PatientPathography::getLastOne($params); if (!empty($patient_pathography)){ $result['is_exist'] = 1; @@ -65,6 +67,7 @@ class PatientPathographyService extends BaseService $params['user_id'] = $user_info['user_id']; $params['patient_id'] = $user_info['client_user_id']; $params['family_id'] = $family_id; + $params['status'] = 1; $patient_pathographys = PatientPathography::getPatientPathographyPage($params, $fields, $page, $per_page); return success($patient_pathographys); @@ -83,6 +86,7 @@ class PatientPathographyService extends BaseService $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); if (empty($patient_pathography)){ return success(null); @@ -157,4 +161,35 @@ class PatientPathographyService extends BaseService return success($result); } + + /** + * 获取家庭成员病情记录分组 + * @return array + */ + public function getFamilyPathographyGroup(): array + { + $user_info = $this->request->getAttribute("userInfo") ?? []; + + $fields = [ + "pathography_id", + "user_id", + "patient_id", + "family_id", + "status", + "name", + "sex", + "age", + Db::raw('COUNT(0) AS `count`') + ]; + $params = array(); + $params['user_id'] = $user_info['user_id']; + $params['patient_id'] = $user_info['client_user_id']; + $params['status'] = 1; + $patient_pathographys = PatientPathography::getFamilyPathographyGroup($params,$fields); + if (empty($patient_pathographys)){ + return success(); + } + + return success($patient_pathographys->toArray()); + } } \ No newline at end of file diff --git a/config/routes.php b/config/routes.php index c55ac89..c0dfe18 100644 --- a/config/routes.php +++ b/config/routes.php @@ -382,17 +382,7 @@ Router::addGroup('/patient', function () { Router::get('/record', [PatientFamilyController::class, 'getFamilyProductRecord']); }); - // 病情记录 - Router::addGroup('/pathography', function () { - // 检测家庭成员是否存在病情记录 - Router::get('/exist', [PatientPathographyController::class, 'existFamilyPathography']); - // 获取家庭成员病情记录列表-分页 - Router::get('', [PatientPathographyController::class, 'getFamilyPathographyPage']); - - // 获取家庭成员病情记录详情 - Router::get('/{pathography_id:\d+}', [PatientPathographyController::class, 'getFamilyPathographyInfo']); - }); }); // 药品 @@ -499,7 +489,20 @@ Router::addGroup('/patient', function () { Router::get('/system/last', [MessageNoticeController::class, 'getPatientMessageServiceLast']); }); + // 病情记录 + 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']); + }); }); // 药师端api