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 {