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/pnotes.inc");
11 require_once("$srcdir/patient.inc");
12 require_once("$srcdir/report.inc");
13 require_once("$srcdir/classes/Document.class.php");
14 require_once("$srcdir/classes/Note.class.php");
15 require_once("$srcdir/formatting.inc.php");
17 $startdate = $enddate = "";
18 if(empty($_POST['start']) ||
empty($_POST['end'])) {
19 // set some default dates
20 $startdate = date('Y-m-d', (time() - 30*24*60*60));
21 $enddate = date('Y-m-d', time());
25 $startdate = $_POST['start'];
26 $enddate = $_POST['end'];
32 <?php
html_header_show();?
>
34 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
42 page
-break-after
: always
;
47 #superbill_description {
63 #superbill_description {
68 border
: 2px dashed black
;
74 #superbill_description {
77 #superbill_startingdate {
80 #superbill_endingdate {
84 #superbill_patientdata {
86 #superbill_patientdata h1 {
92 background
-color
: #eee;
93 border
: 1px solid black
;
95 #superbill_insurancedata {
98 #superbill_insurancedata h1 {
104 background
-color
: #eee;
105 border
: 1px solid black
;
107 #superbill_insurancedata h2 {
113 background
-color
: #eee;
115 #superbill_billingdata {
118 #superbill_billingdata h1 {
124 background
-color
: #eee;
125 border
: 1px solid black
;
127 #superbill_signature {
135 <body
class="body_top">
137 <span
class='title'><?php
xl('Reports','e'); ?
> - <?php
xl('Superbill','e'); ?
></span
>
139 <div id
="superbill_description" class='text'>
140 <?php
xl('Superbills, sometimes referred to as Encounter Forms or Routing Slips, are an essential part of most medical practices.','e'); ?
>
143 <div id
="report_parameters">
145 <form method
="post" id
='theform' action
="custom_report_range.php">
146 <input type
='hidden' name
='form_refresh' id
='form_refresh' value
=''/>
150 <div style
='float:left'>
155 <?php
xl('Start Date','e'); ?
>:
158 <input type
='text' name
='start' id
="form_from_date" size
='10' value
='<?php echo $startdate ?>'
159 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
160 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
161 id
='img_from_date' border
='0' alt
='[?]' style
='cursor:pointer'
162 title
='<?php xl('Click here to choose a date
','e
'); ?>'>
165 <?php
xl('End Date','e'); ?
>:
168 <input type
='text' name
='end' id
="form_to_date" size
='10' value
='<?php echo $enddate ?>'
169 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
170 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
171 id
='img_to_date' border
='0' alt
='[?]' style
='cursor:pointer'
172 title
='<?php xl('Click here to choose a date
','e
'); ?>'>
180 <td align
='left' valign
='middle' height
="100%">
181 <table style
='border-left:1px solid; width:100%; height:100%' >
184 <div style
='margin-left:15px'>
185 <a href
='#' class='css_button' onclick
='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
187 <?php
xl('Submit','e'); ?
>
191 <?php
if ($_POST['form_refresh']) { ?
>
192 <a href
='#' class='css_button' onclick
='window.print()'>
194 <?php
xl('Print','e'); ?
>
205 </div
> <!-- end of parameters
-->
209 <div id
="superbill_results">
212 if( !(empty($_POST['start']) ||
empty($_POST['end']))) {
213 $sql = "select * from facility where billing_location = 1";
214 $db = $GLOBALS['adodb']['db'];
215 $results = $db->Execute($sql);
217 if (!$results->EOF
) {
218 $facility = $results->fields
;
221 <h2
><?php
$facility['name']?
></h2
>
222 <?php
$facility['street']?
><br
>
223 <?php
$facility['city']?
>, <?php
$facility['state']?
> <?php
$facility['postal_code']?
><br
>
229 $res = sqlStatement("select * from forms where " .
230 "form_name = 'New Patient Encounter' and " .
231 "date between '$startdate' and '$enddate' " .
232 "order by date DESC");
233 while($result = sqlFetchArray($res)) {
234 if ($result{"form_name"} == "New Patient Encounter") {
235 $newpatient[] = $result{"form_id"}.":".$result{"encounter"};
236 $pids[] = $result{"pid"};
241 function postToGet($newpatient, $pids) {
243 $serialnewpatient = serialize($newpatient);
244 $serialpids = serialize($pids);
245 $getstring = "newpatient=".urlencode($serialnewpatient)."&pids=".urlencode($serialpids);
251 if(empty($newpatient)){ $newpatient = array(); }
252 foreach($newpatient as $patient){
254 $inclookupres = sqlStatement("select distinct formdir from forms where pid='".$pids[$iCounter]."'");
255 while($result = sqlFetchArray($inclookupres)) {
256 include_once("{$GLOBALS['incdir']}/forms/" . $result{"formdir"} . "/report.php");
260 print "<div id='superbill_patientdata'>";
261 print "<h1>".xl('Patient Data').":</h1>";
262 printRecDataOne($patient_data_array, getRecPatientData ($pids[$iCounter]), $N);
265 print "<div id='superbill_insurancedata'>";
266 print "<h1>".xl('Insurance Data').":</h1>";
267 print "<h2>".xl('Primary').":</h2>";
268 printRecDataOne($insurance_data_array, getRecInsuranceData ($pids[$iCounter],"primary"), $N);
269 print "<h2>".xl('Secondary').":</h2>";
270 printRecDataOne($insurance_data_array, getRecInsuranceData ($pids[$iCounter],"secondary"), $N);
271 print "<h2>".xl('Tertiary').":</h2>";
272 printRecDataOne($insurance_data_array, getRecInsuranceData ($pids[$iCounter],"tertiary"), $N);
275 print "<div id='superbill_billingdata'>";
276 print "<h1>".xl('Billing Information').":</h1>";
277 if (count($patient) > 0) {
279 echo "<table width='100%'>";
281 echo "<td class='bold' width='10%'>".xl('Date')."</td>";
282 echo "<td class='bold' width='20%'>".xl('Provider')."</td>";
283 echo "<td class='bold' width='40%'>".xl('Code')."</td>";
284 echo "<td class='bold' width='10%'>".xl('Fee')."</td></tr>\n";
287 //foreach ($patient as $be) {
289 $ta = split(":",$patient);
290 $billing = getPatientBillingEncounter($pids[$iCounter],$ta[1]);
292 $billings[] = $billing;
293 foreach ($billing as $b) {
294 // grab the date to reformat it in the output
295 $bdate = strtotime($b['date']);
298 echo "<td class='text' style='font-size: 0.8em'>" . oeFormatShortDate(date("Y-m-d",$bdate)) . "<BR>" . date("h:i a", $bdate) . "</td>";
299 echo "<td class='text'>" . $b['provider_name'] . "</td>";
300 echo "<td class='text'>";
301 echo $b['code_type'] . ":\t" . $b['code'] . " ". $b['modifier'] . " " . $b['code_text'] . " ";
303 echo "<td class='text'>";
304 echo oeFormatMoney($b['fee']);
308 if ($b['code_type'] == "COPAY") {
309 $copays +
= $b['fee'];
313 echo "<tr><td> </td></tr>";
314 echo "<tr><td class='bold' colspan=3 style='text-align:right'>".xl('Sub-Total')."</td><td class='text'>" . oeFormatMoney($total +
abs($copays)) . "</td></tr>";
315 echo "<tr><td class='bold' colspan=3 style='text-align:right'>".xl('Paid')."</td><td class='text'>" . oeFormatMoney(abs($copays)) . "</td></tr>";
316 echo "<tr><td class='bold' colspan=3 style='text-align:right'>".xl('Total')."</td><td class='text'>" . oeFormatMoney($total) . "</td></tr>";
319 //print_r($billings);
325 print "<br/><br/>".xl('Physician Signature').": _______________________________________________";
326 print "<hr class='pagebreak' />";
334 <!-- stuff
for the popup calendar
-->
335 <style type
="text/css">@import
url(../../library
/dynarch_calendar
.css
);</style
>
336 <script type
="text/javascript" src
="../../library/dynarch_calendar.js"></script
>
337 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
338 <script type
="text/javascript" src
="../../library/dynarch_calendar_setup.js"></script
>
339 <script type
="text/javascript" src
="../../library/js/jquery.1.3.2.js"></script
>
341 <script language
="Javascript">
342 Calendar
.setup({inputField
:"form_from_date", ifFormat
:"%Y-%m-%d", button
:"img_from_date"});
343 Calendar
.setup({inputField
:"form_to_date", ifFormat
:"%Y-%m-%d", button
:"img_to_date"});