feat: add national code to patient records and user entity, update related functionality

This commit is contained in:
hamed
2026-06-22 19:44:17 +03:30
parent 3c103bc51e
commit 5b1dfe9b40
7 changed files with 252 additions and 130 deletions
@@ -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());