diff --git a/app/Controllers/Opd.php b/app/Controllers/Opd.php
index 09e0920..08837f5 100644
--- a/app/Controllers/Opd.php
+++ b/app/Controllers/Opd.php
@@ -1862,9 +1862,26 @@ class Opd extends BaseController
$inst = trim(($when !== '' ? $when : '') . ($remark !== '' ? ($when !== '' ? ' | ' : '') . $remark : ''));
$doseFreqText = trim($dose . ' ' . $freq);
- // Hindi for freq/schedule: opd_dose_shed > opd_dose_frequency > generic fallback
+ // Hindi for freq/schedule: opd_dose_shed > opd_dose_frequency > prefix match > generic fallback
$freqKey = strtolower($freq);
$doseFreqLocal = $doseShedHindiMap[$freqKey] ?? $doseFreqHindiMap[$freqKey] ?? '';
+ if ($doseFreqLocal === '') {
+ // Prefix match: "od (one time a day) daily" should match key "od (one time a day)"
+ foreach ($doseShedHindiMap as $_k => $_v) {
+ if ($_k !== '' && (str_starts_with($freqKey, $_k . ' ') || str_starts_with($freqKey, $_k . '('))) {
+ $doseFreqLocal = $_v;
+ break;
+ }
+ }
+ }
+ if ($doseFreqLocal === '') {
+ foreach ($doseFreqHindiMap as $_k => $_v) {
+ if ($_k !== '' && str_starts_with($freqKey, $_k . ' ')) {
+ $doseFreqLocal = $_v;
+ break;
+ }
+ }
+ }
if ($doseFreqLocal === '' && $doseFreqText !== '') {
$fallback = $this->translateToLocalPatientText($doseFreqText);
if (strtolower($fallback) !== strtolower($doseFreqText)) {
@@ -1872,9 +1889,17 @@ class Opd extends BaseController
}
}
- // Hindi for when/timing: opd_dose_when > opd_dose_shed > generic fallback
+ // Hindi for when/timing: opd_dose_when > opd_dose_shed > prefix match > generic fallback
$whenKey = strtolower($when);
$instLocal = $doseWhenHindiMap[$whenKey] ?? $doseShedHindiMap[$whenKey] ?? '';
+ if ($instLocal === '') {
+ foreach ($doseWhenHindiMap as $_k => $_v) {
+ if ($_k !== '' && str_starts_with($whenKey, $_k . ' ')) {
+ $instLocal = $_v;
+ break;
+ }
+ }
+ }
if ($instLocal === '' && $when !== '') {
$fallback = $this->translateToLocalPatientText($when);
if (strtolower($fallback) !== strtolower($when)) {
@@ -1884,17 +1909,17 @@ class Opd extends BaseController
$nameHtml = esc($name);
if ($generic !== '') {
- $nameHtml .= '
Salt/Generic: ' . esc($generic) . '
';
+ $nameHtml .= 'Salt/Generic: ' . esc($generic) . '
';
}
$medicalHtml .= ''
. '| ' . $i . ' | '
. '' . $nameHtml . ' | '
. '' . esc($doseFreqText)
- . ($doseFreqLocal !== '' ? (' ' . esc($doseFreqLocal) . ' ') : '')
+ . ($doseFreqLocal !== '' ? ('' . esc($doseFreqLocal) . ' ') : '')
. ' | '
. '' . esc($days) . ' | '
. '' . esc($inst)
- . ($instLocal !== '' ? (' ' . esc($instLocal) . ' ') : '')
+ . ($instLocal !== '' ? ('' . esc($instLocal) . ' ') : '')
. ' | '
. '
';
}
@@ -2094,11 +2119,36 @@ class Opd extends BaseController
'afternoon' => 'दोपहर',
'evening' => 'शाम',
'night' => 'रात',
+ // Dose schedules (longer phrases first for uksort)
+ 'one time a day' => 'दिन में एक बार',
+ 'two times a day' => 'दिन में दो बार',
+ 'three times a day' => 'दिन में तीन बार',
+ 'four times a day' => 'दिन में चार बार',
+ 'twice a day' => 'दिन में दो बार',
+ 'thrice a day' => 'दिन में तीन बार',
'once daily' => 'दिन में एक बार',
'twice daily' => 'दिन में दो बार',
'thrice daily' => 'दिन में तीन बार',
+ 'at bed time' => 'सोते समय',
+ 'at sleep' => 'सोते समय',
+ 'at bedtime' => 'सोते समय',
+ 'with food' => 'भोजन के साथ',
+ 'with water' => 'पानी के साथ',
+ 'with milk' => 'दूध के साथ',
+ 'empty stomach' => 'खाली पेट',
+ 'before meal' => 'भोजन से पहले',
+ 'after meal' => 'भोजन के बाद',
+ 'as required' => 'जरूरत पड़ने पर',
+ 'as needed' => 'जरूरत पड़ने पर',
+ 'when required' => 'जरूरत पड़ने पर',
+ 'every 4 hours' => 'हर 4 घंटे',
+ 'every 6 hours' => 'हर 6 घंटे',
+ 'every 8 hours' => 'हर 8 घंटे',
+ 'every 12 hours' => 'हर 12 घंटे',
'daily' => 'रोज',
'weekly' => 'साप्ताहिक',
+ 'monthly' => 'मासिक',
+ 'alternate day' => 'एक दिन छोड़कर',
'for' => 'के लिए',
'days' => 'दिन',
'day' => 'दिन',
diff --git a/app/Views/billing/opd_letter_head_pdf.php b/app/Views/billing/opd_letter_head_pdf.php
index a75b009..6b0e85e 100644
--- a/app/Views/billing/opd_letter_head_pdf.php
+++ b/app/Views/billing/opd_letter_head_pdf.php
@@ -88,6 +88,30 @@ $toLocalText = static function (string $input): string {
}
$map = [
+ // Dose schedule phrases
+ 'one time a day' => 'दिन में एक बार',
+ 'two times a day' => 'दिन में दो बार',
+ 'three times a day' => 'दिन में तीन बार',
+ 'four times a day' => 'दिन में चार बार',
+ 'twice a day' => 'दिन में दो बार',
+ 'thrice a day' => 'दिन में तीन बार',
+ 'twice daily' => 'दिन में दो बार',
+ 'thrice daily' => 'दिन में तीन बार',
+ 'once daily' => 'दिन में एक बार',
+ 'alternate day' => 'एक दिन छोड़कर',
+ 'every 4 hours' => 'हर 4 घंटे',
+ 'every 6 hours' => 'हर 6 घंटे',
+ 'every 8 hours' => 'हर 8 घंटे',
+ 'every 12 hours' => 'हर 12 घंटे',
+ 'at bed time' => 'सोते समय',
+ 'at bedtime' => 'सोते समय',
+ 'at sleep' => 'सोते समय',
+ 'empty stomach' => 'खाली पेट',
+ 'with food' => 'भोजन के साथ',
+ 'with water' => 'पानी के साथ',
+ 'with milk' => 'दूध के साथ',
+ 'before meal' => 'भोजन से पहले',
+ 'after meal' => 'भोजन के बाद',
'before food' => 'भोजन से पहले',
'after food' => 'भोजन के बाद',
'after breakfast' => 'नाश्ते के बाद',
@@ -96,14 +120,16 @@ $toLocalText = static function (string $input): string {
'before lunch' => 'दोपहर के भोजन से पहले',
'after dinner' => 'रात के भोजन के बाद',
'before dinner' => 'रात के भोजन से पहले',
+ 'as required' => 'जरूरत पड़ने पर',
+ 'as needed' => 'जरूरत पड़ने पर',
+ 'when required' => 'जरूरत पड़ने पर',
'morning' => 'सुबह',
'afternoon' => 'दोपहर',
'evening' => 'शाम',
'night' => 'रात',
- 'once daily' => 'दिन में एक बार',
- 'twice daily' => 'दिन में दो बार',
- 'thrice daily' => 'दिन में तीन बार',
'daily' => 'रोज',
+ 'weekly' => 'साप्ताहिक',
+ 'monthly' => 'मासिक',
'for' => 'के लिए',
'days' => 'दिन',
'day' => 'दिन',