OPD: reduce consult search min chars and wildcard threshold
This commit is contained in:
parent
e625233d96
commit
2b32dfe5da
|
|
@ -7279,14 +7279,14 @@ class Opd_prescription extends BaseController
|
||||||
$qLen = mb_strlen($q);
|
$qLen = mb_strlen($q);
|
||||||
$builder->groupStart();
|
$builder->groupStart();
|
||||||
|
|
||||||
if ($qLen <= 2) {
|
if ($qLen <= 1) {
|
||||||
// 2-char search: prefix only (AB*) for tighter result set.
|
// 1-char search: prefix only (A*) for tighter result set.
|
||||||
$builder->like($nameField, $q, 'after');
|
$builder->like($nameField, $q, 'after');
|
||||||
if ($shortField !== null) {
|
if ($shortField !== null) {
|
||||||
$builder->orLike($shortField, $q, 'after');
|
$builder->orLike($shortField, $q, 'after');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 3+ chars: prefix (ABC*) OR contains (*ABC*).
|
// 2+ chars: prefix (AB*) OR contains (*AB*).
|
||||||
$builder->groupStart()
|
$builder->groupStart()
|
||||||
->like($nameField, $q, 'after');
|
->like($nameField, $q, 'after');
|
||||||
if ($shortField !== null) {
|
if ($shortField !== null) {
|
||||||
|
|
|
||||||
|
|
@ -2110,7 +2110,7 @@
|
||||||
|
|
||||||
function fetchMedicineSuggestions(query, scope, done) {
|
function fetchMedicineSuggestions(query, scope, done) {
|
||||||
var q = (query || '').trim();
|
var q = (query || '').trim();
|
||||||
if (q.length < 2) {
|
if (q.length < 1) {
|
||||||
done([]);
|
done([]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -2570,10 +2570,10 @@
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.autocomplete({
|
.autocomplete({
|
||||||
minLength: 2,
|
minLength: 1,
|
||||||
source: function(request, response) {
|
source: function(request, response) {
|
||||||
var term = extractLastCommaTerm(request.term || '').trim();
|
var term = extractLastCommaTerm(request.term || '').trim();
|
||||||
if (term.length < 2) {
|
if (term.length < 1) {
|
||||||
closeAutocompleteMenu();
|
closeAutocompleteMenu();
|
||||||
response([]);
|
response([]);
|
||||||
return;
|
return;
|
||||||
|
|
@ -5487,7 +5487,7 @@
|
||||||
if (_complaintSearchTimer) {
|
if (_complaintSearchTimer) {
|
||||||
clearTimeout(_complaintSearchTimer);
|
clearTimeout(_complaintSearchTimer);
|
||||||
}
|
}
|
||||||
if (q.length < 2) {
|
if (q.length < 1) {
|
||||||
closeComplaintDropdown();
|
closeComplaintDropdown();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -5864,7 +5864,7 @@
|
||||||
$('#diagnosis_lookup').on('input', function() {
|
$('#diagnosis_lookup').on('input', function() {
|
||||||
var q = ($(this).val() || '').trim();
|
var q = ($(this).val() || '').trim();
|
||||||
if (_diagSearchTimer) clearTimeout(_diagSearchTimer);
|
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();
|
var cacheKey = q.toUpperCase();
|
||||||
if (_diagSearchCache[cacheKey]) { openDiagnosisDropdown(_diagSearchCache[cacheKey]); return; }
|
if (_diagSearchCache[cacheKey]) { openDiagnosisDropdown(_diagSearchCache[cacheKey]); return; }
|
||||||
_diagSearchTimer = setTimeout(function() {
|
_diagSearchTimer = setTimeout(function() {
|
||||||
|
|
@ -6742,7 +6742,7 @@
|
||||||
|
|
||||||
$('#advice_text').on('input', function() {
|
$('#advice_text').on('input', function() {
|
||||||
var q = ($(this).val() || '').trim();
|
var q = ($(this).val() || '').trim();
|
||||||
if (q.length < 2) {
|
if (q.length < 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
apiGet('<?= base_url('Opd_prescription/advice_search') ?>?q=' + encodeURIComponent(q), function(data) {
|
apiGet('<?= base_url('Opd_prescription/advice_search') ?>?q=' + encodeURIComponent(q), function(data) {
|
||||||
|
|
@ -7244,7 +7244,7 @@
|
||||||
|
|
||||||
$('#investigation_name').on('input', function() {
|
$('#investigation_name').on('input', function() {
|
||||||
var q = ($(this).val() || '').trim();
|
var q = ($(this).val() || '').trim();
|
||||||
if (q.length < 2) {
|
if (q.length < 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
apiGet('<?= base_url('Opd_prescription/investigation_search') ?>?q=' + encodeURIComponent(q), function(data) {
|
apiGet('<?= base_url('Opd_prescription/investigation_search') ?>?q=' + encodeURIComponent(q), function(data) {
|
||||||
|
|
@ -7424,18 +7424,18 @@
|
||||||
width: '100%',
|
width: '100%',
|
||||||
multiple: true,
|
multiple: true,
|
||||||
placeholder: 'Search and select...',
|
placeholder: 'Search and select...',
|
||||||
minimumInputLength: 2,
|
minimumInputLength: 1,
|
||||||
allowClear: true,
|
allowClear: true,
|
||||||
language: {
|
language: {
|
||||||
inputTooShort: function() {
|
inputTooShort: function() {
|
||||||
return 'Type at least 2 characters';
|
return 'Type at least 1 character';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ajax: {
|
ajax: {
|
||||||
delay: 250,
|
delay: 250,
|
||||||
transport: function(params, success, failure) {
|
transport: function(params, success, failure) {
|
||||||
var term = (params.data && params.data.term) ? params.data.term : '';
|
var term = (params.data && params.data.term) ? params.data.term : '';
|
||||||
if ((term || '').trim().length < 2) {
|
if ((term || '').trim().length < 1) {
|
||||||
success({ rows: [] });
|
success({ rows: [] });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -8100,7 +8100,7 @@
|
||||||
clearTimeout(crgcMedInputTimer);
|
clearTimeout(crgcMedInputTimer);
|
||||||
crgcMedInputTimer = null;
|
crgcMedInputTimer = null;
|
||||||
}
|
}
|
||||||
if (q.length < 2) {
|
if (q.length < 1) {
|
||||||
crgcMedSuggestRows = [];
|
crgcMedSuggestRows = [];
|
||||||
$('#crgc_med_suggest').html('');
|
$('#crgc_med_suggest').html('');
|
||||||
return;
|
return;
|
||||||
|
|
@ -8365,7 +8365,7 @@
|
||||||
clearTimeout(medInputTimer);
|
clearTimeout(medInputTimer);
|
||||||
medInputTimer = null;
|
medInputTimer = null;
|
||||||
}
|
}
|
||||||
if (q.length < 2) {
|
if (q.length < 1) {
|
||||||
medicineSuggestRows = [];
|
medicineSuggestRows = [];
|
||||||
$('#medicine_suggest').html('');
|
$('#medicine_suggest').html('');
|
||||||
return;
|
return;
|
||||||
|
|
@ -8440,7 +8440,7 @@
|
||||||
.addClass(isFav ? 'btn-warning' : 'btn-outline-warning');
|
.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'));
|
$('.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');
|
$('#med_name').trigger('input');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user