2 // This module shows relative insurance usage by unique patients
3 // that are seen within a given time period. Each patient that had
4 // a visit is counted only once, regardless of how many visits.
6 include_once("../globals.php");
7 include_once("../../library/patient.inc");
8 include_once("../../library/acl.inc");
10 // Might want something different here.
12 // if (! acl_check('acct', 'rep')) die("Unauthorized access.");
14 $from_date = fixDate($_POST['form_from_date']);
15 $to_date = fixDate($_POST['form_to_date'], date('Y-m-d'));
19 <title
><?
xl('Patient Insurance Distribution','e'); ?
></title
>
20 <script type
="text/javascript" src
="../../library/overlib_mini.js"></script
>
21 <script type
="text/javascript" src
="../../library/calendar.js"></script
>
22 <script type
="text/javascript" src
="../../library/textformat.js"></script
>
23 <script language
="JavaScript">
24 var mypcc
= '<? echo $GLOBALS['phone_country_code
'] ?>';
28 <body leftmargin
='0' topmargin
='0' marginwidth
='0' marginheight
='0'>
30 <!-- Required
for the popup date selectors
-->
31 <div id
="overDiv" style
="position:absolute; visibility:hidden; z-index:1000;"></div
>
35 <h2
><?
xl('Patient Insurance Distribution','e'); ?
></h2
>
37 <form name
='theform' method
='post' action
='insurance_allocation_report.php'>
39 <table border
='0' cellpadding
='3'>
43 <?
xl('From','e'); ?
>:
44 <input type
='text' name
='form_from_date' size
='10' value
='<? echo $from_date ?>'
45 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
46 <a href
="javascript:show_calendar('theform.form_from_date')"
47 title
=".xl('Click here to choose a date')"
48 ><img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22' border
='0'></a
>
49  
;<?
xl('To','e'); ?
>:
50 <input type
='text' name
='form_to_date' size
='10' value
='<? echo $to_date ?>'
51 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
52 <a href
="javascript:show_calendar('theform.form_to_date')"
53 title
=".xl('Click here to choose a date')"
54 ><img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22' border
='0'></a
>
56 <input type
='submit' name
='form_refresh' value
=<?
xl('Refresh','e'); ?
>>
67 <table border
='0' cellpadding
='1' cellspacing
='2' width
='98%'>
69 <tr bgcolor
="#dddddd">
71 <?
xl('Primary Insurance','e'); ?
>
73 <td
class='dehead' align
='right'>
74 <?
xl('Patients','e'); ?
>
76 <td
class='dehead' align
='right'>
77 <?
xl('Percent','e'); ?
>
81 if ($_POST['form_refresh']) {
82 $from_date = fixDate($_POST['form_from_date']);
83 $to_date = fixDate($_POST['form_to_date'], date('Y-m-d'));
85 $query = "SELECT DISTINCT c.name, b.pid, i.date " .
86 "FROM billing AS b " .
87 "LEFT OUTER JOIN insurance_data AS i ON " .
88 "i.pid = b.pid AND " .
89 "i.type = 'primary' AND " .
91 "LEFT OUTER JOIN insurance_companies AS c ON " .
92 "c.id = i.provider " .
94 "b.date >= '$from_date' AND " .
95 "b.date <= '$to_date' " .
96 "ORDER BY c.name ASC, b.pid ASC, i.date DESC";
98 // echo "<!-- $query -->\n"; // debugging
99 $res = sqlStatement($query);
104 while ($row = sqlFetchArray($res)) {
105 // echo "<!-- " . $row['name'] . " / " . $row['pid'] . " -->\n"; // debugging
106 $plan = $row['name'] ?
$row['name'] : '-- No Insurance --';
107 if (strcmp($plan, $prevplan) == 0 && $row['pid'] == $prevpid) continue;
109 $prevpid = $row['pid'];
114 while (list($key, $val) = each($insarr)) {
120 <td
class='detail' align
='right'>
123 <td
class='detail' align
='right'>
124 <?
printf("%.1f", $val * 100 / $inscount) ?
>