From 8bfd11ccda562c11789529c7a74acf2e2fbcdeb5 Mon Sep 17 00:00:00 2001 From: DevSoftTech Server Date: Fri, 5 Jun 2026 05:53:24 +0530 Subject: [PATCH] Persist consult NABH fields via remarks fallback --- app/Controllers/Opd_prescription.php | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/app/Controllers/Opd_prescription.php b/app/Controllers/Opd_prescription.php index 902e1de..d830aaa 100644 --- a/app/Controllers/Opd_prescription.php +++ b/app/Controllers/Opd_prescription.php @@ -575,7 +575,7 @@ class Opd_prescription extends BaseController 'adr_history' => (string) ($payload['adr_history'] ?? ''), 'current_medications' => (string) ($payload['current_medications'] ?? ''), ]; - $this->mapNabhFieldsToExistingColumns($payload, $fields, $nabhInput); + $unmappedNabh = $this->mapNabhFieldsToExistingColumns($payload, $fields, $nabhInput); $patientHistoryInput = [ 'obstetric_history' => (string) ($payload['obstetric_history'] ?? ''), @@ -591,6 +591,13 @@ class Opd_prescription extends BaseController $payload['Prescriber_Remarks'] = $this->stripNabhFieldsFromRemarks((string) ($payload['Prescriber_Remarks'] ?? '')); $payload['Prescriber_Remarks'] = $this->stripPatientHistoryFieldsFromRemarks((string) ($payload['Prescriber_Remarks'] ?? '')); + if ($this->hasAnyNabhField($unmappedNabh)) { + $payload['Prescriber_Remarks'] = $this->upsertNabhFieldsIntoRemarks( + (string) ($payload['Prescriber_Remarks'] ?? ''), + $unmappedNabh + ); + } + if ($this->hasAnyPatientHistoryField($unmappedPatientHistory)) { $payload['Prescriber_Remarks'] = $this->upsertPatientHistoryFieldsIntoRemarks( (string) ($payload['Prescriber_Remarks'] ?? ''), @@ -9156,6 +9163,20 @@ class Opd_prescription extends BaseController return implode("\n", $lines); } + /** + * @param array $input + */ + private function hasAnyNabhField(array $input): bool + { + foreach ($input as $value) { + if (trim((string) $value) !== '') { + return true; + } + } + + return false; + } + /** * @param array $input */