preparing for 5.0.1 release in several weeks (#1509)
[openemr.git] / portal / home.php
blob566441a5571d93f2eeaf34d63d75bc170a12f487
1 <?php
2 /**
4 * Copyright (C) 2016-2018 Jerry Padgett <sjpadgett@gmail.com>
6 * LICENSE: This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as
8 * published by the Free Software Foundation, either version 3 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 * @package OpenEMR
20 * @author Jerry Padgett <sjpadgett@gmail.com>
21 * @link http://www.open-emr.org
23 require_once("verify_session.php");
24 require_once("$srcdir/patient.inc");
25 require_once("lib/portal_mail.inc");
27 if ($_SESSION['register'] === true) {
28 session_destroy();
29 header('Location: '.$landingpage.'&w');
30 exit();
33 if (!isset($_SESSION['portal_init'])) {
34 $_SESSION['portal_init'] = true;
37 $whereto = 'profilepanel';
38 if (isset($_SESSION['whereto'])) {
39 $whereto = $_SESSION['whereto'];
42 $user = isset($_SESSION['sessionUser']) ? $_SESSION['sessionUser'] : 'portal user';
43 $result = getPatientData($pid);
45 $msgs = getPortalPatientNotes($_SESSION['portal_username']);
46 $msgcnt = count($msgs);
47 $newcnt = 0;
48 foreach ($msgs as $i) {
49 if ($i['message_status']=='New') {
50 $newcnt += 1;
54 require_once '_header.php';
55 echo "<script>var cpid='" . attr($pid) . "';var cuser='" . attr($user) . "';var webRoot='" . $GLOBALS['web_root'] . "';var ptName='" . attr($_SESSION['ptName']) . "';</script>";
57 <script type="text/javascript">
58 var webroot_url = webRoot;
60 $(document).ready(function () {
62 $("#profilereport").load("./get_profile.php", {'embeddedScreen': true}, function () {
63 $("table").addClass("table table-responsive");
64 $(".demographics td").removeClass("label");
65 $(".demographics td").addClass("bold");
66 $(".insurance table").addClass("table-sm table-striped");
67 $("#editDems").click(function () {
68 showProfileModal()
69 });
70 });
71 $("#reports").load("./report/portal_patient_report.php?pid='<?php echo attr($pid) ?>'", {'embeddedScreen': true}, function () {
72 <?php if ($GLOBALS['portal_two_payments']) { ?>
73 $("#payment").load("./portal_payment.php", {'embeddedScreen': true}, function () {});
74 <?php } ?>
75 });
76 $("#medicationlist").load("./get_medications.php", {'embeddedScreen': true}, function () {
77 $("#allergylist").load("./get_allergies.php", {'embeddedScreen': true}, function () {
78 $("#problemslist").load("./get_problems.php", {'embeddedScreen': true}, function () {
79 $("#amendmentslist").load("./get_amendments.php", {'embeddedScreen': true}, function () {
80 $("#labresults").load("./get_lab_results.php", {'embeddedScreen': true}, function () {
82 });
83 });
84 });
85 });
86 });
88 $('.sigPad').signaturePad({drawOnly: true});
89 $(".generateDoc_download").click(function () {
90 $("#doc_form").submit();
91 });
93 function showProfileModal() {
94 var title = '<?php echo xla('Demographics Legend Red: Charted Values. Blue: Patient Edits'); ?> ';
96 var params = {
97 buttons: [
98 {text: '<?php echo xla('Help'); ?>', close: false, style: 'info', id: 'formHelp'},
99 {text: '<?php echo xla('Cancel'); ?>', close: true, style: 'default'},
100 {text: '<?php echo xla('Revert Edits'); ?>', close: false, style: 'danger', id: 'replaceAllButton'},
101 {text: '<?php echo xla('Send for Review'); ?>',
102 close: false,
103 style: 'success',
104 id: 'donePatientButton'
106 onClosed: 'reload',
107 type: 'GET',
108 url: webRoot + '/portal/patient/patientdata?pid=' + cpid + '&user=' + cuser
110 dlgopen('','','modal-xl', 500, '', title, params);
113 function saveProfile() {
114 page.updateModel();
117 var gowhere = '#<?php echo $whereto?>';
118 $(gowhere).collapse('show');
120 var $doHides = $('#panelgroup');
121 $doHides.on('show.bs.collapse', '.collapse', function () {
122 $doHides.find('.collapse.in').collapse('hide');
124 //Enable sidebar toggle
125 $("[data-toggle='offcanvas']").click(function (e) {
126 e.preventDefault();
127 //If window is small enough, enable sidebar push menu
128 if ($(window).width() <= 992) {
129 $('.row-offcanvas').toggleClass('active');
130 $('.left-side').removeClass("collapse-left");
131 $(".right-side").removeClass("strech");
132 $('.row-offcanvas').toggleClass("relative");
133 } else {
134 //Else, enable content streching
135 $('.left-side').toggleClass("collapse-left");
136 $(".right-side").toggleClass("strech");
139 $(function () {
140 $('#popwait').hide();
141 $('#callccda').click(function () {
142 $('#popwait').show();
147 function editAppointment(mode,deid){
148 if(mode == 'add'){
149 var title = '<?php echo xla('Request New Appointment'); ?>';
150 var mdata = {pid:deid};
152 else{
153 var title = '<?php echo xla('Edit Appointment'); ?>';
154 var mdata = {eid:deid};
156 var params = {
157 dialogId: 'editpop',
158 buttons: [
159 { text: '<?php echo xla('Cancel'); ?>', close: true, style: 'default' }
160 //{ text: 'Print', close: false, style: 'success', click: showCustom }
162 type:'GET',
163 dataType: 'text',
164 url: './add_edit_event_user.php',
165 data: mdata
168 dlgopen('', 'apptModal', 610, 300, '', title, params);
172 </script>
173 <!-- Right side column. Contains content of the page -->
174 <aside class="right-side">
175 <!-- Main content -->
176 <section class="container-fluid content panel-group" id="panelgroup">
177 <div id="popwait" class="alert alert-warning" style="font-size:18px"><strong><?php echo xlt('Working!'); ?></strong> <?php echo xlt('Please wait...'); ?></div>
178 <div class="row collapse" id="lists">
179 <div class="col-sm-6">
180 <div class="panel panel-primary">
181 <header class="panel-heading"><?php echo xlt('Medications'); ?> </header>
182 <div id="medicationlist" class="panel-body"></div>
184 <div class="panel-footer"></div>
185 </div>
187 <div class="panel panel-primary">
188 <header class="panel-heading"><?php echo xlt('Medications Allergy List'); ?> </header>
189 <div id="allergylist" class="panel-body"></div>
191 <div class="panel-footer"></div>
192 </div>
193 </div><!-- /.col -->
194 <div class="col-sm-6">
195 <div class="panel panel-primary">
196 <header class="panel-heading"><?php echo xlt('Issues List'); ?></header>
197 <div id="problemslist" class="panel-body"></div>
199 <div class="panel-footer"></div>
200 </div>
201 <div class="panel panel-primary">
202 <header class="panel-heading"><?php echo xlt('Amendment List'); ?> </header>
203 <div id="amendmentslist" class="panel-body"></div>
205 <div class="panel-footer"></div>
206 </div>
207 </div><!-- /.col -->
208 <div class="col-sm-12">
209 <div class="panel panel-primary">
210 <header class="panel-heading"><?php echo xlt('Lab Results'); ?> </header>
211 <div id="labresults" class="panel-body"></div>
212 <div class="panel-footer"></div>
213 </div><!-- /.panel -->
214 </div><!-- /.col -->
216 </div><!-- /.lists -->
218 <div class="row">
219 <div class="col-sm-6">
220 <div class="panel panel-primary collapse" id="appointmentpanel">
221 <header class="panel-heading"><?php echo xlt('Appointments'); ?> </header>
222 <div id="appointmentslist" class="panel-body">
223 <?php
224 $query = "SELECT e.pc_eid, e.pc_aid, e.pc_title, e.pc_eventDate, " . "e.pc_startTime, e.pc_hometext, e.pc_apptstatus, u.fname, u.lname, u.mname, " .
225 "c.pc_catname " . "FROM openemr_postcalendar_events AS e, users AS u, " .
226 "openemr_postcalendar_categories AS c WHERE " . "e.pc_pid = ? AND e.pc_eventDate >= CURRENT_DATE AND " . "u.id = e.pc_aid AND e.pc_catid = c.pc_catid " . "ORDER BY e.pc_eventDate, e.pc_startTime";
228 $res = sqlStatement($query, array(
229 $pid
232 if (sqlNumRows($res) > 0) {
233 $count = 0;
234 echo '<table id="appttable" style="width:100%;background:#eee;" class="table table-striped fixedtable"><thead>
235 </thead><tbody>';
236 while ($row = sqlFetchArray($res)) {
237 $count++;
238 $dayname = xl(date("l", strtotime($row ['pc_eventDate'])));
239 $dispampm = "am";
240 $disphour = substr($row ['pc_startTime'], 0, 2) + 0;
241 $dispmin = substr($row ['pc_startTime'], 3, 2);
242 if ($disphour >= 12) {
243 $dispampm = "pm";
244 if ($disphour > 12) {
245 $disphour -= 12;
249 if ($row ['pc_hometext'] != "") {
250 $etitle = 'Comments' . ": " . $row ['pc_hometext'] . "\r\n";
251 } else {
252 $etitle = "";
255 echo "<tr><td><p>";
256 echo "<a href='#' onclick='editAppointment(0," . htmlspecialchars($row ['pc_eid'], ENT_QUOTES) . ')' . "' title='" . htmlspecialchars($etitle, ENT_QUOTES) . "'>";
257 echo "<b>" . htmlspecialchars($dayname . ", " . $row ['pc_eventDate'], ENT_NOQUOTES) . "</b><br>";
258 echo htmlspecialchars("$disphour:$dispmin " . $dispampm . " " . $row ['pc_catname'], ENT_NOQUOTES) . "<br>";
259 echo htmlspecialchars($row ['fname'] . " " . $row ['lname'], ENT_NOQUOTES) . "<br>";
260 echo htmlspecialchars("Status: " . $row ['pc_apptstatus'], ENT_NOQUOTES);
261 echo "</a></p></td></tr>";
264 if (isset($res) && $res != null) {
265 if ($count < 1) {
266 echo "&nbsp;&nbsp;" . xlt('None');
269 } else { // if no appts
270 echo xlt('No Appointments');
273 echo '</tbody></table>';
275 <div style='margin: 5px 0 5px'>
276 <a href='#' onclick="editAppointment('add',<?php echo attr($pid); ?>)">
277 <button class='btn btn-primary pull-right'><?php echo xlt('Schedule New Appointment'); ?></button>
278 </a>
279 </div>
280 </div>
281 <div class="panel-footer"></div>
282 </div><!-- /.panel -->
283 </div><!-- /.col -->
284 </div><!-- /.row -->
285 <?php if ($GLOBALS['portal_two_payments']) { ?>
286 <div class="row">
287 <div class="col-sm-12">
288 <div class="panel panel-primary collapse" id="paymentpanel">
289 <header class="panel-heading"> <?php echo xlt('Payments'); ?> </header>
290 <div id="payment" class="panel-body"></div>
291 <div class="panel-footer">
292 </div>
293 </div>
294 </div> <!--/.col -->
295 </div>
296 <?php } ?>
297 <div class="row">
298 <div class="col-sm-12">
299 <div class="panel panel-primary collapse" style="padding-top:0;padding-bottom:0;" id="messagespanel">
300 <!-- <header class="panel-heading"><?php //echo xlt('Secure Chat'); ?> </header>-->
301 <div id="messages" class="panel-body" style="height:calc(100vh - 120px);overflow:auto;padding:0 0 0 0;" >
302 <iframe src="./messaging/secure_chat.php" width="100%" height="100%"></iframe>
303 </div>
304 </div>
305 </div><!-- /.col -->
306 </div>
308 <div class="row">
309 <div class="col-sm-8">
310 <div class="panel panel-primary collapse" id="reportpanel">
311 <header class="panel-heading"><?php echo xlt('Reports'); ?> </header>
312 <div id="reports" class="panel-body"></div>
313 <div class="panel-footer"></div>
314 </div>
316 </div>
317 <!-- /.col -->
318 <div class="col-sm-6">
319 <div class="panel panel-primary collapse" id="downloadpanel">
320 <header class="panel-heading"> <?php echo xlt('Download Documents'); ?> </header>
321 <div id="docsdownload" class="panel-body">
322 <?php if ($GLOBALS['portal_onsite_document_download']) { ?>
323 <div>
324 <span class="text"><?php echo xlt('Download all patient documents');?></span>
325 <form name='doc_form' id='doc_form' action='./get_patient_documents.php' method='post'>
326 <input type="button" class="generateDoc_download" value="<?php echo xla('Download'); ?>" />
327 </form>
328 </div>
329 <?php } ?>
330 </div><!-- /.panel-body -->
331 <div class="panel-footer"></div>
332 </div>
333 </div><!-- /.col -->
334 </div>
336 <div class="row">
337 <div class="col-sm-12">
338 <div class="panel panel-primary collapse" id="ledgerpanel">
339 <header class="panel-heading"><?php echo xlt('Ledger');?> </header>
340 <div id="patledger" class="panel-body"></div>
341 <div class="panel-footer">
342 <iframe src="./report/pat_ledger.php?form=1&patient_id=<?php echo attr($pid);?>" width="100%" height="475" scrolling="yes"></iframe>
343 </div>
344 </div>
345 </div><!-- /.col -->
346 </div>
348 <div class="row">
349 <div class="col-sm-12">
350 <div class="panel panel-primary collapse" id="profilepanel">
351 <header class="panel-heading"><?php echo xlt('Profile'); ?></header>
352 <div id="profilereport" class="panel-body"></div>
353 <div class="panel-footer"></div>
354 </div>
355 </div>
356 </div>
358 </section>
359 <!-- /.content -->
360 <!--<div class="footer-main">Onsite Patient Portal Beta v3.0 Copyright &copy By sjpadgett@gmail.com, 2016 All Rights Reserved and Recorded</div>-->
361 </aside><!-- /.right-side -->
362 </div><!-- ./wrapper -->
363 <div id="openSignModal" class="modal fade" role="dialog">
364 <div class="modal-dialog modal-lg">
365 <div class="modal-content">
366 <div class="modal-header">
367 <button type="button" class="close" data-dismiss="modal">&times;</button>
368 <div class="input-group">
369 <span class="input-group-addon"
370 onclick="getSignature(document.getElementById('patientSignaturem'))"><em> <?php echo xlt('Show Current Signature On File'); ?>
371 <br>
372 <?php echo xlt('As appears on documents'); ?>.</em></span> <img
373 class="signature form-control" type="patient-signature"
374 id="patientSignaturem" onclick="getSignature(this)"
375 alt="Signature On File" src="">
376 </div>
377 </div>
378 <div class="modal-body">
379 <form name="signit" id="signit" class="sigPad">
380 <input type="hidden" name="name" id="name" class="name">
381 <ul class="sigNav">
382 <label style='display: none;'><input style='display: none;'
383 type="checkbox" class="" id="isAdmin" name="isAdmin" /><?php echo xlt('Is Authorizing Signature');?></label>
384 <li class="clearButton"><a href="#clear"><button><?php echo xlt('Clear Signature');?></button></a></li>
385 </ul>
386 <div class="sig sigWrapper">
387 <div class="typed"></div>
388 <canvas class="spad" id="drawpad" width="765" height="325"
389 style="border: 1px solid #000000; left: 0px;"></canvas>
390 <img id="loading"
391 style="display: none; position: absolute; TOP: 150px; LEFT: 315px; WIDTH: 100px; HEIGHT: 100px"
392 src="sign/assets/loading.gif" /> <input type="hidden" id="output"
393 name="output" class="output">
394 </div>
395 <input type="hidden" name="type" id="type"
396 value="patient-signature">
397 <button type="button" onclick="signDoc(this)"><?php echo xlt('Acknowledge as my Electronic Signature');?>.</button>
398 </form>
399 </div>
400 </div>
401 <!-- <div class="modal-footer">
402 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
403 </div> -->
404 </div>
405 </div><!-- Modal -->
406 <img id="waitend"
407 style="display: none; position: absolute; top: 100px; left: 260px; width: 100px; height: 100px"
408 src="sign/assets/loading.gif" />
411 </body>
412 </html>