From 6258e4f0896f59e819dd8579f2e08fdfcd88f377 Mon Sep 17 00:00:00 2001 From: wucongxing8150 <815046773@qq.com> Date: Thu, 29 Feb 2024 16:17:59 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=AE=B6=E5=BA=AD=E6=88=90?= =?UTF-8?q?=E5=91=98=E8=AF=A6=E6=83=85/=E5=88=97=E8=A1=A8=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=AE=A1=E7=AE=97=E5=B9=B4=E9=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/PatientFamilyService.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/app/Services/PatientFamilyService.php b/app/Services/PatientFamilyService.php index 4d06ae9..f565405 100644 --- a/app/Services/PatientFamilyService.php +++ b/app/Services/PatientFamilyService.php @@ -45,10 +45,21 @@ class PatientFamilyService extends BaseService 'age', 'nation_id', 'nation_name', + 'id_number', ]; $patient_familys = PatientFamilyModel::getList($params, $field); + if (empty($patient_familys)){ + return success(); + } - return empty($patient_familys) ? success() : success($patient_familys->toArray()); + $patient_familys = $patient_familys->toArray(); + foreach ($patient_familys as &$value){ + // 计算年龄 + $value['age'] = getIdCardAge($value['id_number']); + unset($value['id_number']); + } + + return success($patient_familys); } /** @@ -316,13 +327,17 @@ class PatientFamilyService extends BaseService return success(); } - return success($patient_family->toArray()); + $patient_family = $patient_family->toArray(); + + // 计算年龄 + $patient_family['age'] = getIdCardAge($patient_family['id_number']); + + return success($patient_family); } /** * 修改家庭成员 * @return array - * @throws GuzzleException */ public function editFamily(): array {