From 2b32dfe5da0b105eb40123cb8d62fd24615bbae7 Mon Sep 17 00:00:00 2001 From: DevSoftTech Server Date: Thu, 9 Jul 2026 16:11:53 +0530 Subject: [PATCH] OPD: reduce consult search min chars and wildcard threshold --- app/Controllers/Opd_prescription.php | 6 ++--- app/Views/billing/opd_prescription_basic.php | 26 ++++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/Controllers/Opd_prescription.php b/app/Controllers/Opd_prescription.php index d623ac8..f1e2cd7 100644 --- a/app/Controllers/Opd_prescription.php +++ b/app/Controllers/Opd_prescription.php @@ -7279,14 +7279,14 @@ class Opd_prescription extends BaseController $qLen = mb_strlen($q); $builder->groupStart(); - if ($qLen <= 2) { - // 2-char search: prefix only (AB*) for tighter result set. + if ($qLen <= 1) { + // 1-char search: prefix only (A*) for tighter result set. $builder->like($nameField, $q, 'after'); if ($shortField !== null) { $builder->orLike($shortField, $q, 'after'); } } else { - // 3+ chars: prefix (ABC*) OR contains (*ABC*). + // 2+ chars: prefix (AB*) OR contains (*AB*). $builder->groupStart() ->like($nameField, $q, 'after'); if ($shortField !== null) { diff --git a/app/Views/billing/opd_prescription_basic.php b/app/Views/billing/opd_prescription_basic.php index 23315aa..9b22a1e 100644 --- a/app/Views/billing/opd_prescription_basic.php +++ b/app/Views/billing/opd_prescription_basic.php @@ -2110,7 +2110,7 @@ function fetchMedicineSuggestions(query, scope, done) { var q = (query || '').trim(); - if (q.length < 2) { + if (q.length < 1) { done([]); return; } @@ -2570,10 +2570,10 @@ } }) .autocomplete({ - minLength: 2, + minLength: 1, source: function(request, response) { var term = extractLastCommaTerm(request.term || '').trim(); - if (term.length < 2) { + if (term.length < 1) { closeAutocompleteMenu(); response([]); return; @@ -5487,7 +5487,7 @@ if (_complaintSearchTimer) { clearTimeout(_complaintSearchTimer); } - if (q.length < 2) { + if (q.length < 1) { closeComplaintDropdown(); return; } @@ -5864,7 +5864,7 @@ $('#diagnosis_lookup').on('input', function() { var q = ($(this).val() || '').trim(); if (_diagSearchTimer) clearTimeout(_diagSearchTimer); - if (q.length < 2) { var $dd2=$('#diagnosis_dropdown'); $dd2.closest('.rx-foldable').removeClass('dropdown-open'); $dd2.hide().empty(); return; } + if (q.length < 1) { var $dd2=$('#diagnosis_dropdown'); $dd2.closest('.rx-foldable').removeClass('dropdown-open'); $dd2.hide().empty(); return; } var cacheKey = q.toUpperCase(); if (_diagSearchCache[cacheKey]) { openDiagnosisDropdown(_diagSearchCache[cacheKey]); return; } _diagSearchTimer = setTimeout(function() { @@ -6742,7 +6742,7 @@ $('#advice_text').on('input', function() { var q = ($(this).val() || '').trim(); - if (q.length < 2) { + if (q.length < 1) { return; } apiGet('?q=' + encodeURIComponent(q), function(data) { @@ -7244,7 +7244,7 @@ $('#investigation_name').on('input', function() { var q = ($(this).val() || '').trim(); - if (q.length < 2) { + if (q.length < 1) { return; } apiGet('?q=' + encodeURIComponent(q), function(data) { @@ -7424,18 +7424,18 @@ width: '100%', multiple: true, placeholder: 'Search and select...', - minimumInputLength: 2, + minimumInputLength: 1, allowClear: true, language: { inputTooShort: function() { - return 'Type at least 2 characters'; + return 'Type at least 1 character'; } }, ajax: { delay: 250, transport: function(params, success, failure) { var term = (params.data && params.data.term) ? params.data.term : ''; - if ((term || '').trim().length < 2) { + if ((term || '').trim().length < 1) { success({ rows: [] }); return; } @@ -8100,7 +8100,7 @@ clearTimeout(crgcMedInputTimer); crgcMedInputTimer = null; } - if (q.length < 2) { + if (q.length < 1) { crgcMedSuggestRows = []; $('#crgc_med_suggest').html(''); return; @@ -8365,7 +8365,7 @@ clearTimeout(medInputTimer); medInputTimer = null; } - if (q.length < 2) { + if (q.length < 1) { medicineSuggestRows = []; $('#medicine_suggest').html(''); return; @@ -8440,7 +8440,7 @@ .addClass(isFav ? 'btn-warning' : 'btn-outline-warning'); $('.jsError').removeClass('text-danger text-muted').addClass('text-success').text(data.error_text || (isFav ? 'Added to favorites' : 'Removed from favorites')); - if (($('#med_name').val() || '').trim().length >= 2) { + if (($('#med_name').val() || '').trim().length >= 1) { $('#med_name').trigger('input'); } });