Merge pull request #1128 from bradymiller/unique-insurance-report-cleanup_1
[openemr.git] / interface / billing / print_daysheet_report_num3.php
blob387bc5c55d62b440c46ad9c62f274749166013dc
1 <?php
2 /**
3 * interface/billing/print_daysheet_report.php Genetating an end of day report.
5 * Program for Generating an End of Day report
8 * Copyright (C) 2014 Terry Hill <terry@lillysystems.com>
10 * LICENSE: This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 3
13 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
21 * @package OpenEMR
22 * @author Terry Hill <terry@lillysystems.com>
23 * @link http://www.open-emr.org
29 include_once("../globals.php");
31 include_once("$srcdir/patient.inc");
32 include_once("$srcdir/../interface/reports/report.inc.php");
33 include_once("$srcdir/daysheet.inc.php");
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"];
44 if (!isset($_GET["to_date"])) {
45 $to_date = date("Y-m-d");
46 } else {
47 $to_date = $_GET["to_date"];
50 if (!isset($_GET["code_type"])) {
51 $code_type="all";
52 } else {
53 $code_type = $_GET["code_type"];
56 if (!isset($_GET["unbilled"])) {
57 $unbilled = "on";
58 } else {
59 $unbilled = $_GET["unbilled"];
62 if (!isset($_GET["authorized"])) {
63 $my_authorized = "on";
64 } else {
65 $my_authorized = $_GET["authorized"];
67 } else {
68 $from_date = $_GET["from_date"];
69 $to_date = $_GET["to_date"];
70 $code_type = $_GET["code_type"];
71 $unbilled = $_GET["unbilled"];
72 $my_authorized = $_GET["authorized"];
77 <html>
78 <head>
79 <?php html_header_show();?>
81 <link rel=stylesheet href="<?php echo $css_header;?>" type="text/css">
83 </head>
84 <body bgcolor="#ffffff" topmargin=0 rightmargin=0 leftmargin=2 bottommargin=0 marginwidth=2 marginheight=0>
86 <a href="javascript:window.close();" target=Main><font class=title><?php echo xlt('Day Sheet Report')?></font></a>
87 <br>
89 <?php
90 if ($my_authorized === 'on') {
91 $my_authorized = true;
92 } else {
93 $my_authorized = '%';
96 if ($unbilled === 'on') {
97 $unbilled = '0';
98 } else {
99 $unbilled = '%';
102 if ($code_type === 'all') {
103 $code_type = '%';
106 if (!isset($_GET["mode"])) {
107 if (!isset($_GET["from_date"])) {
108 $from_date=date("Y-m-d");
109 } else {
110 $from_date = $_GET["from_date"];
113 if (!isset($_GET["to_date"])) {
114 $to_date = date("Y-m-d");
115 } else {
116 $to_date = $_GET["to_date"];
119 if (!isset($_GET["code_type"])) {
120 $code_type="all";
121 } else {
122 $code_type = $_GET["code_type"];
125 if (!isset($_GET["unbilled"])) {
126 $unbilled = "on";
127 } else {
128 $unbilled = $_GET["unbilled"];
131 if (!isset($_GET["authorized"])) {
132 $my_authorized = "on";
133 } else {
134 $my_authorized = $_GET["authorized"];
136 } else {
137 $from_date = $_GET["from_date"];
138 $to_date = $_GET["to_date"];
139 $code_type = $_GET["code_type"];
140 $unbilled = $_GET["unbilled"];
141 $my_authorized = $_GET["authorized"];
144 if ($my_authorized === 'on') {
145 $my_authorized = true;
146 } else {
147 $my_authorized = '%';
150 if ($unbilled === 'on') {
151 $unbilled = '0';
152 } else {
153 $unbilled = '%';
156 if ($code_type === 'all') {
157 $code_type = '%';
160 if (isset($_GET["mode"]) && $_GET["mode"] === 'bill') {
161 billCodesList($list);
164 $res_count = 0;
165 $N = 1;
166 $k = 1;
167 $anypats = 0;
168 $the_first_time = 1;
169 $itero = array();
171 if ($ret = getBillsBetweendayReport($code_type)) {
172 // checking to see if there is any information in the array if not display a message (located after this if statment)
173 $anypats = count($ret);
176 $old_pid = -1;
177 $first_time = 1;
178 $new_old_pid = -1;
180 // $iter has encounter information
182 // this loop gathers the user numbers
183 foreach ($ret as $iter) {
184 $catch_user[] = $iter{'user'};
187 //This statment uniques the array removing duplicates
188 $user_list = array_unique($catch_user);
189 // reorder the list starting with array element zero
190 $final_list = array_values($user_list);
192 // sort array in assending order
193 sort($final_list);
195 $all4 = array_natsort($ret, pid, fulname, asc);
196 if ($_POST['end_of_day_totals_only'] == 1) {
197 $totals_only = 1;
200 foreach ($all4 as $iter) {
201 // Case statment to tally information by user
202 switch ($iter{'user'}) {
203 case $iter{'user'} = $final_list[0]:
204 $us0_user = $iter{'user'};
205 $us0_fee = $us0_fee + $iter{'fee'};
206 $us0_inspay = $us0_inspay + $iter{'ins_code'};
207 $us0_insadj = $us0_insadj + $iter{'ins_adjust_dollar'};
208 $us0_patadj = $us0_patadj + $iter{'pat_adjust_dollar'};
209 $us0_patpay = $us0_patpay + $iter{'pat_code'};
210 break;
211 case $iter{'user'} = $final_list[1]:
212 $us1_user = $iter{'user'};
213 $us1_fee = $us1_fee + $iter{'fee'};
214 $us1_inspay = $us1_inspay + $iter{'ins_code'};
215 $us1_insadj = $us1_insadj + $iter{'ins_adjust_dollar'};
216 $us1_patadj = $us1_patadj + $iter{'pat_adjust_dollar'};
217 $us1_patpay = $us1_patpay + $iter{'pat_code'};
218 break;
219 case $iter{'user'} = $final_list[2]:
220 $us2_user = $iter{'user'};
221 $us2_fee = $us2_fee + $iter{'fee'};
222 $us2_inspay = $us2_inspay + $iter{'ins_code'};
223 $us2_insadj = $us2_insadj + $iter{'ins_adjust_dollar'};
224 $us2_patadj = $us2_patadj + $iter{'pat_adjust_dollar'};
225 $us2_patpay = $us2_patpay + $iter{'pat_code'};
226 break;
227 case $iter{'user'} = $final_list[3]:
228 $us3_user = $iter{'user'};
229 $us3_fee = $us3_fee + $iter{'fee'};
230 $us3_inspay = $us3_inspay + $iter{'ins_code'};
231 $us3_insadj = $us3_insadj + $iter{'ins_adjust_dollar'};
232 $us3_patadj = $us3_patadj + $iter{'pat_adjust_dollar'};
233 $us3_patpay = $us3_patpay + $iter{'pat_code'};
234 break;
235 case $iter{'user'} = $final_list[4]:
236 $us4_user = $iter{'user'};
237 $us4_fee = $us4_fee + $iter{'fee'};
238 $us4_inspay = $us4_inspay + $iter{'ins_code'};
239 $us4_insadj = $us4_insadj + $iter{'ins_adjust_dollar'};
240 $us4_patadj = $us4_patadj + $iter{'pat_adjust_dollar'};
241 $us4_patpay = $us4_patpay + $iter{'pat_code'};
242 break;
243 case $iter{'user'} = $final_list[5]:
244 $us5_user = $iter{'user'};
245 $us5_fee = $us5_fee + $iter{'fee'};
246 $us5_inspay = $us5_inspay + $iter{'ins_code'};
247 $us5_insadj = $us5_insadj + $iter{'ins_adjust_dollar'};
248 $us5_patadj = $us5_patadj + $iter{'pat_adjust_dollar'};
249 $us5_patpay = $us5_patpay + $iter{'pat_code'};
250 break;
251 case $iter{'user'} = $final_list[6]:
252 $us6_user = $iter{'user'};
253 $us6_fee = $us6_fee + $iter{'fee'};
254 $us6_inspay = $us6_inspay + $iter{'ins_code'};
255 $us6_insadj = $us6_insadj + $iter{'ins_adjust_dollar'};
256 $us6_patadj = $us6_patadj + $iter{'pat_adjust_dollar'};
257 $us6_patpay = $us6_patpay + $iter{'pat_code'};
258 break;
259 case $iter{'user'} = $final_list[7]:
260 $us7_user = $iter{'user'};
261 $us7_fee = $us7_fee + $iter{'fee'};
262 $us7_inspay = $us7_inspay + $iter{'ins_code'};
263 $us7_insadj = $us7_insadj + $iter{'ins_adjust_dollar'};
264 $us7_patadj = $us7_patadj + $iter{'pat_adjust_dollar'};
265 $us7_patpay = $us7_patpay + $iter{'pat_code'};
266 break;
267 case $iter{'user'} = $final_list[8]:
268 $us8_user = $iter{'user'};
269 $us8_fee = $us8_fee + $iter{'fee'};
270 $us8_inspay = $us8_inspay + $iter{'ins_code'};
271 $us8_insadj = $us8_insadj + $iter{'ins_adjust_dollar'};
272 $us8_patadj = $us8_patadj + $iter{'pat_adjust_dollar'};
273 $us8_patpay = $us8_patpay + $iter{'pat_code'};
274 break;
275 case $iter{'user'} = $final_list[9]:
276 $us9_user = $iter{'user'};
277 $us9_fee = $us9_fee + $iter{'fee'};
278 $us9_inspay = $us9_inspay + $iter{'ins_code'};
279 $us9_insadj = $us9_insadj + $iter{'ins_adjust_dollar'};
280 $us9_patadj = $us9_patadj + $iter{'pat_adjust_dollar'};
281 $us9_patpay = $us9_patpay + $iter{'pat_code'};
282 break;
283 case $iter{'user'} = $final_list[10]:
284 $us10_user = $iter{'user'};
285 $us10_fee = $us10_fee + $iter{'fee'};
286 $us10_inspay = $us10_inspay + $iter{'ins_code'};
287 $us10_insadj = $us10_insadj + $iter{'ins_adjust_dollar'};
288 $us10_patadj = $us10_patadj + $iter{'pat_adjust_dollar'};
289 $us10_patpay = $us10_patpay + $iter{'pat_code'};
290 break;
291 case $iter{'user'} = $final_list[11]:
292 $us11_user = $iter{'user'};
293 $us11_fee = $us11_fee + $iter{'fee'};
294 $us11_inspay = $us11_inspay + $iter{'ins_code'};
295 $us11_insadj = $us11_insadj + $iter{'ins_adjust_dollar'};
296 $us11_patadj = $us11_patadj + $iter{'pat_adjust_dollar'};
297 $us11_patpay = $us11_patpay + $iter{'pat_code'};
298 break;
299 case $iter{'user'} = $final_list[12]:
300 $us12_user = $iter{'user'};
301 $us12_fee = $us12_fee + $iter{'fee'};
302 $us12_inspay = $us12_inspay + $iter{'ins_code'};
303 $us12_insadj = $us12_insadj + $iter{'ins_adjust_dollar'};
304 $us12_patadj = $us12_patadj + $iter{'pat_adjust_dollar'};
305 $us12_patpay = $us12_patpay + $iter{'pat_code'};
306 break;
307 case $iter{'user'} = $final_list[13]:
308 $us13_user = $iter{'user'};
309 $us13_fee = $us13_fee + $iter{'fee'};
310 $us13_inspay = $us13_inspay + $iter{'ins_code'};
311 $us13_insadj = $us13_insadj + $iter{'ins_adjust_dollar'};
312 $us13_patadj = $us13_patadj + $iter{'pat_adjust_dollar'};
313 $us13_patpay = $us13_patpay + $iter{'pat_code'};
314 break;
315 case $iter{'user'} = $final_list[14]:
316 $us14_user = $iter{'user'};
317 $us14_fee = $us14_fee + $iter{'fee'};
318 $us14_inspay = $us14_inspay + $iter{'ins_code'};
319 $us14_insadj = $us14_insadj + $iter{'ins_adjust_dollar'};
320 $us14_patadj = $us14_patadj + $iter{'pat_adjust_dollar'};
321 $us14_patpay = $us14_patpay + $iter{'pat_code'};
322 break;
323 case $iter{'user'} = $final_list[15]:
324 $us15_user = $iter{'user'};
325 $us15_fee = $us15_fee + $iter{'fee'};
326 $us15_inspay = $us15_inspay + $iter{'ins_code'};
327 $us15_insadj = $us15_insadj + $iter{'ins_adjust_dollar'};
328 $us15_patadj = $us15_patadj + $iter{'pat_adjust_dollar'};
329 $us15_patpay = $us15_patpay + $iter{'pat_code'};
330 break;
331 case $iter{'user'} = $final_list[16]:
332 $us16_user = $iter{'user'};
333 $us16_fee = $us16_fee + $iter{'fee'};
334 $us16_inspay = $us16_inspay + $iter{'ins_code'};
335 $us16_insadj = $us16_insadj + $iter{'ins_adjust_dollar'};
336 $us16_patadj = $us16_patadj + $iter{'pat_adjust_dollar'};
337 $us16_patpay = $us16_patpay + $iter{'pat_code'};
338 break;
339 case $iter{'user'} = $final_list[17]:
340 $us17_user = $iter{'user'};
341 $us17_fee = $us17_fee + $iter{'fee'};
342 $us17_inspay = $us17_inspay + $iter{'ins_code'};
343 $us17_insadj = $us17_insadj + $iter{'ins_adjust_dollar'};
344 $us17_patadj = $us17_patadj + $iter{'pat_adjust_dollar'};
345 $us17_patpay = $us17_patpay + $iter{'pat_code'};
346 break;
347 case $iter{'user'} = $final_list[18]:
348 $us18_user = $iter{'user'};
349 $us18_fee = $us18_fee + $iter{'fee'};
350 $us18_inspay = $us18_inspay + $iter{'ins_code'};
351 $us18_insadj = $us18_insadj + $iter{'ins_adjust_dollar'};
352 $us18_patadj = $us18_patadj + $iter{'pat_adjust_dollar'};
353 $us18_patpay = $us18_patpay + $iter{'pat_code'};
354 break;
355 case $iter{'user'} = $final_list[19]:
356 $us19_user = $iter{'user'};
357 $us19_fee = $us19_fee + $iter{'fee'};
358 $us19_inspay = $us19_inspay + $iter{'ins_code'};
359 $us19_insadj = $us19_insadj + $iter{'ins_adjust_dollar'};
360 $us19_patadj = $us19_patadj + $iter{'pat_adjust_dollar'};
361 $us19_patpay = $us19_patpay + $iter{'pat_code'};
362 break;
365 if ($the_first_time == 1) {
366 $user = $iter{'user'};
367 $first_user = $iter{'user'};
368 $new_old_pid = $iter{'pid'};
369 $the_first_time = 0;
372 if ($totals_only != 1) {
373 if ($old_pid != $iter{'pid'} and ($iter{'code_type'} != 'payment_info')) {
374 // $name has patient information
375 $name = getPatientData($iter{'pid'});
377 // formats the displayed text
380 if ($old_pid == $new_old_pid) {
381 if ($line_total != 0) {
382 print "<td width=100><br><span class=text><b><center>" . xlt('Total') . "</b></center>";
383 Printf("<br></span></td><td width=100><span class=text><center>"." %1\$.2f", text($line_total)). "</center></td>";
384 } else {
385 print "<td width=100><br><span class=text><b><center>" . xlt('Total') . "</b></center>";
386 Printf("<br></span></td><td width=100><span class=text><center>"." %1\$.2f", text($line_total_pay)). "</center></td>";
389 $line_total = 0;
390 $line_total_pay = 0;
393 if ($first_time) {
394 print "<table border=0><tr>\n"; // small table
395 $first_time=0;
398 // Displays name
400 print "<tr><td colspan=10><hr><span class=bold>" . text($name{"fname"}) . " " . text($name{"lname"}) . "</span><br><br></td></tr><tr>\n";
401 //==================================
403 if ($iter{'code_type'} === 'COPAY' || $iter{'code_type'} === 'Patient Payment' || $iter{'code_type'} === 'Insurance Payment') {
404 print "<td width=100><span class=text><center><b>" . xlt("Units") . "</b></center>";
405 print "</span></td><td width=100><span class=text><center><b>" . xlt("Fee"). "</b></center>" ;
406 print "</span></td><td width=100><span class=text><center><b>" . xlt("Code"). "</b></center>" ;
407 print "</span></td><td width=100><span class=text><b>";
408 print "</span></td><td width=100><span class=text><center><b>" . xlt("User"). "</b></center>";
409 print "</span></td><td width=100><span class=small><b>" ;
410 print "</span></td><td width=100><span class=small><center><b>". xlt("Post Date"). "</b></center>";
411 print "</span></td><td></tr><tr>\n";
412 } else {
413 print "<td width=100><span class=text><b><center>" . xlt("Units"). "</b></center>";
414 print "</span></td><td width=100><span class=text><center><b>" . xlt("Fee"). "</b></center>";
415 print "</span></td><td width=100><span class=text><center><b>" . xlt("Code") . "</b></center>";
416 print "</span></td><td width=100><span class=text><b><center>" . xlt("Provider Id"). "</b></center>";
417 print "</span></td><td width=100><span class=text><b><center>" . xlt("User"). "</b></center>";
418 print "</span></td><td width=100><span class=small><center><b>" . xlt("Bill Date"). "</b></center>";
419 print "</span></td><td width=100><span class=small><center><b>". xlt("Date of Service"). "</b></center>";
420 print "</span></td><td></tr><tr>\n";
423 //Next patient
425 $old_pid = $iter{'pid'};
428 // get dollar amounts to appear on pat,ins payments and copays
430 if ($iter{'code_type'} != 'payment_info') {
431 if ($iter{'code_type'} === 'COPAY' || $iter{'code_type'} === 'Patient Payment' || $iter{'code_type'} === 'Insurance Payment') {
432 print "<td width=100><span class=text><center>" . "1". "</center>" ;
434 // start fee output
435 // [pat_code] => 0.00
436 // [ins_code] => 0.00
437 // [pat_adjust_dollar] => 0.00
438 // [ins_adjust_dollar] => 0.00
439 if (($iter{'ins_adjust_dollar'}) != 0 and ($iter{'code_type'}) === 'Insurance Payment') {
440 $line_total_pay = $line_total_pay + $iter{'ins_adjust_dollar'};
441 print "</span></td><td width=100><span class=text><center>" . text($iter{'ins_adjust_dollar'}). "</center>";
444 if (($iter{'ins_code'}) != 0 and ($iter{'code_type'}) === 'Insurance Payment') {
445 $line_total_pay = $line_total_pay + $iter{'ins_code'};
446 print "</span></td><td width=100><span class=text><center>" . text($iter{'ins_code'}). "</center>";
449 if (($iter{'code_type'}) != 'Patient Payment' and ($iter{'code_type'}) != 'Insurance Payment') {
450 $line_total_pay = $line_total_pay + $iter{"code"};
451 print "</span></td><td width=100><span class=text><center>" . text($iter{"code"}). "</center>";
454 if (($iter{'pat_adjust_dollar'}) != 0 and ($iter{'code_type'}) === 'Patient Payment') {
455 $line_total_pay = $line_total_pay + $iter{'pat_adjust_dollar'};
456 print "</span></td><td width=100><span class=text><center>" . text($iter{'pat_adjust_dollar'}). "</center>";
459 if (($iter{'pat_code'}) != 0 and ($iter{'code_type'}) === 'Patient Payment') {
460 $line_total_pay = $line_total_pay + $iter{'pat_code'};
461 print "</span></td><td width=100><span class=text><center>" .text($iter{'pat_code'}). "</center>";
464 // end fee output
466 if (($iter{'ins_adjust_dollar'}) != 0 and ($iter{'code_type'}) === 'Insurance Payment') {
467 print "</span></td><td width=250><span class=text><center>" . xlt("Insurance Adjustment"). "</center>";
470 if (($iter{'pat_adjust_dollar'}) != 0 and ($iter{'code_type'}) === 'Patient Payment') {
471 print "</span></td><td width=250><span class=text><center>" . xlt("Patient Adjustment"). "</center>";
474 if (($iter{'ins_code'}) > 0 and ($iter{'code_type'}) === 'Insurance Payment') {
475 print "</span></td><td width=250><span class=text><center>" . xlt('Insurance Payment'). "</center>";
478 if (($iter{'pat_code'}) > 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
479 print "</span></td><td width=250><span class=text><center>" . xlt('Patient Payment'). "</center>";
482 if (($iter{'ins_code'}) < 0 and ($iter{'code_type'}) === 'Insurance Payment') {
483 print "</span></td><td width=250><span class=text><center>" . xlt("Insurance Credit"). "</center>";
486 if (($iter{'pat_code'}) < 0 and ($iter{'code_type'}) === 'Patient Payment' and $iter{'paytype'} != 'PCP') {
487 print "</span></td><td width=250><span class=text><center>" . xlt("Patient Credit"). "</center>";
490 if ($iter{'paytype'} == 'PCP') {
491 print "</span></td><td width=250><span class=text><center>" . xlt('COPAY'). "</center>";
494 if (($iter{'code_type'}) != 'Insurance Payment' and ($iter{'code_type'}) != 'Patient Payment' and $iter{'paytype'} != 'PCP') {
495 print "</span></td><td width=250><span class=text><center>" . text($iter{'code_type'}). "</center>";
498 print "</span></td><td width=100><span class=text><center>" . text($iter{'provider_id'}). "</center>";
499 print "</span></td><td width=100><span class=text><center>" . text($iter{'user'}). "</center>" ;
500 print "</span></td><td width=100><span class=text>";
501 print "</span></td><td width=100><span class=small><center>" . text(date("Y-m-d", strtotime($iter{'date'}))). "</center>";
502 print "</span></td>\n";
503 } else {
504 if (date("Y-m-d", strtotime($iter{'bill_date'})) == "1969-12-31") {
505 print "<td width=100><span class=text><center>" . text($iter{'units'}) . "</center>" ;
506 print "</span></td><td width=100><span class=text><center>" . text($iter{'fee'}) . "</center>";
507 if ($GLOBALS['language_default'] === 'English (Standard)') {
508 print "</span></td><td width=250><span class=text><center>" . text(ucwords(strtolower(substr($iter{'code_text'}, 0, 38)))) . "</center>";
509 } else {
510 print "</span></td><td width=250><span class=text><center>" . text(substr($iter{'code_text'}, 0, 38)) . "</center>";
513 print "</span></td><td width=100><span class=text><center>" . text($iter{'provider_id'}) . "</center>" ;
514 print "</span></td><td width=100><span class=text><center>" . text($iter{'user'}) . "</center>" ;
515 print "</span></td><td width=100><span class=text><center>" . xlt('Not Billed'). "</center>";
516 print "</span></td><td width=100><span class=small><center>" . text(date("Y-m-d", strtotime($iter{'date'}))). "</center>";
517 print "</span></td>\n";
518 } else {
519 if ($iter{'fee'} != 0) {
520 $line_total = $line_total + $iter{'fee'};
521 print "<td width=100><span class=text><center>" . text($iter{"units"}) . "</center>";
522 print "</span></td><td width=100><span class=text><center>" . text($iter{'fee'}) . "</center>";
523 if ($GLOBALS['language_default'] === 'English (Standard)') {
524 print "</span></td><td width=250><span class=text><center>" . text(ucwords(strtolower(substr($iter{'code_text'}, 0, 38)))) . "</center>";
525 } else {
526 print "</span></td><td width=250><span class=text><center>" . text(substr($iter{'code_text'}, 0, 38)) . "</center>";
529 print "</span></td><td width=100><span class=text><center>" . text($iter{'provider_id'}) . "</center>";
530 print "</span></td><td width=100><span class=text><center>" . text($iter{'user'}) . "</center>";
531 print "</span></td><td width=100><span class=small><center>" . text(date("Y-m-d", strtotime($iter{'bill_date'}))) . "</center>";
532 print "</span></td><td width=100><span class=small><center>" . text(date("Y-m-d", strtotime($iter{"date"}))). "</center>";
533 print "</span></td>\n";
538 $res_count++;
540 if ($res_count == $N) {
541 print "</tr><tr>\n";
542 $res_count = 0;
545 $itero = $iter;
547 if ($old_pid != $new_old_pid and ($iter{'code_type'} != 'payment_info')) {
548 $new_old_pid = $old_pid;
553 // end totals only
556 // end for
560 if ($anypats == 0) {
561 ?><font size = 5 ><?php echo xlt('No Data to Process')?></font><?php
564 // TEST TO SEE IF THERE IS INFORMATION IN THE VARAIBLES THEN ADD TO AN ARRAY FOR PRINTING
566 if ($us0_fee != 0 || $us0_inspay != 0 || $us0_insadj != 0 || $us0_patadj != 0 || $us0_patpay != 0) {
567 $user_info['user'][$k] = $us0_user;
568 $user_info['fee'][$k] = $us0_fee;
569 $user_info['inspay'][$k] = $us0_inspay;
570 $user_info['insadj'][$k] = $us0_insadj;
571 $user_info['patadj'][$k] = $us0_patadj;
572 $user_info['patpay'][$k] = $us0_patpay;
573 ++$k;
576 if ($us1_fee != 0 || $us1_inspay != 0 || $us1_insadj != 0 || $us1_patadj != 0 || $us1_patpay != 0) {
577 $user_info['user'][$k] = $us1_user;
578 $user_info['fee'][$k] = $us1_fee;
579 $user_info['inspay'][$k] = $us1_inspay;
580 $user_info['insadj'][$k] = $us1_insadj;
581 $user_info['patadj'][$k] = $us1_patadj;
582 $user_info['patpay'][$k] = $us1_patpay;
583 ++$k;
586 if ($us2_fee != 0 || $us2_inspay != 0 || $us2_insadj != 0 || $us2_patadj != 0 || $us2_patpay != 0) {
587 $user_info['user'][$k] = $us2_user;
588 $user_info['fee'][$k] = $us2_fee;
589 $user_info['inspay'][$k] = $us2_inspay;
590 $user_info['insadj'][$k] = $us2_insadj;
591 $user_info['patadj'][$k] = $us2_patadj;
592 $user_info['patpay'][$k] = $us2_patpay;
593 ++$k;
596 if ($us3_fee != 0 || $us3_inspay != 0 || $us3_insadj != 0 || $us3_patadj != 0 || $us3_patpay != 0) {
597 $user_info['user'][$k] = $us3_user;
598 $user_info['fee'][$k] = $us3_fee;
599 $user_info['inspay'][$k] = $us3_inspay;
600 $user_info['insadj'][$k] = $us3_insadj;
601 $user_info['patadj'][$k] = $us3_patadj;
602 $user_info['patpay'][$k] = $us3_patpay;
603 ++$k;
606 if ($us4_fee != 0 || $us4_inspay != 0 || $us4_insadj != 0 || $us4_patadj != 0 || $us4_patpay != 0) {
607 $user_info['user'][$k] = $us4_user;
608 $user_info['fee'][$k] = $us4_fee;
609 $user_info['inspay'][$k] = $us4_inspay;
610 $user_info['insadj'][$k] = $us4_insadj;
611 $user_info['patadj'][$k] = $us4_patadj;
612 $user_info['patpay'][$k] = $us4_patpay;
613 ++$k;
616 if ($us5_fee != 0 || $us5_inspay != 0 || $us5_insadj != 0 || $us5_patadj != 0 || $us5_patpay != 0) {
617 $user_info['user'][$k] = $us5_user;
618 $user_info['fee'][$k] = $us5_fee;
619 $user_info['inspay'][$k] = $us5_inspay;
620 $user_info['insadj'][$k] = $us5_insadj;
621 $user_info['patadj'][$k] = $us5_patadj;
622 $user_info['patpay'][$k] = $us5_patpay;
623 ++$k;
626 if ($us6_fee != 0 || $us6_inspay != 0 || $us6_insadj != 0 || $us6_patadj != 0 || $us6_patpay != 0) {
627 $user_info['user'][$k] = $us6_user;
628 $user_info['fee'][$k] = $us6_fee;
629 $user_info['inspay'][$k] = $us6_inspay;
630 $user_info['insadj'][$k] = $us6_insadj;
631 $user_info['patadj'][$k] = $us6_patadj;
632 $user_info['patpay'][$k] = $us6_patpay;
633 ++$k;
636 if ($us7_fee != 0 || $us7_inspay != 0 || $us7_insadj != 0 || $us7_patadj != 0 || $us7_patpay != 0) {
637 $user_info['user'][$k] = $us7_user;
638 $user_info['fee'][$k] = $us7_fee;
639 $user_info['inspay'][$k] = $us7_inspay;
640 $user_info['insadj'][$k] = $us7_insadj;
641 $user_info['patadj'][$k] = $us7_patadj;
642 $user_info['patpay'][$k] = $us7_patpay;
643 ++$k;
646 if ($us8_fee != 0 || $us8_inspay != 0 || $us8_insadj != 0 || $us8_patadj != 0 || $us8_patpay != 0) {
647 $user_info['user'][$k] = $us8_user;
648 $user_info['fee'][$k] = $us8_fee;
649 $user_info['inspay'][$k] = $us8_inspay;
650 $user_info['insadj'][$k] = $us8_insadj;
651 $user_info['patadj'][$k] = $us8_patadj;
652 $user_info['patpay'][$k] = $us8_patpay;
653 ++$k;
656 if ($us9_fee != 0 || $us9_inspay != 0 || $us9_insadj != 0 || $us9_patadj != 0 || $us9_patpay != 0) {
657 $user_info['user'][$k] = $us9_user;
658 $user_info['fee'][$k] = $us9_fee;
659 $user_info['inspay'][$k] = $us9_inspay;
660 $user_info['insadj'][$k] = $us9_insadj;
661 $user_info['patadj'][$k] = $us9_patadj;
662 $user_info['patpay'][$k] = $us9_patpay;
663 ++$k;
666 if ($us10_fee != 0 || $us10_inspay != 0 || $us10_insadj != 0 || $us10_patadj != 0 || $us10_patpay != 0) {
667 $user_info['user'][$k] = $us10_user;
668 $user_info['fee'][$k] = $us10_fee;
669 $user_info['inspay'][$k] = $us10_inspay;
670 $user_info['insadj'][$k] = $us10_insadj;
671 $user_info['patadj'][$k] = $us10_patadj;
672 $user_info['patpay'][$k] = $us10_patpay;
673 ++$k;
676 if ($us11_fee != 0 || $us11_inspay != 0 || $us11_insadj != 0 || $us11_patadj != 0 || $us11_patpay != 0) {
677 $user_info['user'][$k] = $us11_user;
678 $user_info['fee'][$k] = $us11_fee;
679 $user_info['inspay'][$k] = $us11_inspay;
680 $user_info['insadj'][$k] = $us11_insadj;
681 $user_info['patadj'][$k] = $us11_patadj;
682 $user_info['patpay'][$k] = $us11_patpay;
683 ++$k;
686 if ($us12_fee != 0 || $us12_inspay != 0 || $us12_insadj != 0 || $us12_patadj != 0 || $us12_patpay != 0) {
687 $user_info['user'][$k] = $us12_user;
688 $user_info['fee'][$k] = $us12_fee;
689 $user_info['inspay'][$k] = $us12_inspay;
690 $user_info['insadj'][$k] = $us12_insadj;
691 $user_info['patadj'][$k] = $us12_patadj;
692 $user_info['patpay'][$k] = $us12_patpay;
693 ++$k;
696 if ($us13_fee != 0 || $us13_inspay != 0 || $us13_insadj != 0 || $us13_patadj != 0 || $us13_patpay != 0) {
697 $user_info['user'][$k] = $us13_user;
698 $user_info['fee'][$k] = $us13_fee;
699 $user_info['inspay'][$k] = $us13_inspay;
700 $user_info['insadj'][$k] = $us13_insadj;
701 $user_info['patadj'][$k] = $us13_patadj;
702 $user_info['patpay'][$k] = $us13_patpay;
703 ++$k;
706 if ($us14_fee != 0 || $us14_inspay != 0 || $us14_insadj != 0 || $us14_patadj != 0 || $us14_patpay != 0) {
707 $user_info['user'][$k] = $us14_user;
708 $user_info['fee'][$k] = $us14_fee;
709 $user_info['inspay'][$k] = $us14_inspay;
710 $user_info['insadj'][$k] = $us14_insadj;
711 $user_info['patadj'][$k] = $us14_patadj;
712 $user_info['patpay'][$k] = $us14_patpay;
713 ++$k;
716 if ($us15_fee != 0 || $us15_inspay != 0 || $us15_insadj != 0 || $us15_patadj != 0 || $us15_patpay != 0) {
717 $user_info['user'][$k] = $us15_user;
718 $user_info['fee'][$k] = $us15_fee;
719 $user_info['inspay'][$k] = $us15_inspay;
720 $user_info['insadj'][$k] = $us15_insadj;
721 $user_info['patadj'][$k] = $us15_patadj;
722 $user_info['patpay'][$k] = $us15_patpay;
723 ++$k;
726 if ($us16_fee != 0 || $us16_inspay != 0 || $us16_insadj != 0 || $us16_patadj != 0 || $us16_patpay != 0) {
727 $user_info['user'][$k] = $us16_user;
728 $user_info['fee'][$k] = $us16_fee;
729 $user_info['inspay'][$k] = $us16_inspay;
730 $user_info['insadj'][$k] = $us16_insadj;
731 $user_info['patadj'][$k] = $us16_patadj;
732 $user_info['patpay'][$k] = $us16_patpay;
733 ++$k;
736 if ($us17_fee != 0 || $us17_inspay != 0 || $us17_insadj != 0 || $us17_patadj != 0 || $us17_patpay != 0) {
737 $user_info['user'][$k] = $us17_user;
738 $user_info['fee'][$k] = $us17_fee;
739 $user_info['inspay'][$k] = $us17_inspay;
740 $user_info['insadj'][$k] = $us17_insadj;
741 $user_info['patadj'][$k] = $us17_patadj;
742 $user_info['patpay'][$k] = $us17_patpay;
743 ++$k;
746 if ($us18_fee != 0 || $us18_inspay != 0 || $us18_insadj != 0 || $us18_patadj != 0 || $us18_patpay != 0) {
747 $user_info['user'][$k] = $us18_user;
748 $user_info['fee'][$k] = $us18_fee;
749 $user_info['inspay'][$k] = $us18_inspay;
750 $user_info['insadj'][$k] = $us18_insadj;
751 $user_info['patadj'][$k] = $us18_patadj;
752 $user_info['patpay'][$k] = $us18_patpay;
753 ++$k;
756 if ($us19_fee != 0 || $us19_inspay != 0 || $us19_insadj != 0 || $us19_patadj != 0 || $us19_patpay != 0) {
757 $user_info['user'][$k] = $us19_user;
758 $user_info['fee'][$k] = $us19_fee;
759 $user_info['inspay'][$k] = $us19_inspay;
760 $user_info['insadj'][$k] = $us19_insadj;
761 $user_info['patadj'][$k] = $us19_patadj;
762 $user_info['patpay'][$k] = $us19_patpay;
763 ++$k;
766 if ($totals_only != 1) {
767 if ($line_total != 0) {
768 print "<td width=100><br><span class=text><b><center>" . xlt('Total') . "</b></center>";
769 Printf("<br></span></td><td width=100><span class=text><center>"." %1\$.2f", text($line_total)). "</center></span></td>\n<br>";
770 print "</tr><tr>\n";
771 } else {
772 print "<td width=100><br><span class=text><b><center>" . xlt('Total') . "</b></center>";
773 Printf("<br></span></td><td width=100><span class=text><center>"." %1\$.2f", text($line_total_pay)). "</center></td>\n<br>";
774 print "</tr><tr>\n";
778 if ($totals_only == 1) {
779 $from_date = oeFormatShortDate(substr($query_part_day, 37, 10));
780 $to_date = oeFormatShortDate(substr($query_part_day, 63, 10));
781 print "<br><br>";
783 ?><font size = 5 ><?php echo xlt('Totals for '). $from_date . ' ' . xlt('To') . ' ' . $to_date ?></font><?php
786 for ($i=1; $i<$k;) {
787 print "<table border=1><tr>\n";
788 print "<br><br>";
790 Printf("<td width=70><span class=text><b><center>". xlt("User") . ' ' . "</center></b><center>".text($user_info[user][$i])). "</center>";
791 Printf("<td width=140><span class=text><b><center>". xlt("Charges") . ' ' . "</center></b><center>"." %1\$.2f", text($user_info[fee][$i])). "</center>";
792 Printf("<td width=140><span class=text><b><center>". xlt("Insurance Adj").'. '."</center></b><center>"."%1\$.2f", text($user_info[insadj][$i])). "</center>";
793 Printf("<td width=140><span class=text><b><center>". xlt("Insurance Payments") . ' ' . "</center></b><center>"."%1\$.2f", text($user_info[inspay][$i])). "</center>";
794 Printf("<td width=140><span class=text><b><center>". xlt("Patient Adj").'. '."</center></b><center>"."%1\$.2f", text($user_info[patadj][$i])). "</center>";
795 Printf("<td width=140><span class=text><b><center>". xlt("Patient Payments") . ' ' . "</center></b><center>"."%1\$.2f", text($user_info[patpay][$i])). "</center>";
797 $gtotal_fee = $gtotal_fee + $user_info[fee][$i];
798 $gtotal_insadj = $gtotal_insadj + $user_info[insadj][$i];
799 $gtotal_inspay = $gtotal_inspay + $user_info[inspay][$i];
800 $gtotal_patadj = $gtotal_patadj + $user_info[patadj][$i];
801 $gtotal_patpay = $gtotal_patpay + $user_info[patpay][$i];
803 ++$i;
805 print "</br></td>";
808 print "<table border=1><tr>\n";
809 print "<br><br>";
811 Printf("<td width=70><span class=text><b><center>". xlt("Grand Totals") . ' ');
812 Printf("<td width=140><span class=text><b><center>". xlt("Total Charges") . ' ' . "</center></b><center>"." %1\$.2f", text($gtotal_fee)). "</center>";
813 Printf("<td width=140><span class=text><b><center>". xlt("Insurance Adj").'. '."</center></b><center>"."%1\$.2f", text($gtotal_insadj)). "</center>";
814 Printf("<td width=140><span class=text><b><center>". xlt("Insurance Payments") . ' ' . "</center></b><center>"."%1\$.2f", text($gtotal_inspay)). "</center>";
815 Printf("<td width=140><span class=text><b><center>". xlt("Patient Adj").'.'."</center></b><center>"."%1\$.2f", text($gtotal_patadj)). "</center>";
816 Printf("<td width=140><span class=text><b><center>". xlt("Patient Payments") . ' ' . "</center></b><center>"."%1\$.2f", text($gtotal_patpay)). "</center>";
818 print "</br></td>";
819 print "</table>";
822 </body>
823 </html>