新增获取家庭成员时如年龄不对,进行更改

This commit is contained in:
wucongxing8150 2024-02-29 16:38:18 +08:00
parent c474cba67b
commit 641a304caf

View File

@ -7,6 +7,7 @@ use App\Model\BasicJob;
use App\Model\BasicNation; use App\Model\BasicNation;
use App\Model\DiseaseClass; use App\Model\DiseaseClass;
use App\Model\OrderProduct; use App\Model\OrderProduct;
use App\Model\PatientFamily;
use App\Model\PatientFamily as PatientFamilyModel; use App\Model\PatientFamily as PatientFamilyModel;
use App\Model\PatientFamilyHealth; use App\Model\PatientFamilyHealth;
use App\Model\PatientFamilyPersonal as PatientFamilyPersonalModel; use App\Model\PatientFamilyPersonal as PatientFamilyPersonalModel;
@ -55,8 +56,20 @@ class PatientFamilyService extends BaseService
$patient_familys = $patient_familys->toArray(); $patient_familys = $patient_familys->toArray();
foreach ($patient_familys as &$value){ foreach ($patient_familys as &$value){
// 计算年龄 // 计算年龄
$value['age'] = getIdCardAge($value['id_number']); $age = getIdCardAge($value['id_number']);
unset($value['id_number']); unset($value['id_number']);
// 修正年龄
if ($value['age'] != $age){
$params = array();
$params['family_id'] = $value['family_id'];
$data = array();
$data['age'] = $age;
PatientFamily::edit($params,$data);
$value['age'] = $age;
}
} }
return success($patient_familys); return success($patient_familys);