dump db version
[openemr.git] / interface / billing / print_daysheet_report_num1.php
blob785edafac52c7cd00c7f8dd31736df642b9ba8e1
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 require_once("../globals.php");
30 require_once("$srcdir/patient.inc");
31 require_once("$srcdir/../interface/reports/report.inc.php");
32 require_once("$srcdir/daysheet.inc.php");
34 //global variables:
35 if (!isset($_GET["mode"])) {
36 if (!isset($_GET["from_date"])) {
37 $from_date=date("Y-m-d");
38 } else {
39 $from_date = $_GET["from_date"];
42 if (!isset($_GET["to_date"])) {
43 $to_date = date("Y-m-d");
44 } else {
45 $to_date = $_GET["to_date"];
48 if (!isset($_GET["code_type"])) {
49 $code_type="all";
50 } else {
51 $code_type = $_GET["code_type"];
54 if (!isset($_GET["unbilled"])) {
55 $unbilled = "on";
56 } else {
57 $unbilled = $_GET["unbilled"];
60 if (!isset($_GET["authorized"])) {
61 $my_authorized = "on";
62 } else {
63 $my_authorized = $_GET["authorized"];
65 } else {
66 $from_date = $_GET["from_date"];
67 $to_date = $_GET["to_date"];
68 $code_type = $_GET["code_type"];
69 $unbilled = $_GET["unbilled"];
70 $my_authorized = $_GET["authorized"];
75 <html>
76 <head>
77 <?php html_header_show();?>
79 <link rel=stylesheet href="<?php echo $css_header;?>" type="text/css">
81 </head>
82 <body bgcolor="#ffffff" topmargin=0 rightmargin=0 leftmargin=2 bottommargin=0 marginwidth=2 marginheight=0>
84 <a href="javascript:window.close();" target=Main><font class=title><?php echo xlt('Day Sheet Report')?></font></a>
85 <br>
87 <?php
88 if ($my_authorized === 'on') {
89 $my_authorized = true;
90 } else {
91 $my_authorized = '%';
94 if ($unbilled === 'on') {
95 $unbilled = '0';
96 } else {
97 $unbilled = '%';
100 if ($code_type === 'all') {
101 $code_type = '%';
104 if (!isset($_GET["mode"])) {
105 if (!isset($_GET["from_date"])) {
106 $from_date=date("Y-m-d");
107 } else {
108 $from_date = $_GET["from_date"];
111 if (!isset($_GET["to_date"])) {
112 $to_date = date("Y-m-d");
113 } else {
114 $to_date = $_GET["to_date"];
117 if (!isset($_GET["code_type"])) {
118 $code_type="all";
119 } else {
120 $code_type = $_GET["code_type"];
123 if (!isset($_GET["unbilled"])) {
124 $unbilled = "on";
125 } else {
126 $unbilled = $_GET["unbilled"];
129 if (!isset($_GET["authorized"])) {
130 $my_authorized = "on";
131 } else {
132 $my_authorized = $_GET["authorized"];
134 } else {
135 $from_date = $_GET["from_date"];
136 $to_date = $_GET["to_date"];
137 $code_type = $_GET["code_type"];
138 $unbilled = $_GET["unbilled"];
139 $my_authorized = $_GET["authorized"];
142 if ($my_authorized === 'on') {
143 $my_authorized = true;
144 } else {
145 $my_authorized = '%';
148 if ($unbilled === 'on') {
149 $unbilled = '0';
150 } else {
151 $unbilled = '%';
154 if ($code_type === 'all') {
155 $code_type = '%';
158 if (isset($_GET["mode"]) && $_GET["mode"] === 'bill') {
159 billCodesList($list);
162 $res_count = 0;
163 $N = 1;
164 $k = 1;
165 $anypats = 0;
166 $the_first_time = 1;
167 $itero = array();
169 if ($ret = getBillsBetweendayReport($code_type)) {
170 // checking to see if there is any information in the array if not display a message (located after this if statment)
171 $anypats = count($ret);
172 $run_provider = 0;
173 $old_pid = -1;
174 $first_time = 1;
175 $new_old_pid = -1;
177 // $iter has encounter information
179 // this loop gathers the user and provider numbers
180 foreach ($ret as $iter) {
181 $catch_user[] = $iter{'user'};
182 $catch_provider[] = $iter{'provider_id'};
185 //This statment uniques the arrays removing duplicates
187 $user_list = array_unique($catch_user);
188 $provider_list = array_unique($catch_provider);
190 // reorder the list starting with array element zero
191 $user_final_list = array_values($user_list);
192 $provider_final_list = array_values($provider_list);
193 // sort array in assending order
194 sort($user_final_list);
195 sort($provider_final_list);
196 $all4 = array_natsort($ret, pid, fulname, asc);
198 if ($_POST['end_of_day_provider_only'] == 1) {
199 $run_provider = 1;
202 if ($_POST['end_of_day_totals_only'] == 1) {
203 $totals_only = 1;
206 foreach ($all4 as $iter) {
207 // Case statment to tally information by user
208 switch ($iter{'user'}) {
209 case $iter{'user'} = $user_final_list[0]:
210 $us0_user = $iter{'user'};
211 $us0_fee = $us0_fee + $iter{'fee'};
212 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
213 $us0_inspay = $us0_inspay + $iter{'ins_code'};
216 $us0_insadj = $us0_insadj + $iter{'ins_adjust_dollar'};
217 $us0_patadj = $us0_patadj + $iter{'pat_adjust_dollar'};
218 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
219 $us0_patpay = $us0_patpay + $iter{'pat_code'};
222 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
223 $us0_insref = $us0_insref + $iter{'ins_code'};
226 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
227 $us0_patref = $us0_patref + $iter{'pat_code'};
229 break;
230 case $iter{'user'} = $user_final_list[1]:
231 $us1_user = $iter{'user'};
232 $us1_fee = $us1_fee + $iter{'fee'};
233 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
234 $us1_inspay = $us1_inspay + $iter{'ins_code'};
237 $us1_insadj = $us1_insadj + $iter{'ins_adjust_dollar'};
238 $us1_patadj = $us1_patadj + $iter{'pat_adjust_dollar'};
239 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
240 $us1_patpay = $us1_patpay + $iter{'pat_code'};
243 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
244 $us1_insref = $us1_insref + $iter{'ins_code'};
247 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
248 $us1_patref = $us1_patref + $iter{'pat_code'};
250 break;
251 case $iter{'user'} = $user_final_list[2]:
252 $us2_user = $iter{'user'};
253 $us2_fee = $us2_fee + $iter{'fee'};
254 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
255 $us2_inspay = $us2_inspay + $iter{'ins_code'};
258 $us2_insadj = $us2_insadj + $iter{'ins_adjust_dollar'};
259 $us2_patadj = $us2_patadj + $iter{'pat_adjust_dollar'};
260 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
261 $us2_patpay = $us2_patpay + $iter{'pat_code'};
264 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
265 $us2_insref = $us2_insref + $iter{'ins_code'};
268 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
269 $us2_patref = $us2_patref + $iter{'pat_code'};
271 break;
272 case $iter{'user'} = $user_final_list[3]:
273 $us3_user = $iter{'user'};
274 $us3_fee = $us3_fee + $iter{'fee'};
275 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
276 $us3_inspay = $us3_inspay + $iter{'ins_code'};
279 $us3_insadj = $us3_insadj + $iter{'ins_adjust_dollar'};
280 $us3_patadj = $us3_patadj + $iter{'pat_adjust_dollar'};
281 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
282 $us3_patpay = $us3_patpay + $iter{'pat_code'};
285 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
286 $us3_insref = $us3_insref + $iter{'ins_code'};
289 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
290 $us3_patref = $us3_patref + $iter{'pat_code'};
292 break;
293 case $iter{'user'} = $user_final_list[4]:
294 $us4_user = $iter{'user'};
295 $us4_fee = $us4_fee + $iter{'fee'};
296 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
297 $us4_inspay = $us4_inspay + $iter{'ins_code'};
300 $us4_insadj = $us4_insadj + $iter{'ins_adjust_dollar'};
301 $us4_patadj = $us4_patadj + $iter{'pat_adjust_dollar'};
302 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
303 $us4_patpay = $us4_patpay + $iter{'pat_code'};
306 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
307 $us4_insref = $us4_insref + $iter{'ins_code'};
310 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
311 $us4_patref = $us4_patref + $iter{'pat_code'};
313 break;
314 case $iter{'user'} = $user_final_list[5]:
315 $us5_user = $iter{'user'};
316 $us5_fee = $us5_fee + $iter{'fee'};
317 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
318 $us5_inspay = $us5_inspay + $iter{'ins_code'};
321 $us5_insadj = $us5_insadj + $iter{'ins_adjust_dollar'};
322 $us5_patadj = $us5_patadj + $iter{'pat_adjust_dollar'};
323 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
324 $us5_patpay = $us5_patpay + $iter{'pat_code'};
327 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
328 $us5_insref = $us5_insref + $iter{'ins_code'};
331 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
332 $us5_patref = $us5_patref + $iter{'pat_code'};
334 break;
335 case $iter{'user'} = $user_final_list[6]:
336 $us6_user = $iter{'user'};
337 $us6_fee = $us6_fee + $iter{'fee'};
338 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
339 $us6_inspay = $us6_inspay + $iter{'ins_code'};
342 $us6_insadj = $us6_insadj + $iter{'ins_adjust_dollar'};
343 $us6_patadj = $us6_patadj + $iter{'pat_adjust_dollar'};
344 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
345 $us6_patpay = $us6_patpay + $iter{'pat_code'};
348 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
349 $us6_insref = $us6_insref + $iter{'ins_code'};
352 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
353 $us6_patref = $us6_patref + $iter{'pat_code'};
355 break;
356 case $iter{'user'} = $user_final_list[7]:
357 $us7_user = $iter{'user'};
358 $us7_fee = $us7_fee + $iter{'fee'};
359 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
360 $us7_inspay = $us7_inspay + $iter{'ins_code'};
363 $us7_insadj = $us7_insadj + $iter{'ins_adjust_dollar'};
364 $us7_patadj = $us7_patadj + $iter{'pat_adjust_dollar'};
365 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
366 $us7_patpay = $us7_patpay + $iter{'pat_code'};
369 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
370 $us7_insref = $us7_insref + $iter{'ins_code'};
373 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
374 $us7_patref = $us7_patref + $iter{'pat_code'};
376 break;
377 case $iter{'user'} = $user_final_list[8]:
378 $us8_user = $iter{'user'};
379 $us8_fee = $us8_fee + $iter{'fee'};
380 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
381 $us8_inspay = $us8_inspay + $iter{'ins_code'};
384 $us8_insadj = $us8_insadj + $iter{'ins_adjust_dollar'};
385 $us8_patadj = $us8_patadj + $iter{'pat_adjust_dollar'};
386 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
387 $us8_patpay = $us8_patpay + $iter{'pat_code'};
390 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
391 $us8_insref = $us8_insref + $iter{'ins_code'};
394 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
395 $us8_patref = $us8_patref + $iter{'pat_code'};
397 break;
398 case $iter{'user'} = $user_final_list[9]:
399 $us9_user = $iter{'user'};
400 $us9_fee = $us9_fee + $iter{'fee'};
401 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
402 $us9_inspay = $us9_inspay + $iter{'ins_code'};
405 $us9_insadj = $us9_insadj + $iter{'ins_adjust_dollar'};
406 $us9_patadj = $us9_patadj + $iter{'pat_adjust_dollar'};
407 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
408 $us9_patpay = $us9_patpay + $iter{'pat_code'};
411 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
412 $us9_insref = $us9_insref + $iter{'ins_code'};
415 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
416 $us9_patref = $us9_patref + $iter{'pat_code'};
418 break;
419 case $iter{'user'} = $user_final_list[10]:
420 $us10_user = $iter{'user'};
421 $us10_fee = $us10_fee + $iter{'fee'};
422 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
423 $us10_inspay = $us10_inspay + $iter{'ins_code'};
426 $us10_insadj = $us10_insadj + $iter{'ins_adjust_dollar'};
427 $us10_patadj = $us10_patadj + $iter{'pat_adjust_dollar'};
428 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
429 $us10_patpay = $us10_patpay + $iter{'pat_code'};
432 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
433 $us10_insref = $us10_insref + $iter{'ins_code'};
436 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
437 $us10_patref = $us10_patref + $iter{'pat_code'};
439 break;
440 case $iter{'user'} = $user_final_list[11]:
441 $us11_user = $iter{'user'};
442 $us11_fee = $us11_fee + $iter{'fee'};
443 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
444 $us11_inspay = $us11_inspay + $iter{'ins_code'};
447 $us11_insadj = $us11_insadj + $iter{'ins_adjust_dollar'};
448 $us11_patadj = $us11_patadj + $iter{'pat_adjust_dollar'};
449 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
450 $us11_patpay = $us11_patpay + $iter{'pat_code'};
453 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
454 $us11_insref = $us11_insref + $iter{'ins_code'};
457 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
458 $us11_patref = $us11_patref + $iter{'pat_code'};
460 break;
461 case $iter{'user'} = $user_final_list[12]:
462 $us12_user = $iter{'user'};
463 $us12_fee = $us12_fee + $iter{'fee'};
464 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
465 $us12_inspay = $us12_inspay + $iter{'ins_code'};
468 $us12_insadj = $us12_insadj + $iter{'ins_adjust_dollar'};
469 $us12_patadj = $us12_patadj + $iter{'pat_adjust_dollar'};
470 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
471 $us12_patpay = $us12_patpay + $iter{'pat_code'};
474 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
475 $us12_insref = $us12_insref + $iter{'ins_code'};
478 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
479 $us12_patref = $us12_patref + $iter{'pat_code'};
481 break;
482 case $iter{'user'} = $user_final_list[13]:
483 $us13_user = $iter{'user'};
484 $us13_fee = $us13_fee + $iter{'fee'};
485 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
486 $us13_inspay = $us13_inspay + $iter{'ins_code'};
489 $us13_insadj = $us13_insadj + $iter{'ins_adjust_dollar'};
490 $us13_patadj = $us13_patadj + $iter{'pat_adjust_dollar'};
491 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
492 $us13_patpay = $us13_patpay + $iter{'pat_code'};
495 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
496 $us13_insref = $us13_insref + $iter{'ins_code'};
499 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
500 $us13_patref = $us13_patref + $iter{'pat_code'};
502 break;
503 case $iter{'user'} = $user_final_list[14]:
504 $us14_user = $iter{'user'};
505 $us14_fee = $us14_fee + $iter{'fee'};
506 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
507 $us14_inspay = $us14_inspay + $iter{'ins_code'};
510 $us14_insadj = $us14_insadj + $iter{'ins_adjust_dollar'};
511 $us14_patadj = $us14_patadj + $iter{'pat_adjust_dollar'};
512 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
513 $us14_patpay = $us14_patpay + $iter{'pat_code'};
516 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
517 $us14_insref = $us14_insref + $iter{'ins_code'};
520 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
521 $us14_patref = $us14_patref + $iter{'pat_code'};
523 break;
524 case $iter{'user'} = $user_final_list[15]:
525 $us15_user = $iter{'user'};
526 $us15_fee = $us15_fee + $iter{'fee'};
527 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
528 $us15_inspay = $us15_inspay + $iter{'ins_code'};
531 $us15_insadj = $us15_insadj + $iter{'ins_adjust_dollar'};
532 $us15_patadj = $us15_patadj + $iter{'pat_adjust_dollar'};
533 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
534 $us15_patpay = $us15_patpay + $iter{'pat_code'};
537 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
538 $us15_insref = $us15_insref + $iter{'ins_code'};
541 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
542 $us15_patref = $us15_patref + $iter{'pat_code'};
544 break;
545 case $iter{'user'} = $user_final_list[16]:
546 $us16_user = $iter{'user'};
547 $us16_fee = $us16_fee + $iter{'fee'};
548 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
549 $us16_inspay = $us16_inspay + $iter{'ins_code'};
552 $us16_insadj = $us16_insadj + $iter{'ins_adjust_dollar'};
553 $us16_patadj = $us16_patadj + $iter{'pat_adjust_dollar'};
554 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
555 $us16_patpay = $us16_patpay + $iter{'pat_code'};
558 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
559 $us16_insref = $us16_insref + $iter{'ins_code'};
562 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
563 $us16_patref = $us16_patref + $iter{'pat_code'};
565 break;
566 case $iter{'user'} = $user_final_list[17]:
567 $us17_user = $iter{'user'};
568 $us17_fee = $us17_fee + $iter{'fee'};
569 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
570 $us17_inspay = $us17_inspay + $iter{'ins_code'};
573 $us17_insadj = $us17_insadj + $iter{'ins_adjust_dollar'};
574 $us17_patadj = $us17_patadj + $iter{'pat_adjust_dollar'};
575 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
576 $us17_patpay = $us17_patpay + $iter{'pat_code'};
579 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
580 $us17_insref = $us17_insref + $iter{'ins_code'};
583 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
584 $us17_patref = $us17_patref + $iter{'pat_code'};
586 break;
587 case $iter{'user'} = $user_final_list[18]:
588 $us18_user = $iter{'user'};
589 $us18_fee = $us18_fee + $iter{'fee'};
590 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
591 $us18_inspay = $us18_inspay + $iter{'ins_code'};
594 $us18_insadj = $us18_insadj + $iter{'ins_adjust_dollar'};
595 $us18_patadj = $us18_patadj + $iter{'pat_adjust_dollar'};
596 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
597 $us18_patpay = $us18_patpay + $iter{'pat_code'};
600 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
601 $us18_insref = $us18_insref + $iter{'ins_code'};
604 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
605 $us18_patref = $us18_patref + $iter{'pat_code'};
607 break;
608 case $iter{'user'} = $fuser_final_list[19]:
609 $us19_user = $iter{'user'};
610 $us19_fee = $us19_fee + $iter{'fee'};
611 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
612 $us19_inspay = $us19_inspay + $iter{'ins_code'};
615 $us19_insadj = $us19_insadj + $iter{'ins_adjust_dollar'};
616 $us19_patadj = $us19_patadj + $iter{'pat_adjust_dollar'};
617 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
618 $us19_patpay = $us19_patpay + $iter{'pat_code'};
621 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
622 $us19_insref = $us19_insref + $iter{'ins_code'};
625 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
626 $us19_patref = $us19_patref + $iter{'pat_code'};
628 break;
631 // Case statment to tally information by Provider
632 switch ($iter{'provider_id'}) {
633 case $iter{'provider_id'} = $provider_final_list[0]:
634 $pro0_user = $iter{'provider_id'};
635 $pro0_fee = $pro0_fee + $iter{'fee'};
636 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
637 $pro0_inspay = $pro0_inspay + $iter{'ins_code'};
640 $pro0_insadj = $pro0_insadj + $iter{'ins_adjust_dollar'};
641 $pro0_patadj = $pro0_patadj + $iter{'pat_adjust_dollar'};
642 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
643 $pro0_patpay = $pro0_patpay + $iter{'pat_code'};
646 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
647 $pro0_insref = $pro0_insref + $iter{'ins_code'};
650 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
651 $pro0_patref = $pro0_patref + $iter{'pat_code'};
653 break;
654 case $iter{'provider_id'} = $provider_final_list[1]:
655 $pro1_user = $iter{'provider_id'};
656 $pro1_fee = $pro1_fee + $iter{'fee'};
657 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
658 $pro1_inspay = $pro1_inspay + $iter{'ins_code'};
661 $pro1_insadj = $pro1_insadj + $iter{'ins_adjust_dollar'};
662 $pro1_patadj = $pro1_patadj + $iter{'pat_adjust_dollar'};
663 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
664 $pro1_patpay = $pro1_patpay + $iter{'pat_code'};
667 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
668 $pro1_insref = $pro1_insref + $iter{'ins_code'};
671 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
672 $pro1_patref = $pro1_patref + $iter{'pat_code'};
674 break;
675 case $iter{'provider_id'} = $provider_final_list[2]:
676 $pro2_user = $iter{'provider_id'};
677 $pro2_fee = $pro2_fee + $iter{'fee'};
678 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
679 $pro2_inspay = $pro2_inspay + $iter{'ins_code'};
682 $pro2_insadj = $pro2_insadj + $iter{'ins_adjust_dollar'};
683 $pro2_patadj = $pro2_patadj + $iter{'pat_adjust_dollar'};
684 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
685 $pro2_patpay = $pro2_patpay + $iter{'pat_code'};
688 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
689 $pro2_insref = $pro2_insref + $iter{'ins_code'};
692 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
693 $pro2_patref = $pro2_patref + $iter{'pat_code'};
695 break;
696 case $iter{'provider_id'} = $provider_final_list[3]:
697 $pro3_user = $iter{'provider_id'};
698 $pro3_fee = $pro3_fee + $iter{'fee'};
699 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
700 $pro3_inspay = $pro3_inspay + $iter{'ins_code'};
703 $pro3_insadj = $pro3_insadj + $iter{'ins_adjust_dollar'};
704 $pro3_patadj = $pro3_patadj + $iter{'pat_adjust_dollar'};
705 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
706 $pro3_patpay = $pro3_patpay + $iter{'pat_code'};
709 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
710 $pro3_insref = $pro3_insref + $iter{'ins_code'};
713 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
714 $pro3_patref = $pro3_patref + $iter{'pat_code'};
716 break;
717 case $iter{'provider_id'} = $provider_final_list[4]:
718 $pro4_user = $iter{'provider_id'};
719 $pro4_fee = $pro4_fee + $iter{'fee'};
720 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
721 $pro4_inspay = $pro4_inspay + $iter{'ins_code'};
724 $pro4_insadj = $pro4_insadj + $iter{'ins_adjust_dollar'};
725 $pro4_patadj = $pro4_patadj + $iter{'pat_adjust_dollar'};
726 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
727 $pro4_patpay = $pro4_patpay + $iter{'pat_code'};
730 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
731 $pro4_insref = $pro4_insref + $iter{'ins_code'};
734 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
735 $pro4_patref = $pro4_patref + $iter{'pat_code'};
737 break;
738 case $iter{'provider_id'} = $provider_final_list[5]:
739 $pro5_user = $iter{'provider_id'};
740 $pro5_fee = $pro5_fee + $iter{'fee'};
741 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
742 $pro5_inspay = $pro5_inspay + $iter{'ins_code'};
745 $pro5_insadj = $pro5_insadj + $iter{'ins_adjust_dollar'};
746 $pro5_patadj = $pro5_patadj + $iter{'pat_adjust_dollar'};
747 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
748 $pro5_patpay = $pro5_patpay + $iter{'pat_code'};
751 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
752 $pro5_insref = $pro5_insref + $iter{'ins_code'};
755 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
756 $pro5_patref = $pro5_patref + $iter{'pat_code'};
758 break;
759 case $iter{'provider_id'} = $provider_final_list[6]:
760 $pro6_user = $iter{'provider_id'};
761 $pro6_fee = $pro6_fee + $iter{'fee'};
762 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
763 $pro6_inspay = $pro6_inspay + $iter{'ins_code'};
766 $pro6_insadj = $pro6_insadj + $iter{'ins_adjust_dollar'};
767 $pro6_patadj = $pro6_patadj + $iter{'pat_adjust_dollar'};
768 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
769 $pro6_patpay = $pro6_patpay + $iter{'pat_code'};
772 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
773 $pro6_insref = $pro6_insref + $iter{'ins_code'};
776 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
777 $pro6_patref = $pro6_patref + $iter{'pat_code'};
779 break;
780 case $iter{'provider_id'} = $provider_final_list[7]:
781 $pro7_user = $iter{'provider_id'};
782 $pro7_fee = $pro7_fee + $iter{'fee'};
783 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
784 $pro7_inspay = $pro7_inspay + $iter{'ins_code'};
787 $pro7_insadj = $pro7_insadj + $iter{'ins_adjust_dollar'};
788 $pro7_patadj = $pro7_patadj + $iter{'pat_adjust_dollar'};
789 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
790 $pro7_patpay = $pro7_patpay + $iter{'pat_code'};
793 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
794 $pro7_insref = $pro7_insref + $iter{'ins_code'};
797 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
798 $pro7_patref = $pro7_patref + $iter{'pat_code'};
800 break;
801 case $iter{'provider_id'} = $provider_final_list[8]:
802 $pro8_user = $iter{'provider_id'};
803 $pro8_fee = $pro8_fee + $iter{'fee'};
804 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
805 $pro8_inspay = $pro8_inspay + $iter{'ins_code'};
808 $pro8_insadj = $pro8_insadj + $iter{'ins_adjust_dollar'};
809 $pro8_patadj = $pro8_patadj + $iter{'pat_adjust_dollar'};
810 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
811 $pro8_patpay = $pro8_patpay + $iter{'pat_code'};
814 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
815 $pro8_insref = $pro8_insref + $iter{'ins_code'};
818 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
819 $pro8_patref = $pro8_patref + $iter{'pat_code'};
821 break;
822 case $iter{'provider_id'} = $provider_final_list[9]:
823 $pro9_user = $iter{'provider_id'};
824 $pro9_fee = $pro9_fee + $iter{'fee'};
825 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
826 $pro9_inspay = $pro9_inspay + $iter{'ins_code'};
829 $pro9_insadj = $pro9_insadj + $iter{'ins_adjust_dollar'};
830 $pro9_patadj = $pro9_patadj + $iter{'pat_adjust_dollar'};
831 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
832 $pro9_patpay = $pro9_patpay + $iter{'pat_code'};
835 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
836 $pro9_insref = $pro9_insref + $iter{'ins_code'};
839 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
840 $pro9_patref = $pro9_patref + $iter{'pat_code'};
842 break;
843 case $iter{'provider_id'} = $provider_final_list[10]:
844 $pro10_user = $iter{'provider_id'};
845 $pro10_fee = $pro10_fee + $iter{'fee'};
846 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
847 $pro10_inspay = $pro0_inspay + $iter{'ins_code'};
850 $pro10_insadj = $pro10_insadj + $iter{'ins_adjust_dollar'};
851 $pro10_patadj = $pro10_patadj + $iter{'pat_adjust_dollar'};
852 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
853 $pro10_patpay = $pro10_patpay + $iter{'pat_code'};
856 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
857 $pro10_insref = $pro10_insref + $iter{'ins_code'};
860 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
861 $pro10_patref = $pro10_patref + $iter{'pat_code'};
863 break;
864 case $iter{'provider_id'} = $provider_final_list[11]:
865 $pro11_user = $iter{'provider_id'};
866 $pro11_fee = $pro11_fee + $iter{'fee'};
867 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
868 $pro11_inspay = $pro11_inspay + $iter{'ins_code'};
871 $pro11_insadj = $pro11_insadj + $iter{'ins_adjust_dollar'};
872 $pro11_patadj = $pro11_patadj + $iter{'pat_adjust_dollar'};
873 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
874 $pro11_patpay = $pro11_patpay + $iter{'pat_code'};
877 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
878 $pro11_insref = $pro11_insref + $iter{'ins_code'};
881 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
882 $pro11_patref = $pro11_patref + $iter{'pat_code'};
884 break;
885 case $iter{'provider_id'} = $provider_final_list[12]:
886 $pro12_user = $iter{'provider_id'};
887 $pro12_fee = $pro12_fee + $iter{'fee'};
888 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
889 $pro12_inspay = $pro12_inspay + $iter{'ins_code'};
892 $pro12_insadj = $pro12_insadj + $iter{'ins_adjust_dollar'};
893 $pro12_patadj = $pro12_patadj + $iter{'pat_adjust_dollar'};
894 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
895 $pro12_patpay = $pro12_patpay + $iter{'pat_code'};
898 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
899 $pro12_insref = $pro12_insref + $iter{'ins_code'};
902 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
903 $pro12_patref = $pro12_patref + $iter{'pat_code'};
905 break;
906 case $iter{'provider_id'} = $provider_final_list[13]:
907 $pro13_user = $iter{'provider_id'};
908 $pro13_fee = $pro13_fee + $iter{'fee'};
909 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
910 $pro13_inspay = $pro13_inspay + $iter{'ins_code'};
913 $pro13_insadj = $pro13_insadj + $iter{'ins_adjust_dollar'};
914 $pro13_patadj = $pro13_patadj + $iter{'pat_adjust_dollar'};
915 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
916 $pro13_patpay = $pro13_patpay + $iter{'pat_code'};
919 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
920 $pro13_insref = $pro13_insref + $iter{'ins_code'};
923 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
924 $pro13_patref = $pro13_patref + $iter{'pat_code'};
926 break;
927 case $iter{'provider_id'} = $provider_final_list[14]:
928 $pro14_user = $iter{'provider_id'};
929 $pro14_fee = $pro14_fee + $iter{'fee'};
930 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
931 $pro14_inspay = $pro14_inspay + $iter{'ins_code'};
934 $pro14_insadj = $pro14_insadj + $iter{'ins_adjust_dollar'};
935 $pro14_patadj = $pro14_patadj + $iter{'pat_adjust_dollar'};
936 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
937 $pro14_patpay = $pro14_patpay + $iter{'pat_code'};
940 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
941 $pro14_insref = $pro14_insref + $iter{'ins_code'};
944 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
945 $pro14_patref = $pro14_patref + $iter{'pat_code'};
947 break;
948 case $iter{'provider_id'} = $provider_final_list[15]:
949 $pro15_user = $iter{'provider_id'};
950 $pro15_fee = $pro15_fee + $iter{'fee'};
951 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
952 $pro15_inspay = $pro15_inspay + $iter{'ins_code'};
955 $pro15_insadj = $pro15_insadj + $iter{'ins_adjust_dollar'};
956 $pro15_patadj = $pro15_patadj + $iter{'pat_adjust_dollar'};
957 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
958 $pro15_patpay = $pro15_patpay + $iter{'pat_code'};
961 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
962 $pro15_insref = $pro15_insref + $iter{'ins_code'};
965 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
966 $pro15_patref = $pro15_patref + $iter{'pat_code'};
968 break;
969 case $iter{'provider_id'} = $provider_final_list[16]:
970 $pro16_user = $iter{'provider_id'};
971 $pro16_fee = $pro16_fee + $iter{'fee'};
972 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
973 $pro16_inspay = $pro16_inspay + $iter{'ins_code'};
976 $pro16_insadj = $pro16_insadj + $iter{'ins_adjust_dollar'};
977 $pro16_patadj = $pro16_patadj + $iter{'pat_adjust_dollar'};
978 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
979 $pro16_patpay = $pro16_patpay + $iter{'pat_code'};
982 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
983 $pro16_insref = $pro16_insref + $iter{'ins_code'};
986 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
987 $pro16_patref = $pro16_patref + $iter{'pat_code'};
989 break;
990 case $iter{'provider_id'} = $provider_final_list[17]:
991 $pro17_user = $iter{'provider_id'};
992 $pro17_fee = $pro17_fee + $iter{'fee'};
993 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
994 $pro17_inspay = $pro17_inspay + $iter{'ins_code'};
997 $pro17_insadj = $pro17_insadj + $iter{'ins_adjust_dollar'};
998 $pro17_patadj = $pro17_patadj + $iter{'pat_adjust_dollar'};
999 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
1000 $pro17_patpay = $pro17_patpay + $iter{'pat_code'};
1003 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
1004 $pro17_insref = $pro17_insref + $iter{'ins_code'};
1007 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
1008 $pro17_patref = $pro17_patref + $iter{'pat_code'};
1010 break;
1011 case $iter{'provider_id'} = $provider_final_list[18]:
1012 $pro18_user = $iter{'provider_id'};
1013 $pro18_fee = $pro18_fee + $iter{'fee'};
1014 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
1015 $pro18_inspay = $pro18_inspay + $iter{'ins_code'};
1018 $pro18_insadj = $pro18_insadj + $iter{'ins_adjust_dollar'};
1019 $pro18_patadj = $pro18_patadj + $iter{'pat_adjust_dollar'};
1020 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
1021 $pro18_patpay = $pro18_patpay + $iter{'pat_code'};
1024 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
1025 $pro18_insref = $pro18_insref + $iter{'ins_code'};
1028 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
1029 $pro18_patref = $pro18_patref + $iter{'pat_code'};
1031 break;
1032 case $iter{'provider_id'} = $provider_final_list[19]:
1033 $pro19_user = $iter{'provider_id'};
1034 $pro19_fee = $pro19_fee + $iter{'fee'};
1035 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
1036 $pro19_inspay = $pro19_inspay + $iter{'ins_code'};
1039 $pro19_insadj = $pro19_insadj + $iter{'ins_adjust_dollar'};
1040 $pro19_patadj = $pro19_patadj + $iter{'pat_adjust_dollar'};
1041 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment') {
1042 $pro19_patpay = $pro19_patpay + $iter{'pat_code'};
1045 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
1046 $pro19_insref = $pro19_insref + $iter{'ins_code'};
1049 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
1050 $pro19_patref = $pro19_patref + $iter{'pat_code'};
1052 break;
1055 if ($the_first_time === 1) {
1056 $user = $iter{'user'};
1057 $new_old_pid = $iter{'pid'};
1058 $the_first_time = 0;
1061 if ($totals_only != 1) {
1062 if ($old_pid != $iter{'pid'} and ($iter{'code_type'} != 'payment_info')) {
1063 if ($old_pid === $new_old_pid) {
1064 $line_total = 0;
1065 $line_total_pay = 0;
1068 if ($first_time) {
1069 print "<table border=0><tr>\n"; // small table
1070 $first_time=0;
1073 print "<td width=70><span class=text><b><center>" . xlt("Date"). "</b></center>";
1074 print "</span></td><td width=50><span class=text><center><b>" . xlt("Acct").'#'. "</b></center>";
1075 print "</span></td><td width=100><span class=text><center><b>" . xlt("Name") . "</b></center>";
1076 print "</span></td><td width=100><span class=text><b><center>" . xlt("Source"). "</b></center>";
1077 print "</span></td><td width=100><span class=text><b><center>" . xlt("CPT"). "</b></center>";
1078 print "</span></td><td width=100><span class=small><center><b>" . xlt("ICD"). "</b></center>";
1079 print "</span></td><td width=100><span class=small><center><b>". xlt("Charges"). "</b></center>";
1080 print "</span></td><td width=100><span class=small><center><b>". xlt("Payments").'/'.xlt("Adj").".". "</b></center>";
1081 print "</span></td><td><br></tr><tr>\n";
1082 //Next patient
1083 $old_pid = $iter{'pid'};
1086 // get dollar amounts to appear on pat,ins payments and copays
1088 if ($iter{'code_type'} != 'payment_info') {
1089 if ($iter{'code_type'} === 'COPAY' || $iter{'code_type'} === 'Patient Payment' || $iter{'code_type'} === 'Insurance Payment') {
1090 print "<td width=70><span class=text><center>" . text(date("Y-m-d", strtotime($iter{'date'}))). "</center>" ;
1091 print "</span></td><td width=50><span class=text><center>" . text($iter{'pid'}) . "</center>";
1092 print "</span></td><td width=180><span class=text><center>" . text($iter{'last'}) . ", " . text($iter{'first'}) ."</center>";
1093 if (($iter{'ins_adjust_dollar'}) != 0 and ($iter{'code_type'}) === 'Insurance Payment') {
1094 print "</span></td><td width=180><span class=text><center>" . xlt('Insurance Adjustment'). "</center>";
1097 if (($iter{'pat_adjust_dollar'}) != 0 and ($iter{'code_type'}) === 'Patient Payment') {
1098 print "</span></td><td width=180><span class=text><center>" . xlt('Patient Adjustment'). "</center>";
1101 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
1102 print "</span></td><td width=180><span class=text><center>" . xlt('Insurance Payment'). "</center>";
1105 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
1106 print "</span></td><td width=180><span class=text><center>" . xlt('Patient Payment'). "</center>";
1109 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
1110 print "</span></td><td width=180><span class=text><center>" . xlt('Insurance Credit'). "</center>";
1113 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
1114 print "</span></td><td width=180><span class=text><center>" . xlt('Patient Credit'). "</center>";
1117 if ($iter{'paytype'} === 'PCP') {
1118 print "</span></td><td width=180><span class=text><center>" . xlt('COPAY'). "</center>";
1121 print "</span></td><td width=100><span class=text>";
1122 print "</span></td><td width=100><span class=text>";
1123 print "</span></td><td width=100><span class=text>";
1124 if (($iter{'ins_adjust_dollar'}) != 0 and ($iter{'code_type'}) === 'Insurance Payment') {
1125 $line_total_pay = $line_total_pay + $iter{'ins_adjust_dollar'};
1126 print "</span></td><td width=100><span class=text><center>" . text($iter{'ins_adjust_dollar'}). "</center>";
1129 if (($iter{'ins_code'}) != 0 and ($iter{'code_type'}) === 'Insurance Payment') {
1130 $line_total_pay = $line_total_pay + $iter{'ins_code'};
1131 print "</span></td><td width=100><span class=text><center>" . text($iter{'ins_code'}). "</center>";
1134 if (($iter{'code_type'}) != 'Patient Payment' and ($iter{'code_type'}) != 'Insurance Payment') {
1135 $line_total_pay = $line_total_pay + $iter{'code'};
1136 print "</span></td><td width=100><span class=text><center>" . text($iter{'code'}). "</center>";
1139 if (($iter{'pat_adjust_dollar'}) != 0 and ($iter{'code_type'}) === 'Patient Payment') {
1140 $line_total_pay = $line_total_pay + $iter{'pat_adjust_dollar'};
1141 print "</span></td><td width=100><span class=text><center>" . text($iter{'pat_adjust_dollar'}). "</center>";
1144 if (($iter{'pat_code'}) != 0 and ($iter{'code_type'}) === 'Patient Payment') {
1145 $line_total_pay = $line_total_pay + $iter{'pat_code'};
1146 print "</span></td><td width=100><span class=text><center>" . text($iter{'pat_code'}). "</center>";
1149 if (($iter{'code_type'}) != 'Insurance Payment' and ($iter{'code_type'}) != 'Patient Payment' and $iter{'paytype'} != 'PCP') {
1150 print "</span></td><td width=100><span class=text><center>" . text($iter{'code_type'}). "</center>";
1153 print "</span></td><td width=100><span class=text>";
1154 print "</span></td>\n";
1155 } else {
1156 if ($iter{'fee'} != 0) {
1157 $line_total = $line_total + $iter{'fee'};
1158 print "<td width=70><span class=text><center>" . text(date("Y-m-d", strtotime($iter{'date'}))) . "</center>";
1159 print "</span></td><td width=50><span class=text><center>" . text($iter{'pid'}) . "</center>";
1160 print "</span></td><td width=180><span class=text><center>" . text($iter{'last'}) . ", " . text($iter{'first'}) . "</center>";
1161 if ($GLOBALS['language_default'] === 'English (Standard)') {
1162 print "</span></td><td width=100><span class=text><center>" . text(ucwords(strtolower(substr($iter{'code_text'}, 0, 25)))) . "</center>";
1163 } else {
1164 print "</span></td><td width=100><span class=text><center>" . text(substr($iter{'code_text'}, 0, 25)) . "</center>";
1167 print "</span></td><td width=100><span class=text><center>" . text($iter{'code'}) . "</center>";
1168 print "</span></td><td width=100><span class=small><center>" . text(substr($iter{'justify'}, 5, 3)) . "</center>";
1169 print "</span></td><td width=100><span class=small><center>" . text($iter{'fee'}). "</center>";
1170 print "</span></td>\n";
1174 if ($iter{'code_type'} === 'COPAY' || $iter{'code_type'} === 'Patient Payment' || $iter{'code_type'} === 'Insurance Payment' || $iter{'fee'} != 0) {
1175 $res_count++;
1178 if ($res_count === $N) {
1179 print "</tr><tr>\n";
1180 $res_count = 0;
1183 $itero = $iter;
1185 if ($old_pid != $new_old_pid and ($iter{'code_type'} != 'payment_info')) {
1186 $new_old_pid = $old_pid;
1191 // end totals only
1194 // end for
1198 if ($anypats === 0) {
1199 ?><font size = 5 ><?php echo xlt('No Data to Process')?></font><?php
1202 // TEST TO SEE IF THERE IS INFORMATION IN THE VARAIBLES THEN ADD TO AN ARRAY FOR PRINTING
1203 if ($run_provider != 1) {
1204 if ($us0_fee != 0 || $us0_inspay != 0 || $us0_insadj != 0 || $us0_patadj != 0 || $us0_patpay != 0 || $us0_insref != 0 || $us0_patref != 0) {
1205 $user_info['user'][$k] = $us0_user;
1206 $user_info['fee'][$k] = $us0_fee;
1207 $user_info['inspay'][$k] = $us0_inspay;
1208 $user_info['insadj'][$k] = $us0_insadj;
1209 $user_info['insref'][$k] = $us0_insref;
1210 $user_info['patadj'][$k] = $us0_patadj;
1211 $user_info['patpay'][$k] = $us0_patpay;
1212 $user_info['patref'][$k] = $us0_patref;
1213 ++$k;
1216 if ($us1_fee != 0 || $us1_inspay != 0 || $us1_insadj != 0 || $us1_patadj != 0 || $us1_patpay != 0 || $us1_insref != 0 || $us1_patref != 0) {
1217 $user_info['user'][$k] = $us1_user;
1218 $user_info['fee'][$k] = $us1_fee;
1219 $user_info['inspay'][$k] = $us1_inspay;
1220 $user_info['insadj'][$k] = $us1_insadj;
1221 $user_info['insref'][$k] = $us1_insref;
1222 $user_info['patadj'][$k] = $us1_patadj;
1223 $user_info['patpay'][$k] = $us1_patpay;
1224 $user_info['patref'][$k] = $us1_patref;
1225 ++$k;
1228 if ($us2_fee != 0 || $us2_inspay != 0 || $us2_insadj != 0 || $us2_patadj != 0 || $us2_patpay != 0 || $us2_insref != 0 || $us2_patref != 0) {
1229 $user_info['user'][$k] = $us2_user;
1230 $user_info['fee'][$k] = $us2_fee;
1231 $user_info['inspay'][$k] = $us2_inspay;
1232 $user_info['insadj'][$k] = $us2_insadj;
1233 $user_info['insref'][$k] = $us2_insref;
1234 $user_info['patadj'][$k] = $us2_patadj;
1235 $user_info['patpay'][$k] = $us2_patpay;
1236 $user_info['patref'][$k] = $us2_patref;
1237 ++$k;
1240 if ($us3_fee != 0 || $us3_inspay != 0 || $us3_insadj != 0 || $us3_patadj != 0 || $us3_patpay != 0 || $us3_insref != 0 || $us3_patref != 0) {
1241 $user_info['user'][$k] = $us3_user;
1242 $user_info['fee'][$k] = $us3_fee;
1243 $user_info['inspay'][$k] = $us3_inspay;
1244 $user_info['insadj'][$k] = $us3_insadj;
1245 $user_info['insref'][$k] = $us3_insref;
1246 $user_info['patadj'][$k] = $us3_patadj;
1247 $user_info['patpay'][$k] = $us3_patpay;
1248 $user_info['patref'][$k] = $us3_patref;
1249 ++$k;
1252 if ($us4_fee != 0 || $us4_inspay != 0 || $us4_insadj != 0 || $us4_patadj != 0 || $us4_patpay != 0 || $us4_insref != 0 || $us4_patref != 0) {
1253 $user_info['user'][$k] = $us4_user;
1254 $user_info['fee'][$k] = $us4_fee;
1255 $user_info['inspay'][$k] = $us4_inspay;
1256 $user_info['insadj'][$k] = $us4_insadj;
1257 $user_info['insref'][$k] = $us4_insref;
1258 $user_info['patadj'][$k] = $us4_patadj;
1259 $user_info['patpay'][$k] = $us4_patpay;
1260 $user_info['patref'][$k] = $us4_patref;
1261 ++$k;
1264 if ($us5_fee != 0 || $us5_inspay != 0 || $us5_insadj != 0 || $us5_patadj != 0 || $us5_patpay != 0 || $us5_insref != 0 || $us5_patref != 0) {
1265 $user_info['user'][$k] = $us5_user;
1266 $user_info['fee'][$k] = $us5_fee;
1267 $user_info['inspay'][$k] = $us5_inspay;
1268 $user_info['insadj'][$k] = $us5_insadj;
1269 $user_info['insref'][$k] = $us5_insref;
1270 $user_info['patadj'][$k] = $us5_patadj;
1271 $user_info['patpay'][$k] = $us5_patpay;
1272 $user_info['patref'][$k] = $us5_patref;
1273 ++$k;
1276 if ($us6_fee != 0 || $us6_inspay != 0 || $us6_insadj != 0 || $us6_patadj != 0 || $us6_patpay != 0 || $us6_insref != 0 || $us6_patref != 0) {
1277 $user_info['user'][$k] = $us6_user;
1278 $user_info['fee'][$k] = $us6_fee;
1279 $user_info['inspay'][$k] = $us6_inspay;
1280 $user_info['insadj'][$k] = $us6_insadj;
1281 $user_info['insref'][$k] = $us6_insref;
1282 $user_info['patadj'][$k] = $us6_patadj;
1283 $user_info['patpay'][$k] = $us6_patpay;
1284 $user_info['patref'][$k] = $us6_patref;
1285 ++$k;
1288 if ($us7_fee != 0 || $us7_inspay != 0 || $us7_insadj != 0 || $us7_patadj != 0 || $us7_patpay != 0 || $us7_insref != 0 || $us7_patref != 0) {
1289 $user_info['user'][$k] = $us7_user;
1290 $user_info['fee'][$k] = $us7_fee;
1291 $user_info['inspay'][$k] = $us7_inspay;
1292 $user_info['insadj'][$k] = $us7_insadj;
1293 $user_info['insref'][$k] = $us7_insref;
1294 $user_info['patadj'][$k] = $us7_patadj;
1295 $user_info['patpay'][$k] = $us7_patpay;
1296 $user_info['patref'][$k] = $us7_patref;
1297 ++$k;
1300 if ($us8_fee != 0 || $us8_inspay != 0 || $us8_insadj != 0 || $us8_patadj != 0 || $us8_patpay != 0 || $us8_insref != 0 || $us8_patref != 0) {
1301 $user_info['user'][$k] = $us8_user;
1302 $user_info['fee'][$k] = $us8_fee;
1303 $user_info['inspay'][$k] = $us8_inspay;
1304 $user_info['insadj'][$k] = $us8_insadj;
1305 $user_info['insref'][$k] = $us8_insref;
1306 $user_info['patadj'][$k] = $us8_patadj;
1307 $user_info['patpay'][$k] = $us8_patpay;
1308 $user_info['patref'][$k] = $us8_patref;
1309 ++$k;
1312 if ($us9_fee != 0 || $us9_inspay != 0 || $us9_insadj != 0 || $us9_patadj != 0 || $us9_patpay != 0 || $us9_insref != 0 || $us9_patref != 0) {
1313 $user_info['user'][$k] = $us9_user;
1314 $user_info['fee'][$k] = $us9_fee;
1315 $user_info['inspay'][$k] = $us9_inspay;
1316 $user_info['insadj'][$k] = $us9_insadj;
1317 $user_info['insref'][$k] = $us9_insref;
1318 $user_info['patadj'][$k] = $us9_patadj;
1319 $user_info['patpay'][$k] = $us9_patpay;
1320 $user_info['patref'][$k] = $us9_patref;
1321 ++$k;
1324 if ($us10_fee != 0 || $us10_inspay != 0 || $us10_insadj != 0 || $us10_patadj != 0 || $us10_patpay != 0 || $us10_insref != 0 || $us10_patref != 0) {
1325 $user_info['user'][$k] = $us10_user;
1326 $user_info['fee'][$k] = $us10_fee;
1327 $user_info['inspay'][$k] = $us10_inspay;
1328 $user_info['insadj'][$k] = $us10_insadj;
1329 $user_info['insref'][$k] = $us10_insref;
1330 $user_info['patadj'][$k] = $us10_patadj;
1331 $user_info['patpay'][$k] = $us10_patpay;
1332 $user_info['patref'][$k] = $us10_patref;
1333 ++$k;
1336 if ($us11_fee != 0 || $us11_inspay != 0 || $us11_insadj != 0 || $us11_patadj != 0 || $us11_patpay != 0 || $us11_insref != 0 || $us11_patref != 0) {
1337 $user_info['user'][$k] = $us11_user;
1338 $user_info['fee'][$k] = $us11_fee;
1339 $user_info['inspay'][$k] = $us11_inspay;
1340 $user_info['insadj'][$k] = $us11_insadj;
1341 $user_info['insref'][$k] = $us11_insref;
1342 $user_info['patadj'][$k] = $us11_patadj;
1343 $user_info['patpay'][$k] = $us11_patpay;
1344 $user_info['patref'][$k] = $us11_patref;
1345 ++$k;
1348 if ($us12_fee != 0 || $us12_inspay != 0 || $us12_insadj != 0 || $us12_patadj != 0 || $us12_patpay != 0 || $us12_insref != 0 || $us12_patref != 0) {
1349 $user_info['user'][$k] = $us12_user;
1350 $user_info['fee'][$k] = $us12_fee;
1351 $user_info['inspay'][$k] = $us12_inspay;
1352 $user_info['insadj'][$k] = $us12_insadj;
1353 $user_info['insref'][$k] = $us12_insref;
1354 $user_info['patadj'][$k] = $us12_patadj;
1355 $user_info['patpay'][$k] = $us12_patpay;
1356 $user_info['patref'][$k] = $us12_patref;
1357 ++$k;
1360 if ($us13_fee != 0 || $us13_inspay != 0 || $us13_insadj != 0 || $us13_patadj != 0 || $us13_patpay != 0 || $us13_insref != 0 || $us13_patref != 0) {
1361 $user_info['user'][$k] = $us13_user;
1362 $user_info['fee'][$k] = $us13_fee;
1363 $user_info['inspay'][$k] = $us13_inspay;
1364 $user_info['insadj'][$k] = $us13_insadj;
1365 $user_info['insref'][$k] = $us13_insref;
1366 $user_info['patadj'][$k] = $us13_patadj;
1367 $user_info['patpay'][$k] = $us13_patpay;
1368 $user_info['patref'][$k] = $us13_patref;
1369 ++$k;
1372 if ($us14_fee != 0 || $us14_inspay != 0 || $us14_insadj != 0 || $us14_patadj != 0 || $us14_patpay != 0 || $us14_insref != 0 || $us14_patref != 0) {
1373 $user_info['user'][$k] = $us14_user;
1374 $user_info['fee'][$k] = $us14_fee;
1375 $user_info['inspay'][$k] = $us14_inspay;
1376 $user_info['insadj'][$k] = $us14_insadj;
1377 $user_info['insref'][$k] = $us14_insref;
1378 $user_info['patadj'][$k] = $us14_patadj;
1379 $user_info['patpay'][$k] = $us14_patpay;
1380 $user_info['patref'][$k] = $us14_patref;
1381 ++$k;
1384 if ($us15_fee != 0 || $us15_inspay != 0 || $us15_insadj != 0 || $us15_patadj != 0 || $us15_patpay != 0 || $us15_insref != 0 || $us15_patref != 0) {
1385 $user_info['user'][$k] = $us15_user;
1386 $user_info['fee'][$k] = $us15_fee;
1387 $user_info['inspay'][$k] = $us15_inspay;
1388 $user_info['insadj'][$k] = $us15_insadj;
1389 $user_info['insref'][$k] = $us15_insref;
1390 $user_info['patadj'][$k] = $us15_patadj;
1391 $user_info['patpay'][$k] = $us15_patpay;
1392 $user_info['patref'][$k] = $us15_patref;
1393 ++$k;
1396 if ($us16_fee != 0 || $us16_inspay != 0 || $us16_insadj != 0 || $us16_patadj != 0 || $us16_patpay != 0 || $us16_insref != 0 || $us16_patref != 0) {
1397 $user_info['user'][$k] = $us16_user;
1398 $user_info['fee'][$k] = $us16_fee;
1399 $user_info['inspay'][$k] = $us16_inspay;
1400 $user_info['insadj'][$k] = $us16_insadj;
1401 $user_info['insref'][$k] = $us16_insref;
1402 $user_info['patadj'][$k] = $us16_patadj;
1403 $user_info['patpay'][$k] = $us16_patpay;
1404 $user_info['patref'][$k] = $us16_patref;
1405 ++$k;
1408 if ($us17_fee != 0 || $us17_inspay != 0 || $us17_insadj != 0 || $us17_patadj != 0 || $us17_patpay != 0 || $us17_insref != 0 || $us17_patref != 0) {
1409 $user_info['user'][$k] = $us17_user;
1410 $user_info['fee'][$k] = $us17_fee;
1411 $user_info['inspay'][$k] = $us17_inspay;
1412 $user_info['insadj'][$k] = $us17_insadj;
1413 $user_info['insref'][$k] = $us17_insref;
1414 $user_info['patadj'][$k] = $us17_patadj;
1415 $user_info['patpay'][$k] = $us17_patpay;
1416 $user_info['patref'][$k] = $us17_patref;
1417 ++$k;
1420 if ($us18_fee != 0 || $us18_inspay != 0 || $us18_insadj != 0 || $us18_patadj != 0 || $us18_patpay != 0 || $us18_insref != 0 || $us18_patref != 0) {
1421 $user_info['user'][$k] = $us18_user;
1422 $user_info['fee'][$k] = $us18_fee;
1423 $user_info['inspay'][$k] = $us18_inspay;
1424 $user_info['insadj'][$k] = $us18_insadj;
1425 $user_info['insref'][$k] = $us18_insref;
1426 $user_info['patadj'][$k] = $us18_patadj;
1427 $user_info['patpay'][$k] = $us18_patpay;
1428 $user_info['patref'][$k] = $us18_patref;
1429 ++$k;
1432 if ($us19_fee != 0 || $us19_inspay != 0 || $us19_insadj != 0 || $us19_patadj != 0 || $us19_patpay != 0 || $us19_insref != 0 || $us19_patref != 0) {
1433 $user_info['user'][$k] = $us19_user;
1434 $user_info['fee'][$k] = $us19_fee;
1435 $user_info['inspay'][$k] = $us19_inspay;
1436 $user_info['insadj'][$k] = $us19_insadj;
1437 $user_info['insref'][$k] = $us19_insref;
1438 $user_info['patadj'][$k] = $us19_patadj;
1439 $user_info['patpay'][$k] = $us19_patpay;
1440 $user_info['patref'][$k] = $us19_patref;
1441 ++$k;
1445 if ($run_provider === 1) {
1446 if ($pro0_fee != 0 || $pro0_inspay != 0 || $pro0_insadj != 0 || $pro0_patadj != 0 || $pro0_patpay != 0 || $pro0_insref != 0 || $pro0_patref != 0) {
1447 $provider_info['user'][$k] = $pro0_user;
1448 $provider_info['fee'][$k] = $pro0_fee;
1449 $provider_info['inspay'][$k] = $pro0_inspay;
1450 $provider_info['insadj'][$k] = $pro0_insadj;
1451 $provider_info['insref'][$k] = $pro0_insref;
1452 $provider_info['patadj'][$k] = $pro0_patadj;
1453 $provider_info['patpay'][$k] = $pro0_patpay;
1454 $provider_info['patref'][$k] = $pro0_patref;
1455 ++$k;
1458 if ($pro1_fee != 0 || $pro1_inspay != 0 || $pro1_insadj != 0 || $pro1_patadj != 0 || $pro1_patpay != 0 || $pro1_insref != 0 || $pro1_patref != 0) {
1459 $provider_info['user'][$k] = $pro1_user;
1460 $provider_info['fee'][$k] = $pro1_fee;
1461 $provider_info['inspay'][$k] = $pro1_inspay;
1462 $provider_info['insadj'][$k] = $pro1_insadj;
1463 $provider_info['insref'][$k] = $pro1_insref;
1464 $provider_info['patadj'][$k] = $pro1_patadj;
1465 $provider_info['patpay'][$k] = $pro1_patpay;
1466 $provider_info['patref'][$k] = $pro1_patref;
1467 ++$k;
1470 if ($pro2_fee != 0 || $pro2_inspay != 0 || $pro2_insadj != 0 || $pro2_patadj != 0 || $pro2_patpay != 0 || $pro2_insref != 0 || $pro2_patref != 0) {
1471 $provider_info['user'][$k] = $pro2_user;
1472 $provider_info['fee'][$k] = $pro2_fee;
1473 $provider_info['inspay'][$k] = $pro2_inspay;
1474 $provider_info['insadj'][$k] = $pro2_insadj;
1475 $provider_info['insref'][$k] = $pro2_insref;
1476 $provider_info['patadj'][$k] = $pro2_patadj;
1477 $provider_info['patpay'][$k] = $pro2_patpay;
1478 $provider_info['patref'][$k] = $pro2_patref;
1479 ++$k;
1482 if ($pro3_fee != 0 || $pro3_inspay != 0 || $pro3_insadj != 0 || $pro3_patadj != 0 || $pro3_patpay != 0 || $pro3_insref != 0 || $pro3_patref != 0) {
1483 $provider_info['user'][$k] = $pro3_user;
1484 $provider_info['fee'][$k] = $pro3_fee;
1485 $provider_info['inspay'][$k] = $pro3_inspay;
1486 $provider_info['insadj'][$k] = $pro3_insadj;
1487 $provider_info['insref'][$k] = $pro3_insref;
1488 $provider_info['patadj'][$k] = $pro3_patadj;
1489 $provider_info['patpay'][$k] = $pro3_patpay;
1490 $provider_info['patref'][$k] = $pro3_patref;
1491 ++$k;
1494 if ($pro4_fee != 0 || $pro4_inspay != 0 || $pro4_insadj != 0 || $pro4_patadj != 0 || $pro4_patpay != 0 || $pro4_insref != 0 || $pro4_patref != 0) {
1495 $provider_info['user'][$k] = $pro4_user;
1496 $provider_info['fee'][$k] = $pro4_fee;
1497 $provider_info['inspay'][$k] = $pro4_inspay;
1498 $provider_info['insadj'][$k] = $pro4_insadj;
1499 $provider_info['insref'][$k] = $pro4_insref;
1500 $provider_info['patadj'][$k] = $pro4_patadj;
1501 $provider_info['patpay'][$k] = $pro4_patpay;
1502 $provider_info['patref'][$k] = $pro4_patref;
1503 ++$k;
1506 if ($pro5_fee != 0 || $pro5_inspay != 0 || $pro5_insadj != 0 || $pro5_patadj != 0 || $pro5_patpay != 0 || $pro5_insref != 0 || $pro5_patref != 0) {
1507 $provider_info['user'][$k] = $pro5_user;
1508 $provider_info['fee'][$k] = $pro5_fee;
1509 $provider_info['inspay'][$k] = $pro5_inspay;
1510 $provider_info['insadj'][$k] = $pro5_insadj;
1511 $provider_info['insref'][$k] = $pro5_insref;
1512 $provider_info['patadj'][$k] = $pro5_patadj;
1513 $provider_info['patpay'][$k] = $pro5_patpay;
1514 $provider_info['patref'][$k] = $pro5_patref;
1515 ++$k;
1518 if ($pro6_fee != 0 || $pro6_inspay != 0 || $pro6_insadj != 0 || $pro6_patadj != 0 || $pro6_patpay != 0 || $pro6_insref != 0 || $pro6_patref != 0) {
1519 $provider_info['user'][$k] = $pro6_user;
1520 $provider_info['fee'][$k] = $pro6_fee;
1521 $provider_info['inspay'][$k] = $pro6_inspay;
1522 $provider_info['insadj'][$k] = $pro6_insadj;
1523 $provider_info['insref'][$k] = $pro6_insref;
1524 $provider_info['patadj'][$k] = $pro6_patadj;
1525 $provider_info['patpay'][$k] = $pro6_patpay;
1526 $provider_info['patref'][$k] = $pro6_patref;
1527 ++$k;
1530 if ($pro7_fee != 0 || $pro7_inspay != 0 || $pro7_insadj != 0 || $pro7_patadj != 0 || $pro7_patpay != 0 || $pro7_insref != 0 || $pro7_patref != 0) {
1531 $provider_info['user'][$k] = $pro7_user;
1532 $provider_info['fee'][$k] = $pro7_fee;
1533 $provider_info['inspay'][$k] = $pro7_inspay;
1534 $provider_info['insadj'][$k] = $pro7_insadj;
1535 $provider_info['insref'][$k] = $pro7_insref;
1536 $provider_info['patadj'][$k] = $pro7_patadj;
1537 $provider_info['patpay'][$k] = $pro7_patpay;
1538 $provider_info['patref'][$k] = $pro7_patref;
1539 ++$k;
1542 if ($pro8_fee != 0 || $pro8_inspay != 0 || $pro8_insadj != 0 || $pro8_patadj != 0 || $pro8_patpay != 0 || $pro8_insref != 0 || $pro8_patref != 0) {
1543 $provider_info['user'][$k] = $pro8_user;
1544 $provider_info['fee'][$k] = $pro8_fee;
1545 $provider_info['inspay'][$k] = $pro8_inspay;
1546 $provider_info['insadj'][$k] = $pro8_insadj;
1547 $provider_info['insref'][$k] = $pro8_insref;
1548 $provider_info['patadj'][$k] = $pro8_patadj;
1549 $provider_info['patpay'][$k] = $pro8_patpay;
1550 $provider_info['patref'][$k] = $pro8_patref;
1551 ++$k;
1554 if ($pro9_fee != 0 || $pro9_inspay != 0 || $pro9_insadj != 0 || $pro9_patadj != 0 || $pro9_patpay != 0 || $pro9_insref != 0 || $pro9_patref != 0) {
1555 $provider_info['user'][$k] = $pro9_user;
1556 $provider_info['fee'][$k] = $pro9_fee;
1557 $provider_info['inspay'][$k] = $pro9_inspay;
1558 $provider_info['insadj'][$k] = $pro9_insadj;
1559 $provider_info['insref'][$k] = $pro9_insref;
1560 $provider_info['patadj'][$k] = $pro9_patadj;
1561 $provider_info['patpay'][$k] = $pro9_patpay;
1562 $provider_info['patref'][$k] = $pro9_patref;
1563 ++$k;
1566 if ($pro10_fee != 0 || $pro10_inspay != 0 || $pro10_insadj != 0 || $pro10_patadj != 0 || $pro10_patpay != 0 || $pro10_insref != 0 || $pro10_patref != 0) {
1567 $provider_info['user'][$k] = $pro10_user;
1568 $provider_info['fee'][$k] = $pro10_fee;
1569 $provider_info['inspay'][$k] = $pro10_inspay;
1570 $provider_info['insadj'][$k] = $pro10_insadj;
1571 $provider_info['insref'][$k] = $pro10_insref;
1572 $provider_info['patadj'][$k] = $pro10_patadj;
1573 $provider_info['patpay'][$k] = $pro10_patpay;
1574 $provider_info['patref'][$k] = $pro10_patref;
1575 ++$k;
1578 if ($pro11_fee != 0 || $pro11_inspay != 0 || $pro11_insadj != 0 || $pro11_patadj != 0 || $pro11_patpay != 0 || $pro11_insref != 0 || $pro11_patref != 0) {
1579 $provider_info['user'][$k] = $pro11_user;
1580 $provider_info['fee'][$k] = $pro11_fee;
1581 $provider_info['inspay'][$k] = $pro11_inspay;
1582 $provider_info['insadj'][$k] = $pro11_insadj;
1583 $provider_info['insref'][$k] = $pro11_insref;
1584 $provider_info['patadj'][$k] = $pro11_patadj;
1585 $provider_info['patpay'][$k] = $pro11_patpay;
1586 $provider_info['patref'][$k] = $pro11_patref;
1587 ++$k;
1590 if ($pro12_fee != 0 || $pro12_inspay != 0 || $pro12_insadj != 0 || $pro12_patadj != 0 || $pro12_patpay != 0 || $pro12_insref != 0 || $pro12_patref != 0) {
1591 $provider_info['user'][$k] = $pro12_user;
1592 $provider_info['fee'][$k] = $pro12_fee;
1593 $provider_info['inspay'][$k] = $pro12_inspay;
1594 $provider_info['insadj'][$k] = $pro12_insadj;
1595 $provider_info['insref'][$k] = $pro12_insref;
1596 $provider_info['patadj'][$k] = $pro12_patadj;
1597 $provider_info['patpay'][$k] = $pro12_patpay;
1598 $provider_info['patref'][$k] = $pro12_patref;
1599 ++$k;
1602 if ($pro13_fee != 0 || $pro13_inspay != 0 || $pro13_insadj != 0 || $pro13_patadj != 0 || $pro13_patpay != 0 || $pro13_insref != 0 || $pro13_patref != 0) {
1603 $provider_info['user'][$k] = $pro13_user;
1604 $provider_info['fee'][$k] = $pro13_fee;
1605 $provider_info['inspay'][$k] = $pro13_inspay;
1606 $provider_info['insadj'][$k] = $pro13_insadj;
1607 $provider_info['insref'][$k] = $pro13_insref;
1608 $provider_info['patadj'][$k] = $pro13_patadj;
1609 $provider_info['patpay'][$k] = $pro13_patpay;
1610 $provider_info['patref'][$k] = $pro13_patref;
1611 ++$k;
1614 if ($pro14_fee != 0 || $pro14_inspay != 0 || $pro14_insadj != 0 || $pro14_patadj != 0 || $pro14_patpay != 0 || $pro14_insref != 0 || $pro14_patref != 0) {
1615 $provider_info['user'][$k] = $pro14_user;
1616 $provider_info['fee'][$k] = $pro14_fee;
1617 $provider_info['inspay'][$k] = $pro14_inspay;
1618 $provider_info['insadj'][$k] = $pro14_insadj;
1619 $provider_info['insref'][$k] = $pro14_insref;
1620 $provider_info['patadj'][$k] = $pro14_patadj;
1621 $provider_info['patpay'][$k] = $pro14_patpay;
1622 $provider_info['patref'][$k] = $pro14_patref;
1623 ++$k;
1626 if ($pro15_fee != 0 || $pro15_inspay != 0 || $pro15_insadj != 0 || $pro15_patadj != 0 || $pro15_patpay != 0 || $pro15_insref != 0 || $pro15_patref != 0) {
1627 $provider_info['user'][$k] = $pro15_user;
1628 $provider_info['fee'][$k] = $pro15_fee;
1629 $provider_info['inspay'][$k] = $pro15_inspay;
1630 $provider_info['insadj'][$k] = $pro15_insadj;
1631 $provider_info['insref'][$k] = $pro15_insref;
1632 $provider_info['patadj'][$k] = $pro15_patadj;
1633 $provider_info['patpay'][$k] = $pro15_patpay;
1634 $provider_info['patref'][$k] = $pro15_patref;
1635 ++$k;
1638 if ($pro16_fee != 0 || $pro16_inspay != 0 || $pro16_insadj != 0 || $pro16_patadj != 0 || $pro16_patpay != 0 || $pro16_insref != 0 || $pro16_patref != 0) {
1639 $provider_info['user'][$k] = $pro16_user;
1640 $provider_info['fee'][$k] = $pro16_fee;
1641 $provider_info['inspay'][$k] = $pro16_inspay;
1642 $provider_info['insadj'][$k] = $pro16_insadj;
1643 $provider_info['insref'][$k] = $pro16_insref;
1644 $provider_info['patadj'][$k] = $pro16_patadj;
1645 $provider_info['patpay'][$k] = $pro16_patpay;
1646 $provider_info['patref'][$k] = $pro16_patref;
1647 ++$k;
1650 if ($pro17_fee != 0 || $pro17_inspay != 0 || $pro17_insadj != 0 || $pro17_patadj != 0 || $pro17_patpay != 0 || $pro17_insref != 0 || $pro17_patref != 0) {
1651 $provider_info['user'][$k] = $pro17_user;
1652 $provider_info['fee'][$k] = $pro17_fee;
1653 $provider_info['inspay'][$k] = $pro17_inspay;
1654 $provider_info['insadj'][$k] = $pro17_insadj;
1655 $provider_info['insref'][$k] = $pro17_insref;
1656 $provider_info['patadj'][$k] = $pro17_patadj;
1657 $provider_info['patpay'][$k] = $pro17_patpay;
1658 $provider_info['patref'][$k] = $pro17_patref;
1659 ++$k;
1662 if ($pro18_fee != 0 || $pro18_inspay != 0 || $pro18_insadj != 0 || $pro18_patadj != 0 || $pro18_patpay != 0 || $pro18_insref != 0 || $pro18_patref != 0) {
1663 $provider_info['user'][$k] = $pro18_user;
1664 $provider_info['fee'][$k] = $pro18_fee;
1665 $provider_info['inspay'][$k] = $pro18_inspay;
1666 $provider_info['insadj'][$k] = $pro18_insadj;
1667 $provider_info['insref'][$k] = $pro18_insref;
1668 $provider_info['patadj'][$k] = $pro18_patadj;
1669 $provider_info['patpay'][$k] = $pro18_patpay;
1670 $provider_info['patref'][$k] = $pro18_patref;
1671 ++$k;
1674 if ($pro19_fee != 0 || $pro19_inspay != 0 || $pro19_insadj != 0 || $pro19_patadj != 0 || $pro19_patpay != 0 || $pro19_insref != 0 || $pro19_patref != 0) {
1675 $provider_info['user'][$k] = $pro19_user;
1676 $provider_info['fee'][$k] = $pro19_fee;
1677 $provider_info['inspay'][$k] = $pro19_inspay;
1678 $provider_info['insadj'][$k] = $pro19_insadj;
1679 $provider_info['insref'][$k] = $pro19_insref;
1680 $provider_info['patadj'][$k] = $pro19_patadj;
1681 $provider_info['patpay'][$k] = $pro19_patpay;
1682 $provider_info['patref'][$k] = $pro19_patref;
1683 ++$k;
1687 if ($totals_only === 1) {
1688 $from_date = oeFormatShortDate(substr($query_part_day, 37, 10));
1689 $to_date = oeFormatShortDate(substr($query_part_day, 63, 10));
1690 print "<br><br>";
1691 ?><font size = 5 ><?php echo xlt('Totals for '). text($from_date) . ' '. xlt('To'). ' ' . text($to_date) ?></font><?php
1694 if ($run_provider != 1) {
1695 print "<table border=0><tr>\n";
1696 print "<br><br>";
1697 print "<td width=25><span class=text>";
1698 print "</span></td><td width=250><span class=text><b><center>". xlt("User"). "</center></b>";
1699 print "</span></td><td width=125><span class=text>";
1700 print "</span></td><td width=250><span class=text><b>" . xlt("Charges"). "</b>";
1701 print "</span></td><td width=125><span class=text>";
1702 print "</span></td><td width=250><span class=text><b>" . xlt("Payments"). "</b>";
1703 print "</span></td><td width=25><span class=text>";
1705 for ($i=1; $i<$k;) {
1706 print "</br></td>";
1707 print "<table border=0><tr>\n";
1708 print "<td width=25><span class=text>" ;
1709 Printf("</span></td><td width=250><span class=text><center>".text($user_info[user][$i])). "</center>";
1710 print "</span></td><td width=125><span class=text>" ;
1711 printf("</span></td><td width=250><span class=text><b>" . xlt("Total Charges") .': '." %1\$.2f ", text($user_info[fee][$i])). "</b>";
1712 print "</span></td><td width=125><span class=text>";
1713 printf("</span></td><td width=250><span class=text><b>" . xlt("Total Payments").': '. "(%1\$.2f)", text($user_info[inspay][$i] + $user_info[patpay][$i])) . "</b>";
1714 print "</span></td><td width=25><span class=text>" ;
1715 print "</br></td>";
1716 print "<table border=0><tr>\n";
1717 print "<td width=25><span class=text>" ;
1718 print "</span></td><td width=250><span class=text>";
1719 print "</span></td><td width=125><span class=text>" ;
1720 printf("</span></td><td width=250><span class=text><b>" . xlt("Total Adj").'.: '."(%1\$.2f)", text($user_info[patadj][$i] + $user_info[insadj][$i])). "</b>";
1721 print "</span></td><td width=125><span class=text>" ;
1722 printf("</span></td><td width=250><span class=text><b>" . xlt("Refund").': '."(%1\$.2f)", text($user_info[patref][$i] + $user_info[insref][$i]))."</b>";
1723 print "</span></td><td width=25><span class=text>";
1724 print "</br></td>";
1725 print "<table border=0><tr>\n";
1726 print "<td width=25><span class=text>" ;
1727 print "</span></td><td width=250><span class=text>";
1728 print "</span></td><td width=125><span class=text>";
1729 print "</span></td><td width=250><span class=text>";
1730 print "</span></td><td width=125><span class=text>";
1731 print "</span></td><td width=175 height=5><span class=text><b><hr noshade size=3>";
1732 print "</b></hr></span></td><td width=25><span class=text>";
1733 print "</br></td>";
1734 print "<table border=0><tr>\n";
1735 print "<td width=25><span class=text>";
1736 print "</span></td><td width=250><span class=text>";
1737 print "</span></td><td width=125><span class=text>";
1738 print "</span></td><td width=250><span class=text>";
1739 print "</span></td><td width=125><span class=text>";
1740 printf("</span></td><td width=250><span class=text><b>" . xlt("Actual Receipts").': '."(%1\$.2f)", text($user_info[patref][$i] + $user_info[insref][$i] + $user_info[inspay][$i] + $user_info[patpay][$i])). "</b>";
1741 print "</span></td><td width=25><span class=text>";
1742 print "</br></td>";
1743 print "<table border=0><tr>\n";
1744 print "<td width=25><span class=text>";
1745 print "</span></td><td width=250><span class=text>";
1746 print "</span></td><td width=125><span class=text>";
1747 print "</span></td><td width=250><span class=text>";
1748 print "</span></td><td width=125><span class=text>";
1749 print "</span></td><td width=125><span class=text>";
1750 print "</span></td><td width=25><span class=text>";
1752 $gtotal_fee = $gtotal_fee + $user_info[fee][$i];
1753 $gtotal_insadj = $gtotal_insadj + $user_info[insadj][$i];
1754 $gtotal_inspay = $gtotal_inspay + $user_info[inspay][$i];
1755 $gtotal_patadj = $gtotal_patadj + $user_info[patadj][$i];
1756 $gtotal_patpay = $gtotal_patpay + $user_info[patpay][$i];
1758 ++$i;
1760 print "</br></td></tr>";
1763 print "</br></td>";
1764 print "</table>";
1765 } else {
1766 print "<table border=0><tr>\n";
1767 print "<br><br>";
1768 print "<td width=25><span class=text>";
1769 print "</span></td><td width=250><span class=text><b><center>". xlt("Provider"). "</center></b>";
1770 print "</span></td><td width=125><span class=text>";
1771 print "</span></td><td width=250><span class=text><b>" . xlt("Charges"). "</b>";
1772 print "</span></td><td width=125><span class=text>";
1773 print "</span></td><td width=250><span class=text><b>" . xlt("Payments"). "</b>";
1774 print "</span></td><td width=25><span class=text>";
1776 for ($i=1; $i<$k;) {
1777 print "</br></td>";
1778 print "<table border=0><tr>\n";
1779 print "<td width=25><span class=text>";
1780 Printf("</span></td><td width=250><span class=text><center>".text($provider_info[user][$i])). "</center>";
1781 print "</span></td><td width=125><span class=text>";
1782 printf("</span></td><td width=250><span class=text><b>" . xlt("Total Charges").': '." %1\$.2f ", text($provider_info[fee][$i])). "</b>";
1783 print "</span></td><td width=125><span class=text>";
1784 printf("</span></td><td width=250><span class=text><b>" . xlt("Total Payments").': '. "(%1\$.2f)", text($provider_info[inspay][$i] + $provider_info[patpay][$i])) . "</b>";
1785 print "</span></td><td width=25><span class=text>";
1786 print "</br></td>";
1787 print "<table border=0><tr>\n";
1788 print "<td width=25><span class=text>";
1789 print "</span></td><td width=250><span class=text>";
1790 print "</span></td><td width=125><span class=text>";
1791 printf("</span></td><td width=250><span class=text><b>" . xlt("Total Adj").'.: '."(%1\$.2f)", text($provider_info[patadj][$i] + $provider_info[insadj][$i])). "</b>";
1792 print "</span></td><td width=125><span class=text>";
1793 printf("</span></td><td width=250><span class=text><b>" . xlt("Refund").': '."(%1\$.2f)", text($provider_info[patref][$i] + $provider_info[insref][$i]))."</b>";
1794 print "</span></td><td width=25><span class=text>";
1795 print "</br></td>";
1796 print "<table border=0><tr>\n";
1797 print "<td width=25><span class=text>";
1798 print "</span></td><td width=250><span class=text>";
1799 print "</span></td><td width=125><span class=text>";
1800 print "</span></td><td width=250><span class=text>";
1801 print "</span></td><td width=125><span class=text>";
1802 print "</span></td><td width=175 height=5><span class=text><b><hr noshade size=3>";
1803 print "</b></hr></span></td><td width=25><span class=text>";
1804 print "</br></td>";
1805 print "<table border=0><tr>\n";
1806 print "<td width=25><span class=text>";
1807 print "</span></td><td width=250><span class=text>";
1808 print "</span></td><td width=125><span class=text>";
1809 print "</span></td><td width=250><span class=text>";
1810 print "</span></td><td width=125><span class=text>";
1811 printf("</span></td><td width=250><span class=text><b>" . xlt("Actual Receipts").': '."(%1\$.2f)", text($provider_info[patref][$i] + $provider_info[insref][$i] + $provider_info[inspay][$i] + $provider_info[patpay][$i])). "</b>";
1812 print "</span></td><td width=25><span class=text>";
1813 print "</br></td>";
1814 print "<table border=0><tr>\n";
1815 print "<td width=25><span class=text>";
1816 print "</span></td><td width=250><span class=text>";
1817 print "</span></td><td width=125><span class=text>";
1818 print "</span></td><td width=250><span class=text>";
1819 print "</span></td><td width=125><span class=text>";
1820 print "</span></td><td width=125><span class=text>";
1821 print "</span></td><td width=25><span class=text>";
1823 $gtotal_fee = $gtotal_fee + $provider_info[fee][$i];
1824 $gtotal_insadj = $gtotal_insadj + $provider_info[insadj][$i];
1825 $gtotal_inspay = $gtotal_inspay + $provider_info[inspay][$i];
1826 $gtotal_insref = $gtotal_insref + $provider_info[insref][$i];
1827 $gtotal_patadj = $gtotal_patadj + $provider_info[patadj][$i];
1828 $gtotal_patpay = $gtotal_patpay + $provider_info[patpay][$i];
1829 $gtotal_patref = $gtotal_patref + $provider_info[patref][$i];
1831 ++$i;
1833 print "</br></td></tr>";
1836 print "</br></td>";
1837 print "</table>";
1840 </body>
1841 </html>