From 4feb4c9a7207c91ed773ca6641c3e82d28a50f57 Mon Sep 17 00:00:00 2001 From: Jerry Padgett Date: Mon, 17 Jun 2024 23:41:06 -0400 Subject: [PATCH 1/9] Search Tuning - trigger presisted filters on form entry - add refresh button to widget --- .../src/Services/TransmitProperties.php | 1 - .../templates/pharmacy_list_form.php | 38 ++++++++++++------- .../templates/weno_fragment.php | 19 ++++++++-- .../oe-module-weno/templates/weno_setup.php | 6 +-- .../oe-module-weno/templates/weno_users.php | 7 +++- 5 files changed, 48 insertions(+), 23 deletions(-) diff --git a/interface/modules/custom_modules/oe-module-weno/src/Services/TransmitProperties.php b/interface/modules/custom_modules/oe-module-weno/src/Services/TransmitProperties.php index 8124b4471b2..626e98cff46 100644 --- a/interface/modules/custom_modules/oe-module-weno/src/Services/TransmitProperties.php +++ b/interface/modules/custom_modules/oe-module-weno/src/Services/TransmitProperties.php @@ -545,7 +545,6 @@ public function getWenoProviderId($id = null): mixed ON DUPLICATE KEY UPDATE `setting_value` = ?"; sqlQuery($sql, [$provider['weno_prov_id'], $id, $provider['weno_prov_id']]); } - $GLOBALS['weno_provider_uid'] = $GLOBALS['weno_prov_id'] = $provider['weno_prov_id']; // update users $sql = "INSERT INTO `users` (`weno_prov_id`, `id`) VALUES (?, ?) ON DUPLICATE KEY UPDATE `weno_prov_id` = ?"; sqlQuery($sql, [$GLOBALS['weno_provider_uid'], $id, $GLOBALS['weno_provider_uid']]); diff --git a/interface/modules/custom_modules/oe-module-weno/templates/pharmacy_list_form.php b/interface/modules/custom_modules/oe-module-weno/templates/pharmacy_list_form.php index 436d8bbad9c..993c9d75321 100644 --- a/interface/modules/custom_modules/oe-module-weno/templates/pharmacy_list_form.php +++ b/interface/modules/custom_modules/oe-module-weno/templates/pharmacy_list_form.php @@ -53,8 +53,8 @@ $pharmacyService = new PharmacyService(); $prev_prim_pharmacy = $pharmacyService->getWenoPrimaryPharm($_SESSION['pid']) ?? []; $prev_alt_pharmacy = $pharmacyService->getWenoAlternatePharm($_SESSION['pid']) ?? []; -$prev_prim_pharmacy = json_encode($prev_prim_pharmacy); -$prev_alt_pharmacy = json_encode($prev_alt_pharmacy); +$prev_prim_pharmacy = js_escape($prev_prim_pharmacy); +$prev_alt_pharmacy = js_escape($prev_alt_pharmacy); $sql = "SELECT list_id, option_id, title FROM list_options WHERE list_id = 'state'"; $res = sqlStatement($sql); @@ -170,7 +170,7 @@ - +
@@ -179,8 +179,8 @@ - - + + @@ -235,9 +235,9 @@ const clone = document.importNode(template.content, true); wenoForm.appendChild(clone); - const pid = ; - const prevPrimPharmacy = ; - const prevAltPharmacy = ; + const pid = ; + const prevPrimPharmacy = ; + const prevAltPharmacy = ; if (pid > 0) { initPharmacyDisplay(prevPrimPharmacy, prevAltPharmacy); @@ -277,6 +277,15 @@ wenoOnlyEle.checked = defaultFilters.weno_only === "on"; wenoOnly = document.getElementById('weno_only').checked; } + + const defaultCoverage = defaultFilters.weno_coverage; + if (defaultCoverage == 'State') { + document.getElementById('weno_zipcode').style.display = 'none'; + document.getElementById('weno_city_select').style.display = 'none'; + } + + // Initialize the search results + $('#list-search-button').trigger('click'); }; function initPharmacyDisplay(prevPrimPharmacy, prevAltPharmacy) { @@ -335,7 +344,7 @@ function coverageChanged() { const coverageElement = document.getElementById('weno_coverage'); const coverage = coverageElement.selectedOptions[0] ? coverageElement.selectedOptions[0].value : ''; const zipcodeElement = document.getElementById('weno_zipcode'); - const cityElement = document.getElementById('select2-weno_city-container'); + const cityElement = document.getElementById('weno_city_select'); if (coverage === 'State') { zipcodeElement.style.display = 'none'; @@ -453,6 +462,12 @@ function createWenoCitySelect2() { }); } + function destroyWenoCitySelect2() { + if ($('#weno_city').data('select2')) { + $('#weno_city').select2('destroy'); + } + } + function searchOn() { let pharmacySelector = document.getElementById("weno_pharmacy"); if ($('#weno_pharmacy').hasClass('select2-hidden-accessible')) { @@ -471,9 +486,6 @@ function search() { coverage = $('#weno_coverage').val(); $("#searchResults").text(''); - const isValidZipcode = wenoZipcode && coverage; - const isValidCityAndState = wenoCity && wenoState && !wenoZipcode; - if (coverage && (wenoState || wenoZipcode)) { $('#weno_city, #weno_state, #weno_coverage, #weno_zipcode').removeClass("is-invalid"); $('.warn').text(''); @@ -501,6 +513,7 @@ function search() { } function makeRequest() { + testPharmacies = document.getElementById('weno_test_pharmacies').checked; // clear main search fields if (testPharmacies) { wenoState = ''; @@ -510,7 +523,6 @@ function makeRequest() { } wenoOnly = document.getElementById('weno_only').checked; fullDay = document.getElementById('24hr').checked; - testPharmacies = document.getElementById('weno_test_pharmacies').checked; let data = { searchFor: 'weno_drop', weno_state: wenoState, diff --git a/interface/modules/custom_modules/oe-module-weno/templates/weno_fragment.php b/interface/modules/custom_modules/oe-module-weno/templates/weno_fragment.php index fd44c97b930..fcc50730b22 100644 --- a/interface/modules/custom_modules/oe-module-weno/templates/weno_fragment.php +++ b/interface/modules/custom_modules/oe-module-weno/templates/weno_fragment.php @@ -93,7 +93,7 @@ function getProviderByWenoId($external_id, $provider_id = ''): string }
-
+
@@ -116,6 +116,7 @@ function getProviderByWenoId($external_id, $provider_id = ''): string
+ 0) { ?>
@@ -125,7 +126,7 @@ function getProviderByWenoId($external_id, $provider_id = ''): string - +
-
diff --git a/interface/modules/custom_modules/oe-module-weno/templates/pharmacy_list_form.php b/interface/modules/custom_modules/oe-module-weno/templates/pharmacy_list_form.php index 5d99923de0a..7f97cfd7f13 100644 --- a/interface/modules/custom_modules/oe-module-weno/templates/pharmacy_list_form.php +++ b/interface/modules/custom_modules/oe-module-weno/templates/pharmacy_list_form.php @@ -293,7 +293,6 @@ $('#name-search-button').trigger('click'); }, 2000); } - }; function initPharmacyDisplay(prevPrimPharmacy, prevAltPharmacy) { diff --git a/interface/modules/custom_modules/oe-module-weno/templates/weno_fragment.php b/interface/modules/custom_modules/oe-module-weno/templates/weno_fragment.php index a23017b4da0..54305b1d62a 100644 --- a/interface/modules/custom_modules/oe-module-weno/templates/weno_fragment.php +++ b/interface/modules/custom_modules/oe-module-weno/templates/weno_fragment.php @@ -119,7 +119,7 @@ function getProviderByWenoId($external_id, $provider_id = ''): string $titleMessage = xla("Quick Pharmacy Assignment"); $popoverContent = xla("Convenience feature for assigning pharmacy without having to edit Demographics. Click the label or existing pharmacy name, if assigned, to select a pharmacy from a list of all currently assigned pharmacies. The selected pharmacy will be assigned to this patient."); ?> -
+
-
@@ -191,23 +219,18 @@
- +
- +