Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Hide dashboard cards on demographics page #7423

Merged
merged 1 commit into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions Documentation/help_files/medical_dashboard_help.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@

<p><?php echo xlt("These items can be edited if the user has sufficient privilege");?>.</p>

<p><?php echo xlt("Some of these data sections can be turned off if not being utilized by the clinic. Go to Admin, Config, Appearance to hide the cards to streamline the dashboard"); ?></p>

<p><?php echo xlt("Billing - provides a summary of the balances - Patient Balance Due, Insurance Balance Due, Total Balance Due and lists the name of the Primary Insurance along with its effective date");?>.</p>

<p><?php echo xlt("Demographics - patient demographics and insurance information");?>.</p>
Expand Down
43 changes: 31 additions & 12 deletions interface/patient_file/summary/demographics.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@
use OpenEMR\Services\PatientIssuesService;
use OpenEMR\Services\PatientService;
use Symfony\Component\EventDispatcher\EventDispatcher;
use OpenEMR\Patient\Cards\InsuranceViewCard;
use OpenEMR\Patient\Cards\BillingViewCard;
use OpenEMR\Patient\Cards\DemographicsViewCard;

$twig = new TwigContainer(null, $GLOBALS['kernel']);

Expand All @@ -79,6 +76,7 @@
// want smart support in their system.
$smartLaunchController = new SMARTLaunchController($GLOBALS["kernel"]->getEventDispatcher());
$smartLaunchController->registerContextEvents();
$hiddenCards = getHiddenDashboardCards();

/**
* @var EventDispatcher
Expand Down Expand Up @@ -121,6 +119,17 @@
$insurance_array = array('primary', 'secondary', 'tertiary');
}

function getHiddenDashboardCards(): array
{
$hiddenList = [];
$ret = sqlStatement("SELECT gl_value FROM `globals` WHERE `gl_name` = 'hide_dashboard_cards'");
while ($row = sqlFetchArray($ret)) {
$hiddenList[] = $row['gl_value'];
}

return $hiddenList;
}

function print_as_money($money)
{
preg_match("/(\d*)\.?(\d*)/", $money, $moneymatches);
Expand Down Expand Up @@ -1038,9 +1047,9 @@ function setMyPatient() {
<?php
$t = $twig->getTwig();

$allergy = (AclMain::aclCheckIssue('allergy')) ? 1 : 0;
$pl = (AclMain::aclCheckIssue('medical_problem')) ? 1 : 0;
$meds = (AclMain::aclCheckIssue('medication')) ? 1 : 0;
$allergy = (AclMain::aclCheckIssue('allergy') ? 1 : 0) && !in_array('card_allergies', $hiddenCards) ? 1 : 0;
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

won't this result in boolean instead of 1 or 0. Wouldn't this make more sense:

$allergy = (AclMain::aclCheckIssue('allergy') && !in_array('card_allergies', $hiddenCards)) ? 1 : 0;

Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'd think so but think how PHP handles truthy though your way would work but I left same logic as original.

$pl = (AclMain::aclCheckIssue('medical_problem') ? 1 : 0) && !in_array('card_medicalproblems', $hiddenCards) ? 1 : 0;
$meds = (AclMain::aclCheckIssue('medication') ? 1 : 0) && !in_array('card_medication', $hiddenCards) ? 1 : 0;
$rx = (!$GLOBALS['disable_prescriptions'] && AclMain::aclCheckCore('patients', 'rx')) ? 1 : 0;
$cards = max(1, ($allergy + $pl + $meds));
$col = "p-1 ";
Expand Down Expand Up @@ -1189,7 +1198,7 @@ function filterActiveIssues(array $i): array
ob_end_clean();

echo "<div class=\"col\">";
echo $t->render('patient/card/rx.html.twig', $viewArgs);
echo $t->render('patient/card/rx.html.twig', $viewArgs); // render core prescription card
echo "</div>";
endif;
?>
Expand Down Expand Up @@ -1276,7 +1285,9 @@ function filterActiveIssues(array $i): array
'prependedInjection' => $dispatchResult->getPrependedInjection(),
'appendedInjection' => $dispatchResult->getAppendedInjection(),
];
echo $twig->getTwig()->render('patient/card/loader.html.twig', $viewArgs);
if (!in_array('card_patientreminders', $hiddenCards)) {
echo $twig->getTwig()->render('patient/card/loader.html.twig', $viewArgs);
}
endif; //end if prw is activated

if (AclMain::aclCheckCore('patients', 'disclosure')) :
Expand All @@ -1297,7 +1308,9 @@ function filterActiveIssues(array $i): array
'prependedInjection' => $dispatchResult->getPrependedInjection(),
'appendedInjection' => $dispatchResult->getAppendedInjection(),
];
echo $twig->getTwig()->render('patient/card/loader.html.twig', $viewArgs);
if (!in_array('card_disclosure', $hiddenCards)) {
echo $twig->getTwig()->render('patient/card/loader.html.twig', $viewArgs);
}
endif; // end if disclosures authorized

if ($GLOBALS['amendments'] && AclMain::aclCheckCore('patients', 'amendment')) :
Expand Down Expand Up @@ -1325,7 +1338,9 @@ function filterActiveIssues(array $i): array
'prependedInjection' => $dispatchResult->getPrependedInjection(),
'appendedInjection' => $dispatchResult->getAppendedInjection(),
];
echo $twig->getTwig()->render('patient/card/amendments.html.twig', $viewArgs);
if (!in_array('card_amendments', $hiddenCards)) {
echo $twig->getTwig()->render('patient/card/amendments.html.twig', $viewArgs);
}
endif; // end amendments authorized

if (AclMain::aclCheckCore('patients', 'lab')) :
Expand Down Expand Up @@ -1353,7 +1368,9 @@ function filterActiveIssues(array $i): array
'prependedInjection' => $dispatchResult->getPrependedInjection(),
'appendedInjection' => $dispatchResult->getAppendedInjection(),
];
echo $twig->getTwig()->render('patient/card/loader.html.twig', $viewArgs);
if (!in_array('card_lab', $hiddenCards)) {
echo $twig->getTwig()->render('patient/card/loader.html.twig', $viewArgs);
}
endif; // end labs authorized

if ($vitals_is_registered && AclMain::aclCheckCore('patients', 'med')) :
Expand All @@ -1376,7 +1393,9 @@ function filterActiveIssues(array $i): array
'prependedInjection' => $dispatchResult->getPrependedInjection(),
'appendedInjection' => $dispatchResult->getAppendedInjection(),
];
echo $twig->getTwig()->render('patient/card/loader.html.twig', $viewArgs);
if (!in_array('card_vitals', $hiddenCards)) {
echo $twig->getTwig()->render('patient/card/loader.html.twig', $viewArgs);
}
endif; // end vitals

// if anyone wants to render anything after the patient demographic list
Expand Down
32 changes: 32 additions & 0 deletions interface/super/edit_globals.php
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,38 @@ function checkBackgroundServices()
echo "</option>\n";
}
echo " </select>\n";
} elseif ($fldtype == GlobalSetting::DATA_TYPE_MULTI_DASHBOARD_CARDS) {
$hiddenList = [];
$ret = sqlStatement("SELECT gl_value FROM `globals` WHERE `gl_name` = 'hide_dashboard_cards'");
while ($row = sqlFetchArray($ret)) {
$hiddenList[] = $row['gl_value'];
}
// The list of cards to hide. For now add to array new cards.
$res = array(
['card_abrev' => '', 'card_name' => xlt('None or Reset')],
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does this work for a multiselect? Couldn't they select this and still select other items?

Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could but why would you! Even if selected will be ignored. 1 in 100 chance for user doing that. I'll take the odds rather adding a JS or having user unselect to an unselected box.

['card_abrev' => attr('card_allergies'), 'card_name' => xlt('Allergies')],
['card_abrev' => attr('card_amendments'), 'card_name' => xlt('Amendments')],
['card_abrev' => attr('card_disclosure'), 'card_name' => xlt('Disclosures')],
['card_abrev' => attr('card_lab'), 'card_name' => xlt('Labs')],
['card_abrev' => attr('card_medicalproblems'), 'card_name' => xlt('Medical Problems')],
['card_abrev' => attr('card_medication'), 'card_name' => xlt('Medications')],
//['card_abrev' => 'card_rx', 'card_name' => 'Prescriptions'], // For now don't hide because can be disabled as feature.
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

up to you, but i think ok if you want to also include prescriptions in this feature

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bradymiller prescriptions already have its own disable feature. No need to include it here.

Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still say this should be user selectable simply for fact all user don't need all cards but don't want to reargue here!:)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I think I see @bradymiller point is to move the old turn-off feature into here so that people don't have to go to two spots to turn off a card.

Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree but I left to others to decide and I asked admins on signal is why Brady chimed in. but i'll add in my PR. thanks

['card_abrev' => attr('card_vitals'), 'card_name' => xlt('Vitals')]
);
echo " <select multiple class='form-control' name='form_{$i}[]' id='form_{$i}[]' size='8'>\n";
foreach ($res as $row) {
echo " <option value='" . attr($row['card_abrev']) . "'";
foreach ($glarr as $glrow) {
if ($glrow['gl_value'] == $row['card_abrev']) {
echo " selected";
break;
}
}
echo ">";
echo xlt($row['card_name']);
echo "</option>\n";
}
echo " </select>\n";
} elseif ($fldtype == GlobalSetting::DATA_TYPE_COLOR_CODE) {
if ($userMode) {
$globalTitle = $globalValue;
Expand Down
7 changes: 6 additions & 1 deletion library/globals.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,12 @@ function gblTimeZones()
'style_light.css',
xl('Pick a general theme (need to logout/login after changing this setting).')
),

'hide_dashboard_cards' => array(
xl('Hide selected cards on patient dashboard'),
'm_dashboard_cards',
'',
xl('Multi (Shift or CTRL) Select the cards you want to hide on the patient dashboard.')
),
'window_title_add_patient_name' => array(
xl('Add Patient Name To Window Title'),
'bool', // data type
Expand Down
3 changes: 3 additions & 0 deletions src/Services/Globals/GlobalSetting.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class GlobalSetting
// multiple select language selector
const DATA_TYPE_MULTI_LANGUAGE_SELECT = "m_lang";

// multiple select dashboard cards
const DATA_TYPE_MULTI_DASHBOARD_CARDS = "m_dashboard_cards";

// list of default visits in OpenEMR
const DATA_TYPE_DEFAULT_VISIT_CATEGORY = "default_visit_category";
// CSS Theme selector
Expand Down