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
>Patient Insurance Distribution
</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
>Patient Insurance Distribution
</h2
>
37 <form name
='theform' method
='post' action
='insurance_allocation_report.php'>
39 <table border
='0' cellpadding
='3'>
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
="Click here to choose a date"
48 ><img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22' border
='0'></a
>
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
="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
='Refresh'>
67 <table border
='0' cellpadding
='1' cellspacing
='2' width
='98%'>
69 <tr bgcolor
="#dddddd">
73 <td
class='dehead' align
='right'>
76 <td
class='dehead' align
='right'>
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 billing.pid, insurance_companies.name " .
87 "LEFT OUTER JOIN insurance_data ON " .
88 "insurance_data.pid = billing.pid AND " .
89 "insurance_data.type = 'primary' " .
90 "LEFT OUTER JOIN insurance_companies ON " .
91 "insurance_companies.id = insurance_data.provider " .
93 "billing.date >= '$from_date' AND " .
94 "billing.date <= '$to_date' " .
95 "ORDER BY insurance_companies.name, billing.pid";
97 // echo "<!-- $query -->\n"; // debugging
98 $res = sqlStatement($query);
101 while ($row = sqlFetchArray($res)) {
102 // echo "<!-- " . $row['name'] . " / " . $row['pid'] . " -->\n"; // debugging
103 $plan = $row['name'] ?
$row['name'] : '-- No Insurance --';
108 while (list($key, $val) = each($insarr)) {
114 <td
class='detail' align
='right'>
117 <td
class='detail' align
='right'>
118 <?
printf("%.1f", $val * 100 / $inscount) ?
>