forked from openemr/openemr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Portal Quick Start refactor (openemr#7117)
* Portal Quick Start refactor - Pull quickstart dashboard from iFrame embed in home page twig - fix nav topNav syntax * refactor quickstart cardto twig * - Move Dasboard template to render last on page - add events to inject new cards in dashboard - modify existing portal render event class to include new events for cards. * - add me to authorship * - delete obsalete quickstart page.
- Loading branch information
Showing
9 changed files
with
346 additions
and
367 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
* @author Brady Miller <[email protected]> | ||
* @author Shiqiang Tao <[email protected]> | ||
* @author Ben Marte <[email protected]> | ||
* @copyright Copyright (c) 2016-2022 Jerry Padgett <[email protected]> | ||
* @copyright Copyright (c) 2016-2023 Jerry Padgett <[email protected]> | ||
* @copyright Copyright (c) 2019-2021 Brady Miller <[email protected]> | ||
* @copyright Copyright (c) 2020 Shiqiang Tao <[email protected]> | ||
* @copyright Copyright (c) 2021 Ben Marte <[email protected]> | ||
|
@@ -27,6 +27,9 @@ | |
use OpenEMR\Events\PatientPortal\RenderEvent; | ||
use OpenEMR\Events\PatientPortal\AppointmentFilterEvent; | ||
use OpenEMR\Services\LogoService; | ||
use Twig\Error\LoaderError; | ||
use Twig\Error\RuntimeError; | ||
use Twig\Error\SyntaxError; | ||
|
||
if (isset($_SESSION['register']) && $_SESSION['register'] === true) { | ||
require_once(__DIR__ . '/../src/Common/Session/SessionUtil.php'); | ||
|
@@ -78,7 +81,6 @@ | |
$appts = fetchNextXAppts($current_date2, $pid, $apptLimit); | ||
|
||
$appointments = array(); | ||
|
||
if ($appts) { | ||
$stringCM = '(' . xl('Comments field entry present') . ')'; | ||
$stringR = '(' . xl('Recurring appointment') . ')'; | ||
|
@@ -118,6 +120,29 @@ | |
} | ||
} | ||
|
||
$current_theme = sqlQuery("SELECT `setting_value` FROM `patient_settings` WHERE setting_patient = ? AND `setting_label` = ?", array($pid, 'portal_theme'))['setting_value'] ?? ''; | ||
function collectStyles(): array | ||
{ | ||
global $webserver_root; | ||
$theme_dir = "$webserver_root/public/themes"; | ||
$dh = opendir($theme_dir); | ||
$styleArray = array(); | ||
while (false !== ($tfname = readdir($dh))) { | ||
if ( | ||
$tfname == 'style_blue.css' || | ||
$tfname == 'style_pdf.css' || | ||
!preg_match("/^" . 'style_' . ".*\.css$/", $tfname) | ||
) { | ||
continue; | ||
} | ||
$styleDisplayName = str_replace("_", " ", substr($tfname, 6)); | ||
$styleDisplayName = ucfirst(str_replace(".css", "", $styleDisplayName)); | ||
$styleArray[$tfname] = $styleDisplayName; | ||
} | ||
asort($styleArray); | ||
closedir($dh); | ||
return $styleArray; | ||
} | ||
function buildNav($newcnt, $pid, $result) | ||
{ | ||
$navItems = [ | ||
|
@@ -131,7 +156,7 @@ function buildNav($newcnt, $pid, $result) | |
[ | ||
'url' => '#quickstart-card', | ||
'id' => 'quickstart_id', | ||
'label' => xl('My Quick Start'), | ||
'label' => xl('My Dashboard'), | ||
'icon' => 'fa-tasks', | ||
'dataToggle' => 'collapse', | ||
], | ||
|
@@ -159,7 +184,7 @@ function buildNav($newcnt, $pid, $result) | |
],*/ | ||
[ | ||
'url' => '#lists', | ||
'label' => xl('My Dashboard'), | ||
'label' => xl('My Health'), | ||
'icon' => 'fa-list', | ||
'dataToggle' => 'collapse' | ||
], | ||
|
@@ -288,46 +313,57 @@ function buildNav($newcnt, $pid, $result) | |
|
||
return $navItems; | ||
} | ||
|
||
// Available Themes | ||
$styleArray = collectStyles(); | ||
// Build our navigation | ||
$navMenu = buildNav($newcnt, $pid, $result); | ||
|
||
// Render Home Page | ||
$twig = (new TwigContainer('', $GLOBALS['kernel']))->getTwig(); | ||
echo $twig->render('portal/home.html.twig', [ | ||
'user' => $user, | ||
'whereto' => $_SESSION['whereto'] ?? null ?: ($whereto ?? '#quickstart-card'), | ||
'result' => $result, | ||
'msgs' => $msgs, | ||
'msgcnt' => $msgcnt, | ||
'newcnt' => $newcnt, | ||
'menuLogo' => $logoService->getLogo('portal/menu/primary'), | ||
'allow_portal_appointments' => $GLOBALS['allow_portal_appointments'], | ||
'web_root' => $GLOBALS['web_root'], | ||
'payment_gateway' => $GLOBALS['payment_gateway'], | ||
'gateway_mode_production' => $GLOBALS['gateway_mode_production'], | ||
'portal_two_payments' => $GLOBALS['portal_two_payments'], | ||
'allow_portal_chat' => $GLOBALS['allow_portal_chat'], | ||
'portal_onsite_document_download' => $GLOBALS['portal_onsite_document_download'], | ||
'portal_two_ledger' => $GLOBALS['portal_two_ledger'], | ||
'images_static_relative' => $GLOBALS['images_static_relative'], | ||
'youHave' => xl('You have'), | ||
'navMenu' => $navMenu, | ||
'primaryMenuLogoHeight' => $GLOBALS['portal_primary_menu_logo_height'] ?? '30', | ||
'pagetitle' => xl('Home') . ' | ' . $GLOBALS['openemr_name'] . ' ' . xl('Portal'), | ||
'messagesURL' => $messagesURL, | ||
'patientID' => $pid, | ||
'patientName' => $_SESSION['ptName'] ?? null, | ||
'csrfUtils' => CsrfUtils::collectCsrfToken(), | ||
'isEasyPro' => $isEasyPro, | ||
'appointments' => $appointments, | ||
'appts' => $appts, | ||
'appointmentLimit' => $apptLimit, | ||
'appointmentCount' => $count ?? null, | ||
'displayLimitLabel' => xl('Display limit reached'), | ||
'site_id' => $_SESSION['site_id'] ?? ($_GET['site'] ?? 'default'), // one way or another, we will have a site_id. | ||
'portal_timeout' => $GLOBALS['portal_timeout'] ?? 1800, // timeout is in seconds | ||
'language_defs' => $language_defs, | ||
'eventNames' => [ | ||
'sectionRenderPost' => RenderEvent::EVENT_SECTION_RENDER_POST, | ||
'scriptsRenderPre' => RenderEvent::EVENT_SCRIPTS_RENDER_PRE | ||
] | ||
]); | ||
try { | ||
echo $twig->render('portal/home.html.twig', [ | ||
'user' => $user, | ||
'whereto' => $_SESSION['whereto'] ?? null ?: ($whereto ?? '#quickstart-card'), | ||
'result' => $result, | ||
'msgs' => $msgs, | ||
'msgcnt' => $msgcnt, | ||
'newcnt' => $newcnt, | ||
'menuLogo' => $logoService->getLogo('portal/menu/primary'), | ||
'allow_portal_appointments' => $GLOBALS['allow_portal_appointments'], | ||
'web_root' => $GLOBALS['web_root'], | ||
'payment_gateway' => $GLOBALS['payment_gateway'], | ||
'gateway_mode_production' => $GLOBALS['gateway_mode_production'], | ||
'portal_two_payments' => $GLOBALS['portal_two_payments'], | ||
'allow_portal_chat' => $GLOBALS['allow_portal_chat'], | ||
'portal_onsite_document_download' => $GLOBALS['portal_onsite_document_download'], | ||
'portal_two_ledger' => $GLOBALS['portal_two_ledger'], | ||
'images_static_relative' => $GLOBALS['images_static_relative'], | ||
'youHave' => xl('You have'), | ||
'navMenu' => $navMenu, | ||
'primaryMenuLogoHeight' => $GLOBALS['portal_primary_menu_logo_height'] ?? '30', | ||
'pagetitle' => xl('Home') . ' | ' . $GLOBALS['openemr_name'] . ' ' . xl('Portal'), | ||
'messagesURL' => $messagesURL, | ||
'patientID' => $pid, | ||
'patientName' => $_SESSION['ptName'] ?? null, | ||
'csrfUtils' => CsrfUtils::collectCsrfToken(), | ||
'isEasyPro' => $isEasyPro, | ||
'appointments' => $appointments, | ||
'appts' => $appts, | ||
'appointmentLimit' => $apptLimit, | ||
'appointmentCount' => $count ?? null, | ||
'displayLimitLabel' => xl('Display limit reached'), | ||
'site_id' => $_SESSION['site_id'] ?? ($_GET['site'] ?? 'default'), // one way or another, we will have a site_id. | ||
'portal_timeout' => $GLOBALS['portal_timeout'] ?? 1800, // timeout is in seconds | ||
'language_defs' => $language_defs, | ||
'current_theme' => $current_theme, | ||
'styleArray' => $styleArray, | ||
'eventNames' => [ | ||
'sectionRenderPost' => RenderEvent::EVENT_SECTION_RENDER_POST, | ||
'scriptsRenderPre' => RenderEvent::EVENT_SCRIPTS_RENDER_PRE, | ||
'dashboardInjectCard' => RenderEvent::EVENT_DASHBOARD_INJECT_CARD, | ||
'dashboardRenderScripts' => RenderEvent::EVENT_DASHBOARD_RENDER_SCRIPTS | ||
] | ||
]); | ||
} catch (LoaderError | RuntimeError | SyntaxError $e) { | ||
OpenEMR\Common\Session\SessionUtil::portalSessionCookieDestroy(); | ||
die(text($e->getMessage())); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.