Fixes and enhancements of the newcrop erx module.
[openemr.git] / interface / patient_file / summary / demographics.php
blob43996f0c4f27bc9674c76e7cb90dd694d5ef1e58
1 <?php
2 // This program is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU General Public License
4 // as published by the Free Software Foundation; either version 2
5 // of the License, or (at your option) any later version.
7 //SANITIZE ALL ESCAPES
8 $sanitize_all_escapes=true;
9 //
11 //STOP FAKE REGISTER GLOBALS
12 $fake_register_globals=false;
15 require_once("../../globals.php");
16 require_once("$srcdir/patient.inc");
17 require_once("$srcdir/acl.inc");
18 require_once("$srcdir/classes/Address.class.php");
19 require_once("$srcdir/classes/InsuranceCompany.class.php");
20 require_once("$srcdir/classes/Document.class.php");
21 require_once("$srcdir/options.inc.php");
22 require_once("../history/history.inc.php");
23 require_once("$srcdir/formatting.inc.php");
24 require_once("$srcdir/edi.inc");
25 require_once("$srcdir/clinical_rules.php");
27 if ($GLOBALS['concurrent_layout'] && isset($_GET['set_pid'])) {
28 include_once("$srcdir/pid.inc");
29 setpid($_GET['set_pid']);
32 $active_reminders = false;
33 if ((!isset($_SESSION['alert_notify_pid']) || ($_SESSION['alert_notify_pid'] != $pid)) && isset($_GET['set_pid']) && acl_check('patients', 'med') && $GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_crp']) {
34 // showing a new patient, so check for active reminders
35 $active_reminders = active_alert_summary($pid,"reminders-due");
38 function print_as_money($money) {
39 preg_match("/(\d*)\.?(\d*)/",$money,$moneymatches);
40 $tmp = wordwrap(strrev($moneymatches[1]),3,",",1);
41 $ccheck = strrev($tmp);
42 if ($ccheck[0] == ",") {
43 $tmp = substr($ccheck,1,strlen($ccheck)-1);
45 if ($moneymatches[2] != "") {
46 return "$ " . strrev($tmp) . "." . $moneymatches[2];
47 } else {
48 return "$ " . strrev($tmp);
52 // get an array from Photos category
53 function pic_array($pid,$picture_directory) {
54 $pics = array();
55 $sql_query = "select documents.id from documents join categories_to_documents " .
56 "on documents.id = categories_to_documents.document_id " .
57 "join categories on categories.id = categories_to_documents.category_id " .
58 "where categories.name like ? and documents.foreign_id = ?";
59 if ($query = sqlStatement($sql_query, array($picture_directory,$pid))) {
60 while( $results = sqlFetchArray($query) ) {
61 array_push($pics,$results['id']);
64 return ($pics);
66 // Get the document ID of the first document in a specific catg.
67 function get_document_by_catg($pid,$doc_catg) {
69 $result = array();
71 if ($pid and $doc_catg) {
72 $result = sqlQuery("SELECT d.id, d.date, d.url FROM " .
73 "documents AS d, categories_to_documents AS cd, categories AS c " .
74 "WHERE d.foreign_id = ? " .
75 "AND cd.document_id = d.id " .
76 "AND c.id = cd.category_id " .
77 "AND c.name LIKE ? " .
78 "ORDER BY d.date DESC LIMIT 1", array($pid, $doc_catg) );
81 return($result['id']);
84 // Display image in 'widget style'
85 function image_widget($doc_id,$doc_catg)
87 global $pid, $web_root;
88 $docobj = new Document($doc_id);
89 $image_file = $docobj->get_url_file();
90 $extension = substr($image_file, strrpos($image_file,"."));
91 $viewable_types = array('.png','.jpg','.jpeg','.png','.bmp'); // image ext supported by fancybox viewer
92 if ( in_array($extension,$viewable_types) ) { // extention matches list
93 $to_url = "<td> <a href = $web_root" .
94 "/controller.php?document&retrieve&patient_id=$pid&document_id=$doc_id" .
95 "/tmp$extension" . // Force image type URL for fancybox
96 " onclick=top.restoreSession(); class='image_modal'>" .
97 " <img src = $web_root" .
98 "/controller.php?document&retrieve&patient_id=$pid&document_id=$doc_id" .
99 " width=100 alt='$doc_catg:$image_file'> </a> </td> <td valign='center'>".
100 htmlspecialchars($doc_catg) . '<br />&nbsp;' . htmlspecialchars($image_file) .
101 "</td>";
103 else {
104 $to_url = "<td> <a href='" . $web_root . "/controller.php?document&retrieve" .
105 "&patient_id=$pid&document_id=$doc_id'" .
106 " onclick='top.restoreSession()' class='css_button_small'>" .
107 "<span>" .
108 htmlspecialchars( xl("View"), ENT_QUOTES )."</a> &nbsp;" .
109 htmlspecialchars( "$doc_catg - $image_file", ENT_QUOTES ) .
110 "</span> </td>";
112 echo "<table><tr>";
113 echo $to_url;
114 echo "</tr></table>";
117 // Determine if the Vitals form is in use for this site.
118 $tmp = sqlQuery("SELECT count(*) AS count FROM registry WHERE " .
119 "directory = 'vitals' AND state = 1");
120 $vitals_is_registered = $tmp['count'];
122 <html>
124 <head>
125 <?php html_header_show();?>
126 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
127 <link rel="stylesheet" type="text/css" href="../../../library/js/fancybox/jquery.fancybox-1.2.6.css" media="screen" />
128 <style type="text/css">@import url(../../../library/dynarch_calendar.css);</style>
129 <script type="text/javascript" src="../../../library/textformat.js"></script>
130 <script type="text/javascript" src="../../../library/dynarch_calendar.js"></script>
131 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
132 <script type="text/javascript" src="../../../library/dynarch_calendar_setup.js"></script>
133 <script type="text/javascript" src="../../../library/dialog.js"></script>
134 <script type="text/javascript" src="../../../library/js/jquery-1.6.4.min.js"></script>
135 <script type="text/javascript" src="../../../library/js/common.js"></script>
136 <script type="text/javascript" src="../../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
137 <script type="text/javascript" language="JavaScript">
138 //Visolve - sync the radio buttons - Start
139 if((top.window.parent) && (parent.window)){
140 var wname = top.window.parent.left_nav;
141 wname.syncRadios();
142 wname.setRadio(parent.window.name, "dem");
144 //Visolve - sync the radio buttons - End
146 var mypcc = '<?php echo htmlspecialchars($GLOBALS['phone_country_code'],ENT_QUOTES); ?>';
148 function oldEvt(eventid) {
149 dlgopen('../../main/calendar/add_edit_event.php?eid=' + eventid, '_blank', 550, 270);
152 function advdirconfigure() {
153 dlgopen('advancedirectives.php', '_blank', 500, 450);
156 function refreshme() {
157 top.restoreSession();
158 location.reload();
161 // Process click on Delete link.
162 function deleteme() {
163 dlgopen('../deleter.php?patient=<?php echo htmlspecialchars($pid,ENT_QUOTES); ?>', '_blank', 500, 450);
164 return false;
167 // Called by the deleteme.php window on a successful delete.
168 function imdeleted() {
169 <?php if ($GLOBALS['concurrent_layout']) { ?>
170 parent.left_nav.clearPatient();
171 <?php } else { ?>
172 top.restoreSession();
173 top.location.href = '../main/main_screen.php';
174 <?php } ?>
177 function validate() {
178 var f = document.forms[0];
179 <?php
180 if ($GLOBALS['athletic_team']) {
181 echo " if (f.form_userdate1.value != f.form_original_userdate1.value) {\n";
182 $irow = sqlQuery("SELECT id, title FROM lists WHERE " .
183 "pid = ? AND enddate IS NULL ORDER BY begdate DESC LIMIT 1", array($pid));
184 if (!empty($irow)) {
186 if (confirm('Do you wish to also set this new return date in the issue titled "<?php echo htmlspecialchars($irow['title'],ENT_QUOTES); ?>"?')) {
187 f.form_issue_id.value = '<?php echo htmlspecialchars($irow['id'],ENT_QUOTES); ?>';
188 } else {
189 alert('OK, you will need to manually update the return date in any affected issue(s).');
191 <?php } else { ?>
192 alert('You have changed the return date but there are no open issues. You probably need to create or modify one.');
193 <?php
194 } // end empty $irow
195 echo " }\n";
196 } // end athletic team
198 return true;
201 function newEvt() {
202 dlgopen('../../main/calendar/add_edit_event.php?patientid=<?php echo htmlspecialchars($pid,ENT_QUOTES); ?>', '_blank', 550, 270);
203 return false;
206 function sendimage(pid, what) {
207 // alert('Not yet implemented.'); return false;
208 dlgopen('../upload_dialog.php?patientid=' + pid + '&file=' + what,
209 '_blank', 500, 400);
210 return false;
213 </script>
215 <script type="text/javascript">
217 function toggleIndicator(target,div) {
219 $mode = $(target).find(".indicator").text();
220 if ( $mode == "<?php echo htmlspecialchars(xl('collapse'),ENT_QUOTES); ?>" ) {
221 $(target).find(".indicator").text( "<?php echo htmlspecialchars(xl('expand'),ENT_QUOTES); ?>" );
222 $("#"+div).hide();
223 $.post( "../../../library/ajax/user_settings.php", { target: div, mode: 0 });
224 } else {
225 $(target).find(".indicator").text( "<?php echo htmlspecialchars(xl('collapse'),ENT_QUOTES); ?>" );
226 $("#"+div).show();
227 $.post( "../../../library/ajax/user_settings.php", { target: div, mode: 1 });
231 $(document).ready(function(){
232 var msg_updation='';
233 <?php
234 if($GLOBALS['erx_enable']){
235 //$soap_status=sqlQuery("select soap_import_status from patient_data where pid=?",array($pid));
236 $soap_status=sqlStatement("select soap_import_status,pid from patient_data where pid=? and soap_import_status in ('1','3')",array($pid));
237 while($row_soapstatus=sqlFetchArray($soap_status)){
238 //if($soap_status['soap_import_status']=='1' || $soap_status['soap_import_status']=='3'){ ?>
239 top.restoreSession();
240 $.ajax({
241 type: "POST",
242 url: "../../soap_functions/soap_patientfullmedication.php",
243 dataType: "html",
244 data: {
245 patient:<?php echo $row_soapstatus['pid']; ?>,
247 async: false,
248 success: function(thedata){
249 //alert(thedata);
250 msg_updation+=thedata;
252 error:function(){
253 alert('ajax error');
256 <?php
257 //}
258 //elseif($soap_status['soap_import_status']=='3'){ ?>
259 top.restoreSession();
260 $.ajax({
261 type: "POST",
262 url: "../../soap_functions/soap_allergy.php",
263 dataType: "html",
264 data: {
265 patient:<?php echo $row_soapstatus['pid']; ?>,
267 async: false,
268 success: function(thedata){
269 //alert(thedata);
270 msg_updation+=thedata;
272 error:function(){
273 alert('ajax error');
276 <?php
277 if($GLOBALS['erx_import_status_message']){ ?>
278 if(msg_updation)
279 alert(msg_updation);
280 <?php
282 //}
286 // load divs
287 $("#stats_div").load("stats.php", { 'embeddedScreen' : true }, function() {
288 // (note need to place javascript code here also to get the dynamic link to work)
289 $(".rx_modal").fancybox( {
290 'overlayOpacity' : 0.0,
291 'showCloseButton' : true,
292 'frameHeight' : 500,
293 'frameWidth' : 800,
294 'centerOnScroll' : false,
295 'callbackOnClose' : function() {
296 refreshme();
300 $("#pnotes_ps_expand").load("pnotes_fragment.php");
301 $("#disclosures_ps_expand").load("disc_fragment.php");
303 <?php if ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_crw']) { ?>
304 top.restoreSession();
305 $("#clinical_reminders_ps_expand").load("clinical_reminders_fragment.php", { 'embeddedScreen' : true }, function() {
306 // (note need to place javascript code here also to get the dynamic link to work)
307 $(".medium_modal").fancybox( {
308 'overlayOpacity' : 0.0,
309 'showCloseButton' : true,
310 'frameHeight' : 500,
311 'frameWidth' : 800,
312 'centerOnScroll' : false,
313 'callbackOnClose' : function() {
314 refreshme();
318 <?php } // end crw?>
320 <?php if ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_prw']) { ?>
321 top.restoreSession();
322 $("#patient_reminders_ps_expand").load("patient_reminders_fragment.php");
323 <?php } // end prw?>
325 <?php if ($vitals_is_registered) { ?>
326 // Initialize the Vitals form if it is registered.
327 $("#vitals_ps_expand").load("vitals_fragment.php");
328 <?php } ?>
330 <?php
331 // Initialize for each applicable LBF form.
332 $gfres = sqlStatement("SELECT option_id FROM list_options WHERE " .
333 "list_id = 'lbfnames' AND option_value > 0 ORDER BY seq, title");
334 while($gfrow = sqlFetchArray($gfres)) {
336 $("#<?php echo $gfrow['option_id']; ?>_ps_expand").load("lbf_fragment.php?formname=<?php echo $gfrow['option_id']; ?>");
337 <?php
341 // fancy box
342 enable_modals();
344 tabbify();
346 // modal for dialog boxes
347 $(".large_modal").fancybox( {
348 'overlayOpacity' : 0.0,
349 'showCloseButton' : true,
350 'frameHeight' : 600,
351 'frameWidth' : 1000,
352 'centerOnScroll' : false
355 // modal for image viewer
356 $(".image_modal").fancybox( {
357 'overlayOpacity' : 0.0,
358 'showCloseButton' : true,
359 'centerOnScroll' : false,
360 'autoscale' : true
363 $(".iframe1").fancybox( {
364 'left':10,
365 'overlayOpacity' : 0.0,
366 'showCloseButton' : true,
367 'frameHeight' : 300,
368 'frameWidth' : 350
370 // special size for patient portal
371 $(".small_modal").fancybox( {
372 'overlayOpacity' : 0.0,
373 'showCloseButton' : true,
374 'frameHeight' : 180,
375 'frameWidth' : 380,
376 'centerOnScroll' : false
379 <?php if ($active_reminders) { ?>
380 // show the active reminder modal
381 $("#reminder_popup_link").fancybox({
382 'overlayOpacity' : 0.0,
383 'showCloseButton' : true,
384 'frameHeight' : 500,
385 'frameWidth' : 500,
386 'centerOnScroll' : false
387 }).trigger('click');
388 <?php } ?>
392 </script>
394 <style type="css/text">
395 #pnotes_ps_expand {
396 height:auto;
397 width:100%;
399 </style>
401 </head>
403 <body class="body_top">
405 <a href='../reminder/active_reminder_popup.php' id='reminder_popup_link' style='visibility: false;' class='iframe' onclick='top.restoreSession()'></a>
407 <?php
408 $result = getPatientData($pid, "*, DATE_FORMAT(DOB,'%Y-%m-%d') as DOB_YMD");
409 $result2 = getEmployerData($pid);
410 $result3 = getInsuranceData($pid, "primary", "copay, provider, DATE_FORMAT(`date`,'%Y-%m-%d') as effdate");
411 $insco_name = "";
413 if ($result3['provider']) { // Use provider in case there is an ins record w/ unassigned insco
414 $insco_name = getInsuranceProvider($result3['provider']);
417 $thisauth = acl_check('patients', 'demo');
418 if ($thisauth) {
419 if ($result['squad'] && ! acl_check('squads', $result['squad']))
420 $thisauth = 0;
423 if (!$thisauth) {
424 echo "<p>(" . htmlspecialchars(xl('Demographics not authorized'),ENT_NOQUOTES) . ")</p>\n";
425 echo "</body>\n</html>\n";
426 exit();
429 if ($thisauth == 'write') {
430 echo "<table><tr><td><span class='title'>" .
431 htmlspecialchars(getPatientName($pid),ENT_NOQUOTES) .
432 "</span></td>";
434 if (acl_check('admin', 'super')) {
435 echo "<td style='padding-left:1em;'><a class='css_button iframe' href='../deleter.php?patient=" .
436 htmlspecialchars($pid,ENT_QUOTES) . "'>" .
437 "<span>".htmlspecialchars(xl('Delete'),ENT_NOQUOTES).
438 "</span></a></td>";
440 if($GLOBALS['erx_enable']){
441 echo '<td style="padding-left:1em;"><a class="css_button" href="../../eRx.php?page=medentry" onclick="top.restoreSession()">';
442 echo "<span>".htmlspecialchars(xl('NewCrop MedEntry'),ENT_NOQUOTES)."</span></a></td>";
443 echo '<td style="padding-left:1em;"><a class="css_button iframe1" href="../../soap_functions/soap_accountStatusDetails.php" onclick="top.restoreSession()">';
444 echo "<span>".htmlspecialchars(xl('NewCrop Account Status'),ENT_NOQUOTES)."</span></a></td><td id='accountstatus'></td>";
446 //Patient Portal
447 $portalUserSetting = true; //flag to see if patient has authorized access to portal
448 if($GLOBALS['portal_onsite_enable'] && $GLOBALS['portal_onsite_address']){
449 $portalStatus = sqlQuery("SELECT allow_patient_portal FROM patient_data WHERE pid=?",array($pid));
450 if ($portalStatus['allow_patient_portal']=='YES') {
451 $portalLogin = sqlQuery("SELECT pid FROM `patient_access_onsite` WHERE `pid`=?", array($pid));
452 echo "<td style='padding-left:1em;'><a class='css_button iframe small_modal' href='create_portallogin.php?portalsite=on&patient=" . htmlspecialchars($pid,ENT_QUOTES) . "' onclick='top.restoreSession()'>";
453 if (empty($portalLogin)) {
454 echo "<span>".htmlspecialchars(xl('Create Onsite Portal Credentials'),ENT_NOQUOTES)."</span></a></td>";
456 else {
457 echo "<span>".htmlspecialchars(xl('Reset Onsite Portal Credentials'),ENT_NOQUOTES)."</span></a></td>";
460 else {
461 $portalUserSetting = false;
464 if($GLOBALS['portal_offsite_enable'] && $GLOBALS['portal_offsite_address']){
465 $portalStatus = sqlQuery("SELECT allow_patient_portal FROM patient_data WHERE pid=?",array($pid));
466 if ($portalStatus['allow_patient_portal']=='YES') {
467 $portalLogin = sqlQuery("SELECT pid FROM `patient_access_offsite` WHERE `pid`=?", array($pid));
468 echo "<td style='padding-left:1em;'><a class='css_button iframe small_modal' href='create_portallogin.php?portalsite=off&patient=" . htmlspecialchars($pid,ENT_QUOTES) . "' onclick='top.restoreSession()'>";
469 if (empty($portalLogin)) {
470 echo "<span>".htmlspecialchars(xl('Create Offsite Portal Credentials'),ENT_NOQUOTES)."</span></a></td>";
472 else {
473 echo "<span>".htmlspecialchars(xl('Reset Offsite Portal Credentials'),ENT_NOQUOTES)."</span></a></td>";
476 else {
477 $portalUserSetting = false;
480 if (!($portalUserSetting)) {
481 // Show that the patient has not authorized portal access
482 echo "<td style='padding-left:1em;'>" . htmlspecialchars( xl('Patient has not authorized the Patient Portal.'), ENT_NOQUOTES) . "</td>";
484 //Patient Portal
486 // If patient is deceased, then show this (along with the number of days patient has been deceased for)
487 $days_deceased = is_patient_deceased($pid);
488 if ($days_deceased) {
489 echo "<td style='padding-left:1em;font-weight:bold;color:red'>" . htmlspecialchars( xl('DECEASED') ,ENT_NOQUOTES) . " (" . htmlspecialchars($days_deceased,ENT_NOQUOTES) . " " . htmlspecialchars( xl('days ago') ,ENT_NOQUOTES) . ")</td>";
492 echo "</tr></table>";
495 // Get the document ID of the patient ID card if access to it is wanted here.
496 $idcard_doc_id = false;
497 if ($GLOBALS['patient_id_category_name']) {
498 $idcard_doc_id = get_document_by_catg($pid, $GLOBALS['patient_id_category_name']);
502 <table cellspacing='0' cellpadding='0' border='0'>
503 <tr>
504 <td class="small" colspan='4'>
505 <a href="../history/history.php" onclick='top.restoreSession()'>
506 <?php echo htmlspecialchars(xl('History'),ENT_NOQUOTES); ?></a>
508 <?php //note that we have temporarily removed report screen from the modal view ?>
509 <a href="../report/patient_report.php" onclick='top.restoreSession()'>
510 <?php echo htmlspecialchars(xl('Report'),ENT_NOQUOTES); ?></a>
512 <?php //note that we have temporarily removed document screen from the modal view ?>
513 <a href="../../../controller.php?document&list&patient_id=<?php echo $pid;?>" onclick='top.restoreSession()'>
514 <?php echo htmlspecialchars(xl('Documents'),ENT_NOQUOTES); ?></a>
516 <a href="../transaction/transactions.php" class='iframe large_modal' onclick='top.restoreSession()'>
517 <?php echo htmlspecialchars(xl('Transactions'),ENT_NOQUOTES); ?></a>
519 <a href="stats_full.php?active=all" onclick='top.restoreSession()'>
520 <?php echo htmlspecialchars(xl('Issues'),ENT_NOQUOTES); ?></a>
521 </td>
522 </tr>
523 </table> <!-- end header -->
525 <div style='margin-top:10px'> <!-- start main content div -->
526 <table border="0" cellspacing="0" cellpadding="0" width="100%">
527 <tr>
528 <td align="left" valign="top">
529 <!-- start left column div -->
530 <div style='float:left; margin-right:20px'>
531 <table cellspacing=0 cellpadding=0>
532 <tr<?php if ($GLOBALS['athletic_team']) echo " style='display:none;'"; ?>>
533 <td>
534 <?php
535 // Billing expand collapse widget
536 $widgetTitle = xl("Billing");
537 $widgetLabel = "billing";
538 $widgetButtonLabel = xl("Edit");
539 $widgetButtonLink = "return newEvt();";
540 $widgetButtonClass = "";
541 $linkMethod = "javascript";
542 $bodyClass = "notab";
543 $widgetAuth = false;
544 $fixedWidth = true;
545 if ($GLOBALS['force_billing_widget_open']) {
546 $forceExpandAlways = true;
548 else {
549 $forceExpandAlways = false;
551 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
552 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
553 $widgetAuth, $fixedWidth, $forceExpandAlways);
555 <br>
556 <?php
557 if ($GLOBALS['oer_config']['ws_accounting']['enabled']) {
558 // Show current balance and billing note, if any.
559 echo " <div style='margin-left: 10px; margin-right: 10px'>" .
560 "<span class='bold'><font color='#ee6600'>" .
561 htmlspecialchars(xl('Balance Due'),ENT_NOQUOTES) .
562 ": " . htmlspecialchars(oeFormatMoney(get_patient_balance($pid)),ENT_NOQUOTES) .
563 "</font></span><br>";
564 if ($result['genericname2'] == 'Billing') {
565 echo "<span class='bold'><font color='red'>" .
566 htmlspecialchars(xl('Billing Note'),ENT_NOQUOTES) . ":" .
567 htmlspecialchars($result['genericval2'],ENT_NOQUOTES) .
568 "</font></span><br>";
570 if ($result3['provider']) { // Use provider in case there is an ins record w/ unassigned insco
571 echo "<span class='bold'>" .
572 htmlspecialchars(xl('Primary Insurance'),ENT_NOQUOTES) . ': ' . htmlspecialchars($insco_name,ENT_NOQUOTES) .
573 "</span>&nbsp;&nbsp;&nbsp;";
574 if ($result3['copay'] > 0) {
575 echo "<span class='bold'>" .
576 htmlspecialchars(xl('Copay'),ENT_NOQUOTES) . ': ' . htmlspecialchars($result3['copay'],ENT_NOQUOTES) .
577 "</span>&nbsp;&nbsp;&nbsp;";
579 echo "<span class='bold'>" .
580 htmlspecialchars(xl('Effective Date'),ENT_NOQUOTES) . ': ' . htmlspecialchars(oeFormatShortDate($result3['effdate'],ENT_NOQUOTES)) .
581 "</span>";
583 echo "</div><br>";
586 </div> <!-- required for expand_collapse_widget -->
587 </td>
588 </tr>
589 <tr>
590 <td>
591 <?php
592 // Demographics expand collapse widget
593 $widgetTitle = xl("Demographics");
594 $widgetLabel = "demographics";
595 $widgetButtonLabel = xl("Edit");
596 $widgetButtonLink = "demographics_full.php";
597 $widgetButtonClass = "";
598 $linkMethod = "html";
599 $bodyClass = "";
600 $widgetAuth = ($thisauth == "write");
601 $fixedWidth = true;
602 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
603 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
604 $widgetAuth, $fixedWidth);
606 <div id="DEM" >
607 <ul class="tabNav">
608 <?php display_layout_tabs('DEM', $result, $result2); ?>
609 </ul>
610 <div class="tabContainer">
611 <?php display_layout_tabs_data('DEM', $result, $result2); ?>
612 </div>
613 </div>
614 </div> <!-- required for expand_collapse_widget -->
615 </td>
616 </tr>
618 <tr>
619 <td>
620 <?php
621 $insurance_count = 0;
622 foreach (array('primary','secondary','tertiary') as $instype) {
623 $enddate = 'Present';
624 $query = "SELECT * FROM insurance_data WHERE " .
625 "pid = ? AND type = ? " .
626 "ORDER BY date DESC";
627 $res = sqlStatement($query, array($pid, $instype) );
628 while( $row = sqlFetchArray($res) ) {
629 if ($row['provider'] ) $insurance_count++;
633 if ( $insurance_count > 0 ) {
634 // Insurance expand collapse widget
635 $widgetTitle = xl("Insurance");
636 $widgetLabel = "insurance";
637 $widgetButtonLabel = xl("Edit");
638 $widgetButtonLink = "demographics_full.php";
639 $widgetButtonClass = "";
640 $linkMethod = "html";
641 $bodyClass = "";
642 $widgetAuth = ($thisauth == "write");
643 $fixedWidth = true;
644 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
645 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
646 $widgetAuth, $fixedWidth);
648 if ( $insurance_count > 0 ) {
651 <ul class="tabNav"><?php
652 ///////////////////////////////// INSURANCE SECTION
653 $first = true;
654 foreach (array('primary','secondary','tertiary') as $instype) {
656 $query = "SELECT * FROM insurance_data WHERE " .
657 "pid = ? AND type = ? " .
658 "ORDER BY date DESC";
659 $res = sqlStatement($query, array($pid, $instype) );
661 $enddate = 'Present';
663 while( $row = sqlFetchArray($res) ) {
664 if ($row['provider'] ) {
666 $ins_description = ucfirst($instype);
667 $ins_description = xl($ins_description);
668 $ins_description .= strcmp($enddate, 'Present') != 0 ? " (".xl('Old').")" : "";
670 <li <?php echo $first ? 'class="current"' : '' ?>><a href="/play/javascript-tabbed-navigation/">
671 <?php echo htmlspecialchars($ins_description,ENT_NOQUOTES); ?></a></li>
672 <?php
673 $first = false;
675 $enddate = $row['date'];
678 // Display the eligibility tab
679 echo "<li><a href='/play/javascript-tabbed-navigation/'>" .
680 htmlspecialchars( xl('Eligibility'), ENT_NOQUOTES) . "</a></li>";
682 ?></ul><?php
684 } ?>
686 <div class="tabContainer">
687 <?php
688 $first = true;
689 foreach (array('primary','secondary','tertiary') as $instype) {
690 $enddate = 'Present';
692 $query = "SELECT * FROM insurance_data WHERE " .
693 "pid = ? AND type = ? " .
694 "ORDER BY date DESC";
695 $res = sqlStatement($query, array($pid, $instype) );
696 while( $row = sqlFetchArray($res) ) {
697 if ($row['provider'] ) {
699 <div class="tab <?php echo $first ? 'current' : '' ?>">
700 <table border='0' cellpadding='0' width='100%'>
701 <?php
702 $icobj = new InsuranceCompany($row['provider']);
703 $adobj = $icobj->get_address();
704 $insco_name = trim($icobj->get_name());
706 <tr>
707 <td valign='top' colspan='3'>
708 <span class='text'>
709 <?php if (strcmp($enddate, 'Present') != 0) echo htmlspecialchars(xl("Old"),ENT_NOQUOTES)." "; ?>
710 <?php $tempinstype=ucfirst($instype); echo htmlspecialchars(xl($tempinstype.' Insurance'),ENT_NOQUOTES); ?>
711 <?php if (strcmp($row['date'], '0000-00-00') != 0) { ?>
712 <?php echo htmlspecialchars(xl('from','',' ',' ').$row['date'],ENT_NOQUOTES); ?>
713 <?php } ?>
714 <?php echo htmlspecialchars(xl('until','',' ',' '),ENT_NOQUOTES);
715 echo (strcmp($enddate, 'Present') != 0) ? $enddate : htmlspecialchars(xl('Present'),ENT_NOQUOTES); ?>:</span>
716 </td>
717 </tr>
718 <tr>
719 <td valign='top'>
720 <span class='text'>
721 <?php
722 if ($insco_name) {
723 echo htmlspecialchars($insco_name,ENT_NOQUOTES) . '<br>';
724 if (trim($adobj->get_line1())) {
725 echo htmlspecialchars($adobj->get_line1(),ENT_NOQUOTES) . '<br>';
726 echo htmlspecialchars($adobj->get_city() . ', ' . $adobj->get_state() . ' ' . $adobj->get_zip(),ENT_NOQUOTES);
728 } else {
729 echo "<font color='red'><b>".htmlspecialchars(xl('Unassigned'),ENT_NOQUOTES)."</b></font>";
732 <br>
733 <?php echo htmlspecialchars(xl('Policy Number'),ENT_NOQUOTES); ?>:
734 <?php echo htmlspecialchars($row['policy_number'],ENT_NOQUOTES) ?><br>
735 <?php echo htmlspecialchars(xl('Plan Name'),ENT_NOQUOTES); ?>:
736 <?php echo htmlspecialchars($row['plan_name'],ENT_NOQUOTES); ?><br>
737 <?php echo htmlspecialchars(xl('Group Number'),ENT_NOQUOTES); ?>:
738 <?php echo htmlspecialchars($row['group_number'],ENT_NOQUOTES); ?></span>
739 </td>
740 <td valign='top'>
741 <span class='bold'><?php echo htmlspecialchars(xl('Subscriber'),ENT_NOQUOTES); ?>: </span><br>
742 <span class='text'><?php echo htmlspecialchars($row['subscriber_fname'] . ' ' . $row['subscriber_mname'] . ' ' . $row['subscriber_lname'],ENT_NOQUOTES); ?>
743 <?php
744 if ($row['subscriber_relationship'] != "") {
745 echo "(" . htmlspecialchars($row['subscriber_relationship'],ENT_NOQUOTES) . ")";
748 <br>
749 <?php echo htmlspecialchars(xl('S.S.'),ENT_NOQUOTES); ?>:
750 <?php echo htmlspecialchars($row['subscriber_ss'],ENT_NOQUOTES); ?><br>
751 <?php echo htmlspecialchars(xl('D.O.B.'),ENT_NOQUOTES); ?>:
752 <?php if ($row['subscriber_DOB'] != "0000-00-00 00:00:00") echo htmlspecialchars($row['subscriber_DOB'],ENT_NOQUOTES); ?><br>
753 <?php echo htmlspecialchars(xl('Phone'),ENT_NOQUOTES); ?>:
754 <?php echo htmlspecialchars($row['subscriber_phone'],ENT_NOQUOTES); ?>
755 </span>
756 </td>
757 <td valign='top'>
758 <span class='bold'><?php echo htmlspecialchars(xl('Subscriber Address'),ENT_NOQUOTES); ?>: </span><br>
759 <span class='text'><?php echo htmlspecialchars($row['subscriber_street'],ENT_NOQUOTES); ?><br>
760 <?php echo htmlspecialchars($row['subscriber_city'],ENT_NOQUOTES); ?>
761 <?php if($row['subscriber_state'] != "") echo ", "; echo htmlspecialchars($row['subscriber_state'],ENT_NOQUOTES); ?>
762 <?php if($row['subscriber_country'] != "") echo ", "; echo htmlspecialchars($row['subscriber_country'],ENT_NOQUOTES); ?>
763 <?php echo " " . htmlspecialchars($row['subscriber_postal_code'],ENT_NOQUOTES); ?></span>
765 <?php if (trim($row['subscriber_employer'])) { ?>
766 <br><span class='bold'><?php echo htmlspecialchars(xl('Subscriber Employer'),ENT_NOQUOTES); ?>: </span><br>
767 <span class='text'><?php echo htmlspecialchars($row['subscriber_employer'],ENT_NOQUOTES); ?><br>
768 <?php echo htmlspecialchars($row['subscriber_employer_street'],ENT_NOQUOTES); ?><br>
769 <?php echo htmlspecialchars($row['subscriber_employer_city'],ENT_NOQUOTES); ?>
770 <?php if($row['subscriber_employer_city'] != "") echo ", "; echo htmlspecialchars($row['subscriber_employer_state'],ENT_NOQUOTES); ?>
771 <?php if($row['subscriber_employer_country'] != "") echo ", "; echo htmlspecialchars($row['subscriber_employer_country'],ENT_NOQUOTES); ?>
772 <?php echo " " . htmlspecialchars($row['subscriber_employer_postal_code'],ENT_NOQUOTES); ?>
773 </span>
774 <?php } ?>
776 </td>
777 </tr>
778 <tr>
779 <td>
780 <?php if ($row['copay'] != "") { ?>
781 <span class='bold'><?php echo htmlspecialchars(xl('CoPay'),ENT_NOQUOTES); ?>: </span>
782 <span class='text'><?php echo htmlspecialchars($row['copay'],ENT_NOQUOTES); ?></span>
783 <?php } ?>
784 <br>
785 <span class='bold'><?php echo htmlspecialchars(xl('Accept Assignment'),ENT_NOQUOTES); ?>:</span>
786 <span class='text'><?php if($row['accept_assignment'] == "TRUE") echo xl("YES"); ?>
787 <?php if($row['accept_assignment'] == "FALSE") echo xl("NO"); ?></span>
788 </td>
789 <td valign='top'></td>
790 <td valign='top'></td>
791 </tr>
793 </table>
794 </div>
795 <?php
797 } // end if ($row['provider'])
798 $enddate = $row['date'];
799 $first = false;
800 } // end while
801 } // end foreach
803 // Display the eligibility information
804 echo "<div class='tab'>";
805 show_eligibility_information($pid,true);
806 echo "</div>";
808 ///////////////////////////////// END INSURANCE SECTION
810 </div>
812 <?php } // ?>
814 </td>
815 </tr>
817 <tr>
818 <td width='650px'>
820 <?php
821 // Notes expand collapse widget
822 $widgetTitle = xl("Notes");
823 $widgetLabel = "pnotes";
824 $widgetButtonLabel = xl("Edit");
825 $widgetButtonLink = "pnotes_full.php";
826 $widgetButtonClass = "";
827 $linkMethod = "html";
828 $bodyClass = "notab";
829 $widgetAuth = true;
830 $fixedWidth = true;
831 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
832 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
833 $widgetAuth, $fixedWidth);
836 <br/>
837 <div style='margin-left:10px' class='text'><img src='../../pic/ajax-loader.gif'/></div><br/>
838 </div>
839 </td>
840 </tr>
841 <?php if ( (acl_check('patients', 'med')) && ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_prw']) ) {
842 echo "<tr><td width='650px'>";
843 // patient reminders collapse widget
844 $widgetTitle = xl("Patient Reminders");
845 $widgetLabel = "patient_reminders";
846 $widgetButtonLabel = xl("Edit");
847 $widgetButtonLink = "../reminder/patient_reminders.php?mode=simple&patient_id=".$pid;
848 $widgetButtonClass = "";
849 $linkMethod = "html";
850 $bodyClass = "notab";
851 $widgetAuth = true;
852 $fixedWidth = true;
853 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth); ?>
854 <br/>
855 <div style='margin-left:10px' class='text'><image src='../../pic/ajax-loader.gif'/></div><br/>
856 </div>
857 </td>
858 </tr>
859 <?php } //end if prw is activated ?>
861 <tr>
862 <td width='650px'>
863 <?php
864 // disclosures expand collapse widget
865 $widgetTitle = xl("Disclosures");
866 $widgetLabel = "disclosures";
867 $widgetButtonLabel = xl("Edit");
868 $widgetButtonLink = "disclosure_full.php";
869 $widgetButtonClass = "";
870 $linkMethod = "html";
871 $bodyClass = "notab";
872 $widgetAuth = true;
873 $fixedWidth = true;
874 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
875 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
876 $widgetAuth, $fixedWidth);
878 <br/>
879 <div style='margin-left:10px' class='text'><img src='../../pic/ajax-loader.gif'/></div><br/>
880 </div>
881 </td>
882 </tr>
884 <?php if ($vitals_is_registered) { ?>
885 <tr>
886 <td width='650px'>
887 <?php // vitals expand collapse widget
888 $widgetTitle = xl("Vitals");
889 $widgetLabel = "vitals";
890 $widgetButtonLabel = xl("Trend");
891 $widgetButtonLink = "../encounter/trend_form.php?formname=vitals";
892 $widgetButtonClass = "";
893 $linkMethod = "html";
894 $bodyClass = "notab";
895 // check to see if any vitals exist
896 $existVitals = sqlQuery("SELECT * FROM form_vitals WHERE pid=?", array($pid) );
897 if ($existVitals) {
898 $widgetAuth = true;
900 else {
901 $widgetAuth = false;
903 $fixedWidth = true;
904 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
905 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
906 $widgetAuth, $fixedWidth);
908 <br/>
909 <div style='margin-left:10px' class='text'><img src='../../pic/ajax-loader.gif'/></div><br/>
910 </div>
911 </td>
912 </tr>
913 <?php } // end if ($vitals_is_registered) ?>
915 <?php
916 // This generates a section similar to Vitals for each LBF form that
917 // supports charting. The form ID is used as the "widget label".
919 $gfres = sqlStatement("SELECT option_id, title FROM list_options WHERE " .
920 "list_id = 'lbfnames' AND option_value > 0 ORDER BY seq, title");
921 while($gfrow = sqlFetchArray($gfres)) {
923 <tr>
924 <td width='650px'>
925 <?php // vitals expand collapse widget
926 $vitals_form_id = $gfrow['option_id'];
927 $widgetTitle = $gfrow['title'];
928 $widgetLabel = $vitals_form_id;
929 $widgetButtonLabel = xl("Trend");
930 $widgetButtonLink = "../encounter/trend_form.php?formname=$vitals_form_id";
931 $widgetButtonClass = "";
932 $linkMethod = "html";
933 $bodyClass = "notab";
934 // check to see if any instances exist for this patient
935 $existVitals = sqlQuery(
936 "SELECT * FROM forms WHERE pid = ? AND formdir = ? AND deleted = 0",
937 array($pid, $vitals_form_id));
938 $widgetAuth = $existVitals ? true : false;
939 $fixedWidth = true;
940 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
941 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
942 $widgetAuth, $fixedWidth);
944 <br/>
945 <div style='margin-left:10px' class='text'>
946 <image src='../../pic/ajax-loader.gif'/>
947 </div>
948 <br/>
949 </div> <!-- This is required by expand_collapse_widget(). -->
950 </td>
951 </tr>
952 <?php
953 } // end while
956 </table>
958 </div>
959 <!-- end left column div -->
961 <!-- start right column div -->
962 <div>
963 <table>
964 <tr>
965 <td>
967 <div>
968 <?php
970 // If there is an ID Card or any Photos show the widget
971 $photos = pic_array($pid, $GLOBALS['patient_photo_category_name']);
972 if ($photos or $idcard_doc_id )
974 $widgetTitle = xl("ID Card") . '/' . xl("Photos");
975 $widgetLabel = "photos";
976 $linkMethod = "javascript";
977 $bodyClass = "notab-right";
978 $widgetAuth = false;
979 $fixedWidth = false;
980 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel ,
981 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
982 $widgetAuth, $fixedWidth);
984 <br />
985 <?php
986 if ($idcard_doc_id) {
987 image_widget($idcard_doc_id, $GLOBALS['patient_id_category_name']);
990 foreach ($photos as $photo_doc_id) {
991 image_widget($photo_doc_id, $GLOBALS['patient_photo_category_name']);
996 <br />
997 </div>
998 <div>
999 <?php
1000 // Advance Directives
1001 if ($GLOBALS['advance_directives_warning']) {
1002 // advance directives expand collapse widget
1003 $widgetTitle = xl("Advance Directives");
1004 $widgetLabel = "directives";
1005 $widgetButtonLabel = xl("Edit");
1006 $widgetButtonLink = "return advdirconfigure();";
1007 $widgetButtonClass = "";
1008 $linkMethod = "javascript";
1009 $bodyClass = "summary_item small";
1010 $widgetAuth = true;
1011 $fixedWidth = false;
1012 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1013 $counterFlag = false; //flag to record whether any categories contain ad records
1014 $query = "SELECT id FROM categories WHERE name='Advance Directive'";
1015 $myrow2 = sqlQuery($query);
1016 if ($myrow2) {
1017 $parentId = $myrow2['id'];
1018 $query = "SELECT id, name FROM categories WHERE parent=?";
1019 $resNew1 = sqlStatement($query, array($parentId) );
1020 while ($myrows3 = sqlFetchArray($resNew1)) {
1021 $categoryId = $myrows3['id'];
1022 $nameDoc = $myrows3['name'];
1023 $query = "SELECT documents.date, documents.id " .
1024 "FROM documents " .
1025 "INNER JOIN categories_to_documents " .
1026 "ON categories_to_documents.document_id=documents.id " .
1027 "WHERE categories_to_documents.category_id=? " .
1028 "AND documents.foreign_id=? " .
1029 "ORDER BY documents.date DESC";
1030 $resNew2 = sqlStatement($query, array($categoryId, $pid) );
1031 $limitCounter = 0; // limit to one entry per category
1032 while (($myrows4 = sqlFetchArray($resNew2)) && ($limitCounter == 0)) {
1033 $dateTimeDoc = $myrows4['date'];
1034 // remove time from datetime stamp
1035 $tempParse = explode(" ",$dateTimeDoc);
1036 $dateDoc = $tempParse[0];
1037 $idDoc = $myrows4['id'];
1038 echo "<a href='$web_root/controller.php?document&retrieve&patient_id=" .
1039 htmlspecialchars($pid,ENT_QUOTES) . "&document_id=" .
1040 htmlspecialchars($idDoc,ENT_QUOTES) . "&as_file=true'>" .
1041 htmlspecialchars(xl_document_category($nameDoc),ENT_NOQUOTES) . "</a> " .
1042 htmlspecialchars($dateDoc,ENT_NOQUOTES);
1043 echo "<br>";
1044 $limitCounter = $limitCounter + 1;
1045 $counterFlag = true;
1049 if (!$counterFlag) {
1050 echo "&nbsp;&nbsp;" . htmlspecialchars(xl('None'),ENT_NOQUOTES);
1051 } ?>
1052 </div>
1053 <?php } // close advanced dir block
1055 // This is a feature for a specific client. -- Rod
1056 if ($GLOBALS['cene_specific']) {
1057 echo " <br />\n";
1059 $imagedir = $GLOBALS['OE_SITE_DIR'] . "/documents/$pid/demographics";
1060 $imagepath = "$web_root/sites/" . $_SESSION['site_id'] . "/documents/$pid/demographics";
1062 echo " <a href='' onclick=\"return sendimage($pid, 'photo');\" " .
1063 "title='Click to attach patient image'>\n";
1064 if (is_file("$imagedir/photo.jpg")) {
1065 echo " <img src='$imagepath/photo.jpg' /></a>\n";
1066 } else {
1067 echo " Attach Patient Image</a><br />\n";
1069 echo " <br />&nbsp;<br />\n";
1071 echo " <a href='' onclick=\"return sendimage($pid, 'fingerprint');\" " .
1072 "title='Click to attach fingerprint'>\n";
1073 if (is_file("$imagedir/fingerprint.jpg")) {
1074 echo " <img src='$imagepath/fingerprint.jpg' /></a>\n";
1075 } else {
1076 echo " Attach Biometric Fingerprint</a><br />\n";
1078 echo " <br />&nbsp;<br />\n";
1081 // This stuff only applies to athletic team use of OpenEMR. The client
1082 // insisted on being able to quickly change fitness and return date here:
1084 if (false && $GLOBALS['athletic_team']) {
1085 // blue green yellow red orange
1086 $fitcolors = array('#6677ff','#00cc00','#ffff00','#ff3333','#ff8800','#ffeecc','#ffccaa');
1087 if (!empty($GLOBALS['fitness_colors'])) $fitcolors = $GLOBALS['fitness_colors'];
1088 $fitcolor = $fitcolors[0];
1089 $form_fitness = $_POST['form_fitness'];
1090 $form_userdate1 = fixDate($_POST['form_userdate1'], '');
1091 $form_issue_id = $_POST['form_issue_id'];
1092 if ($form_submit) {
1093 $returndate = $form_userdate1 ? "'$form_userdate1'" : "NULL";
1094 sqlStatement("UPDATE patient_data SET fitness = ?, " .
1095 "userdate1 = ? WHERE pid = ?", array($form_fitness, $returndate, $pid) );
1096 // Update return date in the designated issue, if requested.
1097 if ($form_issue_id) {
1098 sqlStatement("UPDATE lists SET returndate = ? WHERE " .
1099 "id = ?", array($returndate, $form_issue_id) );
1101 } else {
1102 $form_fitness = $result['fitness'];
1103 if (! $form_fitness) $form_fitness = 1;
1104 $form_userdate1 = $result['userdate1'];
1106 $fitcolor = $fitcolors[$form_fitness - 1];
1107 echo " <form method='post' action='demographics.php' onsubmit='return validate()'>\n";
1108 echo " <span class='bold'>Fitness to Play:</span><br />\n";
1109 echo " <select name='form_fitness' style='background-color:$fitcolor'>\n";
1110 $res = sqlStatement("SELECT * FROM list_options WHERE " .
1111 "list_id = 'fitness' ORDER BY seq");
1112 while ($row = sqlFetchArray($res)) {
1113 $key = $row['option_id'];
1114 echo " <option value='" . htmlspecialchars($key,ENT_QUOTES) . "'";
1115 if ($key == $form_fitness) echo " selected";
1116 echo ">" . htmlspecialchars($row['title'],ENT_NOQUOTES) . "</option>\n";
1118 echo " </select>\n";
1119 echo " <br /><span class='bold'>Return to Play:</span><br>\n";
1120 echo " <input type='text' size='10' name='form_userdate1' id='form_userdate1' " .
1121 "value='$form_userdate1' " .
1122 "title='" . htmlspecialchars(xl('yyyy-mm-dd Date of return to play'),ENT_QUOTES) . "' " .
1123 "onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' />\n" .
1124 " <img src='../../pic/show_calendar.gif' align='absbottom' width='24' height='22' " .
1125 "id='img_userdate1' border='0' alt='[?]' style='cursor:pointer' " .
1126 "title='" . htmlspecialchars(xl('Click here to choose a date'),ENT_QUOTES) . "'>\n";
1127 echo " <input type='hidden' name='form_original_userdate1' value='" . htmlspecialchars($form_userdate1,ENT_QUOTES) . "' />\n";
1128 echo " <input type='hidden' name='form_issue_id' value='' />\n";
1129 echo "<p><input type='submit' name='form_submit' value='Change' /></p>\n";
1130 echo " </form>\n";
1133 // Show current and upcoming appointments.
1134 if (isset($pid) && !$GLOBALS['disable_calendar']) {
1135 $query = "SELECT e.pc_eid, e.pc_aid, e.pc_title, e.pc_eventDate, " .
1136 "e.pc_startTime, e.pc_hometext, u.fname, u.lname, u.mname, " .
1137 "c.pc_catname " .
1138 "FROM openemr_postcalendar_events AS e, users AS u, " .
1139 "openemr_postcalendar_categories AS c WHERE " .
1140 "e.pc_pid = ? AND e.pc_eventDate >= CURRENT_DATE AND " .
1141 "u.id = e.pc_aid AND e.pc_catid = c.pc_catid " .
1142 "ORDER BY e.pc_eventDate, e.pc_startTime";
1143 $res = sqlStatement($query, array($pid) );
1145 if ( (acl_check('patients', 'med')) && ($GLOBALS['enable_cdr'] && $GLOBALS['enable_cdr_crw']) ) {
1146 // clinical summary expand collapse widget
1147 $widgetTitle = xl("Clinical Reminders");
1148 $widgetLabel = "clinical_reminders";
1149 $widgetButtonLabel = xl("Edit");
1150 $widgetButtonLink = "../reminder/clinical_reminders.php?patient_id=".$pid;;
1151 $widgetButtonClass = "";
1152 $linkMethod = "html";
1153 $bodyClass = "summary_item small";
1154 $widgetAuth = true;
1155 $fixedWidth = false;
1156 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1157 echo "<br/>";
1158 echo "<div style='margin-left:10px' class='text'><image src='../../pic/ajax-loader.gif'/></div><br/>";
1159 echo "</div>";
1160 } // end if crw
1162 // appointments expand collapse widget
1163 $widgetTitle = xl("Appointments");
1164 $widgetLabel = "appointments";
1165 $widgetButtonLabel = xl("Add");
1166 $widgetButtonLink = "return newEvt();";
1167 $widgetButtonClass = "";
1168 $linkMethod = "javascript";
1169 $bodyClass = "summary_item small";
1170 $widgetAuth = (isset($res) && $res != null);
1171 $fixedWidth = false;
1172 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
1174 $count = 0;
1175 while($row = sqlFetchArray($res)) {
1176 $count++;
1177 $dayname = date("l", strtotime($row['pc_eventDate']));
1178 $dispampm = "am";
1179 $disphour = substr($row['pc_startTime'], 0, 2) + 0;
1180 $dispmin = substr($row['pc_startTime'], 3, 2);
1181 if ($disphour >= 12) {
1182 $dispampm = "pm";
1183 if ($disphour > 12) $disphour -= 12;
1185 $etitle = xl('(Click to edit)');
1186 if ($row['pc_hometext'] != "") {
1187 $etitle = xl('Comments').": ".($row['pc_hometext'])."\r\n".$etitle;
1189 echo "<a href='javascript:oldEvt(" . htmlspecialchars($row['pc_eid'],ENT_QUOTES) .
1190 ")' title='" . htmlspecialchars($etitle,ENT_QUOTES) . "'>";
1191 echo "<b>" . htmlspecialchars(xl($dayname) . ", " . $row['pc_eventDate'],ENT_NOQUOTES) . "</b><br>";
1192 echo htmlspecialchars("$disphour:$dispmin " . xl($dispampm) . " " . xl_appt_category($row['pc_catname']),ENT_NOQUOTES) . "<br>\n";
1193 echo htmlspecialchars($row['fname'] . " " . $row['lname'],ENT_NOQUOTES) . "</a><br>\n";
1195 if (isset($res) && $res != null) {
1196 if ( $count < 1 ) { echo "&nbsp;&nbsp;" . htmlspecialchars(xl('None'),ENT_NOQUOTES); }
1197 echo "</div>";
1201 </div>
1203 <div id='stats_div'>
1204 <br/>
1205 <div style='margin-left:10px' class='text'><img src='../../pic/ajax-loader.gif'/></div><br/>
1206 </div>
1207 </td>
1208 </tr>
1209 </table>
1211 </div> <!-- end right column div -->
1213 </td>
1215 </tr>
1216 </table>
1218 </div> <!-- end main content div -->
1220 <?php if ($GLOBALS['concurrent_layout'] && isset($_GET['set_pid'])) { ?>
1221 <script language='JavaScript'>
1222 top.window.parent.left_nav.setPatient(<?php echo "'" . htmlspecialchars(($result['fname']) . " " . ($result['lname']),ENT_QUOTES) .
1223 "'," . htmlspecialchars($pid,ENT_QUOTES) . ",'" . htmlspecialchars(($result['pubpid']),ENT_QUOTES) .
1224 "','', ' " . htmlspecialchars(xl('DOB') . ": " . oeFormatShortDate($result['DOB_YMD']) . " " . xl('Age') . ": " . getPatientAge($result['DOB_YMD']), ENT_QUOTES) . "'"; ?>);
1225 EncounterDateArray=new Array;
1226 CalendarCategoryArray=new Array;
1227 EncounterIdArray=new Array;
1228 Count=0;
1229 <?php
1230 //Encounter details are stored to javacript as array.
1231 $result4 = sqlStatement("SELECT fe.encounter,fe.date,openemr_postcalendar_categories.pc_catname FROM form_encounter AS fe ".
1232 " left join openemr_postcalendar_categories on fe.pc_catid=openemr_postcalendar_categories.pc_catid WHERE fe.pid = ? order by fe.date desc", array($pid));
1233 if(sqlNumRows($result4)>0)
1234 while($rowresult4 = sqlFetchArray($result4))
1237 EncounterIdArray[Count]='<?php echo htmlspecialchars($rowresult4['encounter'], ENT_QUOTES); ?>';
1238 EncounterDateArray[Count]='<?php echo htmlspecialchars(oeFormatShortDate(date("Y-m-d", strtotime($rowresult4['date']))), ENT_QUOTES); ?>';
1239 CalendarCategoryArray[Count]='<?php echo htmlspecialchars( xl_appt_category($rowresult4['pc_catname']), ENT_QUOTES); ?>';
1240 Count++;
1241 <?php
1244 top.window.parent.left_nav.setPatientEncounter(EncounterIdArray,EncounterDateArray,CalendarCategoryArray);
1245 parent.left_nav.setRadio(window.name, 'dem');
1246 </script>
1247 <?php } ?>
1249 <?php if (false && $GLOBALS['athletic_team']) { ?>
1250 <script language='JavaScript'>
1251 Calendar.setup({inputField:"form_userdate1", ifFormat:"%Y-%m-%d", button:"img_userdate1"});
1252 </script>
1253 <?php } ?>
1255 </body>
1256 </html>