Skip to content

Commit

Permalink
Merge pull request openemr#7514 from sjpadgett/weno_cherry
Browse files Browse the repository at this point in the history
Weno cherry to 7.0.2
  • Loading branch information
sjpadgett authored Jun 22, 2024
2 parents 12b35e2 + 1457111 commit f643715
Show file tree
Hide file tree
Showing 18 changed files with 243 additions and 168 deletions.
2 changes: 1 addition & 1 deletion interface/billing/billing_report.php
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,7 @@ function criteriaSelectHasValue(select) {
)
);
$count = 0;
$default_x12_partner = $iter['ic_x12id'] ?? null;
$default_x12_partner = $iter['x12_partner_id'] ?? null;
$prevtype = '';

while ($row = sqlFetchArray($result)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public function sendFax(): string
// needed args
$isContent = $this->getRequest('isContent');
$file = $this->getRequest('file');
$docId = $this->getRequest('docId');
$docId = $this->getRequest('docid');
$phone = $this->formatPhone($this->getRequest('phone'));
$isDocuments = (int)$this->getRequest('isDocuments');
$email = $this->getRequest('email');
Expand All @@ -192,8 +192,14 @@ public function sendFax(): string
$tag = $user['username'];

if (empty($isContent)) {
$file = str_replace(["file://", "\\"], ['', "/"], realpath($file));
if (!$file) {
if (str_starts_with($file, 'file://')) {
// Remove the "file://" prefix
$file = substr($file, 7);
}
$realPath = realpath($file);
if ($realPath !== false) {
$file = str_replace("\\", "/", $realPath);
} else {
return xlt('Error: No content');
}
}
Expand Down Expand Up @@ -658,7 +664,7 @@ public function setFaxDeleted($jobId): bool
public function chartDocument(): string
{
$pid = $this->getRequest('pid');
$docId = $this->getRequest('docId');
$docId = $this->getRequest('docid') ?? $this->getRequest('docId');
$fileName = $this->getRequest('file_name');
$result = $this->chartFaxDocument($pid, $docId, $fileName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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']]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
2 changes: 1 addition & 1 deletion interface/modules/custom_modules/oe-module-weno/table.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -52,6 +53,8 @@
$isKey = $wenoValidate->validateAdminCredentials(true);
*/

$cryptoGen = new CryptoGen();

// set up the dependencies for the page.
$pharmacyService = new PharmacyService();
$wenoProperties = new TransmitProperties();
Expand All @@ -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);

?>
<!doctype html>
<html lang="en">
Expand Down Expand Up @@ -107,15 +112,15 @@
<script>
$(function () {
$('#form_reset_key').addClass('d-none');
/* Toggle reset button. */
<?php if ((int)$isValidKey > 997) { ?>
/* Toggle reset button. */
<?php if ((int)$isValidKey > 997) { ?>
$(function () {
const warnMsg = "<?php echo xlt('Internet connection problem. Returning to Patient chart when alert closes!'); ?>";
syncAlertMsg(warnMsg, 8000, 'danger', 'lg').then(() => {
window.location.href = "<?php echo $GLOBALS['web_root'] ?>/interface/patient_file/summary/demographics.php?set_pid=<?php echo urlencode(attr($_SESSION['pid'] ?? $pid ?? '')) ?>";
});
});
<?php } else if (!$isValidKey) { ?>
<?php } else if (!$isValidKey) { ?>
$(function () {
$('#form_reset_key').removeClass('d-none');
const warnMsg = "<?php
Expand All @@ -124,19 +129,45 @@
xlt('Afterwards you may continue and no other action is required by you.'); ?>";
syncAlertMsg(warnMsg, 8000, 'danger', 'lg');
});
<?php } else { ?>
$(function () {
$('#form_reset_key').addClass('d-none');
});
<?php } ?>
<?php } else { ?>
$(function () {
$('#form_reset_key').addClass('d-none');
});
<?php } ?>
});
$(function () {
// Function to generate debug info and create a downloadable file
function generateDebugInfo() {
let debugInfo = 'Debug Information:';
debugInfo += '\n- User Agent:' + navigator.userAgent;
debugInfo += '\n- Platform:' + navigator.platform;
debugInfo += '\n- Language:' + navigator.language;
debugInfo += '\n\n- URL:\n <?php echo js_escape($urlOut); ?>';
debugInfo += '\n\n- Data Raw:\n <?php echo js_escape($urlParam); ?>';
debugInfo += '\n\n- Encoded Data:\n <?php echo js_escape(urlencode($urlParam)); ?>';

const blob = new Blob([debugInfo], {type: 'text/plain'});
const url = URL.createObjectURL(blob);
$('#downloadLink').attr('href', url);
}

// Event handler for double-click on the trigger button
$('#trigger-debug').dblclick(function () {
generateDebugInfo();
$('#debugModal').modal('show');
});
$('#triggerButton').click(function () {
generateDebugInfo();
$('#debugModal').modal('show');
});
$('#downloadLink').click(function () {
$('#debugModal').modal('hide');
});
});
</script>
</head>
<body>
<?php
$urlOut = $newRxUrl . urlencode($provider_info['email']) . "&data=" . urlencode($urlParam);
?>
<div class="container-xl">
<div id="trigger-debug" class="container-xl">
<div class="container-xl sticky-container bg-light text-dark">
<form>
<header class="bg-light text-dark text-center">
Expand Down Expand Up @@ -188,16 +219,32 @@
</div>
</div>
<div class="container-xl mt-3">
<iframe id="wenoIfram"
title="Weno IFRAME"
width="100%"
height="900"
src="<?php echo $urlOut; ?>">
</iframe>
<iframe id="wenoIfram" title="Weno IFRAME" width="100%" height="900" src="<?php echo $urlOut; ?>"></iframe>
</div>
<footer>
<a href="<?php echo $GLOBALS['web_root'] ?>/interface/patient_file/summary/demographics.php?set_pid=<?php echo urlencode(attr($_SESSION['pid'] ?? $pid)) ?>" class="btn btn-primary float-right mt-2 mb-4 mr-3"><?php echo xlt("Return to Demographics"); ?></a>
<button id="triggerButton" class="btn btn-primary btn-sm m-2 ml-3" title="<?php echo xla("Download debug information to send to Weno support."); ?>"><i class="fa-solid fa-bug"></i></button>
</footer>
<!-- Modal Structure -->
<div class="modal fade" id="debugModal" tabindex="-1" role="dialog" aria-labelledby="debugModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="debugModalLabel"><?php echo xlt("Weno Debug Information"); ?></h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<p><?php echo xlt("Debug information has been generated. Click below to download."); ?></p>
<a id="downloadLink" class="btn btn-success" download="debug_info_<?php echo md5($provider_info['email']); ?>.txt"><?php echo xlt("Download Debug File"); ?></a>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal"><?php echo xlt("Close"); ?></button>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
Loading

0 comments on commit f643715

Please sign in to comment.