Skip to content

Commit

Permalink
fix: fixes to allergy card in patient summary
Browse files Browse the repository at this point in the history
  • Loading branch information
bradymiller committed Sep 20, 2023
1 parent 776475c commit 85cf9d3
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 29 deletions.
13 changes: 2 additions & 11 deletions interface/patient_file/summary/demographics.php
Original file line number Diff line number Diff line change
Expand Up @@ -1051,23 +1051,14 @@ function setMyPatient() {
function filterActiveIssues(array $i): array
{
return array_filter($i, function ($_i) {
return $_i['outcome'] != 1;
return ($_i['outcome'] != 1) && (empty($_i['enddate']) || (strtotime($_i['enddate']) > strtotime('now')));
});
}

// ALLERGY CARD
if ($allergy === 1) {
$allergyService = new AllergyIntoleranceService();
$_rawAllergies = filterActiveIssues($allergyService->getAll(['lists.pid' => $pid])->getData());
$_priority = [];
$_standard = [];
foreach ($_rawAllergies as $_) {
if (in_array($_['severity_al'], ['severe', 'life_threatening_severity', 'fatal'])) {
$_priority[] = $_;
} else {
$_standard[] = $_;
}
}
$id = 'allergy_ps_expand';
$viewArgs = [
'title' => xl('Allergies'),
Expand All @@ -1076,7 +1067,7 @@ function filterActiveIssues(array $i): array
'forceAlwaysOpen' => false,
'initiallyCollapsed' => (getUserSetting($id) == 0) ? true : false,
'linkMethod' => "javascript",
'list' => ['priority' => $_priority, 'standard' => $_standard],
'list' => $_rawAllergies,
'listTouched' => (!empty(getListTouch($pid, 'allergy'))) ? true : false,
'auth' => true,
'btnLabel' => 'Edit',
Expand Down
9 changes: 2 additions & 7 deletions library/options.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@

use OpenEMR\Common\Acl\AclExtended;
use OpenEMR\Common\Acl\AclMain;
use OpenEMR\Common\Layouts\LayoutsUtils;
use OpenEMR\Services\EncounterService;
use OpenEMR\Services\FacilityService;
use OpenEMR\Services\PatientService;
Expand Down Expand Up @@ -4789,13 +4790,7 @@ function billing_facility($name, $select)
//
function getListItemTitle($list, $option)
{
$row = sqlQuery("SELECT title FROM list_options WHERE " .
"list_id = ? AND option_id = ? AND activity = 1", array($list, $option));
if (empty($row['title'])) {
return $option;
}

return xl_list_label($row['title']);
return LayoutsUtils::getListItemTitle($list, $option);
}

//function to get the translated title value in Patient Transactions
Expand Down
25 changes: 25 additions & 0 deletions src/Common/Layouts/LayoutsUtils.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

/**
* LayoutsUtils class.
*
* @package OpenEMR
* @link https://www.open-emr.org
* @author Brady Miller <brady.g.miller@gmail.com>
* @copyright Copyright (c) 2023 Brady Miller <brady.g.miller@gmail.com>
* @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
*/

namespace OpenEMR\Common\Layouts;

class LayoutsUtils
{
public static function getListItemTitle($list, $option)
{
$row = sqlQuery("SELECT `title` FROM `list_options` WHERE `list_id` = ? AND `option_id` = ? AND activity = 1", [$list, $option]);
if (empty($row['title'])) {
return $option;
}
return xl_list_label($row['title']);
}
}
7 changes: 7 additions & 0 deletions src/Common/Twig/TwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

use OpenEMR\Common\Acl\AclMain;
use OpenEMR\Common\Csrf\CsrfUtils;
use OpenEMR\Common\Layouts\LayoutsUtils;
use OpenEMR\Common\Utils\CacheUtils;
use OpenEMR\Core\Header;
use OpenEMR\Core\Kernel;
Expand Down Expand Up @@ -217,6 +218,12 @@ function (string $type, string $filename = "logo.*") {
$ls = new LogoService();
return $ls->getLogo($type, $filename);
}
),
new TwigFunction(
'getListItemTitle',
function (string $list, $option) {
return LayoutsUtils::getListItemTitle($list, $option);
}
)
];
}
Expand Down
18 changes: 7 additions & 11 deletions templates/patient/card/allergies.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,8 @@ list_group_container_class_list with an array of strings representing class name

{% block content %}

{% for a in list.priority %}
{% set _critAllergyClasses = ['bg-warning', 'd-inline-block', 'text-dark', 'font-weight-bold', 'rounded', 'px-1', 'm-1'] %}
{% set _tooltip = a.reaction_title|attr ~ " " ~ a.severity_al|attr %}
<small class="{{ critical_allergy_item_class_list|default(_critAllergyClasses)|join(' ') }}" title="{{ _tooltip }}">{{ a.title|text}}</small>
{% endfor %}

<div class="{{ list_group_container_class_list|default(['list-group', 'list-group-flush', 'pami-list'])|join(' ') }}">
{% if list.priority|length == 0 and list.standard|length == 0 %}
{% if list|length == 0 %}
{% if listTouched == true %}
<div class="list-group-item p-0 pl-1">
{{ "No Known Allergies"|xlt }}
Expand All @@ -41,13 +35,15 @@ list_group_container_class_list with an array of strings representing class name
</div>
{% endif %}
{% else %}
{% for l in list.standard %}
{% set severityAlarms = ["severe", "life_threatening_severity", "fatal"] %}
{% for l in list %}
{% set classes = (l.severity_al in severityAlarms) ? 'bg-warning font-weight-bold px-1' : '' %}
<div class="list-group-item p-1">
<div class="d-flex w-100 justify-content-between">
<div class="flex-fill">
{{ l.title|text }}&nbsp;({{ l.reaction_title|text }})
{% set _severity = getListItemTitle('severity_ccda', l.severity_al) %}
<div class="flex-fill" title="{{ l.title|attr }} {{ 'Reaction'|xla }}: {{ l.reaction_title|xlListLabel|attr }} - {{ _severity|attr }}">
{{ l.title|text }} (<span class="{{ classes|attr }}">{{ _severity|text }}</span>)
</div>
<div class="text-right">{{ l.severity_al|text }}</div>
</div>
</div>
{% endfor %}
Expand Down

0 comments on commit 85cf9d3

Please # to comment.