Skip to content

Commit

Permalink
faxsms module cleanup and implement send email client (openemr#7866)
Browse files Browse the repository at this point in the history
* faxsms module cleanup and implement send email client
Reorg dispatch class for better clarification
Add event handlers for sms and email buttons and listeners
Remove the temporary vendor directory to support RingCentral patch. Dependencies are now and have been included in core composer.

* Add cell phone and email to find_patient_popup results and do some modernizations

* Add Subject input for email to contact form.
Fix message select checkbox without opening message for message delete.

* ensure contact form is enabled correctly
try to remove move cursor
prevent sendSms() in secure messaging if sms not enabled

* fix notification script type select conditional where was always evaluating to email

* ensure url path is normalized before adding webroot.

* Revert "ensure url path is normalized before adding webroot."

This reverts commit b367b5f.
  • Loading branch information
sjpadgett authored Dec 15, 2024
1 parent 7b77397 commit 2c8f0ff
Show file tree
Hide file tree
Showing 663 changed files with 598 additions and 99,291 deletions.
447 changes: 231 additions & 216 deletions interface/main/calendar/find_patient_popup.php

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion interface/main/messages/messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -742,12 +742,14 @@ function selectAll() {

// The two functions below are for managing row styles in Messages table.
function selectRow(row) {
event.stopPropagation();
document.getElementById(row).style.background = "var(--gray200)";
}

function deselectRow(row) {
event.stopPropagation();
document.getElementById(row).style.background = "var(--light)";
}

function makeMessageRowsClickable() {
let items = document.querySelectorAll(".messages-item-row");
items.forEach(function(item) {
Expand Down Expand Up @@ -970,6 +972,7 @@ function makeMessageRowsClickable() {
$("#new_note").submit();
}
};

var PrintNote = function () {
<?php if ($noteid) { ?>
top.restoreSession();
Expand Down
204 changes: 121 additions & 83 deletions interface/modules/custom_modules/oe-module-faxsms/contact.php

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function doOnetimeDocumentRequest()
}
$details = json_decode($service->getRequest('details'), true);
$content = $service->getRequest('comments');
$ot_pid = $details['pid'] ?? $service->getRequest('pid');
$ot_pid = $details['pid'] ?? $service->getRequest('form_pid');
if (!empty($ot_pid)) {
$patient = $service->getPatientDetails($ot_pid);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
$sessionAllowWrite = true;
require_once(__DIR__ . "/../../../../globals.php");
require_once("$srcdir/appointments.inc.php");
require_once __DIR__ . "/../vendor/autoload.php";

// Check for help argument
if ($argc > 1 && (in_array('--help', $argv) || in_array('-h', $argv))) {
Expand All @@ -70,7 +69,7 @@
$TYPE = '';
if (!empty($runtime['type'])) {
$TYPE = strtoupper($runtime['type']);
} elseif ($_GET['type'] ?? '' === 'email') {
} elseif (($_GET['type'] ?? '') === 'email') {
$TYPE = $runtime['type'] = "EMAIL";
} else {
$TYPE = $runtime['type'] = "SMS"; // default
Expand Down Expand Up @@ -113,7 +112,6 @@
$curr_time = time();
$check_date = date("Y-m-d", mktime((date("h") + $SMS_NOTIFICATION_HOUR), 0, 0, date("m"), date("d"), date("Y")));

//$db_sms_msg = cron_getNotificationData($TYPE);
$db_sms_msg['type'] = $TYPE;
$db_sms_msg['sms_gateway_type'] = AppDispatch::getModuleVendor();
$db_sms_msg['message'] = $MESSAGE;
Expand All @@ -125,10 +123,10 @@
<?php Header::setupHeader(); ?>
</head>
<style>
html {
font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif;
font-size: 14px;
}
html {
font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif;
font-size: 14px;
}
</style>
<body>
<div class="container-fluid">
Expand Down Expand Up @@ -183,7 +181,7 @@
$db_sms_msg['email_sender'] ?? ''
);
if (stripos($error, 'error') !== false) {
$strMsg .= " | " . xlt("Error:") . "<strong> " . text($error) . "</strong> \n";
$strMsg .= " | " . xlt("Error:") . "<strong>" . text($error) . "</strong>\n";
error_log($strMsg); // text
echo(nl2br($strMsg));
continue;
Expand Down Expand Up @@ -362,7 +360,7 @@ function cron_InsertNotificationLogEntry($type, $prow, $db_sms_msg): void
$sdate = date("Y-m-d H:i:s");
$sql_loginsert = "INSERT INTO `notification_log` (`iLogId` , `pid` , `pc_eid` , `sms_gateway_type` , `message` , `type` , `patient_info` , `smsgateway_info` , `pc_eventDate` , `pc_endDate` , `pc_startTime` , `pc_endTime` , `dSentDateTime`) VALUES (NULL,?,?,?,?,?,?,?,?,?,?,?,?)";

$safe = array($prow['pid'], $prow['pc_eid'], $db_sms_msg['sms_gateway_type'], $db_sms_msg['message'], $db_sms_msg['type'] || '', $patient_info, $smsgateway_info, $prow['pc_eventDate'], $prow['pc_endDate'], $prow['pc_startTime'], $prow['pc_endTime'], $sdate);
$safe = array($prow['pid'], $prow['pc_eid'], $db_sms_msg['sms_gateway_type'], $db_sms_msg['message'], $db_sms_msg['type'], $patient_info, $smsgateway_info, $prow['pc_eventDate'], $prow['pc_endDate'], $prow['pc_startTime'], $prow['pc_endTime'], $sdate);

sqlStatement($sql_loginsert, $safe);
}
Expand Down
89 changes: 64 additions & 25 deletions interface/modules/custom_modules/oe-module-faxsms/messageUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
require_once(__DIR__ . "/../../../globals.php");

use OpenEMR\Core\Header;
use OpenEMR\Events\Messaging\SendNotificationEvent;
use OpenEMR\Modules\FaxSMS\Controller\AppDispatch;

$serviceType = $_REQUEST['type'] ?? '';
Expand All @@ -22,6 +23,7 @@
$title = $service == "1" ? xlt('RingCentral') : '';
$title = $service == "2" ? xlt('Twilio SMS') : $title;
$title = $service == "3" ? xlt('etherFAX') : $title;
$title = $service == "4" ? xlt('Email') : $title;
$tabTitle = $serviceType == "sms" ? xlt('SMS') : ($serviceType == "email" ? xlt('Email') : xlt('FAX'));
?>
<!DOCTYPE html>
Expand Down Expand Up @@ -78,13 +80,31 @@
$('#received').tab('show');
});

<?php
// modal_size: 'modal-sm', 'modal-md', 'modal-lg', 'modal-xl'
// modal_height: dialog height in pixels. Default is 775
// modal_size_height: 'full' or 'auto'
$param = array(
'is_universal' => 1,
'modal_size' => 'modal-mlg',
'modal_height' => 775,
'modal_size_height' => 'full',
'type' => 'email'
);
$GLOBALS['kernel']->
getEventDispatcher()->
dispatch(
new SendNotificationEvent($pid ?? 0, $param),
SendNotificationEvent::JAVASCRIPT_READY_NOTIFICATION_POST
);
?>
const sendFax = function (filePath, from = '') {
let btnClose = <?php echo xlj("Cancel"); ?>;
let title = <?php echo xlj("Send To Contact"); ?>;
let url = top.webroot_url + '/interface/modules/custom_modules/oe-module-faxsms/contact.php?type=fax&isDocuments=0&isQueue=' +
encodeURIComponent(from) + '&file=' + encodeURIComponent(filePath);
// leave dialog name param empty so send dialogs can cascade.
dlgopen(url, '', 'modal-sm', 800, '', title, { // dialog restores session
dlgopen(url, '', 'modal-sm', 800, '', title, { // dialog auto restores session cookie
buttons: [
{text: btnClose, close: true, style: 'secondary btn-sm'}
],
Expand Down Expand Up @@ -566,6 +586,7 @@ function createPatient(e, faxId, recordId, data) {
);
return false;
}

// drop bucket
const queueMsg = '' + <?php echo xlj('Fax Queue. Drop files or Click here for Fax Contact form.') ?>;
Dropzone.autoDiscover = false;
Expand Down Expand Up @@ -659,25 +680,25 @@ function createPatient(e, faxId, recordId, data) {
</div>
</form>
<?php if ($clientApp->verifyAcl('admin', 'demo')) { ?>
<div class="nav-item dropdown ml-auto">
<button class="btn btn-lg btn-link dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
<?php echo xlt('Account Actions'); ?><span class="caret"></span>
</button>
<div class="dropdown-menu" role="menu">
<a class="dropdown-item" href="#" onclick="doSetup(event)"><?php echo xlt('Account Credentials'); ?></a>
<?php if ($serviceType == 'sms') { ?>
<a class="dropdown-item" href="#" onclick="popNotify('', './library/rc_sms_notification.php?dryrun=1&type=sms&site=<?php echo attr($_SESSION['site_id']) ?>')"><?php echo xlt('Test SMS Reminders'); ?></a>
<a class="dropdown-item" href="#" onclick="popNotify('live', './library/rc_sms_notification.php?type=sms&site=<?php echo attr($_SESSION['site_id']) ?>')"><?php echo xlt('Send SMS Reminders'); ?></a>
<?php } ?>
<?php if ($serviceType == 'email') { ?>
<a class="dropdown-item" href="#" onclick="popNotify('', './library/rc_sms_notification.php?dryrun=1&type=email&site=<?php echo attr($_SESSION['site_id']) ?>')"><?php echo xlt('Test Email Reminders'); ?></a>
<a class="dropdown-item" href="#" onclick="popNotify('live', './library/rc_sms_notification.php?type=email&site=<?php echo attr($_SESSION['site_id']) ?>')"><?php echo xlt('Send Email Reminders'); ?></a>
<?php } ?>
<a class="dropdown-item sms-hide email-hide etherfax" href="#" onclick="docInfo(event, portalUrl)"><?php echo xlt('Portal Gateway'); ?></a>
<div class="nav-item dropdown ml-auto">
<button class="btn btn-lg btn-link dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
<?php echo xlt('Account Actions'); ?><span class="caret"></span>
</button>
<div class="dropdown-menu" role="menu">
<a class="dropdown-item" href="#" onclick="doSetup(event)"><?php echo xlt('Account Credentials'); ?></a>
<?php if ($serviceType == 'sms') { ?>
<a class="dropdown-item" href="#" onclick="popNotify('', './library/rc_sms_notification.php?dryrun=1&type=sms&site=<?php echo attr($_SESSION['site_id']) ?>')"><?php echo xlt('Test SMS Reminders'); ?></a>
<a class="dropdown-item" href="#" onclick="popNotify('live', './library/rc_sms_notification.php?type=sms&site=<?php echo attr($_SESSION['site_id']) ?>')"><?php echo xlt('Send SMS Reminders'); ?></a>
<?php } ?>
<?php if ($serviceType == 'email') { ?>
<a class="dropdown-item" href="#" onclick="popNotify('', './library/rc_sms_notification.php?dryrun=1&type=email&site=<?php echo attr($_SESSION['site_id']) ?>')"><?php echo xlt('Test Email Reminders'); ?></a>
<a class="dropdown-item" href="#" onclick="popNotify('live', './library/rc_sms_notification.php?type=email&site=<?php echo attr($_SESSION['site_id']) ?>')"><?php echo xlt('Send Email Reminders'); ?></a>
<?php } ?>
<a class="dropdown-item sms-hide email-hide etherfax" href="#" onclick="docInfo(event, portalUrl)"><?php echo xlt('Portal Gateway'); ?></a>
</div>
<button type="button" class="nav-item etherfax d-none btn btn-secondary btn-transmit" onclick="docInfo(event, portalUrl)"><?php echo xlt('Account Portal'); ?>
</button>
</div>
<button type="button" class="nav-item etherfax d-none btn btn-secondary btn-transmit" onclick="docInfo(event, portalUrl)"><?php echo xlt('Account Portal'); ?>
</button>
</div>
<?php } ?>
</div><!-- /.navbar-collapse -->
</nav>
Expand All @@ -688,22 +709,40 @@ function createPatient(e, faxId, recordId, data) {
<h3><?php echo xlt("Activities") ?><i class="brand ml-1" id="brand"></i></h3>
<div id="dashboard" class="card">
<!-- Nav tabs -->
<ul id="tab-menu" class="nav nav-pills" role="tablist">
<ul id="tab-menu" class="nav nav-pills mb-1" role="tablist">
<li class="nav-item" role="tab">
<a class="nav-link active" href="#received" aria-controls="received" role="tab" data-toggle="tab"><?php echo xlt("Received") ?>
<a class="nav-link" href="#received" aria-controls="received" role="tab" data-toggle="tab"><?php echo xlt("Received") ?>
<span class="fa fa-redo ml-1" onclick="retrieveMsgs('', this)"
title="<?php echo xla('Click to refresh using current date range. Refreshing just this tab.') ?>">
</span>
</a>
</li>
<li class="nav-item" role="tab"><a class="nav-link" href="#sent" aria-controls="sent" role="tab" data-toggle="tab"><?php echo xlt("Sent") ?></a></li>
<li class="nav-item rc-fax-hide etherfax-hide email-hide" role="tab"><a class="nav-link" href="#messages" aria-controls="messages" role="tab" data-toggle="tab"><?php echo xlt("SMS Log") ?></a></li>
<li class="nav-item email-hide" role="tab"><a class="nav-link" href="#logs" aria-controls="logs" role="tab" data-toggle="tab"><?php echo xlt("Call Log") ?></a></li>
<li class="nav-item" role="tab">
<a class="nav-link" href="#sent" aria-controls="sent" role="tab" data-toggle="tab"><?php echo xlt("Sent") ?></a>
</li>
<li class="nav-item rc-fax-hide etherfax-hide email-hide" role="tab">
<a class="nav-link" href="#messages" aria-controls="messages" role="tab" data-toggle="tab"><?php echo xlt("SMS Log") ?></a>
</li>
<li class="nav-item email-hide" role="tab">
<a class="nav-link" href="#logs" aria-controls="logs" role="tab" data-toggle="tab"><?php echo xlt("Call Log") ?></a>
</li>
<li class="nav-item etherfax-hide rc-fax-hide" role="tab">
<a class="nav-link" href="#alertlogs" aria-controls="alertlogs" role="tab" data-toggle="tab"><?php echo xlt("Reminder Notifications Log") ?><span class="fa fa-redo ml-1" onclick="getNotificationLog(event, this)"
title="<?php echo xla('Click to refresh using current date range. Refreshing just this tab.') ?>"></span></a>
</li>
<li class="nav-item sms-hide email-hide etherfax" role="tab"><a class="nav-link" href="#upLoad" aria-controls="logs" role="tab" data-toggle="tab"><?php echo xlt("Fax Drop Box") ?></a></li>
<li class="nav-item sms-hide email-hide etherfax" role="tab">
<a class="nav-link" href="#upLoad" aria-controls="logs" role="tab" data-toggle="tab"><?php echo xlt("Fax Drop Box") ?></a>
</li>
<?php if ($serviceType == 'email') { ?>
<?php
$param = ['is_universal' => 1, 'type' => 'email'];
$GLOBALS['kernel']->getEventDispatcher()->
dispatch(
new SendNotificationEvent($pid, $param),
SendNotificationEvent::ACTIONS_RENDER_NOTIFICATION_POST
);
?>
<?php } ?>
</ul>
<!-- Tab panes -->
<?php if ($service != '1') { ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
*/
$classLoader->registerNamespaceIfNotExists('OpenEMR\\Modules\\FaxSMS\\', __DIR__ . DIRECTORY_SEPARATOR . 'src');

require __DIR__ . '/vendor/autoload.php';

/**
* @var EventDispatcherInterface $eventDispatcher
* @var array $module
Expand All @@ -64,9 +62,9 @@ function oe_module_faxsms_add_menu_item(MenuEvent $event): MenuEvent
$allowEmail = ($GLOBALS['oe_enable_email'] ?? null);

$sms_label = match ($allowSMS) {
'1' => xlt("RingCentral Messaging"),
'2' => xlt("Twilio Messaging"),
'5' => xlt("Clickatell Messaging"),
'1' => xlt("RingCentral SMS"),
'2' => xlt("Twilio SMS"),
'5' => xlt("Clickatell SMS"),
default => xlt("SMS"),
};
$fax_label = match ($allowFax) {
Expand All @@ -91,7 +89,7 @@ function oe_module_faxsms_add_menu_item(MenuEvent $event): MenuEvent
$menuItemEmail->requirement = 0;
$menuItemEmail->target = 'email';
$menuItemEmail->menu_id = 'email';
$menuItemEmail->label = xlt("Email");
$menuItemEmail->label = xlt("Clinic Email");
$menuItemEmail->url = "/interface/modules/custom_modules/oe-module-faxsms/messageUI.php?type=email";
$menuItemEmail->children = [];
$menuItemEmail->acl_req = ["patients", "docs"];
Expand Down Expand Up @@ -177,12 +175,12 @@ function oe_module_faxsms_add_menu_item(MenuEvent $event): MenuEvent
if (!empty($allowSMS) || !empty($allowFax) || !empty($allowEmail)) {
$item->children[] = $menuItemSetup;
}
if (!empty($allowFax)) {
$item->children[] = $menuItem2;
}
if (!empty($allowEmail)) {
$item->children[] = $menuItemEmail;
}
if (!empty($allowFax)) {
$item->children[] = $menuItem2;
}
if (!empty($allowSMS)) {
$item->children[] = $menuItem;
}
Expand Down Expand Up @@ -239,7 +237,7 @@ function getFaxContent() {
function oe_module_faxsms_document_render_action_anchors(Event $event): void
{
?>
<a class="btn btn-success btn-sm btn-send-msg" href="" onclick="return doFax(event,file,mime)">
<a class="btn btn-success btn-send-msg" href="" onclick="return doFax(event,file,mime)">
<span><?php echo xlt('Send Fax'); ?></span>
</a>
<?php }
Expand Down Expand Up @@ -280,7 +278,8 @@ function sendSMS(pid, phone) {
'/interface/modules/custom_modules/oe-module-faxsms/contact.php?type=sms&isSMS=1&pid=' + encodeURIComponent(pid) +
'&recipient=' + encodeURIComponent(phone);
dlgopen(url, '', 'modal-md', 775, '', title, {
buttons: [{text: btnClose, close: true, style: 'secondary'}]
buttons: [{text: btnClose, close: true, style: 'secondary'}],
sizeHeight: 'full',
});
}
<?php }
Expand All @@ -300,6 +299,6 @@ function sendSMS(pid, phone) {
$eventDispatcher->addListener(SendSmsEvent::JAVASCRIPT_READY_SMS_POST, 'oe_module_faxsms_sms_render_javascript_post_load');
}

if (!(empty($_SESSION['authUserID'] ?? null) && ($_SESSION['pid'] ?? null)) && $allowSMS) {
if (!(empty($_SESSION['authUserID'] ?? null) && ($_SESSION['pid'] ?? null)) && ($allowSMS || $allowEmail)) {
(new NotificationEventListener())->subscribeToEvents($eventDispatcher);
}
Loading

0 comments on commit 2c8f0ff

Please sign in to comment.