From e049ddcf2b0c95bda5b6e300e76e38678a7ced8b Mon Sep 17 00:00:00 2001 From: DevSoftTech Server Date: Sun, 5 Apr 2026 23:57:16 +0530 Subject: [PATCH] fix: dynamic ABHA column SELECT in openReportEditorPage to handle remote DB schema --- app/Controllers/Diagnosis.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Controllers/Diagnosis.php b/app/Controllers/Diagnosis.php index 7b5d193..2802e3a 100644 --- a/app/Controllers/Diagnosis.php +++ b/app/Controllers/Diagnosis.php @@ -1083,8 +1083,11 @@ class Diagnosis extends BaseController return '
Report not found
'; } + $pmFields = $this->db->getFieldNames('patient_master') ?? []; + $abhaColsPm = array_filter(['abha_id', 'abha_no', 'abha_address', 'abha'], fn ($c) => in_array($c, $pmFields, true)); + $abhaSelectPm = $abhaColsPm ? (', ' . implode(', ', $abhaColsPm)) : ''; $patientRow = $this->db->table('patient_master') - ->select('gender, age, age_in, age_in_month, dob, abha_id, abha_no, abha_address, abha') + ->select('gender, age, age_in, age_in_month, dob' . $abhaSelectPm) ->where('id', (int) ($reportRow->patient_id ?? 0)) ->get() ->getRow();