Fixing HTML errors in demographics summary page.
[openemr.git] / interface / patient_file / summary / demographics.php
blobaf897312e8e7ecdc82b03ff5be070cfc10a85238
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");
26 if ($GLOBALS['concurrent_layout'] && $_GET['set_pid']) {
27 include_once("$srcdir/pid.inc");
28 setpid($_GET['set_pid']);
31 function print_as_money($money) {
32 preg_match("/(\d*)\.?(\d*)/",$money,$moneymatches);
33 $tmp = wordwrap(strrev($moneymatches[1]),3,",",1);
34 $ccheck = strrev($tmp);
35 if ($ccheck[0] == ",") {
36 $tmp = substr($ccheck,1,strlen($ccheck)-1);
38 if ($moneymatches[2] != "") {
39 return "$ " . strrev($tmp) . "." . $moneymatches[2];
40 } else {
41 return "$ " . strrev($tmp);
45 // get an array from Photos category
46 function pic_array($pid,$picture_directory) {
47 $pics = array();
48 $sql_query = "select documents.id from documents join categories_to_documents " .
49 "on documents.id = categories_to_documents.document_id " .
50 "join categories on categories.id = categories_to_documents.category_id " .
51 "where categories.name like ? and documents.foreign_id = ?";
52 if ($query = sqlStatement($sql_query, array($picture_directory,$pid))) {
53 while( $results = sqlFetchArray($query) ) {
54 array_push($pics,$results['id']);
57 return ($pics);
59 // Get the document ID of the first document in a specific catg.
60 function get_document_by_catg($pid,$doc_catg) {
62 $result = array();
64 if ($pid and $doc_catg) {
65 $result = sqlQuery("SELECT d.id, d.date, d.url FROM " .
66 "documents AS d, categories_to_documents AS cd, categories AS c " .
67 "WHERE d.foreign_id = ? " .
68 "AND cd.document_id = d.id " .
69 "AND c.id = cd.category_id " .
70 "AND c.name LIKE ? " .
71 "ORDER BY d.date DESC LIMIT 1", array($pid, $doc_catg) );
74 return($result['id']);
77 // Display image in 'widget style'
78 function image_widget($doc_id,$doc_catg)
80 global $pid, $web_root;
81 $docobj = new Document($doc_id);
82 $image_file = $docobj->get_url_file();
83 $extension = substr($image_file, strrpos($image_file,"."));
84 $viewable_types = array('.png','.jpg','.jpeg','.png','.bmp'); // image ext supported by fancybox viewer
85 if ( in_array($extention,$viewable_types) == 0 ) { // extention matches list
86 $to_url = "<a href = $web_root" .
87 "/controller.php?document&retrieve&patient_id=$pid&document_id=$doc_id" .
88 "/tmp.$extension" . // Force image type inot URL for fancybox
89 " onclick=top.restoreSession(); class='image_modal'>" .
90 " <img src = $web_root" .
91 "/controller.php?document&retrieve&patient_id=$pid&document_id=$doc_id" .
92 " width=100 alt='$doc_catg:$image_file' align='center'>" .
93 htmlspecialchars(" $doc_catg: $image_file") .
94 " </a> <br /><br />";
96 else {
97 $to_url = "<a href='" . $web_root . "/controller.php?document&retrieve" .
98 "&patient_id=$pid&document_id=$doc_id'" .
99 " onclick='top.restoreSession()' class='css_button_small'>" .
100 "<span>" .
101 htmlspecialchars( xl("View"), ENT_QUOTES )."</a> &nbsp;" .
102 htmlspecialchars( "$doc_catg - $image_file", ENT_QUOTES ) .
103 "</span> <br /><br />";
105 echo $to_url;
109 <html>
111 <head>
112 <?php html_header_show();?>
113 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
114 <link rel="stylesheet" type="text/css" href="../../../library/js/fancybox/jquery.fancybox-1.2.6.css" media="screen" />
115 <style type="text/css">@import url(../../../library/dynarch_calendar.css);</style>
116 <script type="text/javascript" src="../../../library/textformat.js"></script>
117 <script type="text/javascript" src="../../../library/dynarch_calendar.js"></script>
118 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
119 <script type="text/javascript" src="../../../library/dynarch_calendar_setup.js"></script>
120 <script type="text/javascript" src="../../../library/dialog.js"></script>
121 <script type="text/javascript" src="../../../library/js/jquery.1.3.2.js"></script>
122 <script type="text/javascript" src="../../../library/js/common.js"></script>
123 <script type="text/javascript" src="../../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
124 <script type="text/javascript" language="JavaScript">
125 //Visolve - sync the radio buttons - Start
126 if((top.window.parent) && (parent.window)){
127 var wname = top.window.parent.left_nav;
128 wname.syncRadios();
129 wname.setRadio(parent.window.name, "dem");
131 //Visolve - sync the radio buttons - End
133 var mypcc = '<?php echo htmlspecialchars($GLOBALS['phone_country_code'],ENT_QUOTES); ?>';
135 function oldEvt(eventid) {
136 dlgopen('../../main/calendar/add_edit_event.php?eid=' + eventid, '_blank', 550, 270);
139 function advdirconfigure() {
140 dlgopen('advancedirectives.php', '_blank', 500, 450);
143 function refreshme() {
144 top.restoreSession();
145 location.reload();
148 // Process click on Delete link.
149 function deleteme() {
150 dlgopen('../deleter.php?patient=<?php echo htmlspecialchars($pid,ENT_QUOTES); ?>', '_blank', 500, 450);
151 return false;
154 // Called by the deleteme.php window on a successful delete.
155 function imdeleted() {
156 <?php if ($GLOBALS['concurrent_layout']) { ?>
157 parent.left_nav.clearPatient();
158 <?php } else { ?>
159 top.restoreSession();
160 top.location.href = '../main/main_screen.php';
161 <?php } ?>
164 function validate() {
165 var f = document.forms[0];
166 <?php
167 if ($GLOBALS['athletic_team']) {
168 echo " if (f.form_userdate1.value != f.form_original_userdate1.value) {\n";
169 $irow = sqlQuery("SELECT id, title FROM lists WHERE " .
170 "pid = ? AND enddate IS NULL ORDER BY begdate DESC LIMIT 1", array($pid));
171 if (!empty($irow)) {
173 if (confirm('Do you wish to also set this new return date in the issue titled "<?php echo htmlspecialchars($irow['title'],ENT_QUOTES); ?>"?')) {
174 f.form_issue_id.value = '<?php echo htmlspecialchars($irow['id'],ENT_QUOTES); ?>';
175 } else {
176 alert('OK, you will need to manually update the return date in any affected issue(s).');
178 <?php } else { ?>
179 alert('You have changed the return date but there are no open issues. You probably need to create or modify one.');
180 <?php
181 } // end empty $irow
182 echo " }\n";
183 } // end athletic team
185 return true;
188 function newEvt() {
189 dlgopen('../../main/calendar/add_edit_event.php?patientid=<?php echo htmlspecialchars($pid,ENT_QUOTES); ?>', '_blank', 550, 270);
190 return false;
193 function sendimage(pid, what) {
194 // alert('Not yet implemented.'); return false;
195 dlgopen('../upload_dialog.php?patientid=' + pid + '&file=' + what,
196 '_blank', 500, 400);
197 return false;
200 </script>
202 <script type="text/javascript">
204 function toggleIndicator(target,div) {
206 $mode = $(target).find(".indicator").text();
207 if ( $mode == "<?php echo htmlspecialchars(xl('collapse'),ENT_QUOTES); ?>" ) {
208 $(target).find(".indicator").text( "<?php echo htmlspecialchars(xl('expand'),ENT_QUOTES); ?>" );
209 $("#"+div).hide();
210 $.post( "../../../library/ajax/user_settings.php", { target: div, mode: 0 });
211 } else {
212 $(target).find(".indicator").text( "<?php echo htmlspecialchars(xl('collapse'),ENT_QUOTES); ?>" );
213 $("#"+div).show();
214 $.post( "../../../library/ajax/user_settings.php", { target: div, mode: 1 });
218 $(document).ready(function(){
220 // load divs
221 $("#stats_div").load("stats.php", { 'embeddedScreen' : true }, function() {
222 // (note need to place javascript code here also to get the dynamic link to work)
223 $(".rx_modal").fancybox( {
224 'overlayOpacity' : 0.0,
225 'showCloseButton' : true,
226 'frameHeight' : 500,
227 'frameWidth' : 800,
228 'centerOnScroll' : false,
229 'callbackOnClose' : function() {
230 refreshme();
234 $("#pnotes_ps_expand").load("pnotes_fragment.php");
235 $("#disclosures_ps_expand").load("disc_fragment.php");
236 $("#vitals_ps_expand").load("vitals_fragment.php");
238 // fancy box
239 enable_modals();
241 tabbify();
243 // modal for dialog boxes
244 $(".large_modal").fancybox( {
245 'overlayOpacity' : 0.0,
246 'showCloseButton' : true,
247 'frameHeight' : 600,
248 'frameWidth' : 1000,
249 'centerOnScroll' : false
252 // modal for image viewer
253 $(".image_modal").fancybox( {
254 'overlayOpacity' : 0.0,
255 'showCloseButton' : true,
256 'centerOnScroll' : false,
257 'autoscale' : true
262 </script>
264 <style type="css/text">
265 #pnotes_ps_expand {
266 height:auto;
267 width:100%;
269 </style>
271 </head>
273 <body class="body_top">
275 <?php
276 $result = getPatientData($pid, "*, DATE_FORMAT(DOB,'%Y-%m-%d') as DOB_YMD");
277 $result2 = getEmployerData($pid);
278 $result3 = getInsuranceData($pid, "primary", "copay, provider, DATE_FORMAT(`date`,'%Y-%m-%d') as effdate");
279 $insco_name = "";
281 if ($result3['provider']) { // Use provider in case there is an ins record w/ unassigned insco
282 $insco_name = getInsuranceProvider($result3['provider']);
285 $thisauth = acl_check('patients', 'demo');
286 if ($thisauth) {
287 if ($result['squad'] && ! acl_check('squads', $result['squad']))
288 $thisauth = 0;
291 if (!$thisauth) {
292 echo "<p>(" . htmlspecialchars(xl('Demographics not authorized'),ENT_NOQUOTES) . ")</p>\n";
293 echo "</body>\n</html>\n";
294 exit();
297 if ($thisauth == 'write') {
298 echo "<table><tr><td><span class='title'>" .
299 htmlspecialchars(getPatientName($pid),ENT_NOQUOTES) .
300 "</span></td>";
302 if (acl_check('admin', 'super')) {
303 echo "<td style='padding-left:1em;'><a class='css_button iframe' href='../deleter.php?patient=" .
304 htmlspecialchars($pid,ENT_QUOTES) . "'>" .
305 "<span>".htmlspecialchars(xl('Delete'),ENT_NOQUOTES).
306 "</span></a></td>";
308 echo "</tr></table>";
311 // Get the document ID of the patient ID card if access to it is wanted here.
312 $idcard_doc_id = false;
313 if ($GLOBALS['patient_id_category_name']) {
314 $idcard_doc_id = get_document_by_catg($pid, $GLOBALS['patient_id_category_name']);
318 <table cellspacing='0' cellpadding='0' border='0'>
319 <tr>
320 <td class="small" colspan='4'>
321 <a href="../history/history.php" onclick='top.restoreSession()'>
322 <?php echo htmlspecialchars(xl('History'),ENT_NOQUOTES); ?></a>
324 <?php //note that we have temporarily removed report screen from the modal view ?>
325 <a href="../report/patient_report.php" onclick='top.restoreSession()'>
326 <?php echo htmlspecialchars(xl('Report'),ENT_NOQUOTES); ?></a>
328 <?php //note that we have temporarily removed document screen from the modal view ?>
329 <a href="../../../controller.php?document&list&patient_id=<?php echo $pid;?>" onclick='top.restoreSession()'>
330 <?php echo htmlspecialchars(xl('Documents'),ENT_NOQUOTES); ?></a>
332 <a href="../transaction/transactions.php" class='iframe large_modal' onclick='top.restoreSession()'>
333 <?php echo htmlspecialchars(xl('Transactions'),ENT_NOQUOTES); ?></a>
334 </td>
335 </tr>
336 </table> <!-- end header -->
338 <div style='margin-top:10px'> <!-- start main content div -->
339 <table border="0" cellspacing="0" cellpadding="0" width="100%">
340 <tr>
341 <td align="left" valign="top">
342 <!-- start left column div -->
343 <div style='float:left; margin-right:20px'>
344 <table cellspacing=0 cellpadding=0>
345 <tr>
346 <td>
347 <?php
348 // Billing expand collapse widget
349 $widgetTitle = xl("Billing");
350 $widgetLabel = "billing";
351 $widgetButtonLabel = xl("Edit");
352 $widgetButtonLink = "return newEvt();";
353 $widgetButtonClass = "";
354 $linkMethod = "javascript";
355 $bodyClass = "notab";
356 $widgetAuth = false;
357 $fixedWidth = true;
358 if ($GLOBALS['force_billing_widget_open']) {
359 $forceExpandAlways = true;
361 else {
362 $forceExpandAlways = false;
364 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
365 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
366 $widgetAuth, $fixedWidth, $forceExpandAlways);
368 <br>
369 <?php
370 if ($GLOBALS['oer_config']['ws_accounting']['enabled']) {
371 // Show current balance and billing note, if any.
372 echo " <div style='margin-left: 10px; margin-right: 10px'>" .
373 "<span class='bold'><font color='#ee6600'>" .
374 htmlspecialchars(xl('Balance Due'),ENT_NOQUOTES) .
375 ": " . htmlspecialchars(oeFormatMoney(get_patient_balance($pid)),ENT_NOQUOTES) .
376 "</font></span><br>";
377 if ($result['genericname2'] == 'Billing') {
378 echo "<span class='bold'><font color='red'>" .
379 htmlspecialchars(xl('Billing Note'),ENT_NOQUOTES) . ":" .
380 htmlspecialchars($result['genericval2'],ENT_NOQUOTES) .
381 "</font></span><br>";
383 if ($result3['provider']) { // Use provider in case there is an ins record w/ unassigned insco
384 echo "<span class='bold'>" .
385 htmlspecialchars(xl('Primary Insurance'),ENT_NOQUOTES) . ': ' . htmlspecialchars($insco_name,ENT_NOQUOTES) .
386 "</span>&nbsp;&nbsp;&nbsp;";
387 if ($result3['copay'] > 0) {
388 echo "<span class='bold'>" .
389 htmlspecialchars(xl('Copay'),ENT_NOQUOTES) . ': ' . htmlspecialchars($result3['copay'],ENT_NOQUOTES) .
390 "</span>&nbsp;&nbsp;&nbsp;";
392 echo "<span class='bold'>" .
393 htmlspecialchars(xl('Effective Date'),ENT_NOQUOTES) . ': ' . htmlspecialchars(oeFormatShortDate($result3['effdate'],ENT_NOQUOTES)) .
394 "</span>";
396 echo "</div><br>";
399 </div> <!-- required for expand_collapse_widget -->
400 </td>
401 </tr>
402 <tr>
403 <td>
404 <?php
405 // Demographics expand collapse widget
406 $widgetTitle = xl("Demographics");
407 $widgetLabel = "demographics";
408 $widgetButtonLabel = xl("Edit");
409 $widgetButtonLink = "demographics_full.php";
410 $widgetButtonClass = "";
411 $linkMethod = "html";
412 $bodyClass = "";
413 $widgetAuth = ($thisauth == "write");
414 $fixedWidth = true;
415 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
416 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
417 $widgetAuth, $fixedWidth);
419 <div id="DEM" >
420 <ul class="tabNav">
421 <?php display_layout_tabs('DEM', $result, $result2); ?>
422 </ul>
423 <div class="tabContainer">
424 <?php display_layout_tabs_data('DEM', $result, $result2); ?>
425 </div>
426 </div>
427 </div> <!-- required for expand_collapse_widget -->
428 </td>
429 </tr>
431 <tr>
432 <td>
433 <?php
434 $insurance_count = 0;
435 foreach (array('primary','secondary','tertiary') as $instype) {
436 $enddate = 'Present';
437 $query = "SELECT * FROM insurance_data WHERE " .
438 "pid = ? AND type = ? " .
439 "ORDER BY date DESC";
440 $res = sqlStatement($query, array($pid, $instype) );
441 while( $row = sqlFetchArray($res) ) {
442 if ($row['provider'] ) $insurance_count++;
446 if ( $insurance_count > 0 ) {
447 // Insurance expand collapse widget
448 $widgetTitle = xl("Insurance");
449 $widgetLabel = "insurance";
450 $widgetButtonLabel = xl("Edit");
451 $widgetButtonLink = "demographics_full.php";
452 $widgetButtonClass = "";
453 $linkMethod = "html";
454 $bodyClass = "";
455 $widgetAuth = ($thisauth == "write");
456 $fixedWidth = true;
457 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
458 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
459 $widgetAuth, $fixedWidth);
461 if ( $insurance_count > 0 ) {
464 <ul class="tabNav"><?php
465 ///////////////////////////////// INSURANCE SECTION
466 $first = true;
467 foreach (array('primary','secondary','tertiary') as $instype) {
469 $query = "SELECT * FROM insurance_data WHERE " .
470 "pid = ? AND type = ? " .
471 "ORDER BY date DESC";
472 $res = sqlStatement($query, array($pid, $instype) );
474 $enddate = 'Present';
476 while( $row = sqlFetchArray($res) ) {
477 if ($row['provider'] ) {
479 $ins_description = ucfirst($instype);
480 $ins_description = xl($ins_description);
481 $ins_description .= strcmp($enddate, 'Present') != 0 ? " (".xl('Old').")" : "";
483 <li <?php echo $first ? 'class="current"' : '' ?>><a href="/play/javascript-tabbed-navigation/">
484 <?php echo htmlspecialchars($ins_description,ENT_NOQUOTES); ?></a></li>
485 <?php
486 $first = false;
488 $enddate = $row['date'];
491 // Display the eligibility tab
492 echo "<li><a href='/play/javascript-tabbed-navigation/'>" .
493 htmlspecialchars( xl('Eligibility'), ENT_NOQUOTES) . "</a></li>";
495 ?></ul><?php
497 } ?>
499 <div class="tabContainer">
500 <?php
501 $first = true;
502 foreach (array('primary','secondary','tertiary') as $instype) {
503 $enddate = 'Present';
505 $query = "SELECT * FROM insurance_data WHERE " .
506 "pid = ? AND type = ? " .
507 "ORDER BY date DESC";
508 $res = sqlStatement($query, array($pid, $instype) );
509 while( $row = sqlFetchArray($res) ) {
510 if ($row['provider'] ) {
512 <div class="tab <?php echo $first ? 'current' : '' ?>">
513 <table border='0' cellpadding='0' width='100%'>
514 <?php
515 $icobj = new InsuranceCompany($row['provider']);
516 $adobj = $icobj->get_address();
517 $insco_name = trim($icobj->get_name());
519 <tr>
520 <td valign='top' colspan='3'>
521 <span class='text'>
522 <?php if (strcmp($enddate, 'Present') != 0) echo htmlspecialchars(xl("Old"),ENT_NOQUOTES)." "; ?>
523 <?php $tempinstype=ucfirst($instype); echo htmlspecialchars(xl($tempinstype.' Insurance'),ENT_NOQUOTES); ?>
524 <?php if (strcmp($row['date'], '0000-00-00') != 0) { ?>
525 <?php echo htmlspecialchars(xl('from','',' ',' ').$row['date'],ENT_NOQUOTES); ?>
526 <?php } ?>
527 <?php echo htmlspecialchars(xl('until','',' ',' '),ENT_NOQUOTES);
528 echo (strcmp($enddate, 'Present') != 0) ? $enddate : htmlspecialchars(xl('Present'),ENT_NOQUOTES); ?>:</span>
529 </td>
530 </tr>
531 <tr>
532 <td valign='top'>
533 <span class='text'>
534 <?php
535 if ($insco_name) {
536 echo htmlspecialchars($insco_name,ENT_NOQUOTES) . '<br>';
537 if (trim($adobj->get_line1())) {
538 echo htmlspecialchars($adobj->get_line1(),ENT_NOQUOTES) . '<br>';
539 echo htmlspecialchars($adobj->get_city() . ', ' . $adobj->get_state() . ' ' . $adobj->get_zip(),ENT_NOQUOTES);
541 } else {
542 echo "<font color='red'><b>".htmlspecialchars(xl('Unassigned'),ENT_NOQUOTES)."</b></font>";
545 <br>
546 <?php echo htmlspecialchars(xl('Policy Number'),ENT_NOQUOTES); ?>:
547 <?php echo htmlspecialchars($row['policy_number'],ENT_NOQUOTES) ?><br>
548 <?php echo htmlspecialchars(xl('Plan Name'),ENT_NOQUOTES); ?>:
549 <?php echo htmlspecialchars($row['plan_name'],ENT_NOQUOTES); ?><br>
550 <?php echo htmlspecialchars(xl('Group Number'),ENT_NOQUOTES); ?>:
551 <?php echo htmlspecialchars($row['group_number'],ENT_NOQUOTES); ?></span>
552 </td>
553 <td valign='top'>
554 <span class='bold'><?php echo htmlspecialchars(xl('Subscriber'),ENT_NOQUOTES); ?>: </span><br>
555 <span class='text'><?php echo htmlspecialchars($row['subscriber_fname'] . ' ' . $row['subscriber_mname'] . ' ' . $row['subscriber_lname'],ENT_NOQUOTES); ?>
556 <?php
557 if ($row['subscriber_relationship'] != "") {
558 echo "(" . htmlspecialchars($row['subscriber_relationship'],ENT_NOQUOTES) . ")";
561 <br>
562 <?php echo htmlspecialchars(xl('S.S.'),ENT_NOQUOTES); ?>:
563 <?php echo htmlspecialchars($row['subscriber_ss'],ENT_NOQUOTES); ?><br>
564 <?php echo htmlspecialchars(xl('D.O.B.'),ENT_NOQUOTES); ?>:
565 <?php if ($row['subscriber_DOB'] != "0000-00-00 00:00:00") echo htmlspecialchars($row['subscriber_DOB'],ENT_NOQUOTES); ?><br>
566 <?php echo htmlspecialchars(xl('Phone'),ENT_NOQUOTES); ?>:
567 <?php echo htmlspecialchars($row['subscriber_phone'],ENT_NOQUOTES); ?>
568 </span>
569 </td>
570 <td valign='top'>
571 <span class='bold'><?php echo htmlspecialchars(xl('Subscriber Address'),ENT_NOQUOTES); ?>: </span><br>
572 <span class='text'><?php echo htmlspecialchars($row['subscriber_street'],ENT_NOQUOTES); ?><br>
573 <?php echo htmlspecialchars($row['subscriber_city'],ENT_NOQUOTES); ?>
574 <?php if($row['subscriber_state'] != "") echo ", "; echo htmlspecialchars($row['subscriber_state'],ENT_NOQUOTES); ?>
575 <?php if($row['subscriber_country'] != "") echo ", "; echo htmlspecialchars($row['subscriber_country'],ENT_NOQUOTES); ?>
576 <?php echo " " . htmlspecialchars($row['subscriber_postal_code'],ENT_NOQUOTES); ?></span>
578 <?php if (trim($row['subscriber_employer'])) { ?>
579 <br><span class='bold'><?php echo htmlspecialchars(xl('Subscriber Employer'),ENT_NOQUOTES); ?>: </span><br>
580 <span class='text'><?php echo htmlspecialchars($row['subscriber_employer'],ENT_NOQUOTES); ?><br>
581 <?php echo htmlspecialchars($row['subscriber_employer_street'],ENT_NOQUOTES); ?><br>
582 <?php echo htmlspecialchars($row['subscriber_employer_city'],ENT_NOQUOTES); ?>
583 <?php if($row['subscriber_employer_city'] != "") echo ", "; echo htmlspecialchars($row['subscriber_employer_state'],ENT_NOQUOTES); ?>
584 <?php if($row['subscriber_employer_country'] != "") echo ", "; echo htmlspecialchars($row['subscriber_employer_country'],ENT_NOQUOTES); ?>
585 <?php echo " " . htmlspecialchars($row['subscriber_employer_postal_code'],ENT_NOQUOTES); ?>
586 </span>
587 <?php } ?>
589 </td>
590 </tr>
591 <tr>
592 <td>
593 <?php if ($row['copay'] != "") { ?>
594 <span class='bold'><?php echo htmlspecialchars(xl('CoPay'),ENT_NOQUOTES); ?>: </span>
595 <span class='text'><?php echo htmlspecialchars($row['copay'],ENT_NOQUOTES); ?></span>
596 <?php } ?>
597 <br>
598 <span class='bold'><?php echo htmlspecialchars(xl('Accept Assignment'),ENT_NOQUOTES); ?>:</span>
599 <span class='text'><?php if($row['accept_assignment'] == "TRUE") echo xl("YES"); ?>
600 <?php if($row['accept_assignment'] == "FALSE") echo xl("NO"); ?></span>
601 </td>
602 <td valign='top'></td>
603 <td valign='top'></td>
604 </tr>
606 </table>
607 </div>
608 <?php
610 } // end if ($row['provider'])
611 $enddate = $row['date'];
612 $first = false;
613 } // end while
614 } // end foreach
616 // Display the eligibility information
617 echo "<div class='tab'>";
618 show_eligibility_information($pid,true);
619 echo "</div>";
621 ///////////////////////////////// END INSURANCE SECTION
623 </div>
625 <?php } // ?>
627 </td>
628 </tr>
630 <tr>
631 <td width='650px'>
633 <?php
634 // Notes expand collapse widget
635 $widgetTitle = xl("Notes");
636 $widgetLabel = "pnotes";
637 $widgetButtonLabel = xl("Edit");
638 $widgetButtonLink = "pnotes_full.php";
639 $widgetButtonClass = "";
640 $linkMethod = "html";
641 $bodyClass = "notab";
642 $widgetAuth = true;
643 $fixedWidth = true;
644 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
645 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
646 $widgetAuth, $fixedWidth);
649 <br/>
650 <div style='margin-left:10px' class='text'><img src='../../pic/ajax-loader.gif'/></div><br/>
651 </div>
652 </td>
653 </tr>
654 <tr>
655 <td width='650px'>
656 <?php
657 // disclosures expand collapse widget
658 $widgetTitle = xl("Disclosures");
659 $widgetLabel = "disclosures";
660 $widgetButtonLabel = xl("Edit");
661 $widgetButtonLink = "disclosure_full.php";
662 $widgetButtonClass = "";
663 $linkMethod = "html";
664 $bodyClass = "notab";
665 $widgetAuth = true;
666 $fixedWidth = true;
667 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
668 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
669 $widgetAuth, $fixedWidth);
672 <br/>
673 <div style='margin-left:10px' class='text'><image src='../../pic/ajax-loader.gif'/></div><br/>
674 </div>
675 </td>
676 </tr>
678 <tr>
679 <td width='650px'>
680 <?php // vitals expand collapse widget
681 $widgetTitle = xl("Vitals");
682 $widgetLabel = "vitals";
683 $widgetButtonLabel = xl("Trend");
684 $widgetButtonLink = "../encounter/trend_form.php?formname=vitals";
685 $widgetButtonClass = "";
686 $linkMethod = "html";
687 $bodyClass = "notab";
688 // check to see if any vitals exist
689 $existVitals = sqlQuery("SELECT * FROM form_vitals WHERE pid=?", array($pid) );
690 if ($existVitals) {
691 $widgetAuth = true;
693 else {
694 $widgetAuth = false;
696 $fixedWidth = true;
697 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
698 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
699 $widgetAuth, $fixedWidth);
701 <br/>
702 <div style='margin-left:10px' class='text'><image src='../../pic/ajax-loader.gif'/></div><br/>
703 </div>
704 </td>
705 </tr>
706 </table>
708 </div>
709 <!-- end left column div -->
711 <!-- start right column div -->
712 <div class='text'>
713 <table>
714 <tr>
715 <td>
716 <div>
717 <?php
719 // If there is an ID Card or any Photos show the widget
720 $photos = pic_array($pid, $GLOBALS['patient_photo_category_name']);
721 if ($photos or $idcard_doc_id )
723 $widgetTitle = xl("ID Card") . '/' . xl("Photos");
724 $widgetLabel = "photos";
725 $linkMethod = "javascript";
726 $bodyClass = "notab";
727 $widgetAuth = false;
728 $fixedWidth = true;
729 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel ,
730 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
731 $widgetAuth, $fixedWidth);
733 <br />
734 <?php
735 if ($idcard_doc_id) {
736 image_widget($idcard_doc_id, $GLOBALS['patient_id_category_name']);
739 foreach ($photos as $photo_doc_id) {
740 image_widget($photo_doc_id, $GLOBALS['patient_photo_category_name']);
745 <br />
746 </div>
747 <div>
748 <?php
749 // Advance Directives
750 if ($GLOBALS['advance_directives_warning']) {
751 // advance directives expand collapse widget
752 $widgetTitle = xl("Advance Directives");
753 $widgetLabel = "directives";
754 $widgetButtonLabel = xl("Edit");
755 $widgetButtonLink = "return advdirconfigure();";
756 $widgetButtonClass = "";
757 $linkMethod = "javascript";
758 $bodyClass = "summary_item small";
759 $widgetAuth = true;
760 $fixedWidth = false;
761 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
762 $counterFlag = false; //flag to record whether any categories contain ad records
763 $query = "SELECT id FROM categories WHERE name='Advance Directive'";
764 $myrow2 = sqlQuery($query);
765 if ($myrow2) {
766 $parentId = $myrow2['id'];
767 $query = "SELECT id, name FROM categories WHERE parent=?";
768 $resNew1 = sqlStatement($query, array($parentId) );
769 while ($myrows3 = sqlFetchArray($resNew1)) {
770 $categoryId = $myrows3['id'];
771 $nameDoc = $myrows3['name'];
772 $query = "SELECT documents.date, documents.id " .
773 "FROM documents " .
774 "INNER JOIN categories_to_documents " .
775 "ON categories_to_documents.document_id=documents.id " .
776 "WHERE categories_to_documents.category_id=? " .
777 "AND documents.foreign_id=? " .
778 "ORDER BY documents.date DESC";
779 $resNew2 = sqlStatement($query, array($categoryId, $pid) );
780 $limitCounter = 0; // limit to one entry per category
781 while (($myrows4 = sqlFetchArray($resNew2)) && ($limitCounter == 0)) {
782 $dateTimeDoc = $myrows4['date'];
783 // remove time from datetime stamp
784 $tempParse = explode(" ",$dateTimeDoc);
785 $dateDoc = $tempParse[0];
786 $idDoc = $myrows4['id'];
787 echo "<a href='$web_root/controller.php?document&retrieve&patient_id=" .
788 htmlspecialchars($pid,ENT_QUOTES) . "&document_id=" .
789 htmlspecialchars($idDoc,ENT_QUOTES) . "&as_file=true'>" .
790 htmlspecialchars(xl_document_category($nameDoc),ENT_NOQUOTES) . "</a> " .
791 htmlspecialchars($dateDoc,ENT_NOQUOTES);
792 echo "<br>";
793 $limitCounter = $limitCounter + 1;
794 $counterFlag = true;
798 if (!$counterFlag) {
799 echo "&nbsp;&nbsp;" . htmlspecialchars(xl('None'),ENT_NOQUOTES);
800 } ?>
801 </div>
802 <?php } // close advanced dir block
804 // This is a feature for a specific client. -- Rod
805 if ($GLOBALS['cene_specific']) {
806 echo " <br />\n";
808 $imagedir = $GLOBALS['OE_SITE_DIR'] . "/documents/$pid/demographics";
809 $imagepath = "$web_root/sites/" . $_SESSION['site_id'] . "/documents/$pid/demographics";
811 echo " <a href='' onclick=\"return sendimage($pid, 'photo');\" " .
812 "title='Click to attach patient image'>\n";
813 if (is_file("$imagedir/photo.jpg")) {
814 echo " <img src='$imagepath/photo.jpg' /></a>\n";
815 } else {
816 echo " Attach Patient Image</a><br />\n";
818 echo " <br />&nbsp;<br />\n";
820 echo " <a href='' onclick=\"return sendimage($pid, 'fingerprint');\" " .
821 "title='Click to attach fingerprint'>\n";
822 if (is_file("$imagedir/fingerprint.jpg")) {
823 echo " <img src='$imagepath/fingerprint.jpg' /></a>\n";
824 } else {
825 echo " Attach Biometric Fingerprint</a><br />\n";
827 echo " <br />&nbsp;<br />\n";
830 // This stuff only applies to athletic team use of OpenEMR. The client
831 // insisted on being able to quickly change fitness and return date here:
833 if (false && $GLOBALS['athletic_team']) {
834 // blue green yellow red orange
835 $fitcolors = array('#6677ff','#00cc00','#ffff00','#ff3333','#ff8800','#ffeecc','#ffccaa');
836 if (!empty($GLOBALS['fitness_colors'])) $fitcolors = $GLOBALS['fitness_colors'];
837 $fitcolor = $fitcolors[0];
838 $form_fitness = $_POST['form_fitness'];
839 $form_userdate1 = fixDate($_POST['form_userdate1'], '');
840 $form_issue_id = $_POST['form_issue_id'];
841 if ($form_submit) {
842 $returndate = $form_userdate1 ? "'$form_userdate1'" : "NULL";
843 sqlStatement("UPDATE patient_data SET fitness = ?, " .
844 "userdate1 = ? WHERE pid = ?", array($form_fitness, $returndate, $pid) );
845 // Update return date in the designated issue, if requested.
846 if ($form_issue_id) {
847 sqlStatement("UPDATE lists SET returndate = ? WHERE " .
848 "id = ?", array($returndate, $form_issue_id) );
850 } else {
851 $form_fitness = $result['fitness'];
852 if (! $form_fitness) $form_fitness = 1;
853 $form_userdate1 = $result['userdate1'];
855 $fitcolor = $fitcolors[$form_fitness - 1];
856 echo " <form method='post' action='demographics.php' onsubmit='return validate()'>\n";
857 echo " <span class='bold'>Fitness to Play:</span><br />\n";
858 echo " <select name='form_fitness' style='background-color:$fitcolor'>\n";
859 $res = sqlStatement("SELECT * FROM list_options WHERE " .
860 "list_id = 'fitness' ORDER BY seq");
861 while ($row = sqlFetchArray($res)) {
862 $key = $row['option_id'];
863 echo " <option value='" . htmlspecialchars($key,ENT_QUOTES) . "'";
864 if ($key == $form_fitness) echo " selected";
865 echo ">" . htmlspecialchars($row['title'],ENT_NOQUOTES) . "</option>\n";
867 echo " </select>\n";
868 echo " <br /><span class='bold'>Return to Play:</span><br>\n";
869 echo " <input type='text' size='10' name='form_userdate1' id='form_userdate1' " .
870 "value='$form_userdate1' " .
871 "title='" . htmlspecialchars(xl('yyyy-mm-dd Date of return to play'),ENT_QUOTES) . "' " .
872 "onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' />\n" .
873 " <img src='../../pic/show_calendar.gif' align='absbottom' width='24' height='22' " .
874 "id='img_userdate1' border='0' alt='[?]' style='cursor:pointer' " .
875 "title='" . htmlspecialchars(xl('Click here to choose a date'),ENT_QUOTES) . "'>\n";
876 echo " <input type='hidden' name='form_original_userdate1' value='" . htmlspecialchars($form_userdate1,ENT_QUOTES) . "' />\n";
877 echo " <input type='hidden' name='form_issue_id' value='' />\n";
878 echo "<p><input type='submit' name='form_submit' value='Change' /></p>\n";
879 echo " </form>\n";
882 // Show current and upcoming appointments.
883 if (isset($pid) && !$GLOBALS['disable_calendar']) {
884 $query = "SELECT e.pc_eid, e.pc_aid, e.pc_title, e.pc_eventDate, " .
885 "e.pc_startTime, e.pc_hometext, u.fname, u.lname, u.mname, " .
886 "c.pc_catname " .
887 "FROM openemr_postcalendar_events AS e, users AS u, " .
888 "openemr_postcalendar_categories AS c WHERE " .
889 "e.pc_pid = ? AND e.pc_eventDate >= CURRENT_DATE AND " .
890 "u.id = e.pc_aid AND e.pc_catid = c.pc_catid " .
891 "ORDER BY e.pc_eventDate, e.pc_startTime";
892 $res = sqlStatement($query, array($pid) );
894 // appointments expand collapse widget
895 $widgetTitle = xl("Appointments");
896 $widgetLabel = "appointments";
897 $widgetButtonLabel = xl("Add");
898 $widgetButtonLink = "return newEvt();";
899 $widgetButtonClass = "";
900 $linkMethod = "javascript";
901 $bodyClass = "summary_item small";
902 $widgetAuth = (isset($res) && $res != null);
903 $fixedWidth = false;
904 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
906 $count = 0;
907 while($row = sqlFetchArray($res)) {
908 $count++;
909 $dayname = date("l", strtotime($row['pc_eventDate']));
910 $dispampm = "am";
911 $disphour = substr($row['pc_startTime'], 0, 2) + 0;
912 $dispmin = substr($row['pc_startTime'], 3, 2);
913 if ($disphour >= 12) {
914 $dispampm = "pm";
915 if ($disphour > 12) $disphour -= 12;
917 $etitle = xl('(Click to edit)');
918 if ($row['pc_hometext'] != "") {
919 $etitle = xl('Comments').": ".($row['pc_hometext'])."\r\n".$etitle;
921 echo "<a href='javascript:oldEvt(" . htmlspecialchars($row['pc_eid'],ENT_QUOTES) .
922 ")' title='" . htmlspecialchars($etitle,ENT_QUOTES) . "'>";
923 echo "<b>" . htmlspecialchars(xl($dayname) . ", " . $row['pc_eventDate'],ENT_NOQUOTES) . "</b><br>";
924 echo htmlspecialchars("$disphour:$dispmin " . xl($dispampm) . " " . xl_appt_category($row['pc_catname']),ENT_NOQUOTES) . "<br>\n";
925 echo htmlspecialchars($row['fname'] . " " . $row['lname'],ENT_NOQUOTES) . "</a><br>\n";
927 if (isset($res) && $res != null) {
928 if ( $count < 1 ) { echo "&nbsp;&nbsp;" . htmlspecialchars(xl('None'),ENT_NOQUOTES); }
929 echo "</div>";
933 </div>
935 <div id='stats_div'>
936 <br/>
937 <div style='margin-left:10px' class='text'><image src='../../pic/ajax-loader.gif'/></div><br/>
938 </div>
939 </td>
940 </tr>
941 </table>
943 </div> <!-- end right column div -->
945 </td>
947 </tr>
948 </table>
950 </div> <!-- end main content div -->
952 <?php if ($GLOBALS['concurrent_layout'] && $_GET['set_pid']) { ?>
953 <script language='JavaScript'>
954 top.window.parent.left_nav.setPatient(<?php echo "'" . htmlspecialchars(($result['fname']) . " " . ($result['lname']),ENT_QUOTES) .
955 "'," . htmlspecialchars($pid,ENT_QUOTES) . ",'" . htmlspecialchars(($result['pubpid']),ENT_QUOTES) .
956 "','', ' " . htmlspecialchars(xl('DOB') . ": " . oeFormatShortDate($result['DOB_YMD']) . " " . xl('Age') . ": " . getPatientAge($result['DOB_YMD']), ENT_QUOTES) . "'"; ?>);
957 EncounterDateArray=new Array;
958 CalendarCategoryArray=new Array;
959 EncounterIdArray=new Array;
960 Count=0;
961 <?php
962 //Encounter details are stored to javacript as array.
963 $result4 = sqlStatement("SELECT fe.encounter,fe.date,openemr_postcalendar_categories.pc_catname FROM form_encounter AS fe ".
964 " left join openemr_postcalendar_categories on fe.pc_catid=openemr_postcalendar_categories.pc_catid WHERE fe.pid = ? order by fe.date desc", array($pid));
965 if(sqlNumRows($result4)>0)
966 while($rowresult4 = sqlFetchArray($result4))
969 EncounterIdArray[Count]='<?php echo htmlspecialchars($rowresult4['encounter'], ENT_QUOTES); ?>';
970 EncounterDateArray[Count]='<?php echo htmlspecialchars(oeFormatShortDate(date("Y-m-d", strtotime($rowresult4['date']))), ENT_QUOTES); ?>';
971 CalendarCategoryArray[Count]='<?php echo htmlspecialchars( xl_appt_category($rowresult4['pc_catname']), ENT_QUOTES); ?>';
972 Count++;
973 <?php
976 top.window.parent.left_nav.setPatientEncounter(EncounterIdArray,EncounterDateArray,CalendarCategoryArray);
977 parent.left_nav.setRadio(window.name, 'dem');
978 </script>
979 <?php } ?>
981 <?php if (false && $GLOBALS['athletic_team']) { ?>
982 <script language='JavaScript'>
983 Calendar.setup({inputField:"form_userdate1", ifFormat:"%Y-%m-%d", button:"img_userdate1"});
984 </script>
985 <?php } ?>
987 </body>
988 </html>