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 require_once(dirname(__file__
)."/../globals.php");
8 require_once("$srcdir/forms.inc");
9 require_once("$srcdir/billing.inc");
10 require_once("$srcdir/patient.inc");
11 require_once("$srcdir/report.inc");
12 require_once("$srcdir/classes/Document.class.php");
13 require_once("$srcdir/classes/Note.class.php");
14 require_once("$srcdir/formatting.inc.php");
16 $startdate = $enddate = "";
17 if(empty($_POST['start']) ||
empty($_POST['end'])) {
18 // set some default dates
19 $startdate = date('Y-m-d', (time() - 30*24*60*60));
20 $enddate = date('Y-m-d', time());
24 $startdate = $_POST['start'];
25 $enddate = $_POST['end'];
31 <?php
html_header_show();?
>
33 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
41 page
-break-after
: always
;
46 #superbill_description {
62 #superbill_description {
67 border
: 2px dashed black
;
73 #superbill_description {
76 #superbill_startingdate {
79 #superbill_endingdate {
83 #superbill_patientdata {
85 #superbill_patientdata h1 {
91 background
-color
: #eee;
92 border
: 1px solid black
;
94 #superbill_insurancedata {
97 #superbill_insurancedata h1 {
103 background
-color
: #eee;
104 border
: 1px solid black
;
106 #superbill_insurancedata h2 {
112 background
-color
: #eee;
114 #superbill_billingdata {
117 #superbill_billingdata h1 {
123 background
-color
: #eee;
124 border
: 1px solid black
;
126 #superbill_signature {
134 <body
class="body_top">
136 <span
class='title'><?php
xl('Reports','e'); ?
> - <?php
xl('Superbill','e'); ?
></span
>
138 <div id
="superbill_description" class='text'>
139 <?php
xl('Superbills, sometimes referred to as Encounter Forms or Routing Slips, are an essential part of most medical practices.','e'); ?
>
142 <div id
="report_parameters">
144 <form method
="post" id
='theform' action
="custom_report_range.php">
145 <input type
='hidden' name
='form_refresh' id
='form_refresh' value
=''/>
149 <div style
='float:left'>
154 <?php
xl('Start Date','e'); ?
>:
157 <input type
='text' name
='start' id
="form_from_date" size
='10' value
='<?php echo $startdate ?>'
158 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
159 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
160 id
='img_from_date' border
='0' alt
='[?]' style
='cursor:pointer'
161 title
='<?php xl('Click here to choose a date
','e
'); ?>'>
164 <?php
xl('End Date','e'); ?
>:
167 <input type
='text' name
='end' id
="form_to_date" size
='10' value
='<?php echo $enddate ?>'
168 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
169 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
170 id
='img_to_date' border
='0' alt
='[?]' style
='cursor:pointer'
171 title
='<?php xl('Click here to choose a date
','e
'); ?>'>
179 <td align
='left' valign
='middle' height
="100%">
180 <table style
='border-left:1px solid; width:100%; height:100%' >
183 <div style
='margin-left:15px'>
184 <a href
='#' class='css_button' onclick
='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
186 <?php
xl('Submit','e'); ?
>
190 <?php
if ($_POST['form_refresh']) { ?
>
191 <a href
='#' class='css_button' onclick
='window.print()'>
193 <?php
xl('Print','e'); ?
>
204 </div
> <!-- end of parameters
-->
208 <div id
="superbill_results">
211 if( !(empty($_POST['start']) ||
empty($_POST['end']))) {
212 $sql = "select * from facility where billing_location = 1";
213 $db = $GLOBALS['adodb']['db'];
214 $results = $db->Execute($sql);
216 if (!$results->EOF
) {
217 $facility = $results->fields
;
220 <h2
><?php
$facility['name']?
></h2
>
221 <?php
$facility['street']?
><br
>
222 <?php
$facility['city']?
>, <?php
$facility['state']?
> <?php
$facility['postal_code']?
><br
>
228 $res = sqlStatement("select * from forms where " .
229 "form_name = 'New Patient Encounter' and " .
230 "date between '$startdate' and '$enddate' " .
231 "order by date DESC");
232 while($result = sqlFetchArray($res)) {
233 if ($result{"form_name"} == "New Patient Encounter") {
234 $newpatient[] = $result{"form_id"}.":".$result{"encounter"};
235 $pids[] = $result{"pid"};
240 function postToGet($newpatient, $pids) {
242 $serialnewpatient = serialize($newpatient);
243 $serialpids = serialize($pids);
244 $getstring = "newpatient=".urlencode($serialnewpatient)."&pids=".urlencode($serialpids);
250 if(empty($newpatient)){ $newpatient = array(); }
251 foreach($newpatient as $patient){
253 $inclookupres = sqlStatement("select distinct formdir from forms where pid='".$pids[$iCounter]."'");
254 while($result = sqlFetchArray($inclookupres)) {
255 include_once("{$GLOBALS['incdir']}/forms/" . $result{"formdir"} . "/report.php");
259 print "<div id='superbill_patientdata'>";
260 print "<h1>".xl('Patient Data').":</h1>";
261 printRecDataOne($patient_data_array, getRecPatientData ($pids[$iCounter]), $N);
264 print "<div id='superbill_insurancedata'>";
265 print "<h1>".xl('Insurance Data').":</h1>";
266 print "<h2>".xl('Primary').":</h2>";
267 printRecDataOne($insurance_data_array, getRecInsuranceData ($pids[$iCounter],"primary"), $N);
268 print "<h2>".xl('Secondary').":</h2>";
269 printRecDataOne($insurance_data_array, getRecInsuranceData ($pids[$iCounter],"secondary"), $N);
270 print "<h2>".xl('Tertiary').":</h2>";
271 printRecDataOne($insurance_data_array, getRecInsuranceData ($pids[$iCounter],"tertiary"), $N);
274 print "<div id='superbill_billingdata'>";
275 print "<h1>".xl('Billing Information').":</h1>";
276 if (count($patient) > 0) {
278 echo "<table width='100%'>";
280 echo "<td class='bold' width='10%'>".xl('Date')."</td>";
281 echo "<td class='bold' width='20%'>".xl('Provider')."</td>";
282 echo "<td class='bold' width='40%'>".xl('Code')."</td>";
283 echo "<td class='bold' width='10%'>".xl('Fee')."</td></tr>\n";
286 //foreach ($patient as $be) {
288 $ta = split(":",$patient);
289 $billing = getPatientBillingEncounter($pids[$iCounter],$ta[1]);
291 $billings[] = $billing;
292 foreach ($billing as $b) {
293 // grab the date to reformat it in the output
294 $bdate = strtotime($b['date']);
297 echo "<td class='text' style='font-size: 0.8em'>" . oeFormatShortDate(date("Y-m-d",$bdate)) . "<BR>" . date("h:i a", $bdate) . "</td>";
298 echo "<td class='text'>" . $b['provider_name'] . "</td>";
299 echo "<td class='text'>";
300 echo $b['code_type'] . ":\t" . $b['code'] . " ". $b['modifier'] . " " . $b['code_text'] . " ";
302 echo "<td class='text'>";
303 echo oeFormatMoney($b['fee']);
307 if ($b['code_type'] == "COPAY") {
308 $copays +
= $b['fee'];
312 echo "<tr><td> </td></tr>";
313 echo "<tr><td class='bold' colspan=3 style='text-align:right'>".xl('Sub-Total')."</td><td class='text'>" . oeFormatMoney($total +
abs($copays)) . "</td></tr>";
314 echo "<tr><td class='bold' colspan=3 style='text-align:right'>".xl('Paid')."</td><td class='text'>" . oeFormatMoney(abs($copays)) . "</td></tr>";
315 echo "<tr><td class='bold' colspan=3 style='text-align:right'>".xl('Total')."</td><td class='text'>" . oeFormatMoney($total) . "</td></tr>";
318 //print_r($billings);
324 print "<br/><br/>".xl('Physician Signature').": _______________________________________________";
325 print "<hr class='pagebreak' />";
333 <!-- stuff
for the popup calendar
-->
334 <style type
="text/css">@import
url(../../library
/dynarch_calendar
.css
);</style
>
335 <script type
="text/javascript" src
="../../library/dynarch_calendar.js"></script
>
336 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
337 <script type
="text/javascript" src
="../../library/dynarch_calendar_setup.js"></script
>
338 <script type
="text/javascript" src
="../../library/js/jquery.1.3.2.js"></script
>
340 <script language
="Javascript">
341 Calendar
.setup({inputField
:"form_from_date", ifFormat
:"%Y-%m-%d", button
:"img_from_date"});
342 Calendar
.setup({inputField
:"form_to_date", ifFormat
:"%Y-%m-%d", button
:"img_to_date"});