diff --git a/interface/modules/custom_modules/oe-module-weno/scripts/weno_pharmacy_search.php b/interface/modules/custom_modules/oe-module-weno/scripts/weno_pharmacy_search.php index f549e7052a6..fd316ecc4ee 100644 --- a/interface/modules/custom_modules/oe-module-weno/scripts/weno_pharmacy_search.php +++ b/interface/modules/custom_modules/oe-module-weno/scripts/weno_pharmacy_search.php @@ -56,7 +56,7 @@ $weno_zipcode = $_GET['weno_zipcode'] ?? false ?: ''; $weno_only = $_GET['weno_only'] == 'true' ? 'True' : ''; $full_day = $_GET['full_day'] == 'true' ? 'Yes' : ''; - $weno_test_pharmacies = $_GET['test_pharmacy'] == 'true' ? 'True' : ''; + $weno_test_pharmacies = $_GET['test_pharmacy'] ?? '' == 'true' ? 'True' : ''; // mail order is special case. diff --git a/interface/modules/custom_modules/oe-module-weno/sql/1_0_0-to-2_0_0_upgrade.sql b/interface/modules/custom_modules/oe-module-weno/sql/1_0_0-to-2_0_0_upgrade.sql index 1e76c2d5c22..ffafeacef5c 100644 --- a/interface/modules/custom_modules/oe-module-weno/sql/1_0_0-to-2_0_0_upgrade.sql +++ b/interface/modules/custom_modules/oe-module-weno/sql/1_0_0-to-2_0_0_upgrade.sql @@ -27,7 +27,7 @@ CREATE TABLE `weno_pharmacy` ( `State_Wide_Mail_Order` varchar(15) NOT NULL, `Mail_Order_US_State_Serviced` varchar(255) DEFAULT NULL, `Mail_Order_ US_Territories_Serviced` varchar(255) DEFAULT NULL, - `On_WENO` tinytext DEFAULT NULL, + `On_WENO` varchar(10) DEFAULT NULL, `24HR` varchar(3) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `ncpdp` (`NCPDP_safe`) @@ -49,12 +49,12 @@ CREATE TABLE `weno_assigned_pharmacy` ( #IfNotTable weno_download_log CREATE TABLE `weno_download_log` ( - `id` BIGINT(20) NOT NULL AUTO_INCREMENT, - `value` VARCHAR(63) NOT NULL, - `status` VARCHAR(255) NOT NULL, - `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - PRIMARY KEY (`id`), - KEY `value` (`value`) + `id` BIGINT(20) NOT NULL AUTO_INCREMENT, + `value` VARCHAR(63) NOT NULL, + `status` VARCHAR(255) NOT NULL, + `created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`id`), + KEY `value` (`value`) ) ENGINE = InnoDB; #EndIf diff --git a/interface/modules/custom_modules/oe-module-weno/src/Services/DownloadWenoPharmacies.php b/interface/modules/custom_modules/oe-module-weno/src/Services/DownloadWenoPharmacies.php index 6f8923d1d5a..a3e5c34cdcc 100644 --- a/interface/modules/custom_modules/oe-module-weno/src/Services/DownloadWenoPharmacies.php +++ b/interface/modules/custom_modules/oe-module-weno/src/Services/DownloadWenoPharmacies.php @@ -42,9 +42,10 @@ public function processWenoPharmacyCsv($filePath, bool $isInsertOnly = true): fa $sql = "TRUNCATE TABLE weno_pharmacy"; sqlStatement($sql); } - - // Database configuration. Create connection. - $connect = new mysqli($GLOBALS["host"], $GLOBALS["login"], $GLOBALS["pass"], $GLOBALS["dbase"]); + // Use existing connection. + // Compared to creating a new connection, this method is slower by 3 seconds. + // Using the sqlStatement() method is even slower by 10 seconds. That's 13 seconds slower overall. + $connect = $GLOBALS['dbh']; if ($connect->connect_error) { $wenoLog->insertWenoLog("pharmacy", "Connection Failed."); error_log("Connection failed: " . $connect->connect_error); @@ -140,7 +141,7 @@ public function processWenoPharmacyCsv($filePath, bool $isInsertOnly = true): fa } $connect->commit(); - $connect->close(); + // $connect->close(); } catch (Exception $e) { $connect->rollback(); error_log(text($e->getMessage())); 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/src/Services/WenoValidate.php b/interface/modules/custom_modules/oe-module-weno/src/Services/WenoValidate.php index d0964eb6ef7..1cb1b7088e2 100644 --- a/interface/modules/custom_modules/oe-module-weno/src/Services/WenoValidate.php +++ b/interface/modules/custom_modules/oe-module-weno/src/Services/WenoValidate.php @@ -255,7 +255,6 @@ public function validateAdminCredentials($resetOnInvalid = false, $where = "pres if (!empty($newKey)) { // save new admin production key. $this->setNewEncryptionKey($newKey); - error_log(errorLogEscape("$where Encryption Verify returned Invalid Key. Attempted to reset key.")); $wenoLog = new WenoLogService(); $wenoLog->insertWenoLog(text("$where"), "reset_encryption_key"); } diff --git a/interface/modules/custom_modules/oe-module-weno/table.sql b/interface/modules/custom_modules/oe-module-weno/table.sql index 69f49dc7d68..ae3ccd7ec56 100644 --- a/interface/modules/custom_modules/oe-module-weno/table.sql +++ b/interface/modules/custom_modules/oe-module-weno/table.sql @@ -33,7 +33,7 @@ CREATE TABLE `weno_pharmacy` ( `State_Wide_Mail_Order` varchar(15) NOT NULL, `Mail_Order_US_State_Serviced` varchar(255) DEFAULT NULL, `Mail_Order_ US_Territories_Serviced` varchar(255) DEFAULT NULL, - `On_WENO` tinytext DEFAULT NULL, + `On_WENO` varchar(10) DEFAULT NULL, `24HR` varchar(3) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `ncpdp` (`NCPDP_safe`) diff --git a/interface/modules/custom_modules/oe-module-weno/templates/indexrx.php b/interface/modules/custom_modules/oe-module-weno/templates/indexrx.php index 64f2aeac895..8ca1a5b04b8 100644 --- a/interface/modules/custom_modules/oe-module-weno/templates/indexrx.php +++ b/interface/modules/custom_modules/oe-module-weno/templates/indexrx.php @@ -16,6 +16,7 @@ require_once("$srcdir/patient.inc"); use OpenEMR\Common\Acl\AclMain; +use OpenEMR\Common\Crypto\CryptoGen; use OpenEMR\Common\Twig\TwigContainer; use OpenEMR\Core\Header; use OpenEMR\Modules\WenoModule\Services\PharmacyService; @@ -52,6 +53,8 @@ $isKey = $wenoValidate->validateAdminCredentials(true); */ +$cryptoGen = new CryptoGen(); + // set up the dependencies for the page. $pharmacyService = new PharmacyService(); $wenoProperties = new TransmitProperties(); @@ -63,13 +66,15 @@ $provider_name = $wenoProperties->getProviderName(); $patient_name = $wenoProperties->getPatientName(); $facility_name = $wenoProperties->getFacilityInfo(); - //set the url for the iframe $newRxUrl = "https://online.wenoexchange.com/en/NewRx/ComposeRx?useremail="; if ($urlParam == 'error') { //check to make sure there were no errors echo TransmitProperties::styleErrors(xlt("Cipher failure check encryption key")); exit; } + +$urlOut = $newRxUrl . urlencode($provider_info['email']) . "&data=" . urlencode($urlParam); + ?> @@ -107,15 +112,15 @@ - -
+
@@ -188,16 +219,32 @@
- +
+ +
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..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 @@ -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,22 @@ 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'; + } + + let triggerSearch = defaultFilters.weno_zipcode || defaultFilters.weno_state || defaultFilters.weno_city; + if (triggerSearch) { + // Initialize the search results + $('#list-search-button').trigger('click'); + // Trigger the search after 1 second delay + setTimeout(() => { + $('#name-search-button').trigger('click'); + }, 2000); + } }; function initPharmacyDisplay(prevPrimPharmacy, prevAltPharmacy) { @@ -335,7 +351,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'; @@ -416,7 +432,7 @@ function createWenoPharmacySelect2() { }, minimumInputLength: 3, cache: true, - placeholder: 'Click and Type Filtered Pharmacy Name Search', + placeholder: 'Click here for Selected Filters Pharmacy Search by Name.', allowClear: true }); } @@ -453,6 +469,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 +493,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(''); @@ -488,12 +507,13 @@ function search() { if (!coverage) { $('#weno_coverage').addClass("is-invalid"); $('.warn').text(jsText('Coverage is required')); - } - if (!wenoState) { + } else if (!wenoState && coverage == 'Local') { $('#weno_state').addClass("is-invalid"); $('.warn').text(jsText('State or Zipcode is required')); - } - if (!coverage && !wenoZipcode) { + } else if (!wenoState && coverage == 'State') { + $('#weno_state').addClass("is-invalid"); + $('.warn').text(jsText('State is required')); + } else if (!coverage && !wenoZipcode) { $('#weno_zipcode').addClass("is-invalid"); $('.warn').text(jsText('Zipcode is required')); } @@ -501,6 +521,7 @@ function search() { } function makeRequest() { + testPharmacies = document.getElementById('weno_test_pharmacies').checked; // clear main search fields if (testPharmacies) { wenoState = ''; @@ -510,7 +531,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..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 @@ -72,8 +72,6 @@ $pharmacies[] = $row; } $pharmacyCount = count($pharmacies); -// title for the select dropdown events -$titleMessage = xla("Click to select from a list of previously assigned pharmacies."); function getProviderByWenoId($external_id, $provider_id = ''): string { @@ -93,7 +91,7 @@ function getProviderByWenoId($external_id, $provider_id = ''): string }
-
+
@@ -116,43 +114,71 @@ function getProviderByWenoId($external_id, $provider_id = ''): string
- 0) { ?> -
-
- - - - -
-
- - - - + + 0) { + $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."); + ?> +
+
+ + + + + + +
+
+ + + + + + +
+
-