minor fixes to prior commit
[openemr.git] / interface / billing / print_daysheet_report_num1.php
blob56545d1249be56b8ee436267c7af45e38729a97c
1 <?php
2 /**
3 * interface/billing/print_daysheet_report.php Genetating an end of day report.
4 *
5 * Program for Generating an End of Day report
6 *
7 *
8 * Copyright (C) 2014 Terry Hill <terry@lillysystems.com>
9 *
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
26 $fake_register_globals=false;
27 $sanitize_all_escapes=true;
29 include_once("../globals.php");
31 include_once("$srcdir/patient.inc");
32 include_once("$srcdir/../interface/reports/report.inc.php");
33 require_once("$srcdir/formatting.inc.php");
34 include_once("$srcdir/daysheet.inc.php");
36 //global variables:
37 if (!isset($_GET["mode"])) {
38 if (!isset($_GET["from_date"])) {
39 $from_date=date("Y-m-d");
40 } else {
41 $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"];
48 if (!isset($_GET["code_type"])) {
49 $code_type="all";
50 } else {
51 $code_type = $_GET["code_type"];
53 if (!isset($_GET["unbilled"])) {
54 $unbilled = "on";
55 } else {
56 $unbilled = $_GET["unbilled"];
58 if (!isset($_GET["authorized"])) {
59 $my_authorized = "on";
60 } else {
61 $my_authorized = $_GET["authorized"];
63 } else {
64 $from_date = $_GET["from_date"];
65 $to_date = $_GET["to_date"];
66 $code_type = $_GET["code_type"];
67 $unbilled = $_GET["unbilled"];
68 $my_authorized = $_GET["authorized"];
73 <html>
74 <head>
75 <?php html_header_show();?>
77 <link rel=stylesheet href="<?php echo $css_header;?>" type="text/css">
79 </head>
80 <body bgcolor="#ffffff" topmargin=0 rightmargin=0 leftmargin=2 bottommargin=0 marginwidth=2 marginheight=0>
82 <a href="javascript:window.close();" target=Main><font class=title><?php echo xlt('Day Sheet Report')?></font></a>
83 <br>
85 <?php
86 if ($my_authorized === 'on' ) {
87 $my_authorized = true;
88 } else {
89 $my_authorized = '%';
91 if ($unbilled === 'on') {
92 $unbilled = '0';
93 } else {
94 $unbilled = '%';
96 if ($code_type === 'all') {
97 $code_type = '%';
100 if (!isset($_GET["mode"])) {
101 if (!isset($_GET["from_date"])) {
102 $from_date=date("Y-m-d");
103 } else {
104 $from_date = $_GET["from_date"];
106 if (!isset($_GET["to_date"])) {
107 $to_date = date("Y-m-d");
108 } else {
109 $to_date = $_GET["to_date"];
111 if (!isset($_GET["code_type"])) {
112 $code_type="all";
113 } else {
114 $code_type = $_GET["code_type"];
116 if (!isset($_GET["unbilled"])) {
117 $unbilled = "on";
118 } else {
119 $unbilled = $_GET["unbilled"];
121 if (!isset($_GET["authorized"])) {
122 $my_authorized = "on";
123 } else {
124 $my_authorized = $_GET["authorized"];
126 } else {
127 $from_date = $_GET["from_date"];
128 $to_date = $_GET["to_date"];
129 $code_type = $_GET["code_type"];
130 $unbilled = $_GET["unbilled"];
131 $my_authorized = $_GET["authorized"];
134 if ($my_authorized === 'on' ) {
135 $my_authorized = true;
136 } else {
137 $my_authorized = '%';
139 if ($unbilled === 'on') {
140 $unbilled = '0';
141 } else {
142 $unbilled = '%';
144 if ($code_type === 'all') {
145 $code_type = '%';
148 if (isset($_GET["mode"]) && $_GET["mode"] === 'bill') {
149 billCodesList($list);
152 $res_count = 0;
153 $N = 1;
154 $k = 1;
155 $anypats = 0;
156 $the_first_time = 1;
157 $itero = array();
159 if ($ret = getBillsBetweendayReport($code_type)) {
161 // checking to see if there is any information in the array if not display a message (located after this if statment)
162 $anypats = count($ret);
165 $old_pid = -1;
166 $first_time = 1;
169 // $iter has encounter information
171 // this loop gathers the user numbers
172 foreach ($ret as $iter) {
173 $catch_user[] = $iter{'user'};
176 //This statment uniques the array removing duplicates
177 $user_list = array_unique($catch_user);
178 // reorder the list starting with array element zero
179 $final_list = array_values($user_list);
180 // sort array in assending order
181 sort($final_list);
183 $all4 = array_natsort($ret, pid, fulname, asc);
185 if ($_POST['end_of_day_totals_only'] == 1){
186 $totals_only = 1;
189 foreach ($all4 as $iter) {
191 // Case statment to tally information by user
192 switch ($iter{'user'}) {
193 case $iter{'user'} = $final_list[0]:
194 $us0_user = $iter{'user'};
195 $us0_fee = $us0_fee + $iter{'fee'};
196 $us0_inspay = $us0_inspay + $iter{'ins_code'};
197 $us0_insadj = $us0_insadj + $iter{'ins_adjust_dollar'};
198 $us0_patadj = $us0_patadj + $iter{'pat_adjust_dollar'};
199 $us0_patpay = $us0_patpay + $iter{'pat_code'};
200 break;
201 case $iter{'user'} = $final_list[1]:
202 $us1_user = $iter{'user'};
203 $us1_fee = $us1_fee + $iter{'fee'};
204 $us1_inspay = $us1_inspay + $iter{'ins_code'};
205 $us1_insadj = $us1_insadj + $iter{'ins_adjust_dollar'};
206 $us1_patadj = $us1_patadj + $iter{'pat_adjust_dollar'};
207 $us1_patpay = $us1_patpay + $iter{'pat_code'};
208 break;
209 case $iter{'user'} = $final_list[2]:
210 $us2_user = $iter{'user'};
211 $us2_fee = $us2_fee + $iter{'fee'};
212 $us2_inspay = $us2_inspay + $iter{'ins_code'};
213 $us2_insadj = $us2_insadj + $iter{'ins_adjust_dollar'};
214 $us2_patadj = $us2_patadj + $iter{'pat_adjust_dollar'};
215 $us2_patpay = $us2_patpay + $iter{'pat_code'};
216 break;
217 case $iter{'user'} = $final_list[3]:
218 $us3_user = $iter{'user'};
219 $us3_fee = $us3_fee + $iter{'fee'};
220 $us3_inspay = $us3_inspay + $iter{'ins_code'};
221 $us3_insadj = $us3_insadj + $iter{'ins_adjust_dollar'};
222 $us3_patadj = $us3_patadj + $iter{'pat_adjust_dollar'};
223 $us3_patpay = $us3_patpay + $iter{'pat_code'};
224 break;
225 case $iter{'user'} = $final_list[4]:
226 $us4_user = $iter{'user'};
227 $us4_fee = $us4_fee + $iter{'fee'};
228 $us4_inspay = $us4_inspay + $iter{'ins_code'};
229 $us4_insadj = $us4_insadj + $iter{'ins_adjust_dollar'};
230 $us4_patadj = $us4_patadj + $iter{'pat_adjust_dollar'};
231 $us4_patpay = $us4_patpay + $iter{'pat_code'};
232 break;
233 case $iter{'user'} = $final_list[5]:
234 $us5_user = $iter{'user'};
235 $us5_fee = $us5_fee + $iter{'fee'};
236 $us5_inspay = $us5_inspay + $iter{'ins_code'};
237 $us5_insadj = $us5_insadj + $iter{'ins_adjust_dollar'};
238 $us5_patadj = $us5_patadj + $iter{'pat_adjust_dollar'};
239 $us5_patpay = $us5_patpay + $iter{'pat_code'};
240 break;
241 case $iter{'user'} = $final_list[6]:
242 $us6_user = $iter{'user'};
243 $us6_fee = $us6_fee + $iter{'fee'};
244 $us6_inspay = $us6_inspay + $iter{'ins_code'};
245 $us6_insadj = $us6_insadj + $iter{'ins_adjust_dollar'};
246 $us6_patadj = $us6_patadj + $iter{'pat_adjust_dollar'};
247 $us6_patpay = $us6_patpay + $iter{'pat_code'};
248 break;
249 case $iter{'user'} = $final_list[7]:
250 $us7_user = $iter{'user'};
251 $us7_fee = $us7_fee + $iter{'fee'};
252 $us7_inspay = $us7_inspay + $iter{'ins_code'};
253 $us7_insadj = $us7_insadj + $iter{'ins_adjust_dollar'};
254 $us7_patadj = $us7_patadj + $iter{'pat_adjust_dollar'};
255 $us7_patpay = $us7_patpay + $iter{'pat_code'};
256 break;
257 case $iter{'user'} = $final_list[8]:
258 $us8_user = $iter{'user'};
259 $us8_fee = $us8_fee + $iter{'fee'};
260 $us8_inspay = $us8_inspay + $iter{'ins_code'};
261 $us8_insadj = $us8_insadj + $iter{'ins_adjust_dollar'};
262 $us8_patadj = $us8_patadj + $iter{'pat_adjust_dollar'};
263 $us8_patpay = $us8_patpay + $iter{'pat_code'};
264 break;
265 case $iter{'user'} = $final_list[9]:
266 $us9_user = $iter{'user'};
267 $us9_fee = $us9_fee + $iter{'fee'};
268 $us9_inspay = $us9_inspay + $iter{'ins_code'};
269 $us9_insadj = $us9_insadj + $iter{'ins_adjust_dollar'};
270 $us9_patadj = $us9_patadj + $iter{'pat_adjust_dollar'};
271 $us9_patpay = $us9_patpay + $iter{'pat_code'};
272 break;
273 case $iter{'user'} = $final_list[10]:
274 $us10_user = $iter{'user'};
275 $us10_fee = $us10_fee + $iter{'fee'};
276 $us10_inspay = $us10_inspay + $iter{'ins_code'};
277 $us10_insadj = $us10_insadj + $iter{'ins_adjust_dollar'};
278 $us10_patadj = $us10_patadj + $iter{'pat_adjust_dollar'};
279 $us10_patpay = $us10_patpay + $iter{'pat_code'};
280 break;
281 case $iter{'user'} = $final_list[11]:
282 $us11_user = $iter{'user'};
283 $us11_fee = $us11_fee + $iter{'fee'};
284 $us11_inspay = $us11_inspay + $iter{'ins_code'};
285 $us11_insadj = $us11_insadj + $iter{'ins_adjust_dollar'};
286 $us11_patadj = $us11_patadj + $iter{'pat_adjust_dollar'};
287 $us11_patpay = $us11_patpay + $iter{'pat_code'};
288 break;
289 case $iter{'user'} = $final_list[12]:
290 $us12_user = $iter{'user'};
291 $us12_fee = $us12_fee + $iter{'fee'};
292 $us12_inspay = $us12_inspay + $iter{'ins_code'};
293 $us12_insadj = $us12_insadj + $iter{'ins_adjust_dollar'};
294 $us12_patadj = $us12_patadj + $iter{'pat_adjust_dollar'};
295 $us12_patpay = $us12_patpay + $iter{'pat_code'};
296 break;
297 case $iter{'user'} = $final_list[13]:
298 $us13_user = $iter{'user'};
299 $us13_fee = $us13_fee + $iter{'fee'};
300 $us13_inspay = $us13_inspay + $iter{'ins_code'};
301 $us13_insadj = $us13_insadj + $iter{'ins_adjust_dollar'};
302 $us13_patadj = $us13_patadj + $iter{'pat_adjust_dollar'};
303 $us13_patpay = $us13_patpay + $iter{'pat_code'};
304 break;
305 case $iter{'user'} = $final_list[14]:
306 $us14_user = $iter{'user'};
307 $us14_fee = $us14_fee + $iter{'fee'};
308 $us14_inspay = $us14_inspay + $iter{'ins_code'};
309 $us14_insadj = $us14_insadj + $iter{'ins_adjust_dollar'};
310 $us14_patadj = $us14_patadj + $iter{'pat_adjust_dollar'};
311 $us14_patpay = $us14_patpay + $iter{'pat_code'};
312 break;
313 case $iter{'user'} = $final_list[15]:
314 $us15_user = $iter{'user'};
315 $us15_fee = $us15_fee + $iter{'fee'};
316 $us15_inspay = $us15_inspay + $iter{'ins_code'};
317 $us15_insadj = $us15_insadj + $iter{'ins_adjust_dollar'};
318 $us15_patadj = $us15_patadj + $iter{'pat_adjust_dollar'};
319 $us15_patpay = $us15_patpay + $iter{'pat_code'};
320 break;
321 case $iter{'user'} = $final_list[16]:
322 $us16_user = $iter{'user'};
323 $us16_fee = $us16_fee + $iter{'fee'};
324 $us16_inspay = $us16_inspay + $iter{'ins_code'};
325 $us16_insadj = $us16_insadj + $iter{'ins_adjust_dollar'};
326 $us16_patadj = $us16_patadj + $iter{'pat_adjust_dollar'};
327 $us16_patpay = $us16_patpay + $iter{'pat_code'};
328 break;
329 case $iter{'user'} = $final_list[17]:
330 $us17_user = $iter{'user'};
331 $us17_fee = $us17_fee + $iter{'fee'};
332 $us17_inspay = $us17_inspay + $iter{'ins_code'};
333 $us17_insadj = $us17_insadj + $iter{'ins_adjust_dollar'};
334 $us17_patadj = $us17_patadj + $iter{'pat_adjust_dollar'};
335 $us17_patpay = $us17_patpay + $iter{'pat_code'};
336 break;
337 case $iter{'user'} = $final_list[18]:
338 $us18_user = $iter{'user'};
339 $us18_fee = $us18_fee + $iter{'fee'};
340 $us18_inspay = $us18_inspay + $iter{'ins_code'};
341 $us18_insadj = $us18_insadj + $iter{'ins_adjust_dollar'};
342 $us18_patadj = $us18_patadj + $iter{'pat_adjust_dollar'};
343 $us18_patpay = $us18_patpay + $iter{'pat_code'};
344 break;
345 case $iter{'user'} = $final_list[19]:
346 $us19_user = $iter{'user'};
347 $us19_fee = $us19_fee + $iter{'fee'};
348 $us19_inspay = $us19_inspay + $iter{'ins_code'};
349 $us19_insadj = $us19_insadj + $iter{'ins_adjust_dollar'};
350 $us19_patadj = $us19_patadj + $iter{'pat_adjust_dollar'};
351 $us19_patpay = $us19_patpay + $iter{'pat_code'};
352 break;
355 if ($the_first_time == 1) {
356 $user = $iter{'user'};
357 $first_user = $iter{'user'};
358 $the_first_time = 0;
361 if ($totals_only != 1) {
363 if ($old_pid != $iter{'pid'} AND ($iter{'code_type'} != 'payment_info')) {
365 // $name has patient information
366 $name = getPatientData($iter{"pid"});
368 // formats the displayed text
370 if ($first_time) {
371 print "<table border=0><tr>\n"; // small table
372 $first_time=0;
375 // Displays name
376 print "<tr><td colspan=50><hr><span class=bold>" . " " . text($name{"fname"}) . " " . text($name{"lname"}) . "</span><br><br></td></tr><tr>\n";
377 //==================================
379 if ($iter{'code_type'} === 'COPAY' || $iter{'code_type'} === 'Patient Payment' || $iter{'code_type'} === 'Insurance Payment' ) {
381 print "<td width=40><span class=text><center><b>" . xlt("Units") . "</b></center>";
382 print "</span></td><td width=100><span class=text><center><b>" . xlt("Fee"). "</b></center>" ;
383 print "</span></td><td width=100><span class=text><center><b>" . xlt("Code"). "</b></center>" ;
384 print "</span></td><td width=100><span class=text><b>";
385 print "</span></td><td width=100><span class=text><center><b>" . xlt("User"). "</b></center>";
386 print "</span></td><td width=100><span class=small><b>";
387 print "</span></td><td width=100><span class=small><center><b>". xlt("Post Date"). "</b></center>";
388 print "</span></td><td></tr><tr>\n";
390 else
392 print "<td width=40><span class=text><b><center>" . xlt("Units"). "</b></center>";
393 print "</span></td><td width=100><span class=text><center><b>" . xlt("Fee"). "</b></center>";
394 print "</span></td><td width=100><span class=text><center><b>" . xlt("Code") . "</b></center>";
395 print "</span></td><td width=100><span class=text><b><center>" . xlt("Provider Id"). "</b></center>";
396 print "</span></td><td width=100><span class=text><b><center>" . xlt("User"). "</b></center>";
397 print "</span></td><td width=100><span class=small><center><b>" . xlt("Bill Date"). "</b></center>";
398 print "</span></td><td width=100><span class=small><center><b>". xlt("Date of Service"). "</b></center>";
399 print "</span></td><td width=100><span class=small><center><b>". xlt("Encounter"). "</b></center>";
400 print "</span></td><td></tr><tr>\n";
403 //Next patient
404 $old_pid = $iter{"pid"};
407 // get dollar amounts to appear on pat,ins payments and copays
409 if ($iter{'code_type'} != 'payment_info') {
410 if ($iter{'code_type'} === 'COPAY' || $iter{'code_type'} === 'Patient Payment' || $iter{'code_type'} === 'Insurance Payment' ) {
411 print "<td width=40><span class=text><center>" . "1". "</center>" ;
413 // start fee output
414 // [pat_code] => 0.00
415 // [ins_code] => 0.00
416 // [pat_adjust_dollar] => 0.00
417 // [ins_adjust_dollar] => 0.00
418 if (($iter{'ins_adjust_dollar'}) != 0 AND ($iter{'code_type'}) === 'Insurance Payment' ){
419 print "</span></td><td width=100><span class=text><center>" . text("(". $iter{'ins_adjust_dollar'}.")"). "</center>";
421 if (($iter{'ins_code'}) != 0 AND ($iter{'code_type'}) === 'Insurance Payment' ){
422 print "</span></td><td width=100><span class=text><center>" . text("(". $iter{'ins_code'}.")"). "</center>";
424 if (($iter{'code_type'}) != "Patient Payment" AND ($iter{'code_type'}) != 'Insurance Payment' ){
425 print "</span></td><td width=100><span class=text><center>" . text("(". $iter{"code"}.")"). "</center>";
427 if (($iter{'pat_adjust_dollar'}) != 0 AND ($iter{'code_type'}) === 'Patient Payment' ){
428 print "</span></td><td width=100><span class=text><center>" . text("(". $iter{'pat_adjust_dollar'}.")"). "</center>";
430 if (($iter{'pat_code'}) != 0 AND ($iter{'code_type'}) === 'Patient Payment' ){
431 print "</span></td><td width=100><span class=text><center>" . text("(". $iter{'pat_code'}.")"). "</center>";
433 // end fee output
435 if (($iter{'ins_adjust_dollar'}) != 0 AND ($iter{'code_type'}) === 'Insurance Payment' ){
436 print "</span></td><td width=250><span class=text><center>" . xlt('Insurance Adjustment'). "</center>";
438 if (($iter{'pat_adjust_dollar'}) != 0 AND ($iter{'code_type'}) === 'Patient Payment' ){
439 print "</span></td><td width=250><span class=text><center>" . xlt('Patient Adjustment'). "</center>";
441 if (($iter{'ins_code'}) > 0 AND ($iter{'code_type'}) === 'Insurance Payment' ){
442 print "</span></td><td width=250><span class=text><center>" . xlt('Insurance Payment'). "</center>";
444 if (($iter{'pat_code'}) > 0 AND ($iter{'code_type'}) === 'Patient Payment' AND $iter{'paytype'} != 'PCP' ){
445 print "</span></td><td width=250><span class=text><center>" . xlt('Patient Payment'). "</center>";
447 if (($iter{'ins_code'}) < 0 AND ($iter{'code_type'}) === 'Insurance Payment' ){
448 print "</span></td><td width=250><span class=text><center>" . xlt('Insurance Credit'). "</center>";
450 if (($iter{'pat_code'}) < 0 AND ($iter{'code_type'}) === 'Patient Payment' AND $iter{'paytype'} != 'PCP' ){
451 print "</span></td><td width=250><span class=text><center>" . xlt('Patient Credit'). "</center>";
453 if ($iter{'paytype'} === 'PCP') {
454 print "</span></td><td width=250><span class=text><center>" . xlt('COPAY'). "</center>";
456 if (($iter{'code_type'}) != 'Insurance Payment' AND ($iter{'code_type'}) != 'Patient Payment' AND $iter{'paytype'} != 'PCP') {
457 print "</span></td><td width=100><span class=text><center>" . text($iter{'code_type'}). "</center>";
459 print "</span></td><td width=100><span class=text><center>" . text($iter{'provider_id'}). "</center>";
460 print "</span></td><td width=100><span class=text><center>" . text($iter{'user'}). "</center>" ;
461 print "</span></td><td width=100><span class=text>";
462 print "</span></td><td width=100><span class=small><center>" . text(date("Y-m-d",strtotime($iter{"date"}))). "</center>";
463 print "</span></td>\n";
465 else
467 if (date("Y-m-d",strtotime($iter{'bill_date'})) === '1969-12-31') {
468 print "<td width=40><span class=text><center>" . text($iter{'units'}) . "</center>" ;
469 print "</span></td><td width=100><span class=text><center>" . text($iter{'fee'}) . "</center>";
470 if ($GLOBALS['language_default'] === 'English (Standard)'){
471 print "</span></td><td width=250><span class=text><center>" . text(ucwords(strtolower(substr($iter{'code_text'},0,38)))) . "</center>";
473 else
475 print "</span></td><td width=250><span class=text><center>" . text(substr($iter{'code_text'},0,38)) . "</center>";
477 print "</span></td><td width=100><span class=text><center>" . text($iter{'provider_id'}) . "</center>" ;
478 print "</span></td><td width=100><span class=text><center>" . text($iter{'user'}) . "</center>" ;
479 print "</span></td><td width=100><span class=text><center>" . xlt("Not Billed"). "</center>";
480 print "</span></td><td width=100><span class=small><center>" . text(date("Y-m-d",strtotime($iter{'date'}))). "</center>";
481 print "</span></td><td width=100><span class=small><center>" . text($iter{'encounter'}). "</center>";
482 print "</span></td>\n";
484 else
486 if ($iter{'fee'} != 0) {
487 print "<td width=40><span class=text><center>" . text($iter{"units"}) . "</center>";
488 print "</span></td><td width=100><span class=text><center>" . text($iter{'fee'}) . "</center>";
489 if ($GLOBALS['language_default'] === 'English (Standard)'){
490 print "</span></td><td width=250><span class=text><center>" . text(ucwords(strtolower(substr($iter{'code_text'},0,38)))) . "</center>";
492 else
494 print "</span></td><td width=250><span class=text><center>" . text(substr($iter{'code_text'},0,38)) . "</center>";
496 print "</span></td><td width=100><span class=text><center>" . text($iter{'provider_id'}) . "</center>";
497 print "</span></td><td width=100><span class=text><center>" . text($iter{'user'}) . "</center>";
498 print "</span></td><td width=100><span class=small><center>" . text(date("Y-m-d",strtotime($iter{'bill_date'}))) . "</center>";
499 print "</span></td><td width=100><span class=small><center>" . text(date("Y-m-d",strtotime($iter{'date'}))). "</center>";
500 print "</span></td><td width=100><span class=small><center>" . text($iter{'encounter'}). "</center>";
501 print "</span></td>\n";
506 $res_count++;
508 if ($res_count == $N) {
509 print "</tr><tr>\n";
510 $res_count = 0;
512 $itero = $iter;
516 // end totals only
519 // end for
523 if ($anypats == 0) {
524 ?><font size = 5 ><?php echo xlt('No Data to Process')?></font><?php
527 // TEST TO SEE IF THERE IS INFORMATION IN THE VARAIBLES THEN ADD TO AN ARRAY FOR PRINTING
529 if ($us0_fee != 0 || $us0_inspay != 0 || $us0_insadj != 0 || $us0_patadj != 0 || $us0_patpay != 0) {
530 $user_info['user'][$k] = $us0_user;
531 $user_info['fee'][$k] = $us0_fee;
532 $user_info['inspay'][$k] = $us0_inspay;
533 $user_info['insadj'][$k] = $us0_insadj;
534 $user_info['patadj'][$k] = $us0_patadj;
535 $user_info['patpay'][$k] = $us0_patpay;
536 ++$k;
538 if ($us1_fee != 0 || $us1_inspay != 0 || $us1_insadj != 0 || $us1_patadj != 0 || $us1_patpay != 0) {
539 $user_info['user'][$k] = $us1_user;
540 $user_info['fee'][$k] = $us1_fee;
541 $user_info['inspay'][$k] = $us1_inspay;
542 $user_info['insadj'][$k] = $us1_insadj;
543 $user_info['patadj'][$k] = $us1_patadj;
544 $user_info['patpay'][$k] = $us1_patpay;
545 ++$k;
547 if ($us2_fee != 0 || $us2_inspay != 0 || $us2_insadj != 0 || $us2_patadj != 0 || $us2_patpay != 0) {
548 $user_info['user'][$k] = $us2_user;
549 $user_info['fee'][$k] = $us2_fee;
550 $user_info['inspay'][$k] = $us2_inspay;
551 $user_info['insadj'][$k] = $us2_insadj;
552 $user_info['patadj'][$k] = $us2_patadj;
553 $user_info['patpay'][$k] = $us2_patpay;
554 ++$k;
556 if ($us3_fee != 0 || $us3_inspay != 0 || $us3_insadj != 0 || $us3_patadj != 0 || $us3_patpay != 0) {
557 $user_info['user'][$k] = $us3_user;
558 $user_info['fee'][$k] = $us3_fee;
559 $user_info['inspay'][$k] = $us3_inspay;
560 $user_info['insadj'][$k] = $us3_insadj;
561 $user_info['patadj'][$k] = $us3_patadj;
562 $user_info['patpay'][$k] = $us3_patpay;
563 ++$k;
565 if ($us4_fee != 0 || $us4_inspay != 0 || $us4_insadj != 0 || $us4_patadj != 0 || $us4_patpay != 0) {
566 $user_info['user'][$k] = $us4_user;
567 $user_info['fee'][$k] = $us4_fee;
568 $user_info['inspay'][$k] = $us4_inspay;
569 $user_info['insadj'][$k] = $us4_insadj;
570 $user_info['patadj'][$k] = $us4_patadj;
571 $user_info['patpay'][$k] = $us4_patpay;
572 ++$k;
574 if ($us5_fee != 0 || $us5_inspay != 0 || $us5_insadj != 0 || $us5_patadj != 0 || $us5_patpay != 0) {
575 $user_info['user'][$k] = $us5_user;
576 $user_info['fee'][$k] = $us5_fee;
577 $user_info['inspay'][$k] = $us5_inspay;
578 $user_info['insadj'][$k] = $us5_insadj;
579 $user_info['patadj'][$k] = $us5_patadj;
580 $user_info['patpay'][$k] = $us5_patpay;
581 ++$k;
583 if ($us6_fee != 0 || $us6_inspay != 0 || $us6_insadj != 0 || $us6_patadj != 0 || $us6_patpay != 0) {
584 $user_info['user'][$k] = $us6_user;
585 $user_info['fee'][$k] = $us6_fee;
586 $user_info['inspay'][$k] = $us6_inspay;
587 $user_info['insadj'][$k] = $us6_insadj;
588 $user_info['patadj'][$k] = $us6_patadj;
589 $user_info['patpay'][$k] = $us6_patpay;
590 ++$k;
592 if ($us7_fee != 0 || $us7_inspay != 0 || $us7_insadj != 0 || $us7_patadj != 0 || $us7_patpay != 0) {
593 $user_info['user'][$k] = $us7_user;
594 $user_info['fee'][$k] = $us7_fee;
595 $user_info['inspay'][$k] = $us7_inspay;
596 $user_info['insadj'][$k] = $us7_insadj;
597 $user_info['patadj'][$k] = $us7_patadj;
598 $user_info['patpay'][$k] = $us7_patpay;
599 ++$k;
601 if ($us8_fee != 0 || $us8_inspay != 0 || $us8_insadj != 0 || $us8_patadj != 0 || $us8_patpay != 0) {
602 $user_info['user'][$k] = $us8_user;
603 $user_info['fee'][$k] = $us8_fee;
604 $user_info['inspay'][$k] = $us8_inspay;
605 $user_info['insadj'][$k] = $us8_insadj;
606 $user_info['patadj'][$k] = $us8_patadj;
607 $user_info['patpay'][$k] = $us8_patpay;
608 ++$k;
610 if ($us9_fee != 0 || $us9_inspay != 0 || $us9_insadj != 0 || $us9_patadj != 0 || $us9_patpay != 0) {
611 $user_info['user'][$k] = $us9_user;
612 $user_info['fee'][$k] = $us9_fee;
613 $user_info['inspay'][$k] = $us9_inspay;
614 $user_info['insadj'][$k] = $us9_insadj;
615 $user_info['patadj'][$k] = $us9_patadj;
616 $user_info['patpay'][$k] = $us9_patpay;
617 ++$k;
619 if ($us10_fee != 0 || $us10_inspay != 0 || $us10_insadj != 0 || $us10_patadj != 0 || $us10_patpay != 0) {
620 $user_info['user'][$k] = $us10_user;
621 $user_info['fee'][$k] = $us10_fee;
622 $user_info['inspay'][$k] = $us10_inspay;
623 $user_info['insadj'][$k] = $us10_insadj;
624 $user_info['patadj'][$k] = $us10_patadj;
625 $user_info['patpay'][$k] = $us10_patpay;
626 ++$k;
628 if ($us11_fee != 0 || $us11_inspay != 0 || $us11_insadj != 0 || $us11_patadj != 0 || $us11_patpay != 0) {
629 $user_info['user'][$k] = $us11_user;
630 $user_info['fee'][$k] = $us11_fee;
631 $user_info['inspay'][$k] = $us11_inspay;
632 $user_info['insadj'][$k] = $us11_insadj;
633 $user_info['patadj'][$k] = $us11_patadj;
634 $user_info['patpay'][$k] = $us11_patpay;
635 ++$k;
637 if ($us12_fee != 0 || $us12_inspay != 0 || $us12_insadj != 0 || $us12_patadj != 0 || $us12_patpay != 0) {
638 $user_info['user'][$k] = $us12_user;
639 $user_info['fee'][$k] = $us12_fee;
640 $user_info['inspay'][$k] = $us12_inspay;
641 $user_info['insadj'][$k] = $us12_insadj;
642 $user_info['patadj'][$k] = $us12_patadj;
643 $user_info['patpay'][$k] = $us12_patpay;
644 ++$k;
646 if ($us13_fee != 0 || $us13_inspay != 0 || $us13_insadj != 0 || $us13_patadj != 0 || $us13_patpay != 0) {
647 $user_info['user'][$k] = $us13_user;
648 $user_info['fee'][$k] = $us13_fee;
649 $user_info['inspay'][$k] = $us13_inspay;
650 $user_info['insadj'][$k] = $us13_insadj;
651 $user_info['patadj'][$k] = $us13_patadj;
652 $user_info['patpay'][$k] = $us13_patpay;
653 ++$k;
655 if ($us14_fee != 0 || $us14_inspay != 0 || $us14_insadj != 0 || $us14_patadj != 0 || $us14_patpay != 0) {
656 $user_info['user'][$k] = $us14_user;
657 $user_info['fee'][$k] = $us14_fee;
658 $user_info['inspay'][$k] = $us14_inspay;
659 $user_info['insadj'][$k] = $us14_insadj;
660 $user_info['patadj'][$k] = $us14_patadj;
661 $user_info['patpay'][$k] = $us14_patpay;
662 ++$k;
664 if ($us15_fee != 0 || $us15_inspay != 0 || $us15_insadj != 0 || $us15_patadj != 0 || $us15_patpay != 0) {
665 $user_info['user'][$k] = $us15_user;
666 $user_info['fee'][$k] = $us15_fee;
667 $user_info['inspay'][$k] = $us15_inspay;
668 $user_info['insadj'][$k] = $us15_insadj;
669 $user_info['patadj'][$k] = $us15_patadj;
670 $user_info['patpay'][$k] = $us15_patpay;
671 ++$k;
673 if ($us16_fee != 0 || $us16_inspay != 0 || $us16_insadj != 0 || $us16_patadj != 0 || $us16_patpay != 0) {
674 $user_info['user'][$k] = $us16_user;
675 $user_info['fee'][$k] = $us16_fee;
676 $user_info['inspay'][$k] = $us16_inspay;
677 $user_info['insadj'][$k] = $us16_insadj;
678 $user_info['patadj'][$k] = $us16_patadj;
679 $user_info['patpay'][$k] = $us16_patpay;
680 ++$k;
682 if ($us17_fee != 0 || $us17_inspay != 0 || $us17_insadj != 0 || $us17_patadj != 0 || $us17_patpay != 0) {
683 $user_info['user'][$k] = $us17_user;
684 $user_info['fee'][$k] = $us17_fee;
685 $user_info['inspay'][$k] = $us17_inspay;
686 $user_info['insadj'][$k] = $us17_insadj;
687 $user_info['patadj'][$k] = $us17_patadj;
688 $user_info['patpay'][$k] = $us17_patpay;
689 ++$k;
691 if ($us18_fee != 0 || $us18_inspay != 0 || $us18_insadj != 0 || $us18_patadj != 0 || $us18_patpay != 0) {
692 $user_info['user'][$k] = $us18_user;
693 $user_info['fee'][$k] = $us18_fee;
694 $user_info['inspay'][$k] = $us18_inspay;
695 $user_info['insadj'][$k] = $us18_insadj;
696 $user_info['patadj'][$k] = $us18_patadj;
697 $user_info['patpay'][$k] = $us18_patpay;
698 ++$k;
700 if ($us19_fee != 0 || $us19_inspay != 0 || $us19_insadj != 0 || $us19_patadj != 0 || $us19_patpay != 0) {
701 $user_info['user'][$k] = $us19_user;
702 $user_info['fee'][$k] = $us19_fee;
703 $user_info['inspay'][$k] = $us19_inspay;
704 $user_info['insadj'][$k] = $us19_insadj;
705 $user_info['patadj'][$k] = $us19_patadj;
706 $user_info['patpay'][$k] = $us19_patpay;
707 ++$k;
710 if ($totals_only == 1) {
711 $from_date = oeFormatShortDate(substr($query_part_day,37,10));
712 $to_date = oeFormatShortDate(substr($query_part_day,63,10));
713 print "<br><br>";
714 ?><font size = 5 ><?php echo xlt('Totals for '). $from_date . ' ' . xlt('To') . ' ' . $to_date ?></font><?php
717 for ($i=1 ; $i<$k; ) {
718 print "<table border=1><tr>\n";
719 print "<br><br>";
721 Printf ("<td width=70><span class=text><b>". xlt("User "). "</center></b><center>".text($user_info[user][$i])). "</center>";
722 Printf ("<td width=140><span class=text><b><center>". xlt("Charges") . ' ' ."</center></b><center>"." %1\$.2f",text($user_info[fee][$i])). "</center>";
723 Printf ("<td width=140><span class=text><b><center>". xlt("Insurance Adj").'. '."</center></b><center>"."%1\$.2f",text($user_info[insadj][$i])). "</center>";
724 Printf ("<td width=140><span class=text><b><center>". xlt("Insurance Payments") . ' ' . "</center></b><center>"."%1\$.2f",text($user_info[inspay][$i])). "</center>";
725 Printf ("<td width=140><span class=text><b><center>". xlt("Patient Adj").'. '."</center></b><center>"."%1\$.2f",text($user_info[patadj][$i])). "</center>";
726 Printf ("<td width=140><span class=text><b><center>". xlt("Patient Payments"). ' ' ."</center></b><center>"."%1\$.2f",text($user_info[patpay][$i])). "</center>";
728 $gtotal_fee = $gtotal_fee + $user_info[fee][$i];
729 $gtotal_insadj = $gtotal_insadj + $user_info[insadj][$i];
730 $gtotal_inspay = $gtotal_inspay + $user_info[inspay][$i];
731 $gtotal_patadj = $gtotal_patadj + $user_info[patadj][$i];
732 $gtotal_patpay = $gtotal_patpay + $user_info[patpay][$i];
734 ++$i;
736 print "</br></td>";
738 print "<table border=1><tr>\n";
739 print "<br><br>";
741 Printf ("<td width=70><span class=text><b><center>". xlt("Grand Totals").' ');
742 Printf ("<td width=140><span class=text><b><center>". xlt("Total Charges").' '."</center></b><center>"." %1\$.2f",text($gtotal_fee)). "</center>";
743 Printf ("<td width=140><span class=text><b><center>". xlt("Insurance Adj").'. '."</center></b><center>"."%1\$.2f",text($gtotal_insadj)). "</center>";
744 Printf ("<td width=140><span class=text><b><center>". xlt("Insurance Payments") . ' ' ."</center></b><center>"."%1\$.2f",text($gtotal_inspay)). "</center>";
745 Printf ("<td width=140><span class=text><b><center>". xlt("Patient Adj").'. '."</center></b><center>"."%1\$.2f",text($gtotal_patadj)). "</center>";
746 Printf ("<td width=140><span class=text><b><center>". xlt("Patient Payments"). ' ' . "</center></b><center>"."%1\$.2f",text($gtotal_patpay)). "</center>";
748 print "</br></td>";
749 print "</table>";
752 </body>
753 </html>