Some further cleanup for chartable LBF forms.
[openemr.git] / interface / patient_file / summary / demographics.php
blobb86e2a6dd2e273ea05701bca08b9fb9757928520
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;
108 // Determine if the Vitals form is in use for this site.
109 $tmp = sqlQuery("SELECT count(*) AS count FROM registry WHERE " .
110 "directory = 'vitals' AND state = 1");
111 $vitals_is_registered = $tmp['count'];
113 <html>
115 <head>
116 <?php html_header_show();?>
117 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
118 <link rel="stylesheet" type="text/css" href="../../../library/js/fancybox/jquery.fancybox-1.2.6.css" media="screen" />
119 <style type="text/css">@import url(../../../library/dynarch_calendar.css);</style>
120 <script type="text/javascript" src="../../../library/textformat.js"></script>
121 <script type="text/javascript" src="../../../library/dynarch_calendar.js"></script>
122 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
123 <script type="text/javascript" src="../../../library/dynarch_calendar_setup.js"></script>
124 <script type="text/javascript" src="../../../library/dialog.js"></script>
125 <script type="text/javascript" src="../../../library/js/jquery.1.3.2.js"></script>
126 <script type="text/javascript" src="../../../library/js/common.js"></script>
127 <script type="text/javascript" src="../../../library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
128 <script type="text/javascript" language="JavaScript">
129 //Visolve - sync the radio buttons - Start
130 if((top.window.parent) && (parent.window)){
131 var wname = top.window.parent.left_nav;
132 wname.syncRadios();
133 wname.setRadio(parent.window.name, "dem");
135 //Visolve - sync the radio buttons - End
137 var mypcc = '<?php echo htmlspecialchars($GLOBALS['phone_country_code'],ENT_QUOTES); ?>';
139 function oldEvt(eventid) {
140 dlgopen('../../main/calendar/add_edit_event.php?eid=' + eventid, '_blank', 550, 270);
143 function advdirconfigure() {
144 dlgopen('advancedirectives.php', '_blank', 500, 450);
147 function refreshme() {
148 top.restoreSession();
149 location.reload();
152 // Process click on Delete link.
153 function deleteme() {
154 dlgopen('../deleter.php?patient=<?php echo htmlspecialchars($pid,ENT_QUOTES); ?>', '_blank', 500, 450);
155 return false;
158 // Called by the deleteme.php window on a successful delete.
159 function imdeleted() {
160 <?php if ($GLOBALS['concurrent_layout']) { ?>
161 parent.left_nav.clearPatient();
162 <?php } else { ?>
163 top.restoreSession();
164 top.location.href = '../main/main_screen.php';
165 <?php } ?>
168 function validate() {
169 var f = document.forms[0];
170 <?php
171 if ($GLOBALS['athletic_team']) {
172 echo " if (f.form_userdate1.value != f.form_original_userdate1.value) {\n";
173 $irow = sqlQuery("SELECT id, title FROM lists WHERE " .
174 "pid = ? AND enddate IS NULL ORDER BY begdate DESC LIMIT 1", array($pid));
175 if (!empty($irow)) {
177 if (confirm('Do you wish to also set this new return date in the issue titled "<?php echo htmlspecialchars($irow['title'],ENT_QUOTES); ?>"?')) {
178 f.form_issue_id.value = '<?php echo htmlspecialchars($irow['id'],ENT_QUOTES); ?>';
179 } else {
180 alert('OK, you will need to manually update the return date in any affected issue(s).');
182 <?php } else { ?>
183 alert('You have changed the return date but there are no open issues. You probably need to create or modify one.');
184 <?php
185 } // end empty $irow
186 echo " }\n";
187 } // end athletic team
189 return true;
192 function newEvt() {
193 dlgopen('../../main/calendar/add_edit_event.php?patientid=<?php echo htmlspecialchars($pid,ENT_QUOTES); ?>', '_blank', 550, 270);
194 return false;
197 function sendimage(pid, what) {
198 // alert('Not yet implemented.'); return false;
199 dlgopen('../upload_dialog.php?patientid=' + pid + '&file=' + what,
200 '_blank', 500, 400);
201 return false;
204 </script>
206 <script type="text/javascript">
208 function toggleIndicator(target,div) {
210 $mode = $(target).find(".indicator").text();
211 if ( $mode == "<?php echo htmlspecialchars(xl('collapse'),ENT_QUOTES); ?>" ) {
212 $(target).find(".indicator").text( "<?php echo htmlspecialchars(xl('expand'),ENT_QUOTES); ?>" );
213 $("#"+div).hide();
214 $.post( "../../../library/ajax/user_settings.php", { target: div, mode: 0 });
215 } else {
216 $(target).find(".indicator").text( "<?php echo htmlspecialchars(xl('collapse'),ENT_QUOTES); ?>" );
217 $("#"+div).show();
218 $.post( "../../../library/ajax/user_settings.php", { target: div, mode: 1 });
222 $(document).ready(function(){
224 // load divs
225 $("#stats_div").load("stats.php", { 'embeddedScreen' : true }, function() {
226 // (note need to place javascript code here also to get the dynamic link to work)
227 $(".rx_modal").fancybox( {
228 'overlayOpacity' : 0.0,
229 'showCloseButton' : true,
230 'frameHeight' : 500,
231 'frameWidth' : 800,
232 'centerOnScroll' : false,
233 'callbackOnClose' : function() {
234 refreshme();
238 $("#pnotes_ps_expand").load("pnotes_fragment.php");
239 $("#disclosures_ps_expand").load("disc_fragment.php");
241 <?php if ($vitals_is_registered) { ?>
242 // Initialize the Vitals form if it is registered.
243 $("#vitals_ps_expand").load("vitals_fragment.php");
244 <?php } ?>
246 <?php
247 // Initialize for each applicable LBF form.
248 $gfres = sqlStatement("SELECT option_id FROM list_options WHERE " .
249 "list_id = 'lbfnames' AND option_value > 0 ORDER BY seq, title");
250 while($gfrow = sqlFetchArray($gfres)) {
252 $("#<?php echo $gfrow['option_id']; ?>_ps_expand").load("lbf_fragment.php?formname=<?php echo $gfrow['option_id']; ?>");
253 <?php
257 // fancy box
258 enable_modals();
260 tabbify();
262 // modal for dialog boxes
263 $(".large_modal").fancybox( {
264 'overlayOpacity' : 0.0,
265 'showCloseButton' : true,
266 'frameHeight' : 600,
267 'frameWidth' : 1000,
268 'centerOnScroll' : false
271 // modal for image viewer
272 $(".image_modal").fancybox( {
273 'overlayOpacity' : 0.0,
274 'showCloseButton' : true,
275 'centerOnScroll' : false,
276 'autoscale' : true
281 </script>
283 <style type="css/text">
284 #pnotes_ps_expand {
285 height:auto;
286 width:100%;
288 </style>
290 </head>
292 <body class="body_top">
294 <?php
295 $result = getPatientData($pid, "*, DATE_FORMAT(DOB,'%Y-%m-%d') as DOB_YMD");
296 $result2 = getEmployerData($pid);
297 $result3 = getInsuranceData($pid, "primary", "copay, provider, DATE_FORMAT(`date`,'%Y-%m-%d') as effdate");
298 $insco_name = "";
300 if ($result3['provider']) { // Use provider in case there is an ins record w/ unassigned insco
301 $insco_name = getInsuranceProvider($result3['provider']);
304 $thisauth = acl_check('patients', 'demo');
305 if ($thisauth) {
306 if ($result['squad'] && ! acl_check('squads', $result['squad']))
307 $thisauth = 0;
310 if (!$thisauth) {
311 echo "<p>(" . htmlspecialchars(xl('Demographics not authorized'),ENT_NOQUOTES) . ")</p>\n";
312 echo "</body>\n</html>\n";
313 exit();
316 if ($thisauth == 'write') {
317 echo "<table><tr><td><span class='title'>" .
318 htmlspecialchars(getPatientName($pid),ENT_NOQUOTES) .
319 "</span></td>";
321 if (acl_check('admin', 'super')) {
322 echo "<td style='padding-left:1em;'><a class='css_button iframe' href='../deleter.php?patient=" .
323 htmlspecialchars($pid,ENT_QUOTES) . "'>" .
324 "<span>".htmlspecialchars(xl('Delete'),ENT_NOQUOTES).
325 "</span></a></td>";
327 echo "</tr></table>";
330 // Get the document ID of the patient ID card if access to it is wanted here.
331 $idcard_doc_id = false;
332 if ($GLOBALS['patient_id_category_name']) {
333 $idcard_doc_id = get_document_by_catg($pid, $GLOBALS['patient_id_category_name']);
337 <table cellspacing='0' cellpadding='0' border='0'>
338 <tr>
339 <td class="small" colspan='4'>
340 <a href="../history/history.php" onclick='top.restoreSession()'>
341 <?php echo htmlspecialchars(xl('History'),ENT_NOQUOTES); ?></a>
343 <?php //note that we have temporarily removed report screen from the modal view ?>
344 <a href="../report/patient_report.php" onclick='top.restoreSession()'>
345 <?php echo htmlspecialchars(xl('Report'),ENT_NOQUOTES); ?></a>
347 <?php //note that we have temporarily removed document screen from the modal view ?>
348 <a href="../../../controller.php?document&list&patient_id=<?php echo $pid;?>" onclick='top.restoreSession()'>
349 <?php echo htmlspecialchars(xl('Documents'),ENT_NOQUOTES); ?></a>
351 <a href="../transaction/transactions.php" class='iframe large_modal' onclick='top.restoreSession()'>
352 <?php echo htmlspecialchars(xl('Transactions'),ENT_NOQUOTES); ?></a>
353 </td>
354 </tr>
355 </table> <!-- end header -->
357 <div style='margin-top:10px'> <!-- start main content div -->
358 <table border="0" cellspacing="0" cellpadding="0" width="100%">
359 <tr>
360 <td align="left" valign="top">
361 <!-- start left column div -->
362 <div style='float:left; margin-right:20px'>
363 <table cellspacing=0 cellpadding=0>
364 <tr>
365 <td>
366 <?php
367 // Billing expand collapse widget
368 $widgetTitle = xl("Billing");
369 $widgetLabel = "billing";
370 $widgetButtonLabel = xl("Edit");
371 $widgetButtonLink = "return newEvt();";
372 $widgetButtonClass = "";
373 $linkMethod = "javascript";
374 $bodyClass = "notab";
375 $widgetAuth = false;
376 $fixedWidth = true;
377 if ($GLOBALS['force_billing_widget_open']) {
378 $forceExpandAlways = true;
380 else {
381 $forceExpandAlways = false;
383 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
384 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
385 $widgetAuth, $fixedWidth, $forceExpandAlways);
387 <br>
388 <?php
389 if ($GLOBALS['oer_config']['ws_accounting']['enabled']) {
390 // Show current balance and billing note, if any.
391 echo " <div style='margin-left: 10px; margin-right: 10px'>" .
392 "<span class='bold'><font color='#ee6600'>" .
393 htmlspecialchars(xl('Balance Due'),ENT_NOQUOTES) .
394 ": " . htmlspecialchars(oeFormatMoney(get_patient_balance($pid)),ENT_NOQUOTES) .
395 "</font></span><br>";
396 if ($result['genericname2'] == 'Billing') {
397 echo "<span class='bold'><font color='red'>" .
398 htmlspecialchars(xl('Billing Note'),ENT_NOQUOTES) . ":" .
399 htmlspecialchars($result['genericval2'],ENT_NOQUOTES) .
400 "</font></span><br>";
402 if ($result3['provider']) { // Use provider in case there is an ins record w/ unassigned insco
403 echo "<span class='bold'>" .
404 htmlspecialchars(xl('Primary Insurance'),ENT_NOQUOTES) . ': ' . htmlspecialchars($insco_name,ENT_NOQUOTES) .
405 "</span>&nbsp;&nbsp;&nbsp;";
406 if ($result3['copay'] > 0) {
407 echo "<span class='bold'>" .
408 htmlspecialchars(xl('Copay'),ENT_NOQUOTES) . ': ' . htmlspecialchars($result3['copay'],ENT_NOQUOTES) .
409 "</span>&nbsp;&nbsp;&nbsp;";
411 echo "<span class='bold'>" .
412 htmlspecialchars(xl('Effective Date'),ENT_NOQUOTES) . ': ' . htmlspecialchars(oeFormatShortDate($result3['effdate'],ENT_NOQUOTES)) .
413 "</span>";
415 echo "</div><br>";
418 </div> <!-- required for expand_collapse_widget -->
419 </td>
420 </tr>
421 <tr>
422 <td>
423 <?php
424 // Demographics expand collapse widget
425 $widgetTitle = xl("Demographics");
426 $widgetLabel = "demographics";
427 $widgetButtonLabel = xl("Edit");
428 $widgetButtonLink = "demographics_full.php";
429 $widgetButtonClass = "";
430 $linkMethod = "html";
431 $bodyClass = "";
432 $widgetAuth = ($thisauth == "write");
433 $fixedWidth = true;
434 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
435 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
436 $widgetAuth, $fixedWidth);
438 <div id="DEM" >
439 <ul class="tabNav">
440 <?php display_layout_tabs('DEM', $result, $result2); ?>
441 </ul>
442 <div class="tabContainer">
443 <?php display_layout_tabs_data('DEM', $result, $result2); ?>
444 </div>
445 </div>
446 </div> <!-- required for expand_collapse_widget -->
447 </td>
448 </tr>
450 <tr>
451 <td>
452 <?php
453 $insurance_count = 0;
454 foreach (array('primary','secondary','tertiary') as $instype) {
455 $enddate = 'Present';
456 $query = "SELECT * FROM insurance_data WHERE " .
457 "pid = ? AND type = ? " .
458 "ORDER BY date DESC";
459 $res = sqlStatement($query, array($pid, $instype) );
460 while( $row = sqlFetchArray($res) ) {
461 if ($row['provider'] ) $insurance_count++;
465 if ( $insurance_count > 0 ) {
466 // Insurance expand collapse widget
467 $widgetTitle = xl("Insurance");
468 $widgetLabel = "insurance";
469 $widgetButtonLabel = xl("Edit");
470 $widgetButtonLink = "demographics_full.php";
471 $widgetButtonClass = "";
472 $linkMethod = "html";
473 $bodyClass = "";
474 $widgetAuth = ($thisauth == "write");
475 $fixedWidth = true;
476 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
477 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
478 $widgetAuth, $fixedWidth);
480 if ( $insurance_count > 0 ) {
483 <ul class="tabNav"><?php
484 ///////////////////////////////// INSURANCE SECTION
485 $first = true;
486 foreach (array('primary','secondary','tertiary') as $instype) {
488 $query = "SELECT * FROM insurance_data WHERE " .
489 "pid = ? AND type = ? " .
490 "ORDER BY date DESC";
491 $res = sqlStatement($query, array($pid, $instype) );
493 $enddate = 'Present';
495 while( $row = sqlFetchArray($res) ) {
496 if ($row['provider'] ) {
498 $ins_description = ucfirst($instype);
499 $ins_description = xl($ins_description);
500 $ins_description .= strcmp($enddate, 'Present') != 0 ? " (".xl('Old').")" : "";
502 <li <?php echo $first ? 'class="current"' : '' ?>><a href="/play/javascript-tabbed-navigation/">
503 <?php echo htmlspecialchars($ins_description,ENT_NOQUOTES); ?></a></li>
504 <?php
505 $first = false;
507 $enddate = $row['date'];
510 // Display the eligibility tab
511 echo "<li><a href='/play/javascript-tabbed-navigation/'>" .
512 htmlspecialchars( xl('Eligibility'), ENT_NOQUOTES) . "</a></li>";
514 ?></ul><?php
516 } ?>
518 <div class="tabContainer">
519 <?php
520 $first = true;
521 foreach (array('primary','secondary','tertiary') as $instype) {
522 $enddate = 'Present';
524 $query = "SELECT * FROM insurance_data WHERE " .
525 "pid = ? AND type = ? " .
526 "ORDER BY date DESC";
527 $res = sqlStatement($query, array($pid, $instype) );
528 while( $row = sqlFetchArray($res) ) {
529 if ($row['provider'] ) {
531 <div class="tab <?php echo $first ? 'current' : '' ?>">
532 <table border='0' cellpadding='0' width='100%'>
533 <?php
534 $icobj = new InsuranceCompany($row['provider']);
535 $adobj = $icobj->get_address();
536 $insco_name = trim($icobj->get_name());
538 <tr>
539 <td valign='top' colspan='3'>
540 <span class='text'>
541 <?php if (strcmp($enddate, 'Present') != 0) echo htmlspecialchars(xl("Old"),ENT_NOQUOTES)." "; ?>
542 <?php $tempinstype=ucfirst($instype); echo htmlspecialchars(xl($tempinstype.' Insurance'),ENT_NOQUOTES); ?>
543 <?php if (strcmp($row['date'], '0000-00-00') != 0) { ?>
544 <?php echo htmlspecialchars(xl('from','',' ',' ').$row['date'],ENT_NOQUOTES); ?>
545 <?php } ?>
546 <?php echo htmlspecialchars(xl('until','',' ',' '),ENT_NOQUOTES);
547 echo (strcmp($enddate, 'Present') != 0) ? $enddate : htmlspecialchars(xl('Present'),ENT_NOQUOTES); ?>:</span>
548 </td>
549 </tr>
550 <tr>
551 <td valign='top'>
552 <span class='text'>
553 <?php
554 if ($insco_name) {
555 echo htmlspecialchars($insco_name,ENT_NOQUOTES) . '<br>';
556 if (trim($adobj->get_line1())) {
557 echo htmlspecialchars($adobj->get_line1(),ENT_NOQUOTES) . '<br>';
558 echo htmlspecialchars($adobj->get_city() . ', ' . $adobj->get_state() . ' ' . $adobj->get_zip(),ENT_NOQUOTES);
560 } else {
561 echo "<font color='red'><b>".htmlspecialchars(xl('Unassigned'),ENT_NOQUOTES)."</b></font>";
564 <br>
565 <?php echo htmlspecialchars(xl('Policy Number'),ENT_NOQUOTES); ?>:
566 <?php echo htmlspecialchars($row['policy_number'],ENT_NOQUOTES) ?><br>
567 <?php echo htmlspecialchars(xl('Plan Name'),ENT_NOQUOTES); ?>:
568 <?php echo htmlspecialchars($row['plan_name'],ENT_NOQUOTES); ?><br>
569 <?php echo htmlspecialchars(xl('Group Number'),ENT_NOQUOTES); ?>:
570 <?php echo htmlspecialchars($row['group_number'],ENT_NOQUOTES); ?></span>
571 </td>
572 <td valign='top'>
573 <span class='bold'><?php echo htmlspecialchars(xl('Subscriber'),ENT_NOQUOTES); ?>: </span><br>
574 <span class='text'><?php echo htmlspecialchars($row['subscriber_fname'] . ' ' . $row['subscriber_mname'] . ' ' . $row['subscriber_lname'],ENT_NOQUOTES); ?>
575 <?php
576 if ($row['subscriber_relationship'] != "") {
577 echo "(" . htmlspecialchars($row['subscriber_relationship'],ENT_NOQUOTES) . ")";
580 <br>
581 <?php echo htmlspecialchars(xl('S.S.'),ENT_NOQUOTES); ?>:
582 <?php echo htmlspecialchars($row['subscriber_ss'],ENT_NOQUOTES); ?><br>
583 <?php echo htmlspecialchars(xl('D.O.B.'),ENT_NOQUOTES); ?>:
584 <?php if ($row['subscriber_DOB'] != "0000-00-00 00:00:00") echo htmlspecialchars($row['subscriber_DOB'],ENT_NOQUOTES); ?><br>
585 <?php echo htmlspecialchars(xl('Phone'),ENT_NOQUOTES); ?>:
586 <?php echo htmlspecialchars($row['subscriber_phone'],ENT_NOQUOTES); ?>
587 </span>
588 </td>
589 <td valign='top'>
590 <span class='bold'><?php echo htmlspecialchars(xl('Subscriber Address'),ENT_NOQUOTES); ?>: </span><br>
591 <span class='text'><?php echo htmlspecialchars($row['subscriber_street'],ENT_NOQUOTES); ?><br>
592 <?php echo htmlspecialchars($row['subscriber_city'],ENT_NOQUOTES); ?>
593 <?php if($row['subscriber_state'] != "") echo ", "; echo htmlspecialchars($row['subscriber_state'],ENT_NOQUOTES); ?>
594 <?php if($row['subscriber_country'] != "") echo ", "; echo htmlspecialchars($row['subscriber_country'],ENT_NOQUOTES); ?>
595 <?php echo " " . htmlspecialchars($row['subscriber_postal_code'],ENT_NOQUOTES); ?></span>
597 <?php if (trim($row['subscriber_employer'])) { ?>
598 <br><span class='bold'><?php echo htmlspecialchars(xl('Subscriber Employer'),ENT_NOQUOTES); ?>: </span><br>
599 <span class='text'><?php echo htmlspecialchars($row['subscriber_employer'],ENT_NOQUOTES); ?><br>
600 <?php echo htmlspecialchars($row['subscriber_employer_street'],ENT_NOQUOTES); ?><br>
601 <?php echo htmlspecialchars($row['subscriber_employer_city'],ENT_NOQUOTES); ?>
602 <?php if($row['subscriber_employer_city'] != "") echo ", "; echo htmlspecialchars($row['subscriber_employer_state'],ENT_NOQUOTES); ?>
603 <?php if($row['subscriber_employer_country'] != "") echo ", "; echo htmlspecialchars($row['subscriber_employer_country'],ENT_NOQUOTES); ?>
604 <?php echo " " . htmlspecialchars($row['subscriber_employer_postal_code'],ENT_NOQUOTES); ?>
605 </span>
606 <?php } ?>
608 </td>
609 </tr>
610 <tr>
611 <td>
612 <?php if ($row['copay'] != "") { ?>
613 <span class='bold'><?php echo htmlspecialchars(xl('CoPay'),ENT_NOQUOTES); ?>: </span>
614 <span class='text'><?php echo htmlspecialchars($row['copay'],ENT_NOQUOTES); ?></span>
615 <?php } ?>
616 <br>
617 <span class='bold'><?php echo htmlspecialchars(xl('Accept Assignment'),ENT_NOQUOTES); ?>:</span>
618 <span class='text'><?php if($row['accept_assignment'] == "TRUE") echo xl("YES"); ?>
619 <?php if($row['accept_assignment'] == "FALSE") echo xl("NO"); ?></span>
620 </td>
621 <td valign='top'></td>
622 <td valign='top'></td>
623 </tr>
625 </table>
626 </div>
627 <?php
629 } // end if ($row['provider'])
630 $enddate = $row['date'];
631 $first = false;
632 } // end while
633 } // end foreach
635 // Display the eligibility information
636 echo "<div class='tab'>";
637 show_eligibility_information($pid,true);
638 echo "</div>";
640 ///////////////////////////////// END INSURANCE SECTION
642 </div>
644 <?php } // ?>
646 </td>
647 </tr>
649 <tr>
650 <td width='650px'>
652 <?php
653 // Notes expand collapse widget
654 $widgetTitle = xl("Notes");
655 $widgetLabel = "pnotes";
656 $widgetButtonLabel = xl("Edit");
657 $widgetButtonLink = "pnotes_full.php";
658 $widgetButtonClass = "";
659 $linkMethod = "html";
660 $bodyClass = "notab";
661 $widgetAuth = true;
662 $fixedWidth = true;
663 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
664 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
665 $widgetAuth, $fixedWidth);
668 <br/>
669 <div style='margin-left:10px' class='text'><img src='../../pic/ajax-loader.gif'/></div><br/>
670 </div>
671 </td>
672 </tr>
673 <tr>
674 <td width='650px'>
675 <?php
676 // disclosures expand collapse widget
677 $widgetTitle = xl("Disclosures");
678 $widgetLabel = "disclosures";
679 $widgetButtonLabel = xl("Edit");
680 $widgetButtonLink = "disclosure_full.php";
681 $widgetButtonClass = "";
682 $linkMethod = "html";
683 $bodyClass = "notab";
684 $widgetAuth = true;
685 $fixedWidth = true;
686 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
687 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
688 $widgetAuth, $fixedWidth);
691 <br/>
692 <div style='margin-left:10px' class='text'><image src='../../pic/ajax-loader.gif'/></div><br/>
693 </div>
694 </td>
695 </tr>
697 <?php if ($vitals_is_registered) { ?>
698 <tr>
699 <td width='650px'>
700 <?php // vitals expand collapse widget
701 $widgetTitle = xl("Vitals");
702 $widgetLabel = "vitals";
703 $widgetButtonLabel = xl("Trend");
704 $widgetButtonLink = "../encounter/trend_form.php?formname=vitals";
705 $widgetButtonClass = "";
706 $linkMethod = "html";
707 $bodyClass = "notab";
708 // check to see if any vitals exist
709 $existVitals = sqlQuery("SELECT * FROM form_vitals WHERE pid=?", array($pid) );
710 if ($existVitals) {
711 $widgetAuth = true;
713 else {
714 $widgetAuth = false;
716 $fixedWidth = true;
717 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
718 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
719 $widgetAuth, $fixedWidth);
721 <br/>
722 <div style='margin-left:10px' class='text'><image src='../../pic/ajax-loader.gif'/></div><br/>
723 </div>
724 </td>
725 </tr>
726 <?php } // end if ($vitals_is_registered) ?>
728 <?php
729 // This generates a section similar to Vitals for each LBF form that
730 // supports charting. The form ID is used as the "widget label".
732 $gfres = sqlStatement("SELECT option_id, title FROM list_options WHERE " .
733 "list_id = 'lbfnames' AND option_value > 0 ORDER BY seq, title");
734 while($gfrow = sqlFetchArray($gfres)) {
736 <tr>
737 <td width='650px'>
738 <?php // vitals expand collapse widget
739 $vitals_form_id = $gfrow['option_id'];
740 $widgetTitle = $gfrow['title'];
741 $widgetLabel = $vitals_form_id;
742 $widgetButtonLabel = xl("Trend");
743 $widgetButtonLink = "../encounter/trend_form.php?formname=$vitals_form_id";
744 $widgetButtonClass = "";
745 $linkMethod = "html";
746 $bodyClass = "notab";
747 // check to see if any instances exist for this patient
748 $existVitals = sqlQuery(
749 "SELECT * FROM forms WHERE pid = ? AND formdir = ? AND deleted = 0",
750 array($pid, $vitals_form_id));
751 $widgetAuth = $existVitals ? true : false;
752 $fixedWidth = true;
753 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel,
754 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
755 $widgetAuth, $fixedWidth);
757 <br/>
758 <div style='margin-left:10px' class='text'>
759 <image src='../../pic/ajax-loader.gif'/>
760 </div>
761 <br/>
762 </div> <!-- This is required by expand_collapse_widget(). -->
763 </td>
764 </tr>
765 <?php
766 } // end while
769 </table>
771 </div>
772 <!-- end left column div -->
774 <!-- start right column div -->
775 <div class='text'>
776 <table>
777 <tr>
778 <td>
779 <div>
780 <?php
782 // If there is an ID Card or any Photos show the widget
783 $photos = pic_array($pid, $GLOBALS['patient_photo_category_name']);
784 if ($photos or $idcard_doc_id )
786 $widgetTitle = xl("ID Card") . '/' . xl("Photos");
787 $widgetLabel = "photos";
788 $linkMethod = "javascript";
789 $bodyClass = "notab";
790 $widgetAuth = false;
791 $fixedWidth = true;
792 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel ,
793 $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass,
794 $widgetAuth, $fixedWidth);
796 <br />
797 <?php
798 if ($idcard_doc_id) {
799 image_widget($idcard_doc_id, $GLOBALS['patient_id_category_name']);
802 foreach ($photos as $photo_doc_id) {
803 image_widget($photo_doc_id, $GLOBALS['patient_photo_category_name']);
808 <br />
809 </div>
810 <div>
811 <?php
812 // Advance Directives
813 if ($GLOBALS['advance_directives_warning']) {
814 // advance directives expand collapse widget
815 $widgetTitle = xl("Advance Directives");
816 $widgetLabel = "directives";
817 $widgetButtonLabel = xl("Edit");
818 $widgetButtonLink = "return advdirconfigure();";
819 $widgetButtonClass = "";
820 $linkMethod = "javascript";
821 $bodyClass = "summary_item small";
822 $widgetAuth = true;
823 $fixedWidth = false;
824 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
825 $counterFlag = false; //flag to record whether any categories contain ad records
826 $query = "SELECT id FROM categories WHERE name='Advance Directive'";
827 $myrow2 = sqlQuery($query);
828 if ($myrow2) {
829 $parentId = $myrow2['id'];
830 $query = "SELECT id, name FROM categories WHERE parent=?";
831 $resNew1 = sqlStatement($query, array($parentId) );
832 while ($myrows3 = sqlFetchArray($resNew1)) {
833 $categoryId = $myrows3['id'];
834 $nameDoc = $myrows3['name'];
835 $query = "SELECT documents.date, documents.id " .
836 "FROM documents " .
837 "INNER JOIN categories_to_documents " .
838 "ON categories_to_documents.document_id=documents.id " .
839 "WHERE categories_to_documents.category_id=? " .
840 "AND documents.foreign_id=? " .
841 "ORDER BY documents.date DESC";
842 $resNew2 = sqlStatement($query, array($categoryId, $pid) );
843 $limitCounter = 0; // limit to one entry per category
844 while (($myrows4 = sqlFetchArray($resNew2)) && ($limitCounter == 0)) {
845 $dateTimeDoc = $myrows4['date'];
846 // remove time from datetime stamp
847 $tempParse = explode(" ",$dateTimeDoc);
848 $dateDoc = $tempParse[0];
849 $idDoc = $myrows4['id'];
850 echo "<a href='$web_root/controller.php?document&retrieve&patient_id=" .
851 htmlspecialchars($pid,ENT_QUOTES) . "&document_id=" .
852 htmlspecialchars($idDoc,ENT_QUOTES) . "&as_file=true'>" .
853 htmlspecialchars(xl_document_category($nameDoc),ENT_NOQUOTES) . "</a> " .
854 htmlspecialchars($dateDoc,ENT_NOQUOTES);
855 echo "<br>";
856 $limitCounter = $limitCounter + 1;
857 $counterFlag = true;
861 if (!$counterFlag) {
862 echo "&nbsp;&nbsp;" . htmlspecialchars(xl('None'),ENT_NOQUOTES);
863 } ?>
864 </div>
865 <?php } // close advanced dir block
867 // This is a feature for a specific client. -- Rod
868 if ($GLOBALS['cene_specific']) {
869 echo " <br />\n";
871 $imagedir = $GLOBALS['OE_SITE_DIR'] . "/documents/$pid/demographics";
872 $imagepath = "$web_root/sites/" . $_SESSION['site_id'] . "/documents/$pid/demographics";
874 echo " <a href='' onclick=\"return sendimage($pid, 'photo');\" " .
875 "title='Click to attach patient image'>\n";
876 if (is_file("$imagedir/photo.jpg")) {
877 echo " <img src='$imagepath/photo.jpg' /></a>\n";
878 } else {
879 echo " Attach Patient Image</a><br />\n";
881 echo " <br />&nbsp;<br />\n";
883 echo " <a href='' onclick=\"return sendimage($pid, 'fingerprint');\" " .
884 "title='Click to attach fingerprint'>\n";
885 if (is_file("$imagedir/fingerprint.jpg")) {
886 echo " <img src='$imagepath/fingerprint.jpg' /></a>\n";
887 } else {
888 echo " Attach Biometric Fingerprint</a><br />\n";
890 echo " <br />&nbsp;<br />\n";
893 // This stuff only applies to athletic team use of OpenEMR. The client
894 // insisted on being able to quickly change fitness and return date here:
896 if (false && $GLOBALS['athletic_team']) {
897 // blue green yellow red orange
898 $fitcolors = array('#6677ff','#00cc00','#ffff00','#ff3333','#ff8800','#ffeecc','#ffccaa');
899 if (!empty($GLOBALS['fitness_colors'])) $fitcolors = $GLOBALS['fitness_colors'];
900 $fitcolor = $fitcolors[0];
901 $form_fitness = $_POST['form_fitness'];
902 $form_userdate1 = fixDate($_POST['form_userdate1'], '');
903 $form_issue_id = $_POST['form_issue_id'];
904 if ($form_submit) {
905 $returndate = $form_userdate1 ? "'$form_userdate1'" : "NULL";
906 sqlStatement("UPDATE patient_data SET fitness = ?, " .
907 "userdate1 = ? WHERE pid = ?", array($form_fitness, $returndate, $pid) );
908 // Update return date in the designated issue, if requested.
909 if ($form_issue_id) {
910 sqlStatement("UPDATE lists SET returndate = ? WHERE " .
911 "id = ?", array($returndate, $form_issue_id) );
913 } else {
914 $form_fitness = $result['fitness'];
915 if (! $form_fitness) $form_fitness = 1;
916 $form_userdate1 = $result['userdate1'];
918 $fitcolor = $fitcolors[$form_fitness - 1];
919 echo " <form method='post' action='demographics.php' onsubmit='return validate()'>\n";
920 echo " <span class='bold'>Fitness to Play:</span><br />\n";
921 echo " <select name='form_fitness' style='background-color:$fitcolor'>\n";
922 $res = sqlStatement("SELECT * FROM list_options WHERE " .
923 "list_id = 'fitness' ORDER BY seq");
924 while ($row = sqlFetchArray($res)) {
925 $key = $row['option_id'];
926 echo " <option value='" . htmlspecialchars($key,ENT_QUOTES) . "'";
927 if ($key == $form_fitness) echo " selected";
928 echo ">" . htmlspecialchars($row['title'],ENT_NOQUOTES) . "</option>\n";
930 echo " </select>\n";
931 echo " <br /><span class='bold'>Return to Play:</span><br>\n";
932 echo " <input type='text' size='10' name='form_userdate1' id='form_userdate1' " .
933 "value='$form_userdate1' " .
934 "title='" . htmlspecialchars(xl('yyyy-mm-dd Date of return to play'),ENT_QUOTES) . "' " .
935 "onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' />\n" .
936 " <img src='../../pic/show_calendar.gif' align='absbottom' width='24' height='22' " .
937 "id='img_userdate1' border='0' alt='[?]' style='cursor:pointer' " .
938 "title='" . htmlspecialchars(xl('Click here to choose a date'),ENT_QUOTES) . "'>\n";
939 echo " <input type='hidden' name='form_original_userdate1' value='" . htmlspecialchars($form_userdate1,ENT_QUOTES) . "' />\n";
940 echo " <input type='hidden' name='form_issue_id' value='' />\n";
941 echo "<p><input type='submit' name='form_submit' value='Change' /></p>\n";
942 echo " </form>\n";
945 // Show current and upcoming appointments.
946 if (isset($pid) && !$GLOBALS['disable_calendar']) {
947 $query = "SELECT e.pc_eid, e.pc_aid, e.pc_title, e.pc_eventDate, " .
948 "e.pc_startTime, e.pc_hometext, u.fname, u.lname, u.mname, " .
949 "c.pc_catname " .
950 "FROM openemr_postcalendar_events AS e, users AS u, " .
951 "openemr_postcalendar_categories AS c WHERE " .
952 "e.pc_pid = ? AND e.pc_eventDate >= CURRENT_DATE AND " .
953 "u.id = e.pc_aid AND e.pc_catid = c.pc_catid " .
954 "ORDER BY e.pc_eventDate, e.pc_startTime";
955 $res = sqlStatement($query, array($pid) );
957 // appointments expand collapse widget
958 $widgetTitle = xl("Appointments");
959 $widgetLabel = "appointments";
960 $widgetButtonLabel = xl("Add");
961 $widgetButtonLink = "return newEvt();";
962 $widgetButtonClass = "";
963 $linkMethod = "javascript";
964 $bodyClass = "summary_item small";
965 $widgetAuth = (isset($res) && $res != null);
966 $fixedWidth = false;
967 expand_collapse_widget($widgetTitle, $widgetLabel, $widgetButtonLabel , $widgetButtonLink, $widgetButtonClass, $linkMethod, $bodyClass, $widgetAuth, $fixedWidth);
969 $count = 0;
970 while($row = sqlFetchArray($res)) {
971 $count++;
972 $dayname = date("l", strtotime($row['pc_eventDate']));
973 $dispampm = "am";
974 $disphour = substr($row['pc_startTime'], 0, 2) + 0;
975 $dispmin = substr($row['pc_startTime'], 3, 2);
976 if ($disphour >= 12) {
977 $dispampm = "pm";
978 if ($disphour > 12) $disphour -= 12;
980 $etitle = xl('(Click to edit)');
981 if ($row['pc_hometext'] != "") {
982 $etitle = xl('Comments').": ".($row['pc_hometext'])."\r\n".$etitle;
984 echo "<a href='javascript:oldEvt(" . htmlspecialchars($row['pc_eid'],ENT_QUOTES) .
985 ")' title='" . htmlspecialchars($etitle,ENT_QUOTES) . "'>";
986 echo "<b>" . htmlspecialchars(xl($dayname) . ", " . $row['pc_eventDate'],ENT_NOQUOTES) . "</b><br>";
987 echo htmlspecialchars("$disphour:$dispmin " . xl($dispampm) . " " . xl_appt_category($row['pc_catname']),ENT_NOQUOTES) . "<br>\n";
988 echo htmlspecialchars($row['fname'] . " " . $row['lname'],ENT_NOQUOTES) . "</a><br>\n";
990 if (isset($res) && $res != null) {
991 if ( $count < 1 ) { echo "&nbsp;&nbsp;" . htmlspecialchars(xl('None'),ENT_NOQUOTES); }
992 echo "</div>";
996 </div>
998 <div id='stats_div'>
999 <br/>
1000 <div style='margin-left:10px' class='text'><image src='../../pic/ajax-loader.gif'/></div><br/>
1001 </div>
1002 </td>
1003 </tr>
1004 </table>
1006 </div> <!-- end right column div -->
1008 </td>
1010 </tr>
1011 </table>
1013 </div> <!-- end main content div -->
1015 <?php if ($GLOBALS['concurrent_layout'] && $_GET['set_pid']) { ?>
1016 <script language='JavaScript'>
1017 top.window.parent.left_nav.setPatient(<?php echo "'" . htmlspecialchars(($result['fname']) . " " . ($result['lname']),ENT_QUOTES) .
1018 "'," . htmlspecialchars($pid,ENT_QUOTES) . ",'" . htmlspecialchars(($result['pubpid']),ENT_QUOTES) .
1019 "','', ' " . htmlspecialchars(xl('DOB') . ": " . oeFormatShortDate($result['DOB_YMD']) . " " . xl('Age') . ": " . getPatientAge($result['DOB_YMD']), ENT_QUOTES) . "'"; ?>);
1020 EncounterDateArray=new Array;
1021 CalendarCategoryArray=new Array;
1022 EncounterIdArray=new Array;
1023 Count=0;
1024 <?php
1025 //Encounter details are stored to javacript as array.
1026 $result4 = sqlStatement("SELECT fe.encounter,fe.date,openemr_postcalendar_categories.pc_catname FROM form_encounter AS fe ".
1027 " left join openemr_postcalendar_categories on fe.pc_catid=openemr_postcalendar_categories.pc_catid WHERE fe.pid = ? order by fe.date desc", array($pid));
1028 if(sqlNumRows($result4)>0)
1029 while($rowresult4 = sqlFetchArray($result4))
1032 EncounterIdArray[Count]='<?php echo htmlspecialchars($rowresult4['encounter'], ENT_QUOTES); ?>';
1033 EncounterDateArray[Count]='<?php echo htmlspecialchars(oeFormatShortDate(date("Y-m-d", strtotime($rowresult4['date']))), ENT_QUOTES); ?>';
1034 CalendarCategoryArray[Count]='<?php echo htmlspecialchars( xl_appt_category($rowresult4['pc_catname']), ENT_QUOTES); ?>';
1035 Count++;
1036 <?php
1039 top.window.parent.left_nav.setPatientEncounter(EncounterIdArray,EncounterDateArray,CalendarCategoryArray);
1040 parent.left_nav.setRadio(window.name, 'dem');
1041 </script>
1042 <?php } ?>
1044 <?php if (false && $GLOBALS['athletic_team']) { ?>
1045 <script language='JavaScript'>
1046 Calendar.setup({inputField:"form_userdate1", ifFormat:"%Y-%m-%d", button:"img_userdate1"});
1047 </script>
1048 <?php } ?>
1050 </body>
1051 </html>