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/formatting.inc.php");
32 $startdate = $enddate = "";
33 if(empty($_POST['start']) ||
empty($_POST['end'])) {
34 // set some default dates
35 $startdate = date('Y-m-d', (time() - 30*24*60*60));
36 $enddate = date('Y-m-d', time());
40 $startdate = $_POST['start'];
41 $enddate = $_POST['end'];
43 //Patient related stuff
44 if ($_POST["form_patient"])
45 $form_patient = isset($_POST['form_patient']) ?
$_POST['form_patient'] : '';
46 $form_pid = isset($_POST['form_pid']) ?
$_POST['form_pid'] : '';
47 if ($form_patient == '' ) $form_pid = '';
52 <?php
html_header_show();?
>
54 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
55 <link rel
="stylesheet" href
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.min.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-3-1-1/index.js"></script
>
156 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.full.min.js"></script
>
158 <script language
="Javascript">
159 $
(document
).ready(function() {
160 var win
= top
.printLogSetup ? top
: opener
.top
;
161 win
.printLogSetup(document
.getElementById('printbutton'));
163 $
('.datepicker').datetimepicker({
164 <?php
$datetimepicker_timepicker = false; ?
>
165 <?php
$datetimepicker_formatInput = false; ?
>
166 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
167 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
171 // CapMinds :: invokes find-patient popup.
172 function sel_patient() {
173 dlgopen('../main/calendar/find_patient_popup.php?pflag=0', '_blank', 500, 400);
176 // CapMinds :: callback by the find-patient popup.
177 function setpatient(pid
, lname
, fname
, dob
) {
178 var f
= document
.theform
;
179 f
.form_patient
.value
= lname +
', ' + fname
;
180 f
.form_pid
.value
= pid
;
186 <body
class="body_top">
188 <span
class='title'><?php
echo xlt('Reports'); ?
> - <?php
echo xlt('Superbill'); ?
></span
>
190 <div id
="superbill_description" class='text'>
191 <?php
echo xlt('Superbills, sometimes referred to as Encounter Forms or Routing Slips, are an essential part of most medical practices.'); ?
>
194 <div id
="report_parameters">
196 <form method
="post" name
="theform" id
='theform' action
="custom_report_range.php">
197 <input type
='hidden' name
='form_refresh' id
='form_refresh' value
=''/>
201 <div style
='float:left'>
206 <?php
echo xlt('Start Date'); ?
>:
209 <input type
='text' class='datepicker' name
='start' id
="form_from_date" size
='10' value
='<?php echo attr($startdate) ?>'
213 <?php
echo xlt('End Date'); ?
>:
216 <input type
='text' class='datepicker' name
='end' id
="form_to_date" size
='10' value
='<?php echo attr($enddate) ?>'
221  
; 
;<span
class='text'><?php
echo xlt('Patient'); ?
>: </span
>
224 <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
'); ?>' />
225 <input type
='hidden' name
='form_pid' value
='<?php echo attr($form_pid); ?>' />
235 <td align
='left' valign
='middle' height
="100%">
236 <table style
='border-left:1px solid; width:100%; height:100%' >
239 <div style
='margin-left:15px'>
240 <a href
='#' class='css_button' onclick
='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
242 <?php
echo xlt('Submit'); ?
>
246 <?php
if ($_POST['form_refresh']) { ?
>
247 <a href
='#' class='css_button' id
='printbutton'>
249 <?php
echo xlt('Print'); ?
>
260 </div
> <!-- end of parameters
-->
264 <div id
="superbill_results">
267 if( !(empty($_POST['start']) ||
empty($_POST['end']))) {
268 $sql = "select * from facility where billing_location = 1";
269 $db = $GLOBALS['adodb']['db'];
270 $results = $db->Execute($sql);
272 if (!$results->EOF
) {
273 $facility = $results->fields
;
276 <h2
><?php
text($facility['name'])?
></h2
>
277 <?php
text($facility['street'])?
><br
>
278 <?php
text($facility['city'])?
>, <?php
text($facility['state'])?
> <?php
text($facility['postal_code'])?
><br
>
283 $sqlBindArray = array();
284 $res_query = "select * from forms where " .
285 "form_name = 'New Patient Encounter' and " .
286 "date between ? and ? " ;
287 array_push($sqlBindArray,$startdate,$enddate);
289 $res_query.= " and pid=? ";
290 array_push($sqlBindArray,$form_pid);
292 $res_query.= " order by date DESC" ;
293 $res =sqlStatement($res_query,$sqlBindArray);
295 while($result = sqlFetchArray($res)) {
296 if ($result{"form_name"} == "New Patient Encounter") {
297 $newpatient[] = $result{"form_id"}.":".$result{"encounter"};
298 $pids[] = $result{"pid"};
303 function postToGet($newpatient, $pids) {
305 $serialnewpatient = serialize($newpatient);
306 $serialpids = serialize($pids);
307 $getstring = "newpatient=".urlencode($serialnewpatient)."&pids=".urlencode($serialpids);
313 if(empty($newpatient)){ $newpatient = array(); }
314 foreach($newpatient as $patient){
316 $inclookupres = sqlStatement("select distinct formdir from forms where pid='".$pids[$iCounter]."'");
317 while($result = sqlFetchArray($inclookupres)) {
318 include_once("{$GLOBALS['incdir']}/forms/" . $result{"formdir"} . "/report.php");
322 print "<div id='superbill_patientdata'>";
323 print "<h1>".xlt('Patient Data').":</h1>";
324 printRecDataOne($patient_data_array, getRecPatientData ($pids[$iCounter]), $N);
327 print "<div id='superbill_insurancedata'>";
328 print "<h1>".xlt('Insurance Data').":</h1>";
329 print "<h2>".xlt('Primary').":</h2>";
330 printRecDataOne($insurance_data_array, getRecInsuranceData ($pids[$iCounter],"primary"), $N);
331 print "<h2>".xlt('Secondary').":</h2>";
332 printRecDataOne($insurance_data_array, getRecInsuranceData ($pids[$iCounter],"secondary"), $N);
333 print "<h2>".xlt('Tertiary').":</h2>";
334 printRecDataOne($insurance_data_array, getRecInsuranceData ($pids[$iCounter],"tertiary"), $N);
337 print "<div id='superbill_billingdata'>";
338 print "<h1>".xlt('Billing Information').":</h1>";
339 if (count($patient) > 0) {
341 echo "<table width='100%'>";
343 echo "<td class='bold' width='10%'>".xlt('Date')."</td>";
344 echo "<td class='bold' width='20%'>".xlt('Provider')."</td>";
345 echo "<td class='bold' width='40%'>".xlt('Code')."</td>";
346 echo "<td class='bold' width='10%'>".xlt('Fee')."</td></tr>\n";
349 //foreach ($patient as $be) {
351 $ta = explode(":",$patient);
352 $billing = getPatientBillingEncounter($pids[$iCounter],$ta[1]);
354 $billings[] = $billing;
355 foreach ($billing as $b) {
356 // grab the date to reformat it in the output
357 $bdate = strtotime($b['date']);
360 echo "<td class='text' style='font-size: 0.8em'>" . oeFormatShortDate(date("Y-m-d",$bdate)) . "<BR>" . date("h:i a", $bdate) . "</td>";
361 echo "<td class='text'>" . text($b['provider_name']) . "</td>";
362 echo "<td class='text'>";
363 echo text($b['code_type']) . ":\t" . text($b['code']) . " ". text($b['modifier']) . " " . text($b['code_text']) . " ";
365 echo "<td class='text'>";
366 echo oeFormatMoney($b['fee']);
371 // Calculate the copay for the encounter
372 $copays = getPatientCopay($pids[$iCounter],$ta[1]);
374 echo "<tr><td> </td></tr>";
375 echo "<tr><td class='bold' colspan=3 style='text-align:right'>".xlt('Sub-Total')."</td><td class='text'>" . oeFormatMoney($total +
abs($copays)) . "</td></tr>";
376 echo "<tr><td class='bold' colspan=3 style='text-align:right'>".xlt('Copay Paid')."</td><td class='text'>" . oeFormatMoney(abs($copays)) . "</td></tr>";
377 echo "<tr><td class='bold' colspan=3 style='text-align:right'>".xlt('Total')."</td><td class='text'>" . oeFormatMoney($total) . "</td></tr>";
380 //print_r($billings);
386 print "<br/><br/>".xlt('Physician Signature').": _______________________________________________";
387 print "<hr class='pagebreak' />";