Skip to content

Commit

Permalink
php warnings
Browse files Browse the repository at this point in the history
setup a debug dump for weno support engineers.
add a debug file download
  • Loading branch information
sjpadgett committed Jun 20, 2024
1 parent d1a903c commit 90c325c
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 7 deletions.
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,13 @@
$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;
}

?>
<!doctype html>
<html lang="en">
Expand Down Expand Up @@ -136,7 +139,7 @@
<?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 @@ -197,7 +200,55 @@
</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"><?php echo xlt("Debug"); ?></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("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>
<script>
$(document).ready(function() {
// Function to generate debug info and create a downloadable file
function generateDebugInfo() {
let debugInfo = 'Debug Information:';
debugInfo += '\n\n- User Agent:' + navigator.userAgent;
debugInfo += '\n\n- Platform:' + navigator.platform;
debugInfo += '\n\n- Language:' + navigator.language;
debugInfo += '\n\n- URL: <?php echo js_escape($urlOut); ?>';
debugInfo += '\n\n- Data Raw: <?php echo js_escape($urlParam); ?>';
debugInfo += '\n\n- Encoded Data: <?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');
});
});
</script>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@
$('#name-search-button').trigger('click');
}, 2000);
}

};

function initPharmacyDisplay(prevPrimPharmacy, prevAltPharmacy) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
?>
<div class="form-group mb-0 small">
<div id="trigger-debug" class="form-group mb-0 small">
<div class="input-group">
<label role="button" id="label-primary" class="text-primary mb-0 mr-2" for="select-primary" title="<?php echo $titleMessage ?>" data-toggle="popover" data-content="<?php echo $popoverContent ?>">
<b><?php echo xlt("Assigned Primary"); ?>:</b>
Expand All @@ -131,8 +131,11 @@ function getProviderByWenoId($external_id, $provider_id = ''): string
<select id="select-primary" class="d-none">
<option value=""><?php echo xlt("Select for No Pharmacy or Click for a list"); ?></option>
<?php foreach ($pharmacies as $pharmacy) {
if (empty($pharmacy['ncpdp_safe'] ?? '')) {
continue;
}
$primary = ($pharmacy['business_name'] ?? false) ? ($pharmacy['business_name'] . ' - ' . ($pharmacy['address_line_1'] ?? '') . ' ' . ($pharmacy['city'] ?? '') . ', ' . ($pharmacy['state'] ?? '')) : '';
$isSelected = (($pharmacy['ncpdp_safe'] ?? '') == ($prim_pharmacy['ncpdp_safe'] ?? '')) ? 'selected' : '';
$isSelected = ($pharmacy['ncpdp_safe'] == $prim_pharmacy['ncpdp_safe']) ? 'selected' : '';
?>
<option value="<?php echo attr($pharmacy['ncpdp_safe']); ?>" <?php echo $isSelected; ?>><?php echo text($primary); ?></option>
<?php } ?>
Expand All @@ -149,15 +152,18 @@ function getProviderByWenoId($external_id, $provider_id = ''): string
<select id="select-alternate" class="d-none">
<option value=""><?php echo xlt("Select for No Pharmacy or Click for a list"); ?></option>
<?php foreach ($pharmacies as $pharmacy) {
if (empty($pharmacy['ncpdp_safe'] ?? '')) {
continue;
}
$alternate = ($pharmacy['business_name'] ?? false) ? ($pharmacy['business_name'] . ' - ' . ($pharmacy['address_line_1'] ?? '') . ' ' . ($pharmacy['city'] ?? '') . ', ' . ($pharmacy['state'] ?? '')) : '';
$isSelected = (($pharmacy['ncpdp_safe'] ?? '') == ($alt_pharmacy['ncpdp_safe'] ?? '')) ? 'selected' : '';
$isSelected = ($pharmacy['ncpdp_safe'] == $alt_pharmacy['ncpdp_safe']) ? 'selected' : '';
?>
<option value="<?php echo attr($pharmacy['ncpdp_safe']); ?>" <?php echo $isSelected; ?>><?php echo text($alternate); ?></option>
<?php } ?>
</select>
</div>
<script>
$(document).ready(function(){
$(document).ready(function () {
$('[data-toggle="popover"]').popover({
trigger: 'hover',
placement: 'top'
Expand Down

0 comments on commit 90c325c

Please sign in to comment.