Skip to content

Commit

Permalink
Form save button position, bug fixes
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
adunsulag committed Jun 20, 2024
1 parent 72700e5 commit 0a3c579
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 55 deletions.
4 changes: 4 additions & 0 deletions controllers/C_Prescription.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
require_once($GLOBALS['fileroot'] . "/library/amc.php");

use OpenEMR\Common\Csrf\CsrfUtils;
use OpenEMR\Common\Forms\FormActionBarSettings;
use OpenEMR\Common\Http\oeHttp;
use OpenEMR\Rx\RxList;
use PHPMailer\PHPMailer\PHPMailer;
Expand Down Expand Up @@ -106,6 +107,8 @@ function default_action()
$vars = $this->getTemplateVars();
$vars['enable_amc_prompting'] = $GLOBALS['enable_amc_prompting'] ?? false;
$vars['weno_rx_enable'] = $GLOBALS['weno_rx_enable'] ?? false;
$vars['topActionBarDisplay'] = FormActionBarSettings::shouldDisplayTopActionBar();
$vars['bottomActionBarDisplay'] = FormActionBarSettings::shouldDisplayBottomActionBar();

if ($GLOBALS['enable_amc_prompting']) {
$vars['amcCollectReturnFlag'] = amcCollect('e_prescribe_amc', $prescription->patient->id, 'prescriptions', $prescription->id);
Expand Down Expand Up @@ -202,6 +205,7 @@ function list_action($id, $sort = "")
$this->assign("CAMOS_FORM", isRegistered("CAMOS"));

$vars = $this->getTemplateVars();
$vars['pid'] = $id;
$vars['rx_send_email'] = $GLOBALS['rx_send_email'] ?? false;
$vars['rx_show_drug_drug'] = $GLOBALS['rx_show_drug_drug'] ?? false;
$vars['rx_zend_pdf_template'] = $GLOBALS['rx_zend_pdf_template'] ?? false;
Expand Down
11 changes: 5 additions & 6 deletions interface/forms/eye_mag/js/eye_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -1032,13 +1032,12 @@ function editScripts(url) {
let title = 'Prescriptions';
let w = 810;
w = 910;
function refreshme() {
top.restoreSession();
location.reload();
}

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'}
],
dlgopen(url, 'editScripts', w, 400, '', '', {
onClosed: 'refreshme',
allowResize: true,
allowDrag: true,
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
47 changes: 0 additions & 47 deletions interface/patient_file/summary/demographics.php
Original file line number Diff line number Diff line change
Expand Up @@ -447,58 +447,11 @@ 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',
allowResize: true,
allowDrag: true,
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
8 changes: 8 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
17 changes: 16 additions & 1 deletion templates/prescription/general_edit.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,12 @@
<tr>
<td class="title font-weight-bold">{{"Add"|xlt}}&nbsp;</td>
<td>
{% if topActionBarDisplay %}
<a id="save" href=# onclick="submitfun();" class="btn btn-primary btn-sm btn-save">{{'Save'|xlt}}</a>
{% elseif bottomActionBarDisplay %}
{# We want the back button to show up on top if the settings are to show the bottom action bar #}
<a id="back" class='btn btn-secondary btn-sm btn-back' href="controller.php?prescription&list&id={{prescription.patient.id|attr_url}}">{{'Back'|xlt}}</a>
{% endif %}
{% if DRUG_ARRAY_VALUES is not empty%}
&nbsp; &nbsp; &nbsp; &nbsp;
{% if prescription.get_refills() >= prescription.get_dispensation_count() %}
Expand All @@ -107,7 +112,9 @@
{{'prescription has reached its limit of'|xlt}} {{prescription.get_refills()|text}} {{'refills'|xlt}}.
{% endif %}
{% endif %}
<a id="back" class='btn btn-secondary btn-sm btn-back' href="controller.php?prescription&list&id={{prescription.patient.id|attr_url}}">{{'Back'|xlt}}</a>
{% if topActionBarDisplay %}
<a id="back" class='btn btn-secondary btn-sm btn-back' href="controller.php?prescription&list&id={{prescription.patient.id|attr_url}}">{{'Back'|xlt}}</a>
{% endif %}
</td>
</tr>
</table>
Expand Down Expand Up @@ -319,6 +326,14 @@
</div>
{% endif %}
</div>
{% if bottomActionBarDisplay %}
<div class="row">
<div class="col-12 justify-content-end">
<a id="save" href=# onclick="submitfun();" class="btn btn-primary btn-sm btn-save mr-3">{{'Save'|xlt}}</a>
<a id="back" class='btn btn-secondary btn-sm btn-back' href="controller.php?prescription&list&id={{prescription.patient.id|attr_url}}">{{'Back'|xlt}}</a>
</div>
</div>
{% endif %}

<input type="hidden" name="id" value="{{prescription.id|attr}}" />
<input type="hidden" name="process" value="{{PROCESS|attr}}" />
Expand Down
21 changes: 20 additions & 1 deletion templates/prescription/general_list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#}
<html>
<head>
{{ setupHeader(['no_textformat','no_dialog']) }}
{{ setupHeader(['no_textformat']) }}


<script>
Expand Down Expand Up @@ -180,8 +180,10 @@ $(function () {
<div class="col-12 prescription-main-header">
<h3>{{'List'|xlt}}</h3>
</div>
{% block prescriptionTopNavbar %}
<div id="prescription-btn-navbar" class="col-12 d-flex justify-content-between">
<div class="btn-group">
{% block prescriptionTopNavbarButtons %}
{% if rx_zend_pdf_template %}
<a target="_blank" id="multiprint" href="{{webroot}}/{{baseModDir}}{{zendModDir}}/public/prescription-pdf-template/{{ rx_zend_pdf_action}}?id={% if printm is not empty%}{{printm|attr_url}}{% endif %}" onclick="top.restoreSession()" class="btn btn-primary btn-sm">{{'Download'|xlt}} ({{'PDF'|xlt}})</a>
{% else %}
Expand All @@ -202,12 +204,14 @@ $(function () {
{% if CAMOS_FORM == true %}
<a id="four_panel_rx" href="{{webroot}}/interface/forms/CAMOS/rx_print.php?sigline=plain" onclick="top.restoreSession()" class="btn btn-primary btn-sm">{{'View Four Panel'|xlt}}</a>
{% endif %}
{% endblock %}
</div>
<div class="btn-group">
<a href="#" class="small" onClick="Check(document.presc.check_list);"><span>{{'Check All'|xlt}}</span></a> |
<a href="#" class="small" onClick="Uncheck(document.presc.check_list);"><span>{{'Clear All'|xlt}}</span></a>
</div>
</div>
{% endblock %}

{% if process_result %}
<div class="col-12">
Expand Down Expand Up @@ -368,6 +372,15 @@ $(function () {
<div class="text mt-3">{{ "There are currently no prescriptions"|xlt}}.</div>
{% endif %}
</div>
<div class="row">
<div class="col-12">
<hr />
</div>
<div class="col-12 d-flex justify-content-end">
<a href="{{ CONTROLLER }}?prescription&edit&id=0&pid{{ pid|js_url }}" class="btn-primary btn-sm mr-3" id="addButton">{{ "Add"|xlt }}</a>
<a href="#" class="btn-secondary btn-sm quitButton">{{ "Quit"|xlt }}</a>
</div>
</div>
</div>
</body>

Expand Down Expand Up @@ -421,6 +434,12 @@ $(function () {
$(".btn-delete").on("click", function() {
deleteDrug(this.dataset['prescriptionId'])
});
$(".quitButton").on("click", function(evt) {
evt.preventDefault();
if (window.opener) {
dlgclose();
}
});
$("#multiprintSendEmail").on('click', function(evt) {
evt.preventDefault();
toggleEmailPrescriptionSection();
Expand Down

0 comments on commit 0a3c579

Please sign in to comment.