Merge pull request #1128 from bradymiller/unique-insurance-report-cleanup_1
[openemr.git] / interface / billing / print_daysheet_report_num2.php
blob6231865aa42c403ce27314c5648b5e162a4be568
1 <?php
2 /**
3 * interface/billing/print_daysheet_report.php Genetating an end of day report.
5 * Program for Generating an End of Day report
8 * Copyright (C) 2014 Terry Hill <terry@lillysystems.com>
10 * LICENSE: This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 3
13 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
21 * @package OpenEMR
22 * @author Terry Hill <terry@lillysystems.com>
23 * @link http://www.open-emr.org
29 include_once("../globals.php");
31 include_once("$srcdir/patient.inc");
32 include_once("$srcdir/../interface/reports/report.inc.php");
33 include_once("$srcdir/daysheet.inc.php");
35 //global variables:
36 if (!isset($_GET["mode"])) {
37 if (!isset($_GET["from_date"])) {
38 $from_date=date("Y-m-d");
39 } else {
40 $from_date = $_GET["from_date"];
43 if (!isset($_GET["to_date"])) {
44 $to_date = date("Y-m-d");
45 } else {
46 $to_date = $_GET["to_date"];
49 if (!isset($_GET["code_type"])) {
50 $code_type="all";
51 } else {
52 $code_type = $_GET["code_type"];
55 if (!isset($_GET["unbilled"])) {
56 $unbilled = "on";
57 } else {
58 $unbilled = $_GET["unbilled"];
61 if (!isset($_GET["authorized"])) {
62 $my_authorized = "on";
63 } else {
64 $my_authorized = $_GET["authorized"];
66 } else {
67 $from_date = $_GET["from_date"];
68 $to_date = $_GET["to_date"];
69 $code_type = $_GET["code_type"];
70 $unbilled = $_GET["unbilled"];
71 $my_authorized = $_GET["authorized"];
76 <html>
77 <head>
78 <?php html_header_show();?>
80 <link rel=stylesheet href="<?php echo $css_header;?>" type="text/css">
82 </head>
83 <body bgcolor="#ffffff" topmargin=0 rightmargin=0 leftmargin=2 bottommargin=0 marginwidth=2 marginheight=0>
85 <a href="javascript:window.close();" target=Main><font class=title><?php echo xlt('Day Sheet Report')?></font></a>
86 <br>
88 <?php
89 if ($my_authorized === 'on') {
90 $my_authorized = true;
91 } else {
92 $my_authorized = '%';
95 if ($unbilled === 'on') {
96 $unbilled = '0';
97 } else {
98 $unbilled = '%';
101 if ($code_type === 'all') {
102 $code_type = '%';
105 if (!isset($_GET["mode"])) {
106 if (!isset($_GET["from_date"])) {
107 $from_date=date("Y-m-d");
108 } else {
109 $from_date = $_GET["from_date"];
112 if (!isset($_GET["to_date"])) {
113 $to_date = date("Y-m-d");
114 } else {
115 $to_date = $_GET["to_date"];
118 if (!isset($_GET["code_type"])) {
119 $code_type="all";
120 } else {
121 $code_type = $_GET["code_type"];
124 if (!isset($_GET["unbilled"])) {
125 $unbilled = "on";
126 } else {
127 $unbilled = $_GET["unbilled"];
130 if (!isset($_GET["authorized"])) {
131 $my_authorized = "on";
132 } else {
133 $my_authorized = $_GET["authorized"];
135 } else {
136 $from_date = $_GET["from_date"];
137 $to_date = $_GET["to_date"];
138 $code_type = $_GET["code_type"];
139 $unbilled = $_GET["unbilled"];
140 $my_authorized = $_GET["authorized"];
143 if ($my_authorized === 'on') {
144 $my_authorized = true;
145 } else {
146 $my_authorized = '%';
149 if ($unbilled === 'on') {
150 $unbilled = '0';
151 } else {
152 $unbilled = '%';
155 if ($code_type === 'all') {
156 $code_type = '%';
159 if (isset($_GET["mode"]) && $_GET["mode"] === 'bill') {
160 billCodesList($list);
163 $res_count = 0;
164 $N = 1;
165 $k = 1;
166 $anypats = 0;
167 $the_first_time = 1;
168 $itero = array();
170 if ($ret = getBillsBetweendayReport($code_type)) {
171 // checking to see if there is any information in the array if not display a message (located after this if statment)
172 $anypats = count($ret);
175 $old_pid = -1;
176 $first_time = 1;
179 // $iter has encounter information
181 // this loop gathers the user numbers
182 foreach ($ret as $iter) {
183 $catch_user[] = $iter{'user'};
186 //This statment uniques the array removing duplicates
187 $user_list = array_unique($catch_user);
188 // reorder the list starting with array element zero
189 $final_list = array_values($user_list);
190 // sort array in assending order
191 sort($final_list);
193 $all4 = array_natsort($ret, pid, fulname, asc);
195 if ($_POST['end_of_day_totals_only'] == 1) {
196 $totals_only = 1;
199 foreach ($all4 as $iter) {
200 // Case statment to tally information by user
201 switch ($iter{'user'}) {
202 case $iter{'user'} = $final_list[0]:
203 $us0_user = $iter{'user'};
204 $us0_fee = $us0_fee + $iter{'fee'};
205 $us0_inspay = $us0_inspay + $iter{'ins_code'};
206 $us0_insadj = $us0_insadj + $iter{'ins_adjust_dollar'};
207 $us0_patadj = $us0_patadj + $iter{'pat_adjust_dollar'};
208 $us0_patpay = $us0_patpay + $iter{'pat_code'};
209 break;
210 case $iter{'user'} = $final_list[1]:
211 $us1_user = $iter{'user'};
212 $us1_fee = $us1_fee + $iter{'fee'};
213 $us1_inspay = $us1_inspay + $iter{'ins_code'};
214 $us1_insadj = $us1_insadj + $iter{'ins_adjust_dollar'};
215 $us1_patadj = $us1_patadj + $iter{'pat_adjust_dollar'};
216 $us1_patpay = $us1_patpay + $iter{'pat_code'};
217 break;
218 case $iter{'user'} = $final_list[2]:
219 $us2_user = $iter{'user'};
220 $us2_fee = $us2_fee + $iter{'fee'};
221 $us2_inspay = $us2_inspay + $iter{'ins_code'};
222 $us2_insadj = $us2_insadj + $iter{'ins_adjust_dollar'};
223 $us2_patadj = $us2_patadj + $iter{'pat_adjust_dollar'};
224 $us2_patpay = $us2_patpay + $iter{'pat_code'};
225 break;
226 case $iter{'user'} = $final_list[3]:
227 $us3_user = $iter{'user'};
228 $us3_fee = $us3_fee + $iter{'fee'};
229 $us3_inspay = $us3_inspay + $iter{'ins_code'};
230 $us3_insadj = $us3_insadj + $iter{'ins_adjust_dollar'};
231 $us3_patadj = $us3_patadj + $iter{'pat_adjust_dollar'};
232 $us3_patpay = $us3_patpay + $iter{'pat_code'};
233 break;
234 case $iter{'user'} = $final_list[4]:
235 $us4_user = $iter{'user'};
236 $us4_fee = $us4_fee + $iter{'fee'};
237 $us4_inspay = $us4_inspay + $iter{'ins_code'};
238 $us4_insadj = $us4_insadj + $iter{'ins_adjust_dollar'};
239 $us4_patadj = $us4_patadj + $iter{'pat_adjust_dollar'};
240 $us4_patpay = $us4_patpay + $iter{'pat_code'};
241 break;
242 case $iter{'user'} = $final_list[5]:
243 $us5_user = $iter{'user'};
244 $us5_fee = $us5_fee + $iter{'fee'};
245 $us5_inspay = $us5_inspay + $iter{'ins_code'};
246 $us5_insadj = $us5_insadj + $iter{'ins_adjust_dollar'};
247 $us5_patadj = $us5_patadj + $iter{'pat_adjust_dollar'};
248 $us5_patpay = $us5_patpay + $iter{'pat_code'};
249 break;
250 case $iter{'user'} = $final_list[6]:
251 $us6_user = $iter{'user'};
252 $us6_fee = $us6_fee + $iter{'fee'};
253 $us6_inspay = $us6_inspay + $iter{'ins_code'};
254 $us6_insadj = $us6_insadj + $iter{'ins_adjust_dollar'};
255 $us6_patadj = $us6_patadj + $iter{'pat_adjust_dollar'};
256 $us6_patpay = $us6_patpay + $iter{'pat_code'};
257 break;
258 case $iter{'user'} = $final_list[7]:
259 $us7_user = $iter{'user'};
260 $us7_fee = $us7_fee + $iter{'fee'};
261 $us7_inspay = $us7_inspay + $iter{'ins_code'};
262 $us7_insadj = $us7_insadj + $iter{'ins_adjust_dollar'};
263 $us7_patadj = $us7_patadj + $iter{'pat_adjust_dollar'};
264 $us7_patpay = $us7_patpay + $iter{'pat_code'};
265 break;
266 case $iter{'user'} = $final_list[8]:
267 $us8_user = $iter{'user'};
268 $us8_fee = $us8_fee + $iter{'fee'};
269 $us8_inspay = $us8_inspay + $iter{'ins_code'};
270 $us8_insadj = $us8_insadj + $iter{'ins_adjust_dollar'};
271 $us8_patadj = $us8_patadj + $iter{'pat_adjust_dollar'};
272 $us8_patpay = $us8_patpay + $iter{'pat_code'};
273 break;
274 case $iter{'user'} = $final_list[9]:
275 $us9_user = $iter{'user'};
276 $us9_fee = $us9_fee + $iter{'fee'};
277 $us9_inspay = $us9_inspay + $iter{'ins_code'};
278 $us9_insadj = $us9_insadj + $iter{'ins_adjust_dollar'};
279 $us9_patadj = $us9_patadj + $iter{'pat_adjust_dollar'};
280 $us9_patpay = $us9_patpay + $iter{'pat_code'};
281 break;
282 case $iter{'user'} = $final_list[10]:
283 $us10_user = $iter{'user'};
284 $us10_fee = $us10_fee + $iter{'fee'};
285 $us10_inspay = $us10_inspay + $iter{'ins_code'};
286 $us10_insadj = $us10_insadj + $iter{'ins_adjust_dollar'};
287 $us10_patadj = $us10_patadj + $iter{'pat_adjust_dollar'};
288 $us10_patpay = $us10_patpay + $iter{'pat_code'};
289 break;
290 case $iter{'user'} = $final_list[11]:
291 $us11_user = $iter{'user'};
292 $us11_fee = $us11_fee + $iter{'fee'};
293 $us11_inspay = $us11_inspay + $iter{'ins_code'};
294 $us11_insadj = $us11_insadj + $iter{'ins_adjust_dollar'};
295 $us11_patadj = $us11_patadj + $iter{'pat_adjust_dollar'};
296 $us11_patpay = $us11_patpay + $iter{'pat_code'};
297 break;
298 case $iter{'user'} = $final_list[12]:
299 $us12_user = $iter{'user'};
300 $us12_fee = $us12_fee + $iter{'fee'};
301 $us12_inspay = $us12_inspay + $iter{'ins_code'};
302 $us12_insadj = $us12_insadj + $iter{'ins_adjust_dollar'};
303 $us12_patadj = $us12_patadj + $iter{'pat_adjust_dollar'};
304 $us12_patpay = $us12_patpay + $iter{'pat_code'};
305 break;
306 case $iter{'user'} = $final_list[13]:
307 $us13_user = $iter{'user'};
308 $us13_fee = $us13_fee + $iter{'fee'};
309 $us13_inspay = $us13_inspay + $iter{'ins_code'};
310 $us13_insadj = $us13_insadj + $iter{'ins_adjust_dollar'};
311 $us13_patadj = $us13_patadj + $iter{'pat_adjust_dollar'};
312 $us13_patpay = $us13_patpay + $iter{'pat_code'};
313 break;
314 case $iter{'user'} = $final_list[14]:
315 $us14_user = $iter{'user'};
316 $us14_fee = $us14_fee + $iter{'fee'};
317 $us14_inspay = $us14_inspay + $iter{'ins_code'};
318 $us14_insadj = $us14_insadj + $iter{'ins_adjust_dollar'};
319 $us14_patadj = $us14_patadj + $iter{'pat_adjust_dollar'};
320 $us14_patpay = $us14_patpay + $iter{'pat_code'};
321 break;
322 case $iter{'user'} = $final_list[15]:
323 $us15_user = $iter{'user'};
324 $us15_fee = $us15_fee + $iter{'fee'};
325 $us15_inspay = $us15_inspay + $iter{'ins_code'};
326 $us15_insadj = $us15_insadj + $iter{'ins_adjust_dollar'};
327 $us15_patadj = $us15_patadj + $iter{'pat_adjust_dollar'};
328 $us15_patpay = $us15_patpay + $iter{'pat_code'};
329 break;
330 case $iter{'user'} = $final_list[16]:
331 $us16_user = $iter{'user'};
332 $us16_fee = $us16_fee + $iter{'fee'};
333 $us16_inspay = $us16_inspay + $iter{'ins_code'};
334 $us16_insadj = $us16_insadj + $iter{'ins_adjust_dollar'};
335 $us16_patadj = $us16_patadj + $iter{'pat_adjust_dollar'};
336 $us16_patpay = $us16_patpay + $iter{'pat_code'};
337 break;
338 case $iter{'user'} = $final_list[17]:
339 $us17_user = $iter{'user'};
340 $us17_fee = $us17_fee + $iter{'fee'};
341 $us17_inspay = $us17_inspay + $iter{'ins_code'};
342 $us17_insadj = $us17_insadj + $iter{'ins_adjust_dollar'};
343 $us17_patadj = $us17_patadj + $iter{'pat_adjust_dollar'};
344 $us17_patpay = $us17_patpay + $iter{'pat_code'};
345 break;
346 case $iter{'user'} = $final_list[18]:
347 $us18_user = $iter{'user'};
348 $us18_fee = $us18_fee + $iter{'fee'};
349 $us18_inspay = $us18_inspay + $iter{'ins_code'};
350 $us18_insadj = $us18_insadj + $iter{'ins_adjust_dollar'};
351 $us18_patadj = $us18_patadj + $iter{'pat_adjust_dollar'};
352 $us18_patpay = $us18_patpay + $iter{'pat_code'};
353 break;
354 case $iter{'user'} = $final_list[19]:
355 $us19_user = $iter{'user'};
356 $us19_fee = $us19_fee + $iter{'fee'};
357 $us19_inspay = $us19_inspay + $iter{'ins_code'};
358 $us19_insadj = $us19_insadj + $iter{'ins_adjust_dollar'};
359 $us19_patadj = $us19_patadj + $iter{'pat_adjust_dollar'};
360 $us19_patpay = $us19_patpay + $iter{'pat_code'};
361 break;
364 if ($the_first_time == 1) {
365 $user = $iter{'user'};
366 $first_user = $iter{'user'};
367 $the_first_time = 0;
370 if ($totals_only != 1) {
371 if ($old_pid != $iter{'pid'} and ($iter{'code_type'} != 'payment_info')) {
372 // $name has patient information
373 $name = getPatientData($iter{"pid"});
375 // formats the displayed text
377 if ($first_time) {
378 print "<table border=0><tr>\n"; // small table
379 $first_time=0;
382 // Displays name
383 print "<tr><td colspan=50><hr><span class=bold>" . " " . text($name{"fname"}) . " " . text($name{"lname"}) . "</span><br><br></td></tr><tr>\n";
384 //==================================
386 if ($iter{'code_type'} === 'COPAY' || $iter{'code_type'} === 'Patient Payment' || $iter{'code_type'} === 'Insurance Payment') {
387 print "<td width=40><span class=text><center><b>" . xlt("Units") . "</b></center>";
388 print "</span></td><td width=100><span class=text><center><b>" . xlt("Fee"). "</b></center>" ;
389 print "</span></td><td width=100><span class=text><center><b>" . xlt("Code"). "</b></center>" ;
390 print "</span></td><td width=100><span class=text><b>";
391 print "</span></td><td width=100><span class=text><center><b>" . xlt("User"). "</b></center>";
392 print "</span></td><td width=100><span class=small><b>";
393 print "</span></td><td width=100><span class=small><center><b>". xlt("Post Date"). "</b></center>";
394 print "</span></td><td></tr><tr>\n";
395 } else {
396 print "<td width=40><span class=text><b><center>" . xlt("Units"). "</b></center>";
397 print "</span></td><td width=100><span class=text><center><b>" . xlt("Fee"). "</b></center>";
398 print "</span></td><td width=100><span class=text><center><b>" . xlt("Code") . "</b></center>";
399 print "</span></td><td width=100><span class=text><b><center>" . xlt("Provider Id"). "</b></center>";
400 print "</span></td><td width=100><span class=text><b><center>" . xlt("User"). "</b></center>";
401 print "</span></td><td width=100><span class=small><center><b>" . xlt("Bill Date"). "</b></center>";
402 print "</span></td><td width=100><span class=small><center><b>". xlt("Date of Service"). "</b></center>";
403 print "</span></td><td width=100><span class=small><center><b>". xlt("Encounter"). "</b></center>";
404 print "</span></td><td></tr><tr>\n";
407 //Next patient
408 $old_pid = $iter{"pid"};
411 // get dollar amounts to appear on pat,ins payments and copays
413 if ($iter{'code_type'} != 'payment_info') {
414 if ($iter{'code_type'} === 'COPAY' || $iter{'code_type'} === 'Patient Payment' || $iter{'code_type'} === 'Insurance Payment') {
415 print "<td width=40><span class=text><center>" . "1". "</center>" ;
417 // start fee output
418 // [pat_code] => 0.00
419 // [ins_code] => 0.00
420 // [pat_adjust_dollar] => 0.00
421 // [ins_adjust_dollar] => 0.00
422 if (($iter{'ins_adjust_dollar'}) != 0 and ($iter{'code_type'}) === 'Insurance Payment') {
423 print "</span></td><td width=100><span class=text><center>" . text("(". $iter{'ins_adjust_dollar'}.")"). "</center>";
426 if (($iter{'ins_code'}) != 0 and ($iter{'code_type'}) === 'Insurance Payment') {
427 print "</span></td><td width=100><span class=text><center>" . text("(". $iter{'ins_code'}.")"). "</center>";
430 if (($iter{'code_type'}) != "Patient Payment" and ($iter{'code_type'}) != 'Insurance Payment') {
431 print "</span></td><td width=100><span class=text><center>" . text("(". $iter{"code"}.")"). "</center>";
434 if (($iter{'pat_adjust_dollar'}) != 0 and ($iter{'code_type'}) === 'Patient Payment') {
435 print "</span></td><td width=100><span class=text><center>" . text("(". $iter{'pat_adjust_dollar'}.")"). "</center>";
438 if (($iter{'pat_code'}) != 0 and ($iter{'code_type'}) === 'Patient Payment') {
439 print "</span></td><td width=100><span class=text><center>" . text("(". $iter{'pat_code'}.")"). "</center>";
442 // end fee output
444 if (($iter{'ins_adjust_dollar'}) != 0 and ($iter{'code_type'}) === 'Insurance Payment') {
445 print "</span></td><td width=250><span class=text><center>" . xlt('Insurance Adjustment'). "</center>";
448 if (($iter{'pat_adjust_dollar'}) != 0 and ($iter{'code_type'}) === 'Patient Payment') {
449 print "</span></td><td width=250><span class=text><center>" . xlt('Patient Adjustment'). "</center>";
452 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
453 print "</span></td><td width=250><span class=text><center>" . xlt('Insurance Payment'). "</center>";
456 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
457 print "</span></td><td width=250><span class=text><center>" . xlt('Patient Payment'). "</center>";
460 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
461 print "</span></td><td width=250><span class=text><center>" . xlt('Insurance Credit'). "</center>";
464 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
465 print "</span></td><td width=250><span class=text><center>" . xlt('Patient Credit'). "</center>";
468 if ($iter{'paytype'} === 'PCP') {
469 print "</span></td><td width=250><span class=text><center>" . xlt('COPAY'). "</center>";
472 if (($iter{'code_type'}) != 'Insurance Payment' and ($iter{'code_type'}) != 'Patient Payment' and $iter{'paytype'} != 'PCP') {
473 print "</span></td><td width=100><span class=text><center>" . text($iter{'code_type'}). "</center>";
476 print "</span></td><td width=100><span class=text><center>" . text($iter{'provider_id'}). "</center>";
477 print "</span></td><td width=100><span class=text><center>" . text($iter{'user'}). "</center>" ;
478 print "</span></td><td width=100><span class=text>";
479 print "</span></td><td width=100><span class=small><center>" . text(date("Y-m-d", strtotime($iter{"date"}))). "</center>";
480 print "</span></td>\n";
481 } else {
482 if (date("Y-m-d", strtotime($iter{'bill_date'})) === '1969-12-31') {
483 print "<td width=40><span class=text><center>" . text($iter{'units'}) . "</center>" ;
484 print "</span></td><td width=100><span class=text><center>" . text($iter{'fee'}) . "</center>";
485 if ($GLOBALS['language_default'] === 'English (Standard)') {
486 print "</span></td><td width=250><span class=text><center>" . text(ucwords(strtolower(substr($iter{'code_text'}, 0, 38)))) . "</center>";
487 } else {
488 print "</span></td><td width=250><span class=text><center>" . text(substr($iter{'code_text'}, 0, 38)) . "</center>";
491 print "</span></td><td width=100><span class=text><center>" . text($iter{'provider_id'}) . "</center>" ;
492 print "</span></td><td width=100><span class=text><center>" . text($iter{'user'}) . "</center>" ;
493 print "</span></td><td width=100><span class=text><center>" . xlt("Not Billed"). "</center>";
494 print "</span></td><td width=100><span class=small><center>" . text(date("Y-m-d", strtotime($iter{'date'}))). "</center>";
495 print "</span></td><td width=100><span class=small><center>" . text($iter{'encounter'}). "</center>";
496 print "</span></td>\n";
497 } else {
498 if ($iter{'fee'} != 0) {
499 print "<td width=40><span class=text><center>" . text($iter{"units"}) . "</center>";
500 print "</span></td><td width=100><span class=text><center>" . text($iter{'fee'}) . "</center>";
501 if ($GLOBALS['language_default'] === 'English (Standard)') {
502 print "</span></td><td width=250><span class=text><center>" . text(ucwords(strtolower(substr($iter{'code_text'}, 0, 38)))) . "</center>";
503 } else {
504 print "</span></td><td width=250><span class=text><center>" . text(substr($iter{'code_text'}, 0, 38)) . "</center>";
507 print "</span></td><td width=100><span class=text><center>" . text($iter{'provider_id'}) . "</center>";
508 print "</span></td><td width=100><span class=text><center>" . text($iter{'user'}) . "</center>";
509 print "</span></td><td width=100><span class=small><center>" . text(date("Y-m-d", strtotime($iter{'bill_date'}))) . "</center>";
510 print "</span></td><td width=100><span class=small><center>" . text(date("Y-m-d", strtotime($iter{'date'}))). "</center>";
511 print "</span></td><td width=100><span class=small><center>" . text($iter{'encounter'}). "</center>";
512 print "</span></td>\n";
517 $res_count++;
519 if ($res_count == $N) {
520 print "</tr><tr>\n";
521 $res_count = 0;
524 $itero = $iter;
528 // end totals only
531 // end for
535 if ($anypats == 0) {
536 ?><font size = 5 ><?php echo xlt('No Data to Process')?></font><?php
539 // TEST TO SEE IF THERE IS INFORMATION IN THE VARAIBLES THEN ADD TO AN ARRAY FOR PRINTING
541 if ($us0_fee != 0 || $us0_inspay != 0 || $us0_insadj != 0 || $us0_patadj != 0 || $us0_patpay != 0) {
542 $user_info['user'][$k] = $us0_user;
543 $user_info['fee'][$k] = $us0_fee;
544 $user_info['inspay'][$k] = $us0_inspay;
545 $user_info['insadj'][$k] = $us0_insadj;
546 $user_info['patadj'][$k] = $us0_patadj;
547 $user_info['patpay'][$k] = $us0_patpay;
548 ++$k;
551 if ($us1_fee != 0 || $us1_inspay != 0 || $us1_insadj != 0 || $us1_patadj != 0 || $us1_patpay != 0) {
552 $user_info['user'][$k] = $us1_user;
553 $user_info['fee'][$k] = $us1_fee;
554 $user_info['inspay'][$k] = $us1_inspay;
555 $user_info['insadj'][$k] = $us1_insadj;
556 $user_info['patadj'][$k] = $us1_patadj;
557 $user_info['patpay'][$k] = $us1_patpay;
558 ++$k;
561 if ($us2_fee != 0 || $us2_inspay != 0 || $us2_insadj != 0 || $us2_patadj != 0 || $us2_patpay != 0) {
562 $user_info['user'][$k] = $us2_user;
563 $user_info['fee'][$k] = $us2_fee;
564 $user_info['inspay'][$k] = $us2_inspay;
565 $user_info['insadj'][$k] = $us2_insadj;
566 $user_info['patadj'][$k] = $us2_patadj;
567 $user_info['patpay'][$k] = $us2_patpay;
568 ++$k;
571 if ($us3_fee != 0 || $us3_inspay != 0 || $us3_insadj != 0 || $us3_patadj != 0 || $us3_patpay != 0) {
572 $user_info['user'][$k] = $us3_user;
573 $user_info['fee'][$k] = $us3_fee;
574 $user_info['inspay'][$k] = $us3_inspay;
575 $user_info['insadj'][$k] = $us3_insadj;
576 $user_info['patadj'][$k] = $us3_patadj;
577 $user_info['patpay'][$k] = $us3_patpay;
578 ++$k;
581 if ($us4_fee != 0 || $us4_inspay != 0 || $us4_insadj != 0 || $us4_patadj != 0 || $us4_patpay != 0) {
582 $user_info['user'][$k] = $us4_user;
583 $user_info['fee'][$k] = $us4_fee;
584 $user_info['inspay'][$k] = $us4_inspay;
585 $user_info['insadj'][$k] = $us4_insadj;
586 $user_info['patadj'][$k] = $us4_patadj;
587 $user_info['patpay'][$k] = $us4_patpay;
588 ++$k;
591 if ($us5_fee != 0 || $us5_inspay != 0 || $us5_insadj != 0 || $us5_patadj != 0 || $us5_patpay != 0) {
592 $user_info['user'][$k] = $us5_user;
593 $user_info['fee'][$k] = $us5_fee;
594 $user_info['inspay'][$k] = $us5_inspay;
595 $user_info['insadj'][$k] = $us5_insadj;
596 $user_info['patadj'][$k] = $us5_patadj;
597 $user_info['patpay'][$k] = $us5_patpay;
598 ++$k;
601 if ($us6_fee != 0 || $us6_inspay != 0 || $us6_insadj != 0 || $us6_patadj != 0 || $us6_patpay != 0) {
602 $user_info['user'][$k] = $us6_user;
603 $user_info['fee'][$k] = $us6_fee;
604 $user_info['inspay'][$k] = $us6_inspay;
605 $user_info['insadj'][$k] = $us6_insadj;
606 $user_info['patadj'][$k] = $us6_patadj;
607 $user_info['patpay'][$k] = $us6_patpay;
608 ++$k;
611 if ($us7_fee != 0 || $us7_inspay != 0 || $us7_insadj != 0 || $us7_patadj != 0 || $us7_patpay != 0) {
612 $user_info['user'][$k] = $us7_user;
613 $user_info['fee'][$k] = $us7_fee;
614 $user_info['inspay'][$k] = $us7_inspay;
615 $user_info['insadj'][$k] = $us7_insadj;
616 $user_info['patadj'][$k] = $us7_patadj;
617 $user_info['patpay'][$k] = $us7_patpay;
618 ++$k;
621 if ($us8_fee != 0 || $us8_inspay != 0 || $us8_insadj != 0 || $us8_patadj != 0 || $us8_patpay != 0) {
622 $user_info['user'][$k] = $us8_user;
623 $user_info['fee'][$k] = $us8_fee;
624 $user_info['inspay'][$k] = $us8_inspay;
625 $user_info['insadj'][$k] = $us8_insadj;
626 $user_info['patadj'][$k] = $us8_patadj;
627 $user_info['patpay'][$k] = $us8_patpay;
628 ++$k;
631 if ($us9_fee != 0 || $us9_inspay != 0 || $us9_insadj != 0 || $us9_patadj != 0 || $us9_patpay != 0) {
632 $user_info['user'][$k] = $us9_user;
633 $user_info['fee'][$k] = $us9_fee;
634 $user_info['inspay'][$k] = $us9_inspay;
635 $user_info['insadj'][$k] = $us9_insadj;
636 $user_info['patadj'][$k] = $us9_patadj;
637 $user_info['patpay'][$k] = $us9_patpay;
638 ++$k;
641 if ($us10_fee != 0 || $us10_inspay != 0 || $us10_insadj != 0 || $us10_patadj != 0 || $us10_patpay != 0) {
642 $user_info['user'][$k] = $us10_user;
643 $user_info['fee'][$k] = $us10_fee;
644 $user_info['inspay'][$k] = $us10_inspay;
645 $user_info['insadj'][$k] = $us10_insadj;
646 $user_info['patadj'][$k] = $us10_patadj;
647 $user_info['patpay'][$k] = $us10_patpay;
648 ++$k;
651 if ($us11_fee != 0 || $us11_inspay != 0 || $us11_insadj != 0 || $us11_patadj != 0 || $us11_patpay != 0) {
652 $user_info['user'][$k] = $us11_user;
653 $user_info['fee'][$k] = $us11_fee;
654 $user_info['inspay'][$k] = $us11_inspay;
655 $user_info['insadj'][$k] = $us11_insadj;
656 $user_info['patadj'][$k] = $us11_patadj;
657 $user_info['patpay'][$k] = $us11_patpay;
658 ++$k;
661 if ($us12_fee != 0 || $us12_inspay != 0 || $us12_insadj != 0 || $us12_patadj != 0 || $us12_patpay != 0) {
662 $user_info['user'][$k] = $us12_user;
663 $user_info['fee'][$k] = $us12_fee;
664 $user_info['inspay'][$k] = $us12_inspay;
665 $user_info['insadj'][$k] = $us12_insadj;
666 $user_info['patadj'][$k] = $us12_patadj;
667 $user_info['patpay'][$k] = $us12_patpay;
668 ++$k;
671 if ($us13_fee != 0 || $us13_inspay != 0 || $us13_insadj != 0 || $us13_patadj != 0 || $us13_patpay != 0) {
672 $user_info['user'][$k] = $us13_user;
673 $user_info['fee'][$k] = $us13_fee;
674 $user_info['inspay'][$k] = $us13_inspay;
675 $user_info['insadj'][$k] = $us13_insadj;
676 $user_info['patadj'][$k] = $us13_patadj;
677 $user_info['patpay'][$k] = $us13_patpay;
678 ++$k;
681 if ($us14_fee != 0 || $us14_inspay != 0 || $us14_insadj != 0 || $us14_patadj != 0 || $us14_patpay != 0) {
682 $user_info['user'][$k] = $us14_user;
683 $user_info['fee'][$k] = $us14_fee;
684 $user_info['inspay'][$k] = $us14_inspay;
685 $user_info['insadj'][$k] = $us14_insadj;
686 $user_info['patadj'][$k] = $us14_patadj;
687 $user_info['patpay'][$k] = $us14_patpay;
688 ++$k;
691 if ($us15_fee != 0 || $us15_inspay != 0 || $us15_insadj != 0 || $us15_patadj != 0 || $us15_patpay != 0) {
692 $user_info['user'][$k] = $us15_user;
693 $user_info['fee'][$k] = $us15_fee;
694 $user_info['inspay'][$k] = $us15_inspay;
695 $user_info['insadj'][$k] = $us15_insadj;
696 $user_info['patadj'][$k] = $us15_patadj;
697 $user_info['patpay'][$k] = $us15_patpay;
698 ++$k;
701 if ($us16_fee != 0 || $us16_inspay != 0 || $us16_insadj != 0 || $us16_patadj != 0 || $us16_patpay != 0) {
702 $user_info['user'][$k] = $us16_user;
703 $user_info['fee'][$k] = $us16_fee;
704 $user_info['inspay'][$k] = $us16_inspay;
705 $user_info['insadj'][$k] = $us16_insadj;
706 $user_info['patadj'][$k] = $us16_patadj;
707 $user_info['patpay'][$k] = $us16_patpay;
708 ++$k;
711 if ($us17_fee != 0 || $us17_inspay != 0 || $us17_insadj != 0 || $us17_patadj != 0 || $us17_patpay != 0) {
712 $user_info['user'][$k] = $us17_user;
713 $user_info['fee'][$k] = $us17_fee;
714 $user_info['inspay'][$k] = $us17_inspay;
715 $user_info['insadj'][$k] = $us17_insadj;
716 $user_info['patadj'][$k] = $us17_patadj;
717 $user_info['patpay'][$k] = $us17_patpay;
718 ++$k;
721 if ($us18_fee != 0 || $us18_inspay != 0 || $us18_insadj != 0 || $us18_patadj != 0 || $us18_patpay != 0) {
722 $user_info['user'][$k] = $us18_user;
723 $user_info['fee'][$k] = $us18_fee;
724 $user_info['inspay'][$k] = $us18_inspay;
725 $user_info['insadj'][$k] = $us18_insadj;
726 $user_info['patadj'][$k] = $us18_patadj;
727 $user_info['patpay'][$k] = $us18_patpay;
728 ++$k;
731 if ($us19_fee != 0 || $us19_inspay != 0 || $us19_insadj != 0 || $us19_patadj != 0 || $us19_patpay != 0) {
732 $user_info['user'][$k] = $us19_user;
733 $user_info['fee'][$k] = $us19_fee;
734 $user_info['inspay'][$k] = $us19_inspay;
735 $user_info['insadj'][$k] = $us19_insadj;
736 $user_info['patadj'][$k] = $us19_patadj;
737 $user_info['patpay'][$k] = $us19_patpay;
738 ++$k;
741 if ($totals_only == 1) {
742 $from_date = oeFormatShortDate(substr($query_part_day, 37, 10));
743 $to_date = oeFormatShortDate(substr($query_part_day, 63, 10));
744 print "<br><br>";
745 ?><font size = 5 ><?php echo xlt('Totals for '). $from_date . ' ' . xlt('To') . ' ' . $to_date ?></font><?php
748 for ($i=1; $i<$k;) {
749 print "<table border=1><tr>\n";
750 print "<br><br>";
752 Printf("<td width=70><span class=text><b>". xlt("User "). "</center></b><center>".text($user_info[user][$i])). "</center>";
753 Printf("<td width=140><span class=text><b><center>". xlt("Charges") . ' ' ."</center></b><center>"." %1\$.2f", text($user_info[fee][$i])). "</center>";
754 Printf("<td width=140><span class=text><b><center>". xlt("Insurance Adj").'. '."</center></b><center>"."%1\$.2f", text($user_info[insadj][$i])). "</center>";
755 Printf("<td width=140><span class=text><b><center>". xlt("Insurance Payments") . ' ' . "</center></b><center>"."%1\$.2f", text($user_info[inspay][$i])). "</center>";
756 Printf("<td width=140><span class=text><b><center>". xlt("Patient Adj").'. '."</center></b><center>"."%1\$.2f", text($user_info[patadj][$i])). "</center>";
757 Printf("<td width=140><span class=text><b><center>". xlt("Patient Payments"). ' ' ."</center></b><center>"."%1\$.2f", text($user_info[patpay][$i])). "</center>";
759 $gtotal_fee = $gtotal_fee + $user_info[fee][$i];
760 $gtotal_insadj = $gtotal_insadj + $user_info[insadj][$i];
761 $gtotal_inspay = $gtotal_inspay + $user_info[inspay][$i];
762 $gtotal_patadj = $gtotal_patadj + $user_info[patadj][$i];
763 $gtotal_patpay = $gtotal_patpay + $user_info[patpay][$i];
765 ++$i;
767 print "</br></td>";
770 print "<table border=1><tr>\n";
771 print "<br><br>";
773 Printf("<td width=70><span class=text><b><center>". xlt("Grand Totals").' ');
774 Printf("<td width=140><span class=text><b><center>". xlt("Total Charges").' '."</center></b><center>"." %1\$.2f", text($gtotal_fee)). "</center>";
775 Printf("<td width=140><span class=text><b><center>". xlt("Insurance Adj").'. '."</center></b><center>"."%1\$.2f", text($gtotal_insadj)). "</center>";
776 Printf("<td width=140><span class=text><b><center>". xlt("Insurance Payments") . ' ' ."</center></b><center>"."%1\$.2f", text($gtotal_inspay)). "</center>";
777 Printf("<td width=140><span class=text><b><center>". xlt("Patient Adj").'. '."</center></b><center>"."%1\$.2f", text($gtotal_patadj)). "</center>";
778 Printf("<td width=140><span class=text><b><center>". xlt("Patient Payments"). ' ' . "</center></b><center>"."%1\$.2f", text($gtotal_patpay)). "</center>";
780 print "</br></td>";
781 print "</table>";
784 </body>
785 </html>