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

More Portal Rehab #4684

Merged
merged 3 commits into from
Oct 17, 2021
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
21 changes: 18 additions & 3 deletions portal/get_profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/**
*
* Copyright (C) 2016-2019 Jerry Padgett <sjpadgett@gmail.com>
* Copyright (C) 2016-2021 Jerry Padgett <sjpadgett@gmail.com>
* Copyright (C) 2020 Tyler Wrenn <tyler@tylerwrenn.com>
*
* LICENSE: This program is free software; you can redistribute it and/or
Expand Down Expand Up @@ -34,7 +34,6 @@
require_once("./../library/patient.inc");

require_once("./lib/appsql.class.php");
require_once("./lib/section_fetch.class.php");

$appsql = new ApplicationTable();
$pending = $appsql->getPortalAudit($pid, 'review');
Expand Down Expand Up @@ -125,8 +124,24 @@
echo "<div class='card'>";
echo "<header class='card-header border border-bottom-0 immunizations'>" . xlt('Patient Immunization') . '</header>';
echo "<div class='card-body border'>";
$result = FetchSection::getImmunizations($pid);

$query = "SELECT im.*, cd.code_text, DATE(administered_date) AS administered_date,
DATE_FORMAT(administered_date,'%m/%d/%Y') AS administered_formatted, lo.title as route_of_administration,
u.title, u.fname, u.mname, u.lname, u.npi, u.street, u.streetb, u.city, u.state, u.zip, u.phonew1,
f.name, f.phone, lo.notes as route_code
FROM immunizations AS im
LEFT JOIN codes AS cd ON cd.code = im.cvx_code
JOIN code_types AS ctype ON ctype.ct_key = 'CVX' AND ctype.ct_id=cd.code_type
LEFT JOIN list_options AS lo ON lo.list_id = 'drug_route' AND lo.option_id = im.route
LEFT JOIN users AS u ON u.id = im.administered_by_id
LEFT JOIN facility AS f ON f.id = u.facility_id
WHERE im.patient_id=?";
$result = $appsql->zQuery($query, array($pid));
$records = array();
foreach ($result as $row) {
$records[] = $row;
}
foreach ($records as $row) {
echo text($row['administered_formatted']) . ' : ';
echo text($row['code_text']) . ' : ';
echo text($row['note']) . ' : ';
Expand Down
16 changes: 10 additions & 6 deletions portal/home.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
$_SESSION['portal_init'] = true;
}

//$whereto = $_SESSION['whereto'] ?? 'documentscard';
$whereto = $_SESSION['whereto'] ?? null;

$user = $_SESSION['sessionUser'] ?? 'portal user';
$result = getPatientData($pid);
Expand All @@ -49,7 +49,9 @@
$newcnt += 1;
}
}

if ($newcnt > 0 && $_SESSION['portal_init']) {
$whereto = $_SESSION['whereto'] = '#secure-msgs-card';
}
$messagesURL = $GLOBALS['web_root'] . '' . '/portal/messaging/messages.php';

$isEasyPro = $GLOBALS['easipro_enable'] && !empty($GLOBALS['easipro_server']) && !empty($GLOBALS['easipro_name']);
Expand Down Expand Up @@ -105,10 +107,11 @@ function buildNav($newcnt, $pid, $result)
'label' => $result['fname'] . ' ' . $result['lname'],
'icon' => 'fa-user',
'dropdownID' => 'account',
'messageCount' => $newcnt ?? 0,
'children' => [
[
'url' => '#profilecard',
'label' => xl(' My Profile'),
'label' => xl('My Profile'),
'icon' => 'fa-user',
'dataToggle' => 'collapse',
],
Expand All @@ -118,6 +121,7 @@ function buildNav($newcnt, $pid, $result)
'label' => xl('My Messages'),
'icon' => 'fa-envelope',
'dataToggle' => 'collapse',
'messageCount' => $newcnt ?? 0,
],
[
'url' => '#documentscard',
Expand All @@ -127,7 +131,7 @@ function buildNav($newcnt, $pid, $result)
],
[
'url' => '#lists',
'label' => xl('My Lists'),
'label' => xl('My Dashboard'),
'icon' => 'fa-list',
'dataToggle' => 'collapse'
],
Expand All @@ -147,7 +151,7 @@ function buildNav($newcnt, $pid, $result)
'dropdownID' => 'reports',
'children' => [
[
'url' => $GLOBALS['web_root'] . '' . '/ccdaservice/ccda_gateway.php?action=startandrun',
'url' => $GLOBALS['web_root'] . '' . '/ccdaservice/ccda_gateway.php?action=startandrun&csrf_token_form=' . urlencode(CsrfUtils::collectCsrfToken()),
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

would replace urlencode() with js_url()

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

actually, disregard above post. what you have is correct. too late and not enough coffee :)

'label' => xl('View CCD'),
'icon' => 'fa-envelope',
]
Expand Down Expand Up @@ -245,7 +249,7 @@ function buildNav($newcnt, $pid, $result)

echo (new TwigContainer(''))->getTwig()->render('portal/home.html.twig', [
'user' => $user,
'whereto' => $whereto ?? 'documentscard',
'whereto' => $_SESSION['whereto'] ?: ($whereto ?? '#documentscard'),
'result' => $result,
'msgs' => $msgs,
'msgcnt' => $msgcnt,
Expand Down
6 changes: 3 additions & 3 deletions portal/lib/paylib.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
use OpenEMR\Common\Crypto\CryptoGen;

if ($_SESSION['portal_init'] !== true) {
$_SESSION['whereto'] = 'paymentcard';
$_SESSION['whereto'] = '#paymentcard';
}

$_SESSION['portal_init'] = false;
Expand Down Expand Up @@ -70,7 +70,7 @@
return $ex->getMessage();
}

$_SESSION['whereto'] = 'paymentcard';
$_SESSION['whereto'] = '#paymentcard';
if (!$response->isSuccessful()) {
echo $response;
exit();
Expand Down Expand Up @@ -107,7 +107,7 @@
echo $ex->getMessage();
}

$_SESSION['whereto'] = 'paymentcard';
$_SESSION['whereto'] = '#paymentcard';
if (!$response->isSuccessful()) {
echo $response;
exit();
Expand Down
45 changes: 45 additions & 0 deletions portal/lib/persist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

/**
* persist.php
*
* @package OpenEMR
* @link https://www.open-emr.org
* @author Jerry Padgett <sjpadgett@gmail.com>
* @copyright Copyright (c) 2021 Jerry Padgett <sjpadgett@gmail.com>
* @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
*/

require_once(__DIR__ . '/../../src/Common/Session/SessionUtil.php');
OpenEMR\Common\Session\SessionUtil::portalSessionStart();

$sessionAllowWrite = true;
if (isset($_SESSION['pid']) && isset($_SESSION['patient_portal_onsite_two'])) {
$pid = $_SESSION['pid'];
$ignoreAuth_onsite_portal = true;
require_once(__DIR__ . '/../../interface/globals.php');
} else {
OpenEMR\Common\Session\SessionUtil::portalSessionCookieDestroy();
$ignoreAuth = false;
require_once(__DIR__ . '/../../interface/globals.php');
if (!isset($_SESSION['authUserID'])) {
$landingpage = 'index.php';
header('Location: ' . $landingpage);
exit;
}
}

use OpenEMR\Common\Csrf\CsrfUtils;

$data = (array)(json_decode(file_get_contents('php://input'), true, 512, JSON_THROW_ON_ERROR));

if (!CsrfUtils::verifyCsrfToken($data['csrf_token_form'])) {
CsrfUtils::csrfNotVerified();
}

if (!empty($data['where'] ?? null)) {
$_SESSION['whereto'] = $data['where'];
}
if (isset($data['portal_init']) && $data['portal_init'] !== '') {
$_SESSION['portal_init'] = $data['portal_init'];
}