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'];
45 //Patient related stuff
46 if ($_POST["form_patient"])
47 $form_patient = isset($_POST['form_patient']) ?
$_POST['form_patient'] : '';
48 $form_pid = isset($_POST['form_pid']) ?
$_POST['form_pid'] : '';
49 if ($form_patient == '' ) $form_pid = '';
54 <?php
html_header_show();?
>
56 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
64 page
-break-after
: always
;
69 #superbill_description {
85 #superbill_description {
90 border
: 2px dashed black
;
96 #superbill_description {
99 #superbill_startingdate {
102 #superbill_endingdate {
106 #superbill_patientdata {
108 #superbill_patientdata h1 {
114 background
-color
: #eee;
115 border
: 1px solid black
;
117 #superbill_insurancedata {
120 #superbill_insurancedata h1 {
126 background
-color
: #eee;
127 border
: 1px solid black
;
129 #superbill_insurancedata h2 {
135 background
-color
: #eee;
137 #superbill_billingdata {
140 #superbill_billingdata h1 {
146 background
-color
: #eee;
147 border
: 1px solid black
;
149 #superbill_signature {
154 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js?v=<?php echo $v_js_includes; ?>"></script
>
155 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-3-2/index.js"></script
>
157 <script language
="Javascript">
158 $
(document
).ready(function() {
159 var win
= top
.printLogSetup ? top
: opener
.top
;
160 win
.printLogSetup(document
.getElementById('printbutton'));
163 // CapMinds :: invokes find-patient popup.
164 function sel_patient() {
165 dlgopen('../main/calendar/find_patient_popup.php?pflag=0', '_blank', 500, 400);
168 // CapMinds :: callback by the find-patient popup.
169 function setpatient(pid
, lname
, fname
, dob
) {
170 var f
= document
.theform
;
171 f
.form_patient
.value
= lname +
', ' + fname
;
172 f
.form_pid
.value
= pid
;
178 <body
class="body_top">
180 <span
class='title'><?php
echo xlt('Reports'); ?
> - <?php
echo xlt('Superbill'); ?
></span
>
182 <div id
="superbill_description" class='text'>
183 <?php
echo xlt('Superbills, sometimes referred to as Encounter Forms or Routing Slips, are an essential part of most medical practices.'); ?
>
186 <div id
="report_parameters">
188 <form method
="post" name
="theform" id
='theform' action
="custom_report_range.php">
189 <input type
='hidden' name
='form_refresh' id
='form_refresh' value
=''/>
193 <div style
='float:left'>
198 <?php
echo xlt('Start Date'); ?
>:
201 <input type
='text' name
='start' id
="form_from_date" size
='10' value
='<?php echo attr($startdate) ?>'
202 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
203 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
204 id
='img_from_date' border
='0' alt
='[?]' style
='cursor:pointer'
205 title
='<?php echo xla('Click here to choose a date
'); ?>'>
208 <?php
echo xlt('End Date'); ?
>:
211 <input type
='text' name
='end' id
="form_to_date" size
='10' value
='<?php echo attr($enddate) ?>'
212 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
213 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
214 id
='img_to_date' border
='0' alt
='[?]' style
='cursor:pointer'
215 title
='<?php echo xla('Click here to choose a date
'); ?>'>
219  
; 
;<span
class='text'><?php
echo xlt('Patient'); ?
>: </span
>
222 <input type
='text' size
='20' name
='form_patient' style
='width:100%;cursor:pointer;cursor:hand' value
='<?php echo attr($form_patient) ? attr($form_patient) : xla('Click To Select
'); ?>' onclick
='sel_patient()' title
='<?php echo xla('Click to select patient
'); ?>' />
223 <input type
='hidden' name
='form_pid' value
='<?php echo attr($form_pid); ?>' />
233 <td align
='left' valign
='middle' height
="100%">
234 <table style
='border-left:1px solid; width:100%; height:100%' >
237 <div style
='margin-left:15px'>
238 <a href
='#' class='css_button' onclick
='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
240 <?php
echo xlt('Submit'); ?
>
244 <?php
if ($_POST['form_refresh']) { ?
>
245 <a href
='#' class='css_button' id
='printbutton'>
247 <?php
echo xlt('Print'); ?
>
258 </div
> <!-- end of parameters
-->
262 <div id
="superbill_results">
265 if( !(empty($_POST['start']) ||
empty($_POST['end']))) {
266 $sql = "select * from facility where billing_location = 1";
267 $db = $GLOBALS['adodb']['db'];
268 $results = $db->Execute($sql);
270 if (!$results->EOF
) {
271 $facility = $results->fields
;
274 <h2
><?php
text($facility['name'])?
></h2
>
275 <?php
text($facility['street'])?
><br
>
276 <?php
text($facility['city'])?
>, <?php
text($facility['state'])?
> <?php
text($facility['postal_code'])?
><br
>
281 $sqlBindArray = array();
282 $res_query = "select * from forms where " .
283 "form_name = 'New Patient Encounter' and " .
284 "date between ? and ? " ;
285 array_push($sqlBindArray,$startdate,$enddate);
287 $res_query.= " and pid=? ";
288 array_push($sqlBindArray,$form_pid);
290 $res_query.= " order by date DESC" ;
291 $res =sqlStatement($res_query,$sqlBindArray);
293 while($result = sqlFetchArray($res)) {
294 if ($result{"form_name"} == "New Patient Encounter") {
295 $newpatient[] = $result{"form_id"}.":".$result{"encounter"};
296 $pids[] = $result{"pid"};
301 function postToGet($newpatient, $pids) {
303 $serialnewpatient = serialize($newpatient);
304 $serialpids = serialize($pids);
305 $getstring = "newpatient=".urlencode($serialnewpatient)."&pids=".urlencode($serialpids);
311 if(empty($newpatient)){ $newpatient = array(); }
312 foreach($newpatient as $patient){
314 $inclookupres = sqlStatement("select distinct formdir from forms where pid='".$pids[$iCounter]."'");
315 while($result = sqlFetchArray($inclookupres)) {
316 include_once("{$GLOBALS['incdir']}/forms/" . $result{"formdir"} . "/report.php");
320 print "<div id='superbill_patientdata'>";
321 print "<h1>".xlt('Patient Data').":</h1>";
322 printRecDataOne($patient_data_array, getRecPatientData ($pids[$iCounter]), $N);
325 print "<div id='superbill_insurancedata'>";
326 print "<h1>".xlt('Insurance Data').":</h1>";
327 print "<h2>".xlt('Primary').":</h2>";
328 printRecDataOne($insurance_data_array, getRecInsuranceData ($pids[$iCounter],"primary"), $N);
329 print "<h2>".xlt('Secondary').":</h2>";
330 printRecDataOne($insurance_data_array, getRecInsuranceData ($pids[$iCounter],"secondary"), $N);
331 print "<h2>".xlt('Tertiary').":</h2>";
332 printRecDataOne($insurance_data_array, getRecInsuranceData ($pids[$iCounter],"tertiary"), $N);
335 print "<div id='superbill_billingdata'>";
336 print "<h1>".xlt('Billing Information').":</h1>";
337 if (count($patient) > 0) {
339 echo "<table width='100%'>";
341 echo "<td class='bold' width='10%'>".xlt('Date')."</td>";
342 echo "<td class='bold' width='20%'>".xlt('Provider')."</td>";
343 echo "<td class='bold' width='40%'>".xlt('Code')."</td>";
344 echo "<td class='bold' width='10%'>".xlt('Fee')."</td></tr>\n";
347 //foreach ($patient as $be) {
349 $ta = explode(":",$patient);
350 $billing = getPatientBillingEncounter($pids[$iCounter],$ta[1]);
352 $billings[] = $billing;
353 foreach ($billing as $b) {
354 // grab the date to reformat it in the output
355 $bdate = strtotime($b['date']);
358 echo "<td class='text' style='font-size: 0.8em'>" . oeFormatShortDate(date("Y-m-d",$bdate)) . "<BR>" . date("h:i a", $bdate) . "</td>";
359 echo "<td class='text'>" . text($b['provider_name']) . "</td>";
360 echo "<td class='text'>";
361 echo text($b['code_type']) . ":\t" . text($b['code']) . " ". text($b['modifier']) . " " . text($b['code_text']) . " ";
363 echo "<td class='text'>";
364 echo oeFormatMoney($b['fee']);
369 // Calculate the copay for the encounter
370 $copays = getPatientCopay($pids[$iCounter],$ta[1]);
372 echo "<tr><td> </td></tr>";
373 echo "<tr><td class='bold' colspan=3 style='text-align:right'>".xlt('Sub-Total')."</td><td class='text'>" . oeFormatMoney($total +
abs($copays)) . "</td></tr>";
374 echo "<tr><td class='bold' colspan=3 style='text-align:right'>".xlt('Copay Paid')."</td><td class='text'>" . oeFormatMoney(abs($copays)) . "</td></tr>";
375 echo "<tr><td class='bold' colspan=3 style='text-align:right'>".xlt('Total')."</td><td class='text'>" . oeFormatMoney($total) . "</td></tr>";
378 //print_r($billings);
384 print "<br/><br/>".xlt('Physician Signature').": _______________________________________________";
385 print "<hr class='pagebreak' />";
393 <!-- stuff
for the popup calendar
-->
394 <style type
="text/css">@import
url(../../library
/dynarch_calendar
.css
);</style
>
395 <script type
="text/javascript" src
="../../library/dynarch_calendar.js"></script
>
396 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
397 <script type
="text/javascript" src
="../../library/dynarch_calendar_setup.js"></script
>
399 <script language
="Javascript">
400 Calendar
.setup({inputField
:"form_from_date", ifFormat
:"%Y-%m-%d", button
:"img_from_date"});
401 Calendar
.setup({inputField
:"form_to_date", ifFormat
:"%Y-%m-%d", button
:"img_to_date"});