|
@@ -87,6 +87,15 @@
|
|
|
</div>
|
|
|
</li>
|
|
|
</ul>
|
|
|
+ <div class="d-inline-flex pr-3 mcp-theme-1 position-relative">
|
|
|
+ <input id="patient-search" type="search"
|
|
|
+ class="form-control form-control-sm outline-0"
|
|
|
+ autocomplete="off"
|
|
|
+ placeholder="Search Patients">
|
|
|
+ <div class="suggestions-outer position-absolute d-none">
|
|
|
+
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
<div class="d-flex align-items-center">
|
|
|
<p class="text-white my-0 mr-2 small">Hello, <b title="Cell# {{$pro->cell_number}}">{{ $pro->name_first }}!</b></p>
|
|
|
<form action="{{ route('logout') }}" method="post" target="_top">
|
|
@@ -135,6 +144,93 @@
|
|
|
</div>
|
|
|
</form>
|
|
|
|
|
|
+<script>
|
|
|
+ $(document).ready(function() {
|
|
|
+ const debounce = (func, wait) => {
|
|
|
+ let timeout;
|
|
|
+ return function executedFunction(...args) {
|
|
|
+ const later = () => {
|
|
|
+ clearTimeout(timeout);
|
|
|
+ func(...args);
|
|
|
+ };
|
|
|
+ clearTimeout(timeout);
|
|
|
+ timeout = setTimeout(later, wait);
|
|
|
+ };
|
|
|
+ };
|
|
|
+ var lastTerm = '';
|
|
|
+ var returnedFunction = debounce(function() {
|
|
|
+ var term = $.trim($('#patient-search').val());
|
|
|
+ if(!!term && lastTerm !== term) {
|
|
|
+ $.get('/patients-suggest?term=' + term, function(_data) {
|
|
|
+ $('.suggestions-outer').html(_data).removeClass('d-none');
|
|
|
+ });
|
|
|
+ lastTerm = term;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $('.suggestions-outer').addClass('d-none');
|
|
|
+ }
|
|
|
+ }, 250);
|
|
|
+ $('#patient-search')
|
|
|
+ .on('keydown', function(e) {
|
|
|
+ var term = $.trim($('#patient-search').val());
|
|
|
+ var activeItem = $('.suggestions-outer .suggest-item.active');
|
|
|
+ switch(e.which) {
|
|
|
+ case 27:
|
|
|
+ $('.suggestions-outer').addClass('d-none');
|
|
|
+ return false;
|
|
|
+ case 38:
|
|
|
+ if(activeItem.prev().length) {
|
|
|
+ activeItem.prev()
|
|
|
+ .addClass('active')
|
|
|
+ .siblings().removeClass('active');
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ case 40:
|
|
|
+ if(activeItem.next().length) {
|
|
|
+ activeItem.next()
|
|
|
+ .addClass('active')
|
|
|
+ .siblings().removeClass('active');
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ case 13:
|
|
|
+ if(activeItem.length) {
|
|
|
+ activeItem.first().click();
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ default:
|
|
|
+ if(!!term) {
|
|
|
+ $('.suggestions-outer')
|
|
|
+ .html('<span class="d-block no-suggest-items">Searching...</span>')
|
|
|
+ .removeClass('d-none');
|
|
|
+ returnedFunction();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $('.suggestions-outer').addClass('d-none');
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .on('keypress', function(e) {
|
|
|
+ var term = $.trim($('#patient-search').val());
|
|
|
+ if(!!term) {
|
|
|
+ $('.suggestions-outer')
|
|
|
+ .html('<span class="d-block no-suggest-items">Searching...</span>')
|
|
|
+ .removeClass('d-none');
|
|
|
+ returnedFunction();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $('.suggestions-outer').addClass('d-none');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $(document).on('click', '.suggest-item[data-target-uid]', function() {
|
|
|
+ $('#patient-search').val('');
|
|
|
+ $('.suggestions-outer').addClass('d-none');
|
|
|
+ fastLoad('/patients/view/' + $(this).attr('data-target-uid'), true, false, false);
|
|
|
+ return false;
|
|
|
+ });
|
|
|
+ });
|
|
|
+</script>
|
|
|
+
|
|
|
</body>
|
|
|
|
|
|
</html>
|