Skip to content

Commit

Permalink
Custom patient report cleanup (Fixes: openemr#5744, openemr#5765, ope…
Browse files Browse the repository at this point in the history
…nemr#5766) (openemr#5751)

* Initial checkbox modification workflow

* Make the patient name much larger (Fixes: openemr#5766)

* Fix rendering the history form as well

* Fix text alignment in PDF generation of custom reports

* Remove redundant Generated on line and add a missing space (Fixes: openemr#5765)

* Minor escaping fix, thanks Brady!
  • Loading branch information
tsimonq2 authored Oct 1, 2022
1 parent cc60e43 commit 758a42b
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 15 deletions.
10 changes: 6 additions & 4 deletions interface/patient_file/report/custom_report.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ function zip_content($source, $destination, $content = '', $create = true)
/******************************************************************/
// Setup Headers and Footers for mPDF only Download
// in HTML view it's just one line at the top of page 1
echo '<page_header class="custom-tag text-right"> ' . xlt("PATIENT") . ':' . text($titleres['lname']) . ', ' . text($titleres['fname']) . ' - ' . text($titleres['DOB_TS']) . '</page_header> ';
echo '<page_header class="custom-tag text-right"> ' . xlt("PATIENT") . ': ' . text($titleres['lname']) . ', ' . text($titleres['fname']) . ' - ' . text($titleres['DOB_TS']) . '</page_header> ';
echo '<page_footer class="custom-tag text-right">' . xlt('Generated on') . ' ' . text(oeFormatShortDate()) . ' - ' . text($facility['name']) . ' ' . text($facility['phone']) . '</page_footer>';

// Use logo if it exists as 'practice_logo.gif' in the site dir
Expand All @@ -262,7 +262,11 @@ function zip_content($source, $destination, $content = '', $create = true)
$practice_logo = $plogo[$k];
}

echo "<div class='table-responsive'><table class='table'><tbody><tr><td>";
echo "<div class='table-responsive'><table class='table' style='width:100%;'><tbody><tr><td align='left' class='align-middle'>";
?>
<a href="javascript:window.close();"><h1><?php echo text($titleres['lname']) . ", " . text($titleres['fname']); ?></h1></a>
<?php
echo "<br clear='all' /></td><td align='right'>";
if (file_exists($practice_logo)) {
$logo_path = $GLOBALS['OE_SITE_WEBROOT'] . "/images/" . basename($practice_logo);
echo "<img class='h-auto' style='max-width:250px;' src='$logo_path'>"; // keep size within reason
Expand All @@ -274,8 +278,6 @@ function zip_content($source, $destination, $content = '', $create = true)
<?php echo text($facility['city']); ?>, <?php echo text($facility['state']); ?><?php echo text($facility['postal_code']); ?><br clear='all'>
<?php echo text($facility['phone']); ?><br />

<a href="javascript:window.close();"><span class='title'><?php echo xlt('Patient') . ": " . text($titleres['fname']) . " " . text($titleres['lname']); ?></span></a><br />
<span class='text'><?php echo xlt('Generated on'); ?>: <?php echo text(oeFormatShortDate()); ?></span>
<?php echo "</td></tr></tbody></table></div>"; ?>

<?php } else { // not printable
Expand Down
13 changes: 13 additions & 0 deletions interface/super/edit_layout_props.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ function get_related() {
// "grp_save_close = ?, " .
"grp_init_open = ?, " .
"grp_referrals = ?, " .
"grp_unchecked = ?, " .
"grp_services = ?, " .
"grp_products = ?, " .
"grp_diags = ?";
Expand All @@ -146,6 +147,7 @@ function get_related() {
// empty($_POST['form_save_close']) ? 0 : 1,
empty($_POST['form_init_open' ]) ? 0 : 1,
empty($_POST['form_referrals']) ? 0 : 1,
empty($_POST['form_unchecked']) ? 0 : 1,
empty($_POST['form_services']) ? '' : (empty($_POST['form_services_codes']) ? '*' : $_POST['form_services_codes']),
empty($_POST['form_products']) ? '' : (empty($_POST['form_products_codes']) ? '*' : $_POST['form_products_codes']),
empty($_POST['form_diags' ]) ? '' : (empty($_POST['form_diags_codes' ]) ? '*' : $_POST['form_diags_codes' ]),
Expand Down Expand Up @@ -223,6 +225,7 @@ function get_related() {
// 'grp_save_close' => '0',
'grp_init_open' => '0',
'grp_referrals' => '0',
'grp_unchecked' => '0',
'grp_services' => '',
'grp_products' => '',
'grp_diags' => '',
Expand Down Expand Up @@ -512,6 +515,16 @@ function get_related() {

<?php } ?>

<tr>
<td valign='top' width='1%' nowrap>
<input type='checkbox' name='form_unchecked' <?php echo ($row['grp_unchecked']) ? "checked" : ""; ?> />
<?php echo xlt('Show Unchecked Boxes'); ?>
</td>
<td>
&nbsp;
</td>
</tr>

</table>

<input type='submit' class='btn btn-primary' name='form_submit' value='<?php echo xla('Submit'); ?>' />
Expand Down
38 changes: 27 additions & 11 deletions library/options.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -2427,6 +2427,9 @@ function generate_display_field($frow, $currvalue)
$field_id = isset($frow['field_id']) ? $frow['field_id'] : null;
$list_id = $frow['list_id'];
$backup_list = isset($frow['list_backup_id']) ? $frow['list_backup_id'] : null;
$show_unchecked_arr = array();
getLayoutProperties($frow['form_id'], $show_unchecked_arr, 'grp_unchecked', "1");
$show_unchecked = strval($show_unchecked_arr['']['grp_unchecked']) == "0" ? false : true;

$s = '';

Expand Down Expand Up @@ -2564,7 +2567,7 @@ function generate_display_field($frow, $currvalue)
$s = htmlspecialchars($crow['pc_catname'], ENT_NOQUOTES);
} elseif ($data_type == 21) { // a single checkbox or set of labeled checkboxes
if (!$list_id) {
$s .= $currvalue ? '[ x ]' : '[ &nbsp;&nbsp; ]';
$s .= $currvalue ? '&#9745;' : '&#9744;';
} else {
// In this special case, fld_length is the number of columns generated.
$cols = max(1, $frow['fld_length']);
Expand All @@ -2581,11 +2584,17 @@ function generate_display_field($frow, $currvalue)
}
$s .= "<tr>";
}
$s .= "<td nowrap>";
$checked = in_array($option_id, $avalue);
$s .= $checked ? '[ x ]' : '[ &nbsp;&nbsp; ]';
$s .= '&nbsp;' . text(xl_list_label($lrow['title'])) . '&nbsp;&nbsp;';
$s .= "</td>";
if (!$show_unchecked && $checked) {
$s .= "<td nowrap>";
$s .= text(xl_list_label($lrow['title'])) . '&nbsp;&nbsp;';
$s .= "</td>";
} elseif ($show_unchecked) {
$s .= "<td nowrap>";
$s .= $checked ? '&#9745;' : '&#9744;';
$s .= '&nbsp;' . text(xl_list_label($lrow['title'])) . '&nbsp;&nbsp;';
$s .= "</td>";
}
}
if ($count) {
$s .= "</tr>";
Expand Down Expand Up @@ -2711,12 +2720,18 @@ function generate_display_field($frow, $currvalue)
}
$s .= "<tr>";
}
$s .= "<td nowrap>";
$checked = ((strlen($currvalue) == 0 && $lrow['is_default']) ||
(strlen($currvalue) > 0 && $option_id == $currvalue));
$s .= $checked ? '[ x ]' : '[ &nbsp;&nbsp; ]';
$s .= '&nbsp;' . text(xl_list_label($lrow['title'])) . '&nbsp;&nbsp;';
$s .= "</td>";
if (!$show_unchecked && $checked) {
$s .= "<td nowrap>";
$s .= text(xl_list_label($lrow['title'])) . '&nbsp;&nbsp;';
$s .= "</td>";
} elseif ($show_unchecked) {
$s .= "<td nowrap>";
$s .= $checked ? '&#9745;' : '&#9744;';
$s .= '&nbsp;' . text(xl_list_label($lrow['title'])) . '&nbsp;&nbsp;';
$s .= "</td>";
}
}
if ($count) {
$s .= "</tr>";
Expand Down Expand Up @@ -3498,13 +3513,14 @@ function isSkipped(&$frow, $currvalue)
}

// Load array of names of the given layout and its groups.
function getLayoutProperties($formtype, &$grparr, $sel = "grp_title")
function getLayoutProperties($formtype, &$grparr, $sel = "grp_title", $limit = null)
{
if ($sel != '*' && strpos($sel, 'grp_group_id') === false) {
$sel = "grp_group_id, $sel";
}
$gres = sqlStatement("SELECT $sel FROM layout_group_properties WHERE grp_form_id = ? " .
"ORDER BY grp_group_id", array($formtype));
" ORDER BY grp_group_id " .
($limit ? "LIMIT " . escape_limit($limit) : ""), array($formtype));
while ($grow = sqlFetchArray($gres)) {
// TBD: Remove this after grp_init_open column is implemented.
if ($sel == '*' && !isset($grow['grp_init_open'])) {
Expand Down
4 changes: 4 additions & 0 deletions sql/7_0_0-to-7_0_1_upgrade.sql
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,7 @@ ALTER TABLE `form_questionnaire_assessments` CHANGE `code_type` `questionnaire_i
#IfNotRow2D list_options list_id Document_Template_Categories option_id questionnaire
INSERT INTO `list_options` (`list_id`, `option_id`, `title`, `seq`, `is_default`, `option_value`, `mapping`, `notes`, `codes`, `toggle_setting_1`, `toggle_setting_2`, `activity`) VALUES ('Document_Template_Categories','questionnaire','Questionnaires',10,0,0,'','','',0,0,1);
#EndIf

#IfMissingColumn layout_group_properties grp_unchecked
ALTER TABLE `layout_group_properties` ADD `grp_unchecked` tinyint(1) NOT NULL DEFAULT 0;
#EndIf
1 change: 1 addition & 0 deletions sql/database.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3384,6 +3384,7 @@ CREATE TABLE `layout_group_properties` (
grp_save_close tinyint(1) not null default 0,
grp_init_open tinyint(1) not null default 0,
grp_referrals tinyint(1) not null default 0,
grp_unchecked tinyint(1) not null default 0,
grp_services varchar(4095) not null default '',
grp_products varchar(4095) not null default '',
grp_diags varchar(4095) not null default '',
Expand Down

0 comments on commit 758a42b

Please sign in to comment.