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());
|
||||
|
||||
@@ -72,8 +72,9 @@ class PatientRecord
|
||||
'entity_type' => $this->entityType,
|
||||
'entity_id' => $this->entityId,
|
||||
'user_uuid' => $this->user->getUuid(),
|
||||
'user_name' => $this->user->getRealName(),
|
||||
'user_mobile' => $this->user->getMobileNumber(),
|
||||
'user_name' => $this->user->getRealName(),
|
||||
'user_mobile' => $this->user->getMobileNumber(),
|
||||
'user_national_code' => $this->user->getNationalCode(),
|
||||
'created_by_type' => $this->createdByType,
|
||||
'created_at' => $this->createdAt,
|
||||
];
|
||||
|
||||
@@ -41,7 +41,7 @@ class PatientRecordRepository extends ServiceEntityRepository
|
||||
->setMaxResults($limit);
|
||||
|
||||
if ($search !== null && $search !== '') {
|
||||
$qb->andWhere('u.realName LIKE :search OR u.mobileNumber LIKE :search')
|
||||
$qb->andWhere('u.realName LIKE :search OR u.mobileNumber LIKE :search OR u.nationalCode LIKE :search')
|
||||
->setParameter('search', '%' . $search . '%');
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ class PatientRecordRepository extends ServiceEntityRepository
|
||||
->setParameter('id', $entityId);
|
||||
|
||||
if ($search !== null && $search !== '') {
|
||||
$qb->andWhere('u.realName LIKE :search OR u.mobileNumber LIKE :search')
|
||||
$qb->andWhere('u.realName LIKE :search OR u.mobileNumber LIKE :search OR u.nationalCode LIKE :search')
|
||||
->setParameter('search', '%' . $search . '%');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user