feat: enrich patient record with full profile
GET /api/v1/patient/{uuid} now returns a `profile` object from UserProfile
(demographics, contact, insurance names resolved). Admin record detail shows
a "patient info" section. Empty fields render as "ثبت نشده".
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -37,8 +37,37 @@ class PatientController extends BaseController
|
||||
private readonly ClinicRepository $clinicRepo,
|
||||
private readonly DoctorSecretaryRepository $secretaryRepo,
|
||||
private readonly UserActiveContextRepository $contextRepo,
|
||||
private readonly \App\UserProfile\Repository\UserProfileRepository $profileRepo,
|
||||
private readonly \App\Insurance\Repository\InsuranceRepository $insuranceRepo,
|
||||
) {}
|
||||
|
||||
private function buildPatientProfile(User $patient): array
|
||||
{
|
||||
$p = $this->profileRepo->findByUser($patient);
|
||||
$insName = function (?int $id): ?string {
|
||||
if ($id === null) { return null; }
|
||||
return $this->insuranceRepo->find($id)?->getName();
|
||||
};
|
||||
|
||||
return [
|
||||
'full_name' => trim(($patient->getRealName() ?? '') . ' ' . ($p?->getFamily() ?? '')) ?: $patient->getRealName(),
|
||||
'national_code' => $p?->getNationalCode() ?? $patient->getNationalCode(),
|
||||
'gender' => $p?->getGender(),
|
||||
'date_of_birth' => $p?->getDateOfBirth(),
|
||||
'blood_type' => $p?->getBloodType(),
|
||||
'marital_status' => $p?->getMaritalStatus(),
|
||||
'job' => $p?->getJob(),
|
||||
'address' => $p?->getAddress(),
|
||||
'home_phone' => $p?->getHomePhone(),
|
||||
'work_phone' => $p?->getWorkPhone(),
|
||||
'mobile' => $patient->getMobileNumber(),
|
||||
'basic_insurance_id' => $p?->getBasicInsuranceId(),
|
||||
'basic_insurance_name' => $insName($p?->getBasicInsuranceId()),
|
||||
'supplementary_insurance_id' => $p?->getSupplementaryInsuranceId(),
|
||||
'supplementary_insurance_name' => $insName($p?->getSupplementaryInsuranceId()),
|
||||
];
|
||||
}
|
||||
|
||||
#[Route('/api/v1/patient/search-user', methods: ['GET'])]
|
||||
public function searchUser(Request $request, #[CurrentUser] User $user): JsonResponse
|
||||
{
|
||||
@@ -148,7 +177,10 @@ class PatientController extends BaseController
|
||||
return $this->error(ErrorCodes::ERR_PATIENT_NOT_FOUND, ErrorCodes::message(ErrorCodes::ERR_PATIENT_NOT_FOUND), 404);
|
||||
}
|
||||
|
||||
return $this->success($record->toArray());
|
||||
$data = $record->toArray();
|
||||
$data['profile'] = $this->buildPatientProfile($record->getUser());
|
||||
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
#[Route('/api/v1/patient/{uuid}/sessions', methods: ['GET'])]
|
||||
|
||||
Reference in New Issue
Block a user