4 * Copyright (C) 2016-2017 Jerry Padgett <sjpadgett@gmail.com>
5 * Copyright (C) 2011 Cassian LUP <cassi.lup@gmail.com>
7 * LICENSE: This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as
9 * published by the Free Software Foundation, either version 3 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 * @author Jerry Padgett <sjpadgett@gmail.com>
22 * @author Cassian LUP <cassi.lup@gmail.com>
23 * @link http://www.open-emr.org
26 //setting the session & other config options
29 //don't require standard openemr authorization in globals.php
32 //For redirect if the site on session does not match
33 $landingpage = "index.php?site=".$_GET['site'];
36 require_once('../interface/globals.php');
38 use OpenEMR\Core\Header
;
40 ini_set("error_log", E_ERROR || ~E_NOTICE
);
41 //exit if portal is turned off
42 if (!(isset($GLOBALS['portal_onsite_two_enable'])) ||
!($GLOBALS['portal_onsite_two_enable'])) {
43 echo htmlspecialchars(xl('Patient Portal is turned off'), ENT_NOQUOTES
);
47 // security measure -- will check on next page.
48 $_SESSION['itsme'] = 1;
52 // Deal with language selection
54 // collect default language id (skip this if this is a password update)
55 if (!(isset($_SESSION['password_update']) ||
isset($_GET['requestNew']))) {
56 $res2 = sqlStatement("select * from lang_languages where lang_description = ?", array($GLOBALS['language_default']));
57 for ($iter = 0; $row = sqlFetchArray($res2); $iter++
) {
58 $result2[$iter] = $row;
61 if (count($result2) == 1) {
62 $defaultLangID = $result2[0]{"lang_id"};
63 $defaultLangName = $result2[0]{"lang_description"};
65 //default to english if any problems
67 $defaultLangName = "English";
70 // set session variable to default so login information appears in default language
71 $_SESSION['language_choice'] = $defaultLangID;
72 // collect languages if showing language menu
73 if ($GLOBALS['language_menu_login']) {
74 // sorting order of language titles depends on language translation options.
75 $mainLangID = empty($_SESSION['language_choice']) ?
'1' : $_SESSION['language_choice'];
76 if ($mainLangID == '1' && !empty($GLOBALS['skip_english_translation'])) {
77 $sql = "SELECT * FROM lang_languages ORDER BY lang_description, lang_id";
78 $res3=SqlStatement($sql);
80 // Use and sort by the translated language name.
81 $sql = "SELECT ll.lang_id, " .
82 "IF(LENGTH(ld.definition),ld.definition,ll.lang_description) AS trans_lang_description, " .
83 "ll.lang_description " .
84 "FROM lang_languages AS ll " .
85 "LEFT JOIN lang_constants AS lc ON lc.constant_name = ll.lang_description " .
86 "LEFT JOIN lang_definitions AS ld ON ld.cons_id = lc.cons_id AND " .
88 "ORDER BY IF(LENGTH(ld.definition),ld.definition,ll.lang_description), ll.lang_id";
89 $res3=SqlStatement($sql, array($mainLangID));
91 for ($iter = 0; $row = sqlFetchArray($res3); $iter++
) {
92 $result3[$iter] = $row;
94 if (count($result3) == 1) {
95 //default to english if only return one language
96 $hiddenLanguageField = "<input type='hidden' name='languageChoice' value='1' />\n";
99 $hiddenLanguageField = "<input type='hidden' name='languageChoice' value='".htmlspecialchars($defaultLangID, ENT_QUOTES
)."' />\n";
106 <title
><?php
echo xlt('Patient Portal Login'); ?
></title
>
107 <?php Header
::setupHeader(['datetime-picker']); ?
>
108 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery.gritter-1-7-4/js/jquery.gritter.min.js"></script
>
109 <link rel
="stylesheet" type
="text/css" href
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery.gritter-1-7-4/css/jquery.gritter.css" />
110 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/emodal-1-2-65/dist/eModal.js"></script
>
111 <link rel
="stylesheet" type
="text/css" href
="assets/css/base.css?v=<?php echo $v_js_includes; ?>" />
112 <link rel
="stylesheet" type
="text/css" href
="assets/css/register.css?v=<?php echo $v_js_includes; ?>" />
113 <script type
="text/javascript">
116 alert ('<?php echo addslashes(xl('Field(s
) are missing
!')); ?>');
120 function validate() {
122 if (document
.getElementById('uname').value
== "") {
123 document
.getElementById('uname').style
.border
= "1px solid red";
126 if (document
.getElementById('pass').value
== "") {
127 document
.getElementById('pass').style
.border
= "1px solid red";
132 function process_new_pass() {
133 if (!(validate_new_pass())) {
134 alert ('<?php echo addslashes(xl('Field(s
) are missing
!')); ?>');
137 if (document
.getElementById('pass_new').value
!= document
.getElementById('pass_new_confirm').value
) {
138 alert ('<?php echo addslashes(xl('The
new password fields are not the same
.')); ?>');
141 if (document
.getElementById('pass').value
== document
.getElementById('pass_new').value
) {
142 alert ('<?php echo addslashes(xl('The
new password can not be the same
as the current password
.')); ?>');
147 function validate_new_pass() {
149 if (document
.getElementById('uname').value
== "") {
150 document
.getElementById('uname').style
.border
= "1px solid red";
153 if (document
.getElementById('pass').value
== "") {
154 document
.getElementById('pass').style
.border
= "1px solid red";
157 if (document
.getElementById('pass_new').value
== "") {
158 document
.getElementById('pass_new').style
.border
= "1px solid red";
161 if (document
.getElementById('pass_new_confirm').value
== "") {
162 document
.getElementById('pass_new_confirm').style
.border
= "1px solid red";
171 <div
class="container text-center">
172 <?php
if (isset($_SESSION['password_update']) ||
isset($_GET['password_update'])) {
173 $_SESSION['password_update']=1;
175 <div id
="wrapper" class="centerwrapper" style
="text-align:center;">
176 <h2
class="title"><?php
echo xlt('Please Enter a New Password'); ?
></h2
>
177 <form action
="get_patient_info.php" method
="POST" onsubmit
="return process_new_pass()" >
178 <table style
="width:100%">
180 <td
class="algnRight"><?php
echo xlt('User Name'); ?
></td
>
181 <td
><input name
="uname" id
="uname" type
="text" autocomplete
="off" value
="<?php echo attr($_SESSION['portal_username']); ?>"/></td
>
184 <td
class="algnRight"><?php
echo xlt('Current Password');?
></td
>
186 <input name
="pass" id
="pass" type
="password" autocomplete
="off" value
="" />
190 <td
class="algnRight"><?php
echo xlt('New Password');?
></td
>
192 <input name
="pass_new" id
="pass_new" type
="password" />
196 <td
class="algnRight"><?php
echo xlt('Confirm New Password');?
></td
>
198 <input name
="pass_new_confirm" id
="pass_new_confirm" type
="password" />
202 <td
class="algnRight"><?php
echo xlt('Confirm Email Address');?
></td
>
204 <input name
="passaddon" id
="passaddon" placeholder
="<?php echo xla('Your on file email address'); ?>" type
="email" autocomplete
="off" value
="" />
208 <td colspan
=2><br
><input
class="pull-right" type
="submit" value
="<?php echo xla('Log In');?>" /></td
>
212 <div
class="copyright"><?php
echo xlt('Powered by');?
> OpenEMR
</div
>
214 <?php
} elseif (isset($_GET['requestNew'])) { ?
>
215 <div id
="wrapper" class="centerwrapper" style
="text-align:center;" >
216 <form
class="form-inline" id
="resetPass" action
="" method
="" >
218 <div
class="col-sm-10 col-md-offset-1 text-center">
220 <legend
class='bg-primary'><h3
><?php
echo xlt('Patient Credentials Reset') ?
></h3
></legend
>
223 <div
class="form-group inline">
224 <label
class="control-label" for="fname"><?php
echo xlt('First')?
></label
>
225 <div
class="controls inline-inputs">
226 <input type
="text" class="form-control" id
="fname" required placeholder
="<?php echo xla('First Name'); ?>">
229 <div
class="form-group inline">
230 <label
class="control-label" for="lname"><?php
echo xlt('Last Name')?
></label
>
231 <div
class="controls inline-inputs">
232 <input type
="text" class="form-control" id
="lname" required placeholder
="<?php echo xla('Enter Last'); ?>">
235 <div
class="form-group inline">
236 <label
class="control-label" for="dob"><?php
echo xlt('Birth Date')?
></label
>
237 <div
class="controls inline-inputs">
238 <div
class="input-group">
239 <input id
="dob" type
="text" required
class="form-control datepicker" placeholder
="<?php echo xla('YYYY-MM-DD'); ?>" />
244 <div
class="col-sm-12 form-group">
245 <label
class="control-label" for="emailInput"><?php
echo xlt('Enter E-Mail Address')?
></label
>
246 <div
class="controls inline-inputs">
247 <input id
="emailInput" type
="email" class="form-control" style
="width: 100%" required
248 placeholder
="<?php echo xla('Must be current email address on file.'); ?>" maxlength
="100">
253 <button id
="submitRequest" class="btn btn-primary nextBtn btn-sm pull-right" type
="button"><?php
echo xlt('Verify') ?
></button
>
260 ?
> <!-- Main logon
-->
261 <div id
="wrapper" class="row centerwrapper text-center">
262 <img style
="width:65%" src
='<?php echo $GLOBALS['images_static_relative
']; ?>/login-logo.png'/>
263 <form
class="form-inline text-center" action
="get_patient_info.php" method
="POST" onsubmit
="return process()">
265 <div
class="col-sm-12 text-center">
267 <legend
class="bg-primary"><h3
><?php
echo xlt('Patient Portal Login'); ?
></h3
></legend
>
270 <div
class="col-sm-12">
271 <div
class="form-group inline">
272 <label
class="control-label" for="uname"><?php
echo xlt('Username')?
></label
>
273 <div
class="controls inline-inputs">
274 <input type
="text" class="form-control" name
="uname" id
="uname" type
="text" autocomplete
="on" required
>
277 <div
class="form-group inline">
278 <label
class="control-label" for="pass"><?php
echo xlt('Password')?
></label
>
279 <div
class="controls inline-inputs">
280 <input
class="form-control" name
="pass" id
="pass" type
="password" required autocomplete
="on">
286 <div
class="col-sm-12 form-group">
287 <label
class="control-label" for="passaddon"><?php
echo xlt('E-Mail Address')?
></label
>
288 <div
class="controls inline-inputs">
289 <input
class="form-control" style
="width: 100%" name
="passaddon" id
="passaddon" placeholder
="<?php echo xla('on file email'); ?>" type
="email" autocomplete
="on" />
293 <?php
if ($GLOBALS['language_menu_login']) { ?
>
294 <?php
if (count($result3) != 1) { ?
>
295 <div
class="form-group row">
296 <label
for="selLanguage"><?php
echo xlt('Language'); ?
></label
>
297 <select
class="form-control" id
="selLanguage" name
="languageChoice">
299 echo "<option selected='selected' value='" . htmlspecialchars($defaultLangID, ENT_QUOTES
) . "'>" .
300 htmlspecialchars(xl('Default') . " - " . xl($defaultLangName), ENT_NOQUOTES
) . "</option>\n";
301 foreach ($result3 as $iter) {
302 if ($GLOBALS['language_menu_showall']) {
303 if (! $GLOBALS['allow_debug_language'] && $iter['lang_description'] == 'dummy') {
304 continue; // skip the dummy language
306 echo "<option value='" . htmlspecialchars($iter['lang_id'], ENT_QUOTES
) . "'>" .
307 htmlspecialchars($iter['trans_lang_description'], ENT_NOQUOTES
) . "</option>\n";
309 if (in_array($iter['lang_description'], $GLOBALS['language_menu_show'])) {
310 if (! $GLOBALS['allow_debug_language'] && $iter['lang_description'] == 'dummy') {
311 continue; // skip the dummy language
313 echo "<option value='" . htmlspecialchars($iter['lang_id'], ENT_QUOTES
) . "'>" .
314 htmlspecialchars($iter['trans_lang_description'], ENT_NOQUOTES
) . "</option>\n";
323 <div
class="col-sm-12 col-md-12">
324 <?php
if ($GLOBALS['portal_onsite_two_register']) { ?
>
325 <button
class="btn btn-default pull-left" onclick
="location.replace('./account/register.php')"><?php
echo xlt('Register');?
></button
>
327 <?php
if ($GLOBALS['portal_two_pass_reset'] && isset($_GET['w']) && (isset($_GET['u']) ||
isset($_GET['p']))) { ?
>
328 <button
class="btn btn-danger" onclick
="location.replace('./index.php?requestNew=1')" style
="margin-left:10px"><?php
echo xlt('Reset Credentials');?
></button
>
330 <button
class="btn btn-success pull-right" type
="submit" ><?php
echo xlt('Log In');?
></button
>
335 <?php
if (!(empty($hiddenLanguageField))) {
336 echo $hiddenLanguageField; } ?
>
338 </div
><!-- div wrapper
-->
339 <?php
} ?
> <!-- logon wrapper
-->
340 </div
><!-- container
-->
342 <script type
="text/javascript">
343 $
(document
).ready(function() {
345 <?php
// if something went wrong
346 if (isset($_GET['requestNew'])) {
347 $_SESSION['patient_portal_onsite_two'] = true;
348 $_SESSION['authUser'] = 'portal-user';
349 $_SESSION['pid'] = true;
351 $
('.datepicker').datetimepicker({
352 <?php
$datetimepicker_timepicker = false; ?
>
353 <?php
$datetimepicker_showseconds = false; ?
>
354 <?php
$datetimepicker_formatInput = false; ?
>
355 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
357 $
(document
.body
).on('hidden.bs.modal', function () {
358 callServer('cleanup');
360 $
("#submitRequest").click(function () {
361 callServer('is_new', '');
364 <?php
if (isset($_GET['w'])) { ?
>
365 var unique_id
= $
.gritter
.add({
366 title
: '<span class="red"><?php echo xlt('Oops
!');?></span>',
367 text
: '<?php echo xlt('Something went wrong
. Please
try again
.'); ?>',
370 class_name
: 'my-nonsticky-class'
373 <?php
// if successfully logged out
374 if (isset($_GET['logout'])) { ?
>
375 var unique_id
= $
.gritter
.add({
376 title
: '<span class="green"><?php echo xlt('Success
');?></span>',
377 text
: '<?php echo xlt('You have been successfully logged out
.');?>',
380 class_name
: 'my-nonsticky-class'
387 $("#emailInput").val("me@me.com");
388 $("#fname").val("Jerry");
389 $("#lname").val("Padgett");
390 $("#dob").val("1919-03-03"); */
392 function callServer(action
, value
, value2
, last
, first
) {
396 'dob' : $
("#dob").val(),
397 'last' : $
("#lname").val(),
398 'first' : $
("#fname").val(),
399 'email' : $
("#emailInput").val()
401 if (action
== 'do_signup') {
407 else if (action
== 'notify_admin') {
414 else if (action
== 'cleanup') {
421 url
: './account/account.php',
423 }).done(function (rtn
) {
424 if (action
== "cleanup") {
425 window
.location
.href
= "./index.php" // Goto landing page.
427 else if (action
== "is_new") {
428 if (parseInt(rtn
) > 0) {
429 var yes
= confirm('<?php echo xls("Account is validated. Send new credentials?") ?>');
431 callServer('cleanup');
433 callServer('do_signup', parseInt(rtn
));
436 // After error alert app exit to landing page.
437 var message
= "<?php echo xls('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.'); ?>";
438 eModal
.alert(message
);
441 else if (action
== 'do_signup') {
443 var message
= "<?php echo xlt('Unable to either create credentials or send email.'); ?>";
447 //alert(rtn); // sync alert.. rtn holds username and password for testing.
448 var message
= "<?php echo xls(" 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
."); ?>"
449 eModal
.alert(message
); // This is an async call. The modal close event exits us to portal landing page after cleanup.
451 }).fail(function (err
) {
452 var message
= "<?php echo xls('Something went wrong.') ?>";