diff --git a/app/Views/billing/opd_prescription_basic.php b/app/Views/billing/opd_prescription_basic.php index b81327b..756db02 100644 --- a/app/Views/billing/opd_prescription_basic.php +++ b/app/Views/billing/opd_prescription_basic.php @@ -5437,13 +5437,19 @@ // # column $tr.append($('').text(idx + 1)); - // Diagnosis name - var $nameTd = $(''); - var nameStyle = isSnomed ? 'color:#0d6efd;font-weight:600;max-width:260px' : 'max-width:260px'; - var $nameDiv = $('
').text(item.term); - if (item.concept_id) { $nameDiv.attr('title', 'SNOMED/ICD: ' + item.concept_id); } - $nameTd.append($nameDiv); - $tr.append($nameTd); + // Diagnosis name — editable input (SNOMED = blue, local = default) + var titleText = item.concept_id ? 'SNOMED/ICD: ' + item.concept_id : ''; + var $nameInput = $('') + .val(item.term || '') + .attr('data-idx', idx) + .attr('title', titleText); + + // Apply SNOMED styling if applicable + if (isSnomed) { + $nameInput.css({ color: '#0d6efd', fontWeight: '600' }); + } + + $tr.append($('').append($nameInput)); // Duration input $tr.append( @@ -5499,6 +5505,30 @@ return true; } + // ─── Diagnosis Name: event delegation for editing diagnosis text ────────── + $(document).on('input', '.diagnosis-name-input', function() { + var idx = parseInt($(this).attr('data-idx'), 10); + if (idx >= 0 && idx < selectedDiagnosisItems.length) { + selectedDiagnosisItems[idx].term = ($(this).val() || '').trim(); + syncDiagnosisJson(); + } + }); + $(document).on('blur', '.diagnosis-name-input', function() { + var idx = parseInt($(this).attr('data-idx'), 10); + if (idx >= 0 && idx < selectedDiagnosisItems.length) { + selectedDiagnosisItems[idx].term = ($(this).val() || '').trim(); + syncDiagnosisJson(); + markDirty('Diagnosis name updated'); + } + }); + $(document).on('keydown', '.diagnosis-name-input', function(e) { + if (e.key === 'Enter') { + e.preventDefault(); + // Move to duration input in same row + $(this).closest('tr').find('.diag-dur-input').trigger('focus'); + } + }); + // Duration delegation for diagnosis table $(document).on('input focus', '.diag-dur-input', function() { _diagDurDdIdx = -1;