6 * LICENSE: This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
18 * @author Brady Miller <brady@sparmy.com>
19 * @link http://www.open-emr.org
22 $fake_register_globals=false;
23 $sanitize_all_escapes=true;
25 require_once(dirname(__file__
)."/../globals.php");
26 require_once("$srcdir/forms.inc");
27 require_once("$srcdir/billing.inc");
28 require_once("$srcdir/patient.inc");
29 require_once("$srcdir/report.inc");
30 require_once("$srcdir/classes/Document.class.php");
31 require_once("$srcdir/classes/Note.class.php");
32 require_once("$srcdir/formatting.inc.php");
34 $startdate = $enddate = "";
35 if(empty($_POST['start']) ||
empty($_POST['end'])) {
36 // set some default dates
37 $startdate = date('Y-m-d', (time() - 30*24*60*60));
38 $enddate = date('Y-m-d', time());
42 $startdate = $_POST['start'];
43 $enddate = $_POST['end'];
49 <?php
html_header_show();?
>
51 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
59 page
-break-after
: always
;
64 #superbill_description {
80 #superbill_description {
85 border
: 2px dashed black
;
91 #superbill_description {
94 #superbill_startingdate {
97 #superbill_endingdate {
101 #superbill_patientdata {
103 #superbill_patientdata h1 {
109 background
-color
: #eee;
110 border
: 1px solid black
;
112 #superbill_insurancedata {
115 #superbill_insurancedata h1 {
121 background
-color
: #eee;
122 border
: 1px solid black
;
124 #superbill_insurancedata h2 {
130 background
-color
: #eee;
132 #superbill_billingdata {
135 #superbill_billingdata h1 {
141 background
-color
: #eee;
142 border
: 1px solid black
;
144 #superbill_signature {
152 <body
class="body_top">
154 <span
class='title'><?php
echo xlt('Reports'); ?
> - <?php
echo xlt('Superbill'); ?
></span
>
156 <div id
="superbill_description" class='text'>
157 <?php
echo xlt('Superbills, sometimes referred to as Encounter Forms or Routing Slips, are an essential part of most medical practices.'); ?
>
160 <div id
="report_parameters">
162 <form method
="post" id
='theform' action
="custom_report_range.php">
163 <input type
='hidden' name
='form_refresh' id
='form_refresh' value
=''/>
167 <div style
='float:left'>
172 <?php
echo xlt('Start Date'); ?
>:
175 <input type
='text' name
='start' id
="form_from_date" size
='10' value
='<?php echo attr($startdate) ?>'
176 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
177 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
178 id
='img_from_date' border
='0' alt
='[?]' style
='cursor:pointer'
179 title
='<?php echo xla('Click here to choose a date
'); ?>'>
182 <?php
echo xlt('End Date'); ?
>:
185 <input type
='text' name
='end' id
="form_to_date" size
='10' value
='<?php echo attr($enddate) ?>'
186 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
187 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
188 id
='img_to_date' border
='0' alt
='[?]' style
='cursor:pointer'
189 title
='<?php echo xla('Click here to choose a date
'); ?>'>
197 <td align
='left' valign
='middle' height
="100%">
198 <table style
='border-left:1px solid; width:100%; height:100%' >
201 <div style
='margin-left:15px'>
202 <a href
='#' class='css_button' onclick
='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
204 <?php
echo xlt('Submit'); ?
>
208 <?php
if ($_POST['form_refresh']) { ?
>
209 <a href
='#' class='css_button' onclick
='window.print()'>
211 <?php
echo xlt('Print'); ?
>
222 </div
> <!-- end of parameters
-->
226 <div id
="superbill_results">
229 if( !(empty($_POST['start']) ||
empty($_POST['end']))) {
230 $sql = "select * from facility where billing_location = 1";
231 $db = $GLOBALS['adodb']['db'];
232 $results = $db->Execute($sql);
234 if (!$results->EOF
) {
235 $facility = $results->fields
;
238 <h2
><?php
text($facility['name'])?
></h2
>
239 <?php
text($facility['street'])?
><br
>
240 <?php
text($facility['city'])?
>, <?php
text($facility['state'])?
> <?php
text($facility['postal_code'])?
><br
>
246 $res = sqlStatement("select * from forms where " .
247 "form_name = 'New Patient Encounter' and " .
248 "date between ? and ? " .
249 "order by date DESC", array($startdate,$enddate) );
250 while($result = sqlFetchArray($res)) {
251 if ($result{"form_name"} == "New Patient Encounter") {
252 $newpatient[] = $result{"form_id"}.":".$result{"encounter"};
253 $pids[] = $result{"pid"};
258 function postToGet($newpatient, $pids) {
260 $serialnewpatient = serialize($newpatient);
261 $serialpids = serialize($pids);
262 $getstring = "newpatient=".urlencode($serialnewpatient)."&pids=".urlencode($serialpids);
268 if(empty($newpatient)){ $newpatient = array(); }
269 foreach($newpatient as $patient){
271 $inclookupres = sqlStatement("select distinct formdir from forms where pid='".$pids[$iCounter]."'");
272 while($result = sqlFetchArray($inclookupres)) {
273 include_once("{$GLOBALS['incdir']}/forms/" . $result{"formdir"} . "/report.php");
277 print "<div id='superbill_patientdata'>";
278 print "<h1>".xlt('Patient Data').":</h1>";
279 printRecDataOne($patient_data_array, getRecPatientData ($pids[$iCounter]), $N);
282 print "<div id='superbill_insurancedata'>";
283 print "<h1>".xlt('Insurance Data').":</h1>";
284 print "<h2>".xlt('Primary').":</h2>";
285 printRecDataOne($insurance_data_array, getRecInsuranceData ($pids[$iCounter],"primary"), $N);
286 print "<h2>".xlt('Secondary').":</h2>";
287 printRecDataOne($insurance_data_array, getRecInsuranceData ($pids[$iCounter],"secondary"), $N);
288 print "<h2>".xlt('Tertiary').":</h2>";
289 printRecDataOne($insurance_data_array, getRecInsuranceData ($pids[$iCounter],"tertiary"), $N);
292 print "<div id='superbill_billingdata'>";
293 print "<h1>".xlt('Billing Information').":</h1>";
294 if (count($patient) > 0) {
296 echo "<table width='100%'>";
298 echo "<td class='bold' width='10%'>".xlt('Date')."</td>";
299 echo "<td class='bold' width='20%'>".xlt('Provider')."</td>";
300 echo "<td class='bold' width='40%'>".xlt('Code')."</td>";
301 echo "<td class='bold' width='10%'>".xlt('Fee')."</td></tr>\n";
304 //foreach ($patient as $be) {
306 $ta = split(":",$patient);
307 $billing = getPatientBillingEncounter($pids[$iCounter],$ta[1]);
309 $billings[] = $billing;
310 foreach ($billing as $b) {
311 // grab the date to reformat it in the output
312 $bdate = strtotime($b['date']);
315 echo "<td class='text' style='font-size: 0.8em'>" . oeFormatShortDate(date("Y-m-d",$bdate)) . "<BR>" . date("h:i a", $bdate) . "</td>";
316 echo "<td class='text'>" . text($b['provider_name']) . "</td>";
317 echo "<td class='text'>";
318 echo text($b['code_type']) . ":\t" . text($b['code']) . " ". text($b['modifier']) . " " . text($b['code_text']) . " ";
320 echo "<td class='text'>";
321 echo oeFormatMoney($b['fee']);
325 if ($b['code_type'] == "COPAY") {
326 $copays +
= $b['fee'];
330 echo "<tr><td> </td></tr>";
331 echo "<tr><td class='bold' colspan=3 style='text-align:right'>".xlt('Sub-Total')."</td><td class='text'>" . oeFormatMoney($total +
abs($copays)) . "</td></tr>";
332 echo "<tr><td class='bold' colspan=3 style='text-align:right'>".xlt('Paid')."</td><td class='text'>" . oeFormatMoney(abs($copays)) . "</td></tr>";
333 echo "<tr><td class='bold' colspan=3 style='text-align:right'>".xlt('Total')."</td><td class='text'>" . oeFormatMoney($total) . "</td></tr>";
336 //print_r($billings);
342 print "<br/><br/>".xlt('Physician Signature').": _______________________________________________";
343 print "<hr class='pagebreak' />";
351 <!-- stuff
for the popup calendar
-->
352 <style type
="text/css">@import
url(../../library
/dynarch_calendar
.css
);</style
>
353 <script type
="text/javascript" src
="../../library/dynarch_calendar.js"></script
>
354 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
355 <script type
="text/javascript" src
="../../library/dynarch_calendar_setup.js"></script
>
356 <script type
="text/javascript" src
="../../library/js/jquery.1.3.2.js"></script
>
358 <script language
="Javascript">
359 Calendar
.setup({inputField
:"form_from_date", ifFormat
:"%Y-%m-%d", button
:"img_from_date"});
360 Calendar
.setup({inputField
:"form_to_date", ifFormat
:"%Y-%m-%d", button
:"img_to_date"});