diff --git a/app/Controllers/Patient.php b/app/Controllers/Patient.php index 4025f97..212f11b 100644 --- a/app/Controllers/Patient.php +++ b/app/Controllers/Patient.php @@ -971,6 +971,8 @@ class Patient extends BaseController return $this->response->setStatusCode(404)->setBody('Patient not found'); } + $profileFilePath = $this->getProfileFilePath((int) ($patient->profile_file_id ?? 0)); + $request = service('request'); $backUrl = trim((string) $request->getGet('back_url')); $backTitle = trim((string) $request->getGet('back_title')); @@ -997,6 +999,16 @@ class Patient extends BaseController ->get() ->getResultArray(); + $totalOpdVisits = count($opdList); + $lastVisitDate = ''; + $lastVisitSrNo = ''; + if ($totalOpdVisits > 0 && !empty($opdList[0]['apointment_date'])) { + $lastVisitDate = (string) $opdList[0]['apointment_date']; + } + if ($totalOpdVisits > 0) { + $lastVisitSrNo = trim((string) ($opdList[0]['queue_no'] ?? '')); + } + $opdIds = array_column($opdList, 'opd_id'); $filesByOpd = []; $rxByOpd = []; @@ -1103,7 +1115,11 @@ class Patient extends BaseController return view('billing/Patient_Profile_Opd_V', [ 'patient' => $patient, + 'profileFilePath' => $profileFilePath, 'opdGroups' => $opdGroups, + 'totalOpdVisits' => $totalOpdVisits, + 'lastVisitDate' => $lastVisitDate, + 'lastVisitSrNo' => $lastVisitSrNo, 'backUrl' => $backUrl, 'backTitle' => $backTitle, ]); diff --git a/app/Views/billing/Patient_Profile_Opd_V.php b/app/Views/billing/Patient_Profile_Opd_V.php index 73a1416..599e51d 100644 --- a/app/Views/billing/Patient_Profile_Opd_V.php +++ b/app/Views/billing/Patient_Profile_Opd_V.php @@ -18,6 +18,39 @@ $abhaVerifiedStatus = strtoupper(trim((string) ($patient->abha_verified_status ? $abhaKycVerified = (int) ($patient->abha_kyc_verified ?? 0) === 1; $abhaMobileVerified = (int) ($patient->abha_mobile_verified ?? 0) === 1; $abhaIsVerified = $abhaVerifiedStatus === 'VERIFIED' || ($abhaKycVerified && $abhaMobileVerified); +$totalOpdVisits = (int) ($totalOpdVisits ?? 0); +$lastVisitDateRaw = trim((string) ($lastVisitDate ?? '')); +$lastVisitDateLabel = $lastVisitDateRaw !== '' ? date('d-m-Y', strtotime($lastVisitDateRaw)) : 'Not available'; +$lastVisitSrNo = trim((string) ($lastVisitSrNo ?? '')); + +$patientAge = trim((string) get_age_1($patient->dob ?? null, $patient->age ?? '', $patient->age_in_month ?? '', $patient->estimate_dob ?? '')); +$genderRaw = trim((string) ($patient->xgender ?? $patient->gender ?? '')); +$genderNormalized = strtoupper($genderRaw); +if ($genderNormalized === '1' || $genderNormalized === 'M' || $genderNormalized === 'MALE') { + $patientGender = 'Male'; +} elseif ($genderNormalized === '2' || $genderNormalized === 'F' || $genderNormalized === 'FEMALE') { + $patientGender = 'Female'; +} elseif ($genderNormalized === '3' || $genderNormalized === 'O' || $genderNormalized === 'OTHER') { + $patientGender = 'Other'; +} else { + $patientGender = $genderRaw !== '' ? $genderRaw : 'Not available'; +} + +$patientPhotoPath = trim((string) ($profileFilePath ?? '')); +if ($patientPhotoPath === '') { + $patientPhotoPath = trim((string) ($patient->profile_picture ?? '')); +} + +$abhaPhotoBase64 = trim((string) ($patient->abha_profile_photo_base64 ?? '')); +if ($patientPhotoPath === '' && $abhaPhotoBase64 !== '') { + $patientPhotoPath = str_starts_with($abhaPhotoBase64, 'data:image') + ? $abhaPhotoBase64 + : 'data:image/jpeg;base64,' . $abhaPhotoBase64; +} + +if ($patientPhotoPath === '') { + $patientPhotoPath = '/assets/images/no_image.svg'; +} ?>
Patient: = esc($patient->p_fname ?? '') ?>
+