added Urdu language
[openemr.git] / interface / reports / custom_report_range.php
blobe3a04c812c28ce02905b4394b5c16c76ab707ddd
1 <?php
2 /**
4 * Superbill Report
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>;.
17 * @package OpenEMR
18 * @author Brady Miller <brady.g.miller@gmail.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");
31 $startdate = $enddate = "";
32 if(empty($_POST['start']) || empty($_POST['end'])) {
33 // set some default dates
34 $startdate = date('Y-m-d', (time() - 30*24*60*60));
35 $enddate = date('Y-m-d', time());
37 else {
38 // set dates
39 $startdate = $_POST['start'];
40 $enddate = $_POST['end'];
42 //Patient related stuff
43 if ($_POST["form_patient"])
44 $form_patient = isset($_POST['form_patient']) ? $_POST['form_patient'] : '';
45 $form_pid = isset($_POST['form_pid']) ? $_POST['form_pid'] : '';
46 if ($form_patient == '' ) $form_pid = '';
48 <html>
50 <head>
51 <?php html_header_show();?>
53 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
54 <link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.min.css">
56 <style>
58 @media print {
59 .title {
60 visibility: hidden;
62 .pagebreak {
63 page-break-after: always;
64 border: none;
65 visibility: hidden;
68 #superbill_description {
69 visibility: hidden;
72 #report_parameters {
73 visibility: hidden;
75 #superbill_results {
76 margin-top: -30px;
80 @media screen {
81 .title {
82 visibility: visible;
84 #superbill_description {
85 visibility: visible;
87 .pagebreak {
88 width: 100%;
89 border: 2px dashed black;
91 #report_parameters {
92 visibility: visible;
95 #superbill_description {
96 margin: 10px;
98 #superbill_startingdate {
99 margin: 10px;
101 #superbill_endingdate {
102 margin: 10px;
105 #superbill_patientdata {
107 #superbill_patientdata h1 {
108 font-weight: bold;
109 font-size: 1.2em;
110 margin: 0px;
111 padding: 5px;
112 width: 100%;
113 background-color: #eee;
114 border: 1px solid black;
116 #superbill_insurancedata {
117 margin-top: 10px;
119 #superbill_insurancedata h1 {
120 font-weight: bold;
121 font-size: 1.2em;
122 margin: 0px;
123 padding: 5px;
124 width: 100%;
125 background-color: #eee;
126 border: 1px solid black;
128 #superbill_insurancedata h2 {
129 font-weight: bold;
130 font-size: 1.0em;
131 margin: 0px;
132 padding: 0px;
133 width: 100%;
134 background-color: #eee;
136 #superbill_billingdata {
137 margin-top: 10px;
139 #superbill_billingdata h1 {
140 font-weight: bold;
141 font-size: 1.2em;
142 margin: 0px;
143 padding: 5px;
144 width: 100%;
145 background-color: #eee;
146 border: 1px solid black;
148 #superbill_signature {
150 #superbill_logo {
152 </style>
153 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
154 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-3-1-1/index.js"></script>
155 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.full.min.js"></script>
157 <script language="Javascript">
158 $(document).ready(function() {
159 var win = top.printLogSetup ? top : opener.top;
160 win.printLogSetup(document.getElementById('printbutton'));
162 $('.datepicker').datetimepicker({
163 <?php $datetimepicker_timepicker = false; ?>
164 <?php $datetimepicker_showseconds = 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;
183 </script>
184 </head>
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.'); ?>
192 </div>
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=''/>
198 <table>
199 <tr>
200 <td width='650px'>
201 <div style='float:left'>
203 <table class='text'>
204 <tr>
205 <td class='label_custom'>
206 <?php echo xlt('Start Date'); ?>:
207 </td>
208 <td>
209 <input type='text' class='datepicker' name='start' id="form_from_date" size='10' value='<?php echo attr($startdate) ?>'
210 title='yyyy-mm-dd'>
211 </td>
212 <td class='label_custom'>
213 <?php echo xlt('End Date'); ?>:
214 </td>
215 <td>
216 <input type='text' class='datepicker' name='end' id="form_to_date" size='10' value='<?php echo attr($enddate) ?>'
217 title='yyyy-mm-dd'>
218 </td>
220 <td>
221 &nbsp;&nbsp;<span class='text'><?php echo xlt('Patient'); ?>: </span>
222 </td>
223 <td>
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); ?>' />
226 </td>
227 </tr>
228 <tr><td>
229 </tr>
230 </table>
232 </div>
234 </td>
235 <td align='left' valign='middle' height="100%">
236 <table style='border-left:1px solid; width:100%; height:100%' >
237 <tr>
238 <td>
239 <div style='margin-left:15px'>
240 <a href='#' class='css_button' onclick='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
241 <span>
242 <?php echo xlt('Submit'); ?>
243 </span>
244 </a>
246 <?php if ($_POST['form_refresh']) { ?>
247 <a href='#' class='css_button' id='printbutton'>
248 <span>
249 <?php echo xlt('Print'); ?>
250 </span>
251 </a>
252 <?php } ?>
253 </div>
254 </td>
255 </tr>
256 </table>
257 </td>
258 </tr>
259 </table>
260 </div> <!-- end of parameters -->
262 </form>
264 <div id="superbill_results">
266 <?php
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);
271 $facility = array();
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>
280 </p>
281 <?php
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);
288 if($form_pid) {
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"};
301 $N = 6;
303 function postToGet($newpatient, $pids) {
304 $getstring="";
305 $serialnewpatient = serialize($newpatient);
306 $serialpids = serialize($pids);
307 $getstring = "newpatient=".urlencode($serialnewpatient)."&pids=".urlencode($serialpids);
309 return $getstring;
312 $iCounter = 0;
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);
325 print "</div>";
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);
335 print "</div>";
337 print "<div id='superbill_billingdata'>";
338 print "<h1>".xlt('Billing Information').":</h1>";
339 if (count($patient) > 0) {
340 $billings = array();
341 echo "<table width='100%'>";
342 echo "<tr>";
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";
347 $total = 0.00;
348 $copays = 0.00;
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']);
359 echo "<tr>\n";
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']) . "&nbsp;". text($b['modifier']) . "&nbsp;&nbsp;&nbsp;" . text($b['code_text']) . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
364 echo "</td>\n";
365 echo "<td class='text'>";
366 echo oeFormatMoney($b['fee']);
367 echo "</td>\n";
368 echo "</tr>\n";
369 $total += $b['fee'];
371 // Calculate the copay for the encounter
372 $copays = getPatientCopay($pids[$iCounter],$ta[1]);
374 echo "<tr><td>&nbsp;</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>";
378 echo "</table>";
379 echo "<pre>";
380 //print_r($billings);
381 echo "</pre>";
383 echo "</div>";
385 ++$iCounter;
386 print "<br/><br/>".xlt('Physician Signature').": _______________________________________________";
387 print "<hr class='pagebreak' />";
391 </div>
393 </body>
395 </html>