From fbb03a6abb713766f2c8d2beb6bc86c46dfa79bd Mon Sep 17 00:00:00 2001 From: DevSoftTech Server Date: Fri, 8 May 2026 13:29:57 +0530 Subject: [PATCH] billing: redesign ABHA wizard, enhance patient info panels and consult page photo/layout --- app/Controllers/Opd_prescription.php | 27 ++ app/Controllers/Patient.php | 12 + app/Views/billing/Patient_Profile_Image_V.php | 7 +- app/Views/billing/Patient_Profile_Opd_V.php | 122 +++++- app/Views/billing/Patient_V.php | 381 +++++++++++++++--- app/Views/billing/opd_prescription_basic.php | 64 ++- 6 files changed, 547 insertions(+), 66 deletions(-) diff --git a/app/Controllers/Opd_prescription.php b/app/Controllers/Opd_prescription.php index 2e57cee..7bb65a1 100644 --- a/app/Controllers/Opd_prescription.php +++ b/app/Controllers/Opd_prescription.php @@ -49,6 +49,32 @@ class Opd_prescription extends BaseController $query = $this->db->query($sql); $patient = $query->getResult(); + $patientProfileFilePath = '/assets/images/no_image.svg'; + if (!empty($patient)) { + $profilePicturePath = ''; + if ($this->db->fieldExists('profile_picture', 'patient_master')) { + $profilePicturePath = trim((string) ($patient[0]->profile_picture ?? '')); + } + + $profileFileId = (int) ($patient[0]->profile_file_id ?? 0); + if ($profileFileId > 0 && $this->db->tableExists('file_upload_data')) { + $fileRow = $this->db->table('file_upload_data') + ->select('full_path') + ->where('id', $profileFileId) + ->get(1) + ->getRow(); + + $fullPath = trim((string) ($fileRow->full_path ?? '')); + if ($fullPath !== '') { + $pos = strpos($fullPath, '/uploads/', 1); + $patientProfileFilePath = $pos !== false ? substr($fullPath, $pos) : $fullPath; + } + } elseif ($profilePicturePath !== '') { + $pos = strpos($profilePicturePath, '/uploads/', 1); + $patientProfileFilePath = $pos !== false ? substr($profilePicturePath, $pos) : $profilePicturePath; + } + } + if (!empty($patient)) { $patient[0]->str_age = get_age_1($patient[0]->dob ?? null, $patient[0]->age ?? '', $patient[0]->age_in_month ?? '', $patient[0]->estimate_dob ?? '', $opdRow->apointment_date ?? null); } @@ -110,6 +136,7 @@ class Opd_prescription extends BaseController 'opd_id' => $opdId, 'opd_master' => $opdMaster, 'patient_master' => $patient, + 'patient_profile_file_path' => $patientProfileFilePath, 'opd_prescription' => $prescription, 'next_visit_options' => $this->getNextVisitOptions(date('Y-m-d')), 'addiction_flags' => $this->getPatientAddictionFlags($patientId), diff --git a/app/Controllers/Patient.php b/app/Controllers/Patient.php index d089bf8..4f3f345 100644 --- a/app/Controllers/Patient.php +++ b/app/Controllers/Patient.php @@ -717,11 +717,23 @@ class Patient extends BaseController return $this->response->setStatusCode(404)->setBody('Patient not found'); } + $defaultBackUrl = base_url('billing/patient/person_record') . '/' . (int) ($patient->id ?? 0) . '/0'; + $backUrl = trim((string) $this->request->getGet('back_url')); + $backTitle = trim((string) $this->request->getGet('back_title')); + if ($backUrl === '') { + $backUrl = $defaultBackUrl; + } + if ($backTitle === '') { + $backTitle = 'Profile'; + } + $profileFilePath = $this->getProfileFilePath((int) ($patient->profile_file_id ?? 0)); return view('billing/Patient_Profile_Image_V', [ 'patient' => $patient, 'profileFilePath' => $profileFilePath, + 'backUrl' => $backUrl, + 'backTitle' => $backTitle, ]); } diff --git a/app/Views/billing/Patient_Profile_Image_V.php b/app/Views/billing/Patient_Profile_Image_V.php index 0e736e5..3d7bc6d 100644 --- a/app/Views/billing/Patient_Profile_Image_V.php +++ b/app/Views/billing/Patient_Profile_Image_V.php @@ -2,7 +2,7 @@

Profile Image

@@ -11,7 +11,10 @@
-

Profile Image

+
+

Profile Image

+ Back +

Patient: p_fname ?? '') ?>

diff --git a/app/Views/billing/Patient_Profile_Opd_V.php b/app/Views/billing/Patient_Profile_Opd_V.php index 042afe2..65f5b81 100644 --- a/app/Views/billing/Patient_Profile_Opd_V.php +++ b/app/Views/billing/Patient_Profile_Opd_V.php @@ -10,8 +10,94 @@ if ($backTitle === '') { $backTitle = 'Profile'; } + + $patientName = trim((string) (($patient->title ?? '') . ' ' . ($patient->p_fname ?? ''))); + $relationText = trim((string) ($patient->p_relative ?? '')); + $relativeName = trim((string) ($patient->p_rname ?? '')); + $relationWithName = trim($relationText . ($relativeName !== '' ? ' ' . $relativeName : '')); + + $ageYears = trim((string) ($patient->age ?? '')); + $ageMonths = trim((string) ($patient->age_in_month ?? '')); + $ageDisplay = ''; + if ($ageYears !== '' || $ageMonths !== '') { + $ageDisplay = trim(($ageYears !== '' ? ($ageYears . ' Year') : '') . ($ageMonths !== '' ? (' ' . $ageMonths . ' Month') : '')); + } + + // Fallback: derive age from DOB when explicit age fields are empty. + if ($ageDisplay === '' && !empty($patient->dob)) { + $dobTs = strtotime((string) $patient->dob); + if ($dobTs !== false) { + $today = new DateTime(date('Y-m-d')); + $dobDate = new DateTime(date('Y-m-d', $dobTs)); + $diff = $dobDate->diff($today); + if ($diff->y > 0) { + $ageDisplay = $diff->y . ' Year'; + } elseif ($diff->m > 0) { + $ageDisplay = $diff->m . ' Month'; + } else { + $ageDisplay = $diff->d . ' Day'; + } + } + } + + $firstVisitRaw = ''; + $patientData = (array) ($patient ?? []); + foreach (['date_of_registration', 'date_registration', 'insert_date', 'created_at', 'created_on', 'register_date'] as $candidate) { + if (!empty($patientData[$candidate])) { + $firstVisitRaw = (string) $patientData[$candidate]; + break; + } + } + + $firstVisitDisplay = '-'; + if ($firstVisitRaw !== '') { + $firstVisitTs = strtotime($firstVisitRaw); + if ($firstVisitTs !== false) { + $firstVisitDisplay = date('d-m-Y', $firstVisitTs); + } + } ?> + +

Consult History