Rx print: persist and print Hindi advice from opd_advice
This commit is contained in:
parent
ddf8fd2345
commit
2b391705fe
|
|
@ -1950,15 +1950,25 @@ class Opd extends BaseController
|
|||
}
|
||||
|
||||
$rxAdvice = $rxRead($rx, ['advice', 'Advice', 'prescription_advice', 'advice_notes', 'advice_note']);
|
||||
$rxAdviceLocal = '';
|
||||
if ($rxAdvice === '' && !empty($data['rx_advices']) && is_array($data['rx_advices'])) {
|
||||
$parts = [];
|
||||
$partsLocal = [];
|
||||
foreach ($data['rx_advices'] as $adv) {
|
||||
$txt = trim((string) ($adv['advice_txt'] ?? $adv['advice'] ?? ''));
|
||||
if ($txt !== '') {
|
||||
$parts[] = $txt;
|
||||
}
|
||||
|
||||
$localTxt = trim((string) ($adv['advice_hindi'] ?? ($adv['advice_txt_hindi'] ?? '')));
|
||||
if ($localTxt !== '') {
|
||||
$partsLocal[] = $localTxt;
|
||||
}
|
||||
}
|
||||
$rxAdvice = implode(', ', $parts);
|
||||
if (!empty($partsLocal)) {
|
||||
$rxAdviceLocal = implode(' | ', $partsLocal);
|
||||
}
|
||||
}
|
||||
|
||||
$complaintText = $rxRead($rx, ['complaints', 'Complaint', 'complaint', 'chief_complaint', 'chief_complaints']);
|
||||
|
|
@ -1981,7 +1991,9 @@ class Opd extends BaseController
|
|||
$complaintLocal = $this->translateToLocalPatientText($complaintText);
|
||||
$diagnosisLocal = $this->translateToLocalPatientText($diagnosisText);
|
||||
$investigationLocal = $this->translateToLocalPatientText($rxInvestigation);
|
||||
$rxAdviceLocal = $this->translateToLocalPatientText($rxAdvice);
|
||||
if ($rxAdviceLocal === '') {
|
||||
$rxAdviceLocal = $this->translateToLocalPatientText($rxAdvice);
|
||||
}
|
||||
|
||||
if (strtolower(trim($complaintLocal)) === strtolower(trim($complaintText))) {
|
||||
$complaintLocal = '';
|
||||
|
|
@ -3202,8 +3214,9 @@ class Opd extends BaseController
|
|||
}
|
||||
|
||||
foreach ($data['rx_advices'] as $idx => $advRow) {
|
||||
$currentHindi = trim((string) ($advRow['advice_hindi'] ?? ''));
|
||||
$currentHindi = trim((string) ($advRow['advice_hindi'] ?? ($advRow['advice_txt_hindi'] ?? '')));
|
||||
if ($currentHindi !== '') {
|
||||
$data['rx_advices'][$idx]['advice_hindi'] = $currentHindi;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3930,6 +3930,7 @@ class Opd_prescription extends BaseController
|
|||
$sessionId = (int) $this->request->getPost('opd_session_id');
|
||||
$adviceText = trim((string) $this->request->getPost('advice_text'));
|
||||
$adviceId = (int) $this->request->getPost('advice_id');
|
||||
$adviceHindi = trim((string) $this->request->getPost('advice_hindi'));
|
||||
|
||||
if ($opdId <= 0 || $adviceText === '') {
|
||||
return $this->response->setJSON(['update' => 0, 'error_text' => 'Advice text is required']);
|
||||
|
|
@ -3946,6 +3947,33 @@ class Opd_prescription extends BaseController
|
|||
}
|
||||
|
||||
$fields = $this->db->getFieldNames($table);
|
||||
|
||||
if ($adviceHindi === '' && $this->db->tableExists('opd_advice')) {
|
||||
$masterFields = $this->db->getFieldNames('opd_advice');
|
||||
$masterIdField = $this->resolveFirstField($masterFields, ['id', 'advice_id']);
|
||||
$masterAdviceField = $this->resolveFirstField($masterFields, ['advice', 'advice_txt', 'advice_text']);
|
||||
$masterHindiField = $this->resolveFirstField($masterFields, ['advice_hindi', 'advice_local', 'hindi_advice', 'advice_hin']);
|
||||
|
||||
if ($masterAdviceField !== null && $masterHindiField !== null) {
|
||||
$masterBuilder = $this->db->table('opd_advice')
|
||||
->select($masterAdviceField . ' as advice_text, ' . $masterHindiField . ' as advice_hindi'
|
||||
. ($masterIdField !== null ? (', ' . $masterIdField . ' as advice_id') : ''));
|
||||
|
||||
if ($masterIdField !== null && $adviceId > 0) {
|
||||
$masterBuilder->where($masterIdField, $adviceId);
|
||||
} else {
|
||||
$normalizedAdviceText = preg_replace('/\s+/', ' ', $adviceText) ?? $adviceText;
|
||||
$masterBuilder->groupStart()
|
||||
->where($masterAdviceField, $adviceText)
|
||||
->orWhere($masterAdviceField, $normalizedAdviceText)
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
$masterRow = $masterBuilder->get(1)->getRowArray() ?? [];
|
||||
$adviceHindi = trim((string) ($masterRow['advice_hindi'] ?? ''));
|
||||
}
|
||||
}
|
||||
|
||||
$insert = [];
|
||||
if (in_array('opd_id', $fields, true)) {
|
||||
$insert['opd_id'] = $opdId;
|
||||
|
|
@ -3961,6 +3989,13 @@ class Opd_prescription extends BaseController
|
|||
} elseif (in_array('advice', $fields, true)) {
|
||||
$insert['advice'] = $adviceText;
|
||||
}
|
||||
if ($adviceHindi !== '') {
|
||||
if (in_array('advice_txt_hindi', $fields, true)) {
|
||||
$insert['advice_txt_hindi'] = $adviceHindi;
|
||||
} elseif (in_array('advice_hindi', $fields, true)) {
|
||||
$insert['advice_hindi'] = $adviceHindi;
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->table($table)->insert($insert);
|
||||
$insertId = (int) $this->db->insertID();
|
||||
|
|
|
|||
|
|
@ -225,7 +225,10 @@
|
|||
<tbody>
|
||||
<?php foreach (($rx_advices ?? []) as $adv) : ?>
|
||||
<tr>
|
||||
<td><?= esc((string) ($adv['advice_txt'] ?? ($adv['advice'] ?? ''))) ?></td>
|
||||
<td>
|
||||
<?php $advLocal = trim((string) ($adv['advice_hindi'] ?? ($adv['advice_txt_hindi'] ?? ''))); ?>
|
||||
<?= esc($advLocal !== '' ? $advLocal : (string) ($adv['advice_txt'] ?? ($adv['advice'] ?? ''))) ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
|
|
|
|||
|
|
@ -397,7 +397,7 @@ $toLocalText = static function (string $input): string {
|
|||
}
|
||||
$adviceLine[] = $t;
|
||||
|
||||
$localStored = trim((string) ($adv['advice_hindi'] ?? ''));
|
||||
$localStored = trim((string) ($adv['advice_hindi'] ?? ($adv['advice_txt_hindi'] ?? '')));
|
||||
if ($localStored !== '') {
|
||||
$adviceLocalLine[] = $localStored;
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user