feat: add national code to patient records and user entity, update related functionality
This commit is contained in:
@@ -59,6 +59,7 @@ class PatientController extends BaseController
|
||||
'uuid' => $patient->getUuid(),
|
||||
'name' => $patient->getRealName(),
|
||||
'mobile' => $patient->getMobileNumber(),
|
||||
'national_code' => $patient->getNationalCode(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -101,6 +102,15 @@ class PatientController extends BaseController
|
||||
return $this->error(ErrorCodes::ERR_NOT_FOUND_001, 'کاربر یافت نشد', 404);
|
||||
}
|
||||
|
||||
$nationalCode = trim((string) ($data['national_code'] ?? ''));
|
||||
if ($nationalCode !== '' && $patient->getNationalCode() === null) {
|
||||
if (!preg_match('/^\d{10}$/', $nationalCode)) {
|
||||
return $this->error(ErrorCodes::ERR_VALIDATION_001, 'کد ملی باید ۱۰ رقم باشد', 422);
|
||||
}
|
||||
$patient->setNationalCode($nationalCode);
|
||||
$this->userRepo->save($patient);
|
||||
}
|
||||
|
||||
$existing = $this->recordRepo->findByEntityAndUser($entityType, $entityId, $patient);
|
||||
if ($existing !== null) {
|
||||
return $this->success($existing->toArray());
|
||||
|
||||
Reference in New Issue
Block a user