6 * @link https://www.open-emr.org
7 * @author Cassian LUP <cassi.lup@gmail.com>
8 * @author Jerry Padgett <sjpadgett@gmail.com>
9 * @author Brady Miller <brady.g.miller@gmail.com>
10 * @copyright Copyright (c) 2011 Cassian LUP <cassi.lup@gmail.com>
11 * @copyright Copyright (c) 2016-2017 Jerry Padgett <sjpadgett@gmail.com>
12 * @copyright Copyright (c) 2019 Brady Miller <brady.g.miller@gmail.com>
13 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
16 //setting the session & other config options
18 // Will start the (patient) portal OpenEMR session/cookie.
19 require_once(dirname(__FILE__
) . "/../src/Common/Session/SessionUtil.php");
20 OpenEMR\Common\Session\SessionUtil
::portalSessionStart();
22 //don't require standard openemr authorization in globals.php
25 //For redirect if the site on session does not match
26 $landingpage = "index.php?site=" . urlencode($_GET['site']);
29 require_once('../interface/globals.php');
31 use OpenEMR\Core\Header
;
33 //exit if portal is turned off
34 if (!(isset($GLOBALS['portal_onsite_two_enable'])) ||
!($GLOBALS['portal_onsite_two_enable'])) {
35 echo xlt('Patient Portal is turned off');
39 // security measure -- will check on next page.
40 $_SESSION['itsme'] = 1;
44 // Deal with language selection
46 // collect default language id (skip this if this is a password update)
47 if (!(isset($_SESSION['password_update']) ||
isset($_GET['requestNew']))) {
48 $res2 = sqlStatement("select * from lang_languages where lang_description = ?", array($GLOBALS['language_default']));
49 for ($iter = 0; $row = sqlFetchArray($res2); $iter++
) {
50 $result2[$iter] = $row;
53 if (count($result2) == 1) {
54 $defaultLangID = $result2[0]{"lang_id"};
55 $defaultLangName = $result2[0]{"lang_description"};
57 //default to english if any problems
59 $defaultLangName = "English";
62 // set session variable to default so login information appears in default language
63 $_SESSION['language_choice'] = $defaultLangID;
64 // collect languages if showing language menu
65 if ($GLOBALS['language_menu_login']) {
66 // sorting order of language titles depends on language translation options.
67 $mainLangID = empty($_SESSION['language_choice']) ?
'1' : $_SESSION['language_choice'];
68 if ($mainLangID == '1' && !empty($GLOBALS['skip_english_translation'])) {
69 $sql = "SELECT * FROM lang_languages ORDER BY lang_description, lang_id";
70 $res3=SqlStatement($sql);
72 // Use and sort by the translated language name.
73 $sql = "SELECT ll.lang_id, " .
74 "IF(LENGTH(ld.definition),ld.definition,ll.lang_description) AS trans_lang_description, " .
75 "ll.lang_description " .
76 "FROM lang_languages AS ll " .
77 "LEFT JOIN lang_constants AS lc ON lc.constant_name = ll.lang_description " .
78 "LEFT JOIN lang_definitions AS ld ON ld.cons_id = lc.cons_id AND " .
80 "ORDER BY IF(LENGTH(ld.definition),ld.definition,ll.lang_description), ll.lang_id";
81 $res3=SqlStatement($sql, array($mainLangID));
83 for ($iter = 0; $row = sqlFetchArray($res3); $iter++
) {
84 $result3[$iter] = $row;
86 if (count($result3) == 1) {
87 //default to english if only return one language
88 $hiddenLanguageField = "<input type='hidden' name='languageChoice' value='1' />\n";
91 $hiddenLanguageField = "<input type='hidden' name='languageChoice' value='" . attr($defaultLangID) . "' />\n";
98 <title
><?php
echo xlt('Patient Portal Login'); ?
></title
>
100 Header
::setupHeader(['no_main-theme', 'datetime-picker']);
102 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/gritter/js/jquery.gritter.min.js"></script
>
103 <link rel
="stylesheet" type
="text/css" href
="<?php echo $GLOBALS['assets_static_relative']; ?>/gritter/css/jquery.gritter.css" />
104 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/emodal/dist/eModal.min.js"></script
>
105 <link rel
="stylesheet" type
="text/css" href
="assets/css/base.css?v=<?php echo $v_js_includes; ?>" />
106 <link rel
="stylesheet" type
="text/css" href
="assets/css/register.css?v=<?php echo $v_js_includes; ?>" />
107 <script type
="text/javascript">
110 alert (<?php
echo xlj('Field(s) are missing!'); ?
>);
114 function validate() {
116 if (document
.getElementById('uname').value
== "") {
117 document
.getElementById('uname').style
.border
= "1px solid red";
120 if (document
.getElementById('pass').value
== "") {
121 document
.getElementById('pass').style
.border
= "1px solid red";
126 function process_new_pass() {
127 if (!(validate_new_pass())) {
128 alert (<?php
echo xlj('Field(s) are missing!'); ?
>);
131 if (document
.getElementById('pass_new').value
!= document
.getElementById('pass_new_confirm').value
) {
132 alert (<?php
echo xlj('The new password fields are not the same.'); ?
>);
135 if (document
.getElementById('pass').value
== document
.getElementById('pass_new').value
) {
136 alert (<?php
echo xlj('The new password can not be the same as the current password.'); ?
>);
141 function validate_new_pass() {
143 if (document
.getElementById('uname').value
== "") {
144 document
.getElementById('uname').style
.border
= "1px solid red";
147 if (document
.getElementById('pass').value
== "") {
148 document
.getElementById('pass').style
.border
= "1px solid red";
151 if (document
.getElementById('pass_new').value
== "") {
152 document
.getElementById('pass_new').style
.border
= "1px solid red";
155 if (document
.getElementById('pass_new_confirm').value
== "") {
156 document
.getElementById('pass_new_confirm').style
.border
= "1px solid red";
163 <body
class="skin-blue">
165 <div
class="container text-center">
166 <?php
if (isset($_SESSION['password_update']) ||
isset($_GET['password_update'])) {
167 $_SESSION['password_update']=1;
169 <div id
="wrapper" class="centerwrapper" style
="text-align:center;">
170 <h2
class="title"><?php
echo xlt('Please Enter a New Password'); ?
></h2
>
171 <form action
="get_patient_info.php" method
="POST" onsubmit
="return process_new_pass()" >
172 <table style
="width:100%">
174 <td
class="algnRight"><?php
echo xlt('User Name'); ?
></td
>
175 <td
><input name
="uname" id
="uname" type
="text" autocomplete
="off" value
="<?php echo attr($_SESSION['portal_username']); ?>"/></td
>
178 <td
class="algnRight"><?php
echo xlt('Current Password');?
></td
>
180 <input name
="pass" id
="pass" type
="password" autocomplete
="off" value
="" />
184 <td
class="algnRight"><?php
echo xlt('New Password');?
></td
>
186 <input name
="pass_new" id
="pass_new" type
="password" />
190 <td
class="algnRight"><?php
echo xlt('Confirm New Password');?
></td
>
192 <input name
="pass_new_confirm" id
="pass_new_confirm" type
="password" />
195 <?php
if ($GLOBALS['enforce_signin_email']) { ?
>
197 <td
class="algnRight"><?php
echo xlt('Confirm Email Address');?
></td
>
199 <input name
="passaddon" id
="passaddon" placeholder
="<?php echo xla('Your on file email address'); ?>" type
="email" autocomplete
="off" value
="" />
204 <td colspan
=2><br
><input
class="pull-right" type
="submit" value
="<?php echo xla('Log In');?>" /></td
>
208 <div
class="copyright"><?php
echo xlt('Powered by');?
> OpenEMR
</div
>
210 <?php
} elseif (isset($_GET['requestNew'])) { ?
>
211 <div id
="wrapper" class="centerwrapper" style
="text-align:center;" >
212 <form
class="form-inline" id
="resetPass" action
="" method
="" >
214 <div
class="col-sm-10 col-md-offset-1 text-center">
216 <legend
class='bg-primary'><h3
><?php
echo xlt('Patient Credentials Reset') ?
></h3
></legend
>
219 <div
class="form-group inline">
220 <label
class="control-label" for="fname"><?php
echo xlt('First')?
></label
>
221 <div
class="controls inline-inputs">
222 <input type
="text" class="form-control" id
="fname" required placeholder
="<?php echo xla('First Name'); ?>">
225 <div
class="form-group inline">
226 <label
class="control-label" for="lname"><?php
echo xlt('Last Name')?
></label
>
227 <div
class="controls inline-inputs">
228 <input type
="text" class="form-control" id
="lname" required placeholder
="<?php echo xla('Enter Last'); ?>">
231 <div
class="form-group inline">
232 <label
class="control-label" for="dob"><?php
echo xlt('Birth Date')?
></label
>
233 <div
class="controls inline-inputs">
234 <div
class="input-group">
235 <input id
="dob" type
="text" required
class="form-control datepicker" placeholder
="<?php echo xla('YYYY-MM-DD'); ?>" />
240 <div
class="col-sm-12 form-group">
241 <label
class="control-label" for="emailInput"><?php
echo xlt('Enter E-Mail Address')?
></label
>
242 <div
class="controls inline-inputs">
243 <input id
="emailInput" type
="email" class="form-control" style
="width: 100%" required
244 placeholder
="<?php echo xla('Must be current email address on file.'); ?>" maxlength
="100">
249 <button id
="submitRequest" class="btn btn-primary nextBtn btn-sm pull-right" type
="button"><?php
echo xlt('Verify') ?
></button
>
256 ?
> <!-- Main logon
-->
257 <div id
="wrapper" class="row centerwrapper text-center">
258 <img style
="width:65%" src
='<?php echo $GLOBALS['images_static_relative
']; ?>/login-logo.png'/>
259 <form
class="form-inline text-center" action
="get_patient_info.php" method
="POST" onsubmit
="return process()">
261 <div
class="col-sm-12 text-center">
263 <legend
class="bg-primary"><h3
><?php
echo xlt('Patient Portal Login'); ?
></h3
></legend
>
266 <div
class="col-sm-12">
267 <div
class="form-group inline">
268 <label
class="control-label" for="uname"><?php
echo xlt('Username')?
></label
>
269 <div
class="controls inline-inputs">
270 <input type
="text" class="form-control" name
="uname" id
="uname" type
="text" autocomplete
="on" required
>
273 <div
class="form-group inline">
274 <label
class="control-label" for="pass"><?php
echo xlt('Password')?
></label
>
275 <div
class="controls inline-inputs">
276 <input
class="form-control" name
="pass" id
="pass" type
="password" required autocomplete
="on">
282 <?php
if ($GLOBALS['enforce_signin_email']) { ?
>
283 <div
class="col-sm-12 form-group">
284 <label
class="control-label" for="passaddon"><?php
echo xlt('E-Mail Address')?
></label
>
285 <div
class="controls inline-inputs">
286 <input
class="form-control" style
="width: 100%" name
="passaddon" id
="passaddon" placeholder
="<?php echo xla('on file email'); ?>" type
="email" autocomplete
="on" />
291 <?php
if ($GLOBALS['language_menu_login']) { ?
>
292 <?php
if (count($result3) != 1) { ?
>
293 <div
class="form-group row">
294 <label
for="selLanguage"><?php
echo xlt('Language'); ?
></label
>
295 <select
class="form-control" id
="selLanguage" name
="languageChoice">
297 echo "<option selected='selected' value='" . attr($defaultLangID) . "'>" .
298 text(xl('Default') . " - " . xl($defaultLangName)) . "</option>\n";
299 foreach ($result3 as $iter) {
300 if ($GLOBALS['language_menu_showall']) {
301 if (! $GLOBALS['allow_debug_language'] && $iter['lang_description'] == 'dummy') {
302 continue; // skip the dummy language
304 echo "<option value='" . attr($iter['lang_id']) . "'>" .
305 text($iter['trans_lang_description']) . "</option>\n";
307 if (in_array($iter['lang_description'], $GLOBALS['language_menu_show'])) {
308 if (! $GLOBALS['allow_debug_language'] && $iter['lang_description'] == 'dummy') {
309 continue; // skip the dummy language
311 echo "<option value='" . attr($iter['lang_id']) . "'>" .
312 text($iter['trans_lang_description']) . "</option>\n";
321 <div
class="col-sm-12 col-md-12">
322 <?php
if ($GLOBALS['portal_onsite_two_register']) { ?
>
323 <button
class="btn btn-default pull-left" onclick
="location.replace('./account/register.php')"><?php
echo xlt('Register');?
></button
>
325 <?php
if ($GLOBALS['portal_two_pass_reset'] && isset($_GET['w']) && (isset($_GET['u']) ||
isset($_GET['p']))) { ?
>
326 <button
class="btn btn-danger" onclick
="location.replace('./index.php?requestNew=1')" style
="margin-left:10px"><?php
echo xlt('Reset Credentials');?
></button
>
328 <button
class="btn btn-success pull-right" type
="submit" ><?php
echo xlt('Log In');?
></button
>
333 <?php
if (!(empty($hiddenLanguageField))) {
334 echo $hiddenLanguageField; } ?
>
336 </div
><!-- div wrapper
-->
337 <?php
} ?
> <!-- logon wrapper
-->
338 </div
><!-- container
-->
340 <script type
="text/javascript">
343 <?php
// if something went wrong
344 if (isset($_GET['requestNew'])) {
345 $_SESSION['register'] = true;
346 $_SESSION['authUser'] = 'portal-user';
347 $_SESSION['pid'] = true;
349 $
('.datepicker').datetimepicker({
350 <?php
$datetimepicker_timepicker = false; ?
>
351 <?php
$datetimepicker_showseconds = false; ?
>
352 <?php
$datetimepicker_formatInput = false; ?
>
353 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
355 $
(document
.body
).on('hidden.bs.modal', function () {
356 callServer('cleanup');
358 $
("#submitRequest").click(function () {
359 callServer('is_new', '');
362 <?php
if (isset($_GET['w'])) { ?
>
363 var unique_id
= $
.gritter
.add({
364 title
: '<span class="red">' +
<?php
echo xlj('Oops!');?
> +
'</span>',
365 text
: <?php
echo xlj('Something went wrong. Please try again.'); ?
>,
368 class_name
: 'my-nonsticky-class'
371 <?php
// if successfully logged out
372 if (isset($_GET['logout'])) { ?
>
373 var unique_id
= $
.gritter
.add({
374 title
: '<span class="green">' +
<?php
echo xlj('Success');?
> +
'</span>',
375 text
: <?php
echo xlj('You have been successfully logged out.');?
>,
378 class_name
: 'my-nonsticky-class'
385 $("#emailInput").val("me@me.com");
386 $("#fname").val("Jerry");
387 $("#lname").val("Padgett");
388 $("#dob").val("1919-03-03"); */
390 function callServer(action
, value
, value2
, last
, first
) {
394 'dob' : $
("#dob").val(),
395 'last' : $
("#lname").val(),
396 'first' : $
("#fname").val(),
397 'email' : $
("#emailInput").val()
399 if (action
== 'do_signup') {
405 else if (action
== 'notify_admin') {
412 else if (action
== 'cleanup') {
419 url
: './account/account.php',
421 }).done(function (rtn
) {
422 if (action
== "cleanup") {
423 window
.location
.href
= "./index.php" // Goto landing page.
425 else if (action
== "is_new") {
426 if (parseInt(rtn
) > 0) {
427 var yes
= confirm(<?php
echo xlj("Account is validated. Send new credentials?") ?
>);
429 callServer('cleanup');
431 callServer('do_signup', parseInt(rtn
));
434 // After error alert app exit to landing page.
435 var message
= <?php
echo xlj('Unable to find your records. Be sure to use your correct Dob, First and Last name and Email of record. If you have opted out of email with none on file then leave blank.'); ?
>;
436 eModal
.alert(message
);
439 else if (action
== 'do_signup') {
441 var message
= <?php
echo xlj('Unable to either create credentials or send email.'); ?
>;
445 //alert(rtn); // sync alert.. rtn holds username and password for testing.
446 var message
= <?php
echo xlj("Your new credentials have been sent. Check your email inbox and also possibly your spam folder. Once you log into your patient portal feel free to make an appointment or send us a secure message. We look forward to seeing you soon."); ?
>;
447 eModal
.alert(message
); // This is an async call. The modal close event exits us to portal landing page after cleanup.
449 }).fail(function (err
) {
450 var message
= <?php
echo xlj('Something went wrong.') ?
>;