diff --git a/app/Controllers/Patient.php b/app/Controllers/Patient.php index 8407da0..5b15cd7 100644 --- a/app/Controllers/Patient.php +++ b/app/Controllers/Patient.php @@ -36,6 +36,8 @@ class Patient extends BaseController ->getResultArray(); } + $data['refer_master'] = $this->getActiveReferMasters(); + return view('billing/Patient_V', $data); } @@ -130,6 +132,7 @@ class Patient extends BaseController 'udai' => strtoupper((string) $this->request->getPost('input_udai')), 'estimate_dob' => $estimate_dob, ]; + $this->applyPatientReferbyField($data, (string) $this->request->getPost('refer_by_name')); $this->applyPatientAbhaFieldValues($data, $abhaId, $abhaAddress); if ($chk_age === 'on') { @@ -715,6 +718,8 @@ class Patient extends BaseController $query = $this->db->query($sql); $data['blood_group'] = $query->getResult(); + $data['refer_master'] = $this->getActiveReferMasters(); + $sql = "select * from tag_master Order by tag_name"; $query = $this->db->query($sql); $data['tag_master'] = $query->getResult(); @@ -823,6 +828,7 @@ class Patient extends BaseController 'estimate_dob' => $estimate_dob, 'blood_group' => $this->request->getPost('input_blood_group'), ]; + $this->applyPatientReferbyField($data, (string) $this->request->getPost('refer_by_name')); if ($isAbhaVerifiedLocked) { $data['p_fname'] = (string) ($existingPatient['p_fname'] ?? $data['p_fname']); @@ -863,6 +869,28 @@ class Patient extends BaseController ]); } + private function getActiveReferMasters(): array + { + if (! $this->db->tableExists('refer_master')) { + return []; + } + + return $this->db->table('refer_master') + ->where('active', 1) + ->orderBy('f_name', 'ASC') + ->get() + ->getResult(); + } + + private function applyPatientReferbyField(array &$data, string $referByName): void + { + if (! $this->db->fieldExists('referby', 'patient_master')) { + return; + } + + $data['referby'] = trim(strtoupper($referByName)); + } + public function update_aadhar() { if (!$this->request->isAJAX()) { diff --git a/app/Views/Setting/Reffer/reffer_add.php b/app/Views/Setting/Reffer/reffer_add.php index 6249c9b..1fe683c 100644 --- a/app/Views/Setting/Reffer/reffer_add.php +++ b/app/Views/Setting/Reffer/reffer_add.php @@ -15,12 +15,7 @@