Skip to content

Commit

Permalink
Feat openemr fix 7480 7494 email prescription (openemr#7495)
Browse files Browse the repository at this point in the history
* Prep template to be moved to twig

* openemr#7480 openemr#7494 email prescriptions

This supports sending a prescription as a
pdf to an email address, sending the prescription inline as a formatted
html email, and sending the prescription in the native mail client using
the mailto: protocol.  Mailto: doesn't support email attachments so the
pdf option currently doesn't work with this.

When the Default Mail Client is selected (openemr#7494) then the mailto link is
generated and if the browser or operating system has a mailto: protocol
handler setup it will launch the registered handler with the subject and
email body populated.

* Initial refactor to make edit page extensible

* Fixes openemr#7496 move erx general edit to twig

Made it so the edit prescription dialog is in twig instead of in the old
html format.  This fixes openemr#7496.  I've done some testing but probably
need to do more testing to verify we've handled all the use cases.

* Form save button position, bug fixes

Fixed a bug in the eye base where the window closing wasn't working
properly.

Moved the prescription action buttons out of the demographics.php file
and put them directly into the prescription dialog forms.

This helps fix some UX buttons flow issues as well as allows us to move
the buttons around as needed in the form.

Added a feature to have the form buttons on top of the form or on the
bottom.  Tried to have an option to show both top and bottom but that
fails in demographics.  I put the option in the demographics as well as
in the prescriptions form.  Hopefully other forms will follow suite and
allow the customization.

* Fix escaping issue.

* Not sure how this got left out but it did.

* Fixes openemr#7525, openemr#7524 prescription faxing

Made it so the prescription pdf faxing button will ask you to continue
printing if the signature isn't setup properly (at least to let users
know about it). Fixes openemr#7525.

Fixed some php8 typecast errors preventing the pdf signature from
printing in the print to fax button for prescriptions. openemr#7525.

* Switch to promise for erx dialog

* Handling variable escaping.

* Mark deprecated function
  • Loading branch information
adunsulag authored Jul 3, 2024
1 parent f854649 commit fd4bc8a
Show file tree
Hide file tree
Showing 10 changed files with 1,058 additions and 635 deletions.
430 changes: 278 additions & 152 deletions controllers/C_Prescription.class.php

Large diffs are not rendered by default.

12 changes: 5 additions & 7 deletions interface/forms/eye_mag/js/eye_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -1033,17 +1033,15 @@ function editScripts(url) {
let w = 810;
w = 910;

dlgopen(url, 'editScripts', w, 300, '', '', {
buttons: [
{text: 'Add', close: false, style: 'primary btn-sm', click: AddScript},
{text: 'List', close: false, style: 'primary btn-sm', click: ListScripts},
{text: 'Done', close: true, style: 'default btn-sm'}
],
onClosed: 'refreshme',
dlgopen(url, 'editScripts', w, 400, '', '', {
resolvePromiseOn: 'close',
allowResize: true,
allowDrag: true,
dialogId: 'editscripts',
type: 'iframe'
}).then(() => {
top.restoreSession();
location.reload();
});
}

Expand Down
1 change: 1 addition & 0 deletions interface/patient_file/encounter/coding.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

/**
* TODO: @adunsulag need to find out if this file is used anywhere anymore since it links out to prescriptions and will be impacted by encounter navigation changes.
* coding.php
*
* @package OpenEMR
Expand Down
52 changes: 3 additions & 49 deletions interface/patient_file/summary/demographics.php
Original file line number Diff line number Diff line change
Expand Up @@ -447,64 +447,18 @@ function toggleIndicator(target, div) {
// called from stats.php.
//
function editScripts(url) {
var AddScript = function () {
var __this = $(this);
__this.find("#clearButton").css("display", "");
__this.find("#backButton").css("display", "");
__this.find("#addButton").css("display", "none");

var iam = top.frames.editScripts;
iam.location.href = '<?php echo $GLOBALS['webroot'] ?>/controller.php?prescription&edit&id=0&pid=' + <?php echo js_url($pid); ?>;
};
var ListScripts = function () {
var __this = $(this);
__this.find("#clearButton").css("display", "none");
__this.find("#backButton").css("display", "none");
__this.find("#addButton").css("display", "");
var iam = top.frames.editScripts
iam.location.href = '<?php echo $GLOBALS['webroot'] ?>/controller.php?prescription&list&id=' + <?php echo js_url($pid); ?>;
};

let title = <?php echo xlj('Prescriptions'); ?>;
let w = 960; // for weno width

dlgopen(url, 'editScripts', w, 400, '', '', {
buttons: [{
text: <?php echo xlj('Add'); ?>,
close: false,
id: 'addButton',
class: 'btn-primary btn-sm',
click: AddScript
},
{
text: <?php echo xlj('Clear'); ?>,
close: false,
id: 'clearButton',
style: 'display:none;',
class: 'btn-primary btn-sm',
click: AddScript
},
{
text: <?php echo xlj('Back'); ?>,
close: false,
id: 'backButton',
style: 'display:none;',
class: 'btn-primary btn-sm',
click: ListScripts
},
{
text: <?php echo xlj('Quit'); ?>,
close: true,
id: 'doneButton',
class: 'btn-secondary btn-sm'
}
],
onClosed: 'refreshme',
resolvePromiseOn: 'close',
allowResize: true,
allowDrag: true,
dialogId: 'editscripts',
type: 'iframe'
});
})
.then(() => refreshme());
return false;
}

Expand Down
24 changes: 24 additions & 0 deletions interface/patient_file/summary/demographics_full.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
require_once("$srcdir/patient.inc.php");

use OpenEMR\Common\Acl\AclMain;
use OpenEMR\Common\Forms\FormActionBarSettings;
use OpenEMR\Common\Csrf\CsrfUtils;
use OpenEMR\Core\Header;
use OpenEMR\Events\PatientDemographics\UpdateEvent;
Expand Down Expand Up @@ -418,6 +419,7 @@ function validate(f) {

<div class="container-xl">
<div class="row">
<?php if (FormActionBarSettings::shouldDisplayTopActionBar()) { ?>
<div class="col-12">
<h2><?php echo xlt('Edit Current Patient');?></h2>
</div>
Expand All @@ -432,6 +434,11 @@ function validate(f) {
</div>
<hr>
</div>
<?php } else { ?>
<div class="col-12">
<h2><?php echo xlt('Edit Current Patient');?></h2>
</div>
<?php } ?>
</div>
</div>
<?php
Expand All @@ -450,6 +457,23 @@ function validate(f) {
<?php display_layout_tabs_data_editable('DEM', $result, $result2); ?>
</div>
</div>
<?php if (FormActionBarSettings::shouldDisplayBottomActionBar()) { ?>
<div class="container-xl">
<div class="row">
<div class="col-12">
<hr>
<div class="btn-group">
<button type="submit" class="btn btn-primary btn-save" id="submit_btn" disabled="disabled" value="<?php echo xla('Save'); ?>">
<?php echo xlt('Save'); ?>
</button>
<a class="btn btn-secondary btn-cancel" href="demographics.php" onclick="top.restoreSession()">
<?php echo xlt('Cancel'); ?>
</a>
</div>
</div>
</div>
</div>
<?php } ?>
</form>

<br />
Expand Down
14 changes: 14 additions & 0 deletions library/globals.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
// Uzbek // xl('Uzbek')
// Vietnamese // xl('Vietnamese')

use OpenEMR\Common\Forms\FormActionBarSettings;
use OpenEMR\Events\Globals\GlobalsInitializedEvent;
use OpenEMR\OeUI\RenderFormFieldHelper;
use OpenEMR\Services\Globals\GlobalsService;
Expand Down Expand Up @@ -433,6 +434,13 @@ function gblTimeZones()
xl('Recommended setting is warn and prevent web browser refresh. Only use other settings if needed and use at own risk.')
),

'form_actionbar_position' => array(
xl('Form ActionBar (save, cancel, etc) position')
,FormActionBarSettings::getGlobalSettingsList()
,FormActionBarSettings::getDefaultSetting() // default = top of the form
,xl('Placement of the save/cancel, and other bottons where supported (Demographics, Encounter Forms, etc).')
),

),

'Branding' => [
Expand Down Expand Up @@ -3804,6 +3812,12 @@ function gblTimeZones()
'default',
xl('Name of zend template for pdf export, possible to add custom template in the PrescriptionTemplate module')
),
'rx_send_email' => array(
xl('Allow email sending of prescriptions'),
'bool', // data type
'1',
xl('Enable email option (available on prescriptions list screen) for emailing prescriptions')
),
),
'PDF' => array(
'pdf_layout' => array(
Expand Down
37 changes: 37 additions & 0 deletions src/Common/Forms/FormActionBarSettings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace OpenEMR\Common\Forms;

class FormActionBarSettings
{
const ACTION_BAR_DISPLAY_FORM_TOP = '0';
const ACTION_BAR_DISPLAY_FORM_BOTTOM = '1';

// TODO: @adunsulag demographics_full.php does NOT like the TOP_AND_BOTTOM option so going to skip this for now as a valid setting.
const ACTION_BAR_DISPLAY_FORM_TOP_AND_BOTTOM = '2';
public static function getGlobalSettingsList()
{
return array(
self::ACTION_BAR_DISPLAY_FORM_TOP => xl('Top of Form (default)')
,self::ACTION_BAR_DISPLAY_FORM_BOTTOM => xl('Bottom of Form')
// ,self::ACTION_BAR_DISPLAY_FORM_TOP_AND_BOTTOM => xl('Top and Bottom of Form')
);
}

public static function getDefaultSetting()
{
return self::ACTION_BAR_DISPLAY_FORM_TOP;
}

public static function shouldDisplayTopActionBar()
{
// probably could make this more efficient by doing integer position comparisons, but the global values are stored as strings...
return $GLOBALS['form_actionbar_position'] == self::ACTION_BAR_DISPLAY_FORM_TOP
|| $GLOBALS['form_actionbar_position'] == self::ACTION_BAR_DISPLAY_FORM_TOP_AND_BOTTOM;
}
public static function shouldDisplayBottomActionBar()
{
return $GLOBALS['form_actionbar_position'] == self::ACTION_BAR_DISPLAY_FORM_BOTTOM
|| $GLOBALS['form_actionbar_position'] == self::ACTION_BAR_DISPLAY_FORM_TOP_AND_BOTTOM;
}
}
Loading

0 comments on commit fd4bc8a

Please sign in to comment.