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']); }); - - }); // 药品