feat(appointment): update patient identification to use national code from profile and enhance appointment creation logic

This commit is contained in:
hamed
2026-07-15 18:46:56 +03:30
parent 0dc1ab949a
commit de6fe1bd56
8 changed files with 94 additions and 32 deletions
@@ -41,6 +41,7 @@ class MyAppointmentsController extends BaseController
private readonly \App\Staff\Repository\ClinicStaffRepository $staffRepo,
private readonly PatientResolver $patientResolver,
private readonly \App\Auth\Repository\UserRepository $userRepo,
private readonly \App\UserProfile\Repository\UserProfileRepository $profileRepo,
) {}
#[Route('/api/v1/my/appointment', methods: ['POST'])]
@@ -123,6 +124,7 @@ class MyAppointmentsController extends BaseController
$appointment->setDepositAmountRials((int) $data['deposit_amount_rials']);
}
$appointment->setPatientName($patientName);
$appointment->setPatientMobile($mobile);
if ($isReserve) {
// Day-level reserve: no slot occupation, plain save (no atomic slot check).
@@ -170,11 +172,14 @@ class MyAppointmentsController extends BaseController
return $this->success(['found' => false]);
}
// National code lives on the profile (profiles.national_code), not on User.
$nationalCode = $this->profileRepo->findByUser($patient)?->getNationalCode();
return $this->success([
'found' => true,
'name' => $patient->getRealName(),
'mobile' => $patient->getMobileNumber(),
'national_code' => $patient->getNationalCode(),
'national_code' => $nationalCode,
]);
}