From 9b0504a445e57f4cf504d6a1ba8defe0b07e8bf5 Mon Sep 17 00:00:00 2001 From: Brady Miller Date: Wed, 20 Sep 2023 20:03:55 -0700 Subject: [PATCH] fix: fixes to allergy card in patient summary (#6863) --- interface/patient_file/summary/demographics.php | 13 ++----------- library/options.inc.php | 9 ++------- src/Common/Layouts/LayoutsUtils.php | 25 +++++++++++++++++++++++++ src/Common/Twig/TwigExtension.php | 7 +++++++ templates/patient/card/allergies.html.twig | 18 +++++++----------- 5 files changed, 43 insertions(+), 29 deletions(-) create mode 100644 src/Common/Layouts/LayoutsUtils.php diff --git a/interface/patient_file/summary/demographics.php b/interface/patient_file/summary/demographics.php index 5f4c88c06..c583a9d35 100644 --- a/interface/patient_file/summary/demographics.php +++ b/interface/patient_file/summary/demographics.php @@ -1051,7 +1051,7 @@ $oemr_ui = new OemrUI($arrOeUiSettings); 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'))); }); } @@ -1059,15 +1059,6 @@ $oemr_ui = new OemrUI($arrOeUiSettings); 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'), @@ -1076,7 +1067,7 @@ $oemr_ui = new OemrUI($arrOeUiSettings); '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', diff --git a/library/options.inc.php b/library/options.inc.php index d3c68cd9c..953b634d8 100644 --- a/library/options.inc.php +++ b/library/options.inc.php @@ -56,6 +56,7 @@ require_once(dirname(dirname(__FILE__)) . "/custom/code_types.inc.php"); 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; @@ -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 diff --git a/src/Common/Layouts/LayoutsUtils.php b/src/Common/Layouts/LayoutsUtils.php new file mode 100644 index 000000000..e12af1b6b --- /dev/null +++ b/src/Common/Layouts/LayoutsUtils.php @@ -0,0 +1,25 @@ + + * @copyright Copyright (c) 2023 Brady Miller + * @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']); + } +} diff --git a/src/Common/Twig/TwigExtension.php b/src/Common/Twig/TwigExtension.php index ebd7f609b..9924ceb3b 100644 --- a/src/Common/Twig/TwigExtension.php +++ b/src/Common/Twig/TwigExtension.php @@ -17,6 +17,7 @@ namespace OpenEMR\Common\Twig; 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; @@ -217,6 +218,12 @@ class TwigExtension extends AbstractExtension implements GlobalsInterface $ls = new LogoService(); return $ls->getLogo($type, $filename); } + ), + new TwigFunction( + 'getListItemTitle', + function (string $list, $option) { + return LayoutsUtils::getListItemTitle($list, $option); + } ) ]; } diff --git a/templates/patient/card/allergies.html.twig b/templates/patient/card/allergies.html.twig index d1826f78d..54ea5316a 100644 --- a/templates/patient/card/allergies.html.twig +++ b/templates/patient/card/allergies.html.twig @@ -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 %} - {{ a.title|text}} -{% endfor %} -
-{% if list.priority|length == 0 and list.standard|length == 0 %} +{% if list|length == 0 %} {% if listTouched == true %}
{{ "No Known Allergies"|xlt }} @@ -41,13 +35,15 @@ list_group_container_class_list with an array of strings representing class name
{% 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' : '' %}
-
- {{ l.title|text }} ({{ l.reaction_title|text }}) + {% set _severity = getListItemTitle('severity_ccda', l.severity_al) %} +
+ {{ l.title|text }} ({{ _severity|text }})
-
{{ l.severity_al|text }}
{% endfor %} -- 2.11.4.GIT