From d156e26ac17ed69180541494d4a78b2c67eab299 Mon Sep 17 00:00:00 2001 From: DevSoftTech Server Date: Sat, 6 Jun 2026 02:50:44 +0530 Subject: [PATCH] Make complaint column editable in OPD consult form - Convert complaint name from static text to editable input field - Add event handlers for complaint name editing (input, blur, keydown) - Users can now edit complaint text after adding it to the table - Frequency, Severity, Duration remain editable as before - Enter key moves focus from complaint to frequency field - Auto-sync with selectedComplaintItems and SNOMED JSON on edit --- app/Views/billing/opd_prescription_basic.php | 43 ++++++++++++++++---- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/app/Views/billing/opd_prescription_basic.php b/app/Views/billing/opd_prescription_basic.php index 87b71b1..b377baf 100644 --- a/app/Views/billing/opd_prescription_basic.php +++ b/app/Views/billing/opd_prescription_basic.php @@ -4825,13 +4825,18 @@ // # column $tr.append($('').text(idx + 1)); - // Complaint name — SNOMED = blue, local = default - var $nameTd = $(''); - var nameStyle = isSnomed ? 'color:#0d6efd;font-weight:600;max-width:210px' : 'max-width:210px'; - var $nameDiv = $('
').text(item.term); - if (item.concept_id) { $nameDiv.attr('title', 'SNOMED: ' + item.concept_id); } - $nameTd.append($nameDiv); - $tr.append($nameTd); + // Complaint name — editable input (SNOMED = blue, local = default) + var nameStyle = isSnomed ? 'color:#0d6efd;font-weight:600;' : ''; + var titleText = item.concept_id ? 'SNOMED: ' + item.concept_id : ''; + $tr.append( + $('').append( + $('') + .val(item.term || '') + .attr('data-idx', idx) + .attr('title', titleText) + .css(nameStyle) + ) + ); // Frequency input $tr.append( @@ -4958,6 +4963,30 @@ .on('click', function() { onSelect(text); }); } + // ─── Complaint Name: event delegation for editing complaint text ────────── + $(document).on('input', '.complaint-name-input', function() { + var idx = parseInt($(this).attr('data-idx'), 10); + if (idx >= 0 && idx < selectedComplaintItems.length) { + selectedComplaintItems[idx].term = ($(this).val() || '').trim(); + syncComplaintSnomedJson(); + } + }); + $(document).on('blur', '.complaint-name-input', function() { + var idx = parseInt($(this).attr('data-idx'), 10); + if (idx >= 0 && idx < selectedComplaintItems.length) { + selectedComplaintItems[idx].term = ($(this).val() || '').trim(); + syncComplaintSnomedJson(); + markDirty('Complaint name updated'); + } + }); + $(document).on('keydown', '.complaint-name-input', function(e) { + if (e.key === 'Enter') { + e.preventDefault(); + // Move to frequency input in same row + $(this).closest('tr').find('.complaint-freq-input').trigger('focus'); + } + }); + // ─── Frequency: event delegation on table rows ──────────────────── var _FREQUENCY_OPTIONS = ['daily', 'twice daily', 'weekly', 'intermittent', 'continuous', 'occasional'];