From 1f1aa14804e60e79725fb0c60b1ef07d76785af6 Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Mon, 18 Dec 2023 11:32:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=8E=B7=E5=8F=96=E5=AE=B6?= =?UTF-8?q?=E5=BA=AD=E6=88=90=E5=91=98=E7=97=85=E6=83=85=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E5=88=86=E7=BB=84=E4=B8=BA=E4=BB=8E=E5=AE=B6=E5=BA=AD=E6=88=90?= =?UTF-8?q?=E5=91=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Model/PatientFamily.php | 1 + app/Services/PatientPathographyService.php | 48 ++++++++++++++-------- config/routes.php | 2 - 3 files changed, 33 insertions(+), 18 deletions(-) diff --git a/app/Model/PatientFamily.php b/app/Model/PatientFamily.php index a2768fe..aa1bbfd 100644 --- a/app/Model/PatientFamily.php +++ b/app/Model/PatientFamily.php @@ -7,6 +7,7 @@ namespace App\Model; use Hyperf\Database\Model\Collection; +use Hyperf\Database\Model\Relations\HasOne; use Hyperf\Snowflake\Concern\Snowflake; /** diff --git a/app/Services/PatientPathographyService.php b/app/Services/PatientPathographyService.php index c4674a6..ed76afc 100644 --- a/app/Services/PatientPathographyService.php +++ b/app/Services/PatientPathographyService.php @@ -229,27 +229,43 @@ class PatientPathographyService extends BaseService { $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)){ + $patient_familys = PatientFamily::getList($params); + if (empty($patient_familys)){ return success(); } - return success($patient_pathographys->toArray()); + // 定义返回数据 + $results = array(); + + foreach ($patient_familys as $patient_family){ + // 定义返回数据 + $result = array(); + $result['user_id'] = $user_info['user_id']; + $result['patient_id'] = $patient_family['patient_id']; + $result['family_id'] = $patient_family['family_id']; + $result['status'] = $patient_family['status']; + $result['card_name'] = $patient_family['card_name']; + $result['sex'] = $patient_family['sex']; + $result['age'] = $patient_family['age']; + $result['count'] = 0; + + $params = array(); + $params['user_id'] = $user_info['user_id']; + $params['patient_id'] = $patient_family['patient_id']; + $params['family_id'] = $patient_family['family_id']; + $params['status'] = 1; + $patient_pathographys = PatientPathography::getList($params); + if (!empty($patient_pathographys)){ + $result['count'] = count($patient_pathographys); + } + + $results[] = $result; + } + + return success($results); } /** diff --git a/config/routes.php b/config/routes.php index 43edbc2..d218763 100644 --- a/config/routes.php +++ b/config/routes.php @@ -377,8 +377,6 @@ Router::addGroup('/patient', function () { // 获取家庭成员用药记录列表 Router::get('/record', [PatientFamilyController::class, 'getFamilyProductRecord']); }); - - }); // 药品