minor fixes to prior commit
[openemr.git] / interface / billing / print_daysheet_report_num2.php
blobf0b4a3d404e97164c6d21ee200bba01371249eee
1 <?php
2 /**
3 * interface/billing/print_daysheet_report.php Genetating an end of day report.
4 *
5 * Program for Generating an End of Day report
6 *
7 *
8 * Copyright (C) 2014 Terry Hill <terry@lillysystems.com>
9 *
10 * LICENSE: This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 3
13 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
21 * @package OpenEMR
22 * @author Terry Hill <terry@lillysystems.com>
23 * @link http://www.open-emr.org
26 $fake_register_globals=false;
27 $sanitize_all_escapes=true;
29 include_once("../globals.php");
31 include_once("$srcdir/patient.inc");
32 include_once("$srcdir/../interface/reports/report.inc.php");
33 require_once("$srcdir/formatting.inc.php");
34 include_once("$srcdir/daysheet.inc.php");
37 //global variables:
38 if (!isset($_GET["mode"])) {
39 if (!isset($_GET["from_date"])) {
40 $from_date=date("Y-m-d");
41 } else {
42 $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"];
49 if (!isset($_GET["code_type"])) {
50 $code_type="all";
51 } else {
52 $code_type = $_GET["code_type"];
54 if (!isset($_GET["unbilled"])) {
55 $unbilled = "on";
56 } else {
57 $unbilled = $_GET["unbilled"];
59 if (!isset($_GET["authorized"])) {
60 $my_authorized = "on";
61 } else {
62 $my_authorized = $_GET["authorized"];
64 } else {
65 $from_date = $_GET["from_date"];
66 $to_date = $_GET["to_date"];
67 $code_type = $_GET["code_type"];
68 $unbilled = $_GET["unbilled"];
69 $my_authorized = $_GET["authorized"];
74 <html>
75 <head>
76 <?php html_header_show();?>
78 <link rel=stylesheet href="<?php echo $css_header;?>" type="text/css">
80 </head>
81 <body bgcolor="#ffffff" topmargin=0 rightmargin=0 leftmargin=2 bottommargin=0 marginwidth=2 marginheight=0>
83 <a href="javascript:window.close();" target=Main><font class=title><?php echo xlt('Day Sheet Report')?></font></a>
84 <br>
86 <?php
87 if ($my_authorized === 'on' ) {
88 $my_authorized = true;
89 } else {
90 $my_authorized = '%';
92 if ($unbilled === 'on') {
93 $unbilled = '0';
94 } else {
95 $unbilled = '%';
97 if ($code_type === 'all') {
98 $code_type = '%';
101 if (!isset($_GET["mode"])) {
102 if (!isset($_GET["from_date"])) {
103 $from_date=date("Y-m-d");
104 } else {
105 $from_date = $_GET["from_date"];
107 if (!isset($_GET["to_date"])) {
108 $to_date = date("Y-m-d");
109 } else {
110 $to_date = $_GET["to_date"];
112 if (!isset($_GET["code_type"])) {
113 $code_type="all";
114 } else {
115 $code_type = $_GET["code_type"];
117 if (!isset($_GET["unbilled"])) {
118 $unbilled = "on";
119 } else {
120 $unbilled = $_GET["unbilled"];
122 if (!isset($_GET["authorized"])) {
123 $my_authorized = "on";
124 } else {
125 $my_authorized = $_GET["authorized"];
127 } else {
128 $from_date = $_GET["from_date"];
129 $to_date = $_GET["to_date"];
130 $code_type = $_GET["code_type"];
131 $unbilled = $_GET["unbilled"];
132 $my_authorized = $_GET["authorized"];
135 if ($my_authorized === 'on' ) {
136 $my_authorized = true;
137 } else {
138 $my_authorized = '%';
140 if ($unbilled === 'on') {
141 $unbilled = '0';
142 } else {
143 $unbilled = '%';
145 if ($code_type === 'all') {
146 $code_type = '%';
149 if (isset($_GET["mode"]) && $_GET["mode"] === 'bill') {
150 billCodesList($list);
153 $res_count = 0;
154 $N = 1;
155 $k = 1;
156 $anypats = 0;
157 $the_first_time = 1;
158 $itero = array();
160 if ($ret = getBillsBetweendayReport($code_type)) {
162 // checking to see if there is any information in the array if not display a message (located after this if statment)
163 $anypats = count($ret);
166 $old_pid = -1;
167 $first_time = 1;
168 $new_old_pid = -1;
170 // $iter has encounter information
172 // this loop gathers the user numbers
173 foreach ($ret as $iter) {
174 $catch_user[] = $iter{'user'};
177 //This statment uniques the array removing duplicates
178 $user_list = array_unique($catch_user);
179 // reorder the list starting with array element zero
180 $final_list = array_values($user_list);
182 // sort array in assending order
183 sort($final_list);
185 $all4 = array_natsort($ret, pid, fulname, asc);
186 if ($_POST['end_of_day_totals_only'] == 1){
187 $totals_only = 1;
190 foreach ($all4 as $iter) {
192 // Case statment to tally information by user
193 switch ($iter{'user'}) {
194 case $iter{'user'} = $final_list[0]:
195 $us0_user = $iter{'user'};
196 $us0_fee = $us0_fee + $iter{'fee'};
197 $us0_inspay = $us0_inspay + $iter{'ins_code'};
198 $us0_insadj = $us0_insadj + $iter{'ins_adjust_dollar'};
199 $us0_patadj = $us0_patadj + $iter{'pat_adjust_dollar'};
200 $us0_patpay = $us0_patpay + $iter{'pat_code'};
201 break;
202 case $iter{'user'} = $final_list[1]:
203 $us1_user = $iter{'user'};
204 $us1_fee = $us1_fee + $iter{'fee'};
205 $us1_inspay = $us1_inspay + $iter{'ins_code'};
206 $us1_insadj = $us1_insadj + $iter{'ins_adjust_dollar'};
207 $us1_patadj = $us1_patadj + $iter{'pat_adjust_dollar'};
208 $us1_patpay = $us1_patpay + $iter{'pat_code'};
209 break;
210 case $iter{'user'} = $final_list[2]:
211 $us2_user = $iter{'user'};
212 $us2_fee = $us2_fee + $iter{'fee'};
213 $us2_inspay = $us2_inspay + $iter{'ins_code'};
214 $us2_insadj = $us2_insadj + $iter{'ins_adjust_dollar'};
215 $us2_patadj = $us2_patadj + $iter{'pat_adjust_dollar'};
216 $us2_patpay = $us2_patpay + $iter{'pat_code'};
217 break;
218 case $iter{'user'} = $final_list[3]:
219 $us3_user = $iter{'user'};
220 $us3_fee = $us3_fee + $iter{'fee'};
221 $us3_inspay = $us3_inspay + $iter{'ins_code'};
222 $us3_insadj = $us3_insadj + $iter{'ins_adjust_dollar'};
223 $us3_patadj = $us3_patadj + $iter{'pat_adjust_dollar'};
224 $us3_patpay = $us3_patpay + $iter{'pat_code'};
225 break;
226 case $iter{'user'} = $final_list[4]:
227 $us4_user = $iter{'user'};
228 $us4_fee = $us4_fee + $iter{'fee'};
229 $us4_inspay = $us4_inspay + $iter{'ins_code'};
230 $us4_insadj = $us4_insadj + $iter{'ins_adjust_dollar'};
231 $us4_patadj = $us4_patadj + $iter{'pat_adjust_dollar'};
232 $us4_patpay = $us4_patpay + $iter{'pat_code'};
233 break;
234 case $iter{'user'} = $final_list[5]:
235 $us5_user = $iter{'user'};
236 $us5_fee = $us5_fee + $iter{'fee'};
237 $us5_inspay = $us5_inspay + $iter{'ins_code'};
238 $us5_insadj = $us5_insadj + $iter{'ins_adjust_dollar'};
239 $us5_patadj = $us5_patadj + $iter{'pat_adjust_dollar'};
240 $us5_patpay = $us5_patpay + $iter{'pat_code'};
241 break;
242 case $iter{'user'} = $final_list[6]:
243 $us6_user = $iter{'user'};
244 $us6_fee = $us6_fee + $iter{'fee'};
245 $us6_inspay = $us6_inspay + $iter{'ins_code'};
246 $us6_insadj = $us6_insadj + $iter{'ins_adjust_dollar'};
247 $us6_patadj = $us6_patadj + $iter{'pat_adjust_dollar'};
248 $us6_patpay = $us6_patpay + $iter{'pat_code'};
249 break;
250 case $iter{'user'} = $final_list[7]:
251 $us7_user = $iter{'user'};
252 $us7_fee = $us7_fee + $iter{'fee'};
253 $us7_inspay = $us7_inspay + $iter{'ins_code'};
254 $us7_insadj = $us7_insadj + $iter{'ins_adjust_dollar'};
255 $us7_patadj = $us7_patadj + $iter{'pat_adjust_dollar'};
256 $us7_patpay = $us7_patpay + $iter{'pat_code'};
257 break;
258 case $iter{'user'} = $final_list[8]:
259 $us8_user = $iter{'user'};
260 $us8_fee = $us8_fee + $iter{'fee'};
261 $us8_inspay = $us8_inspay + $iter{'ins_code'};
262 $us8_insadj = $us8_insadj + $iter{'ins_adjust_dollar'};
263 $us8_patadj = $us8_patadj + $iter{'pat_adjust_dollar'};
264 $us8_patpay = $us8_patpay + $iter{'pat_code'};
265 break;
266 case $iter{'user'} = $final_list[9]:
267 $us9_user = $iter{'user'};
268 $us9_fee = $us9_fee + $iter{'fee'};
269 $us9_inspay = $us9_inspay + $iter{'ins_code'};
270 $us9_insadj = $us9_insadj + $iter{'ins_adjust_dollar'};
271 $us9_patadj = $us9_patadj + $iter{'pat_adjust_dollar'};
272 $us9_patpay = $us9_patpay + $iter{'pat_code'};
273 break;
274 case $iter{'user'} = $final_list[10]:
275 $us10_user = $iter{'user'};
276 $us10_fee = $us10_fee + $iter{'fee'};
277 $us10_inspay = $us10_inspay + $iter{'ins_code'};
278 $us10_insadj = $us10_insadj + $iter{'ins_adjust_dollar'};
279 $us10_patadj = $us10_patadj + $iter{'pat_adjust_dollar'};
280 $us10_patpay = $us10_patpay + $iter{'pat_code'};
281 break;
282 case $iter{'user'} = $final_list[11]:
283 $us11_user = $iter{'user'};
284 $us11_fee = $us11_fee + $iter{'fee'};
285 $us11_inspay = $us11_inspay + $iter{'ins_code'};
286 $us11_insadj = $us11_insadj + $iter{'ins_adjust_dollar'};
287 $us11_patadj = $us11_patadj + $iter{'pat_adjust_dollar'};
288 $us11_patpay = $us11_patpay + $iter{'pat_code'};
289 break;
290 case $iter{'user'} = $final_list[12]:
291 $us12_user = $iter{'user'};
292 $us12_fee = $us12_fee + $iter{'fee'};
293 $us12_inspay = $us12_inspay + $iter{'ins_code'};
294 $us12_insadj = $us12_insadj + $iter{'ins_adjust_dollar'};
295 $us12_patadj = $us12_patadj + $iter{'pat_adjust_dollar'};
296 $us12_patpay = $us12_patpay + $iter{'pat_code'};
297 break;
298 case $iter{'user'} = $final_list[13]:
299 $us13_user = $iter{'user'};
300 $us13_fee = $us13_fee + $iter{'fee'};
301 $us13_inspay = $us13_inspay + $iter{'ins_code'};
302 $us13_insadj = $us13_insadj + $iter{'ins_adjust_dollar'};
303 $us13_patadj = $us13_patadj + $iter{'pat_adjust_dollar'};
304 $us13_patpay = $us13_patpay + $iter{'pat_code'};
305 break;
306 case $iter{'user'} = $final_list[14]:
307 $us14_user = $iter{'user'};
308 $us14_fee = $us14_fee + $iter{'fee'};
309 $us14_inspay = $us14_inspay + $iter{'ins_code'};
310 $us14_insadj = $us14_insadj + $iter{'ins_adjust_dollar'};
311 $us14_patadj = $us14_patadj + $iter{'pat_adjust_dollar'};
312 $us14_patpay = $us14_patpay + $iter{'pat_code'};
313 break;
314 case $iter{'user'} = $final_list[15]:
315 $us15_user = $iter{'user'};
316 $us15_fee = $us15_fee + $iter{'fee'};
317 $us15_inspay = $us15_inspay + $iter{'ins_code'};
318 $us15_insadj = $us15_insadj + $iter{'ins_adjust_dollar'};
319 $us15_patadj = $us15_patadj + $iter{'pat_adjust_dollar'};
320 $us15_patpay = $us15_patpay + $iter{'pat_code'};
321 break;
322 case $iter{'user'} = $final_list[16]:
323 $us16_user = $iter{'user'};
324 $us16_fee = $us16_fee + $iter{'fee'};
325 $us16_inspay = $us16_inspay + $iter{'ins_code'};
326 $us16_insadj = $us16_insadj + $iter{'ins_adjust_dollar'};
327 $us16_patadj = $us16_patadj + $iter{'pat_adjust_dollar'};
328 $us16_patpay = $us16_patpay + $iter{'pat_code'};
329 break;
330 case $iter{'user'} = $final_list[17]:
331 $us17_user = $iter{'user'};
332 $us17_fee = $us17_fee + $iter{'fee'};
333 $us17_inspay = $us17_inspay + $iter{'ins_code'};
334 $us17_insadj = $us17_insadj + $iter{'ins_adjust_dollar'};
335 $us17_patadj = $us17_patadj + $iter{'pat_adjust_dollar'};
336 $us17_patpay = $us17_patpay + $iter{'pat_code'};
337 break;
338 case $iter{'user'} = $final_list[18]:
339 $us18_user = $iter{'user'};
340 $us18_fee = $us18_fee + $iter{'fee'};
341 $us18_inspay = $us18_inspay + $iter{'ins_code'};
342 $us18_insadj = $us18_insadj + $iter{'ins_adjust_dollar'};
343 $us18_patadj = $us18_patadj + $iter{'pat_adjust_dollar'};
344 $us18_patpay = $us18_patpay + $iter{'pat_code'};
345 break;
346 case $iter{'user'} = $final_list[19]:
347 $us19_user = $iter{'user'};
348 $us19_fee = $us19_fee + $iter{'fee'};
349 $us19_inspay = $us19_inspay + $iter{'ins_code'};
350 $us19_insadj = $us19_insadj + $iter{'ins_adjust_dollar'};
351 $us19_patadj = $us19_patadj + $iter{'pat_adjust_dollar'};
352 $us19_patpay = $us19_patpay + $iter{'pat_code'};
353 break;
356 if ($the_first_time == 1) {
357 $user = $iter{'user'};
358 $first_user = $iter{'user'};
359 $new_old_pid = $iter{'pid'};
360 $the_first_time = 0;
363 if ($totals_only != 1) {
365 if ($old_pid != $iter{'pid'} AND ($iter{'code_type'} != 'payment_info')) {
368 // $name has patient information
369 $name = getPatientData($iter{'pid'});
371 // formats the displayed text
374 if ($old_pid == $new_old_pid) {
375 if ($line_total != 0) {
376 print "<td width=100><br><span class=text><b><center>" . xlt('Total') . "</b></center>";
377 Printf ("<br></span></td><td width=100><span class=text><center>"." %1\$.2f",text($line_total)). "</center></td>";
379 else
381 print "<td width=100><br><span class=text><b><center>" . xlt('Total') . "</b></center>";
382 Printf ("<br></span></td><td width=100><span class=text><center>"." %1\$.2f",text($line_total_pay)). "</center></td>";
384 $line_total = 0;
385 $line_total_pay = 0;
388 if ($first_time) {
389 print "<table border=0><tr>\n"; // small table
390 $first_time=0;
393 // Displays name
395 print "<tr><td colspan=10><hr><span class=bold>" . text($name{"fname"}) . " " . text($name{"lname"}) . "</span><br><br></td></tr><tr>\n";
396 //==================================
398 if ($iter{'code_type'} === 'COPAY' || $iter{'code_type'} === 'Patient Payment' || $iter{'code_type'} === 'Insurance Payment' ) {
400 print "<td width=100><span class=text><center><b>" . xlt("Units") . "</b></center>";
401 print "</span></td><td width=100><span class=text><center><b>" . xlt("Fee"). "</b></center>" ;
402 print "</span></td><td width=100><span class=text><center><b>" . xlt("Code"). "</b></center>" ;
403 print "</span></td><td width=100><span class=text><b>";
404 print "</span></td><td width=100><span class=text><center><b>" . xlt("User"). "</b></center>";
405 print "</span></td><td width=100><span class=small><b>" ;
406 print "</span></td><td width=100><span class=small><center><b>". xlt("Post Date"). "</b></center>";
407 print "</span></td><td></tr><tr>\n";
409 else
411 print "<td width=100><span class=text><b><center>" . xlt("Units"). "</b></center>";
412 print "</span></td><td width=100><span class=text><center><b>" . xlt("Fee"). "</b></center>";
413 print "</span></td><td width=100><span class=text><center><b>" . xlt("Code") . "</b></center>";
414 print "</span></td><td width=100><span class=text><b><center>" . xlt("Provider Id"). "</b></center>";
415 print "</span></td><td width=100><span class=text><b><center>" . xlt("User"). "</b></center>";
416 print "</span></td><td width=100><span class=small><center><b>" . xlt("Bill Date"). "</b></center>";
417 print "</span></td><td width=100><span class=small><center><b>". xlt("Date of Service"). "</b></center>";
418 print "</span></td><td></tr><tr>\n";
421 //Next patient
423 $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>";
443 if (($iter{'ins_code'}) != 0 AND ($iter{'code_type'}) === 'Insurance Payment' ){
444 $line_total_pay = $line_total_pay + $iter{'ins_code'};
445 print "</span></td><td width=100><span class=text><center>" . text($iter{'ins_code'}). "</center>";
447 if (($iter{'code_type'}) != 'Patient Payment' AND ($iter{'code_type'}) != 'Insurance Payment' ){
448 $line_total_pay = $line_total_pay + $iter{"code"};
449 print "</span></td><td width=100><span class=text><center>" . text($iter{"code"}). "</center>";
451 if (($iter{'pat_adjust_dollar'}) != 0 AND ($iter{'code_type'}) === 'Patient Payment' ){
452 $line_total_pay = $line_total_pay + $iter{'pat_adjust_dollar'};
453 print "</span></td><td width=100><span class=text><center>" . text($iter{'pat_adjust_dollar'}). "</center>";
455 if (($iter{'pat_code'}) != 0 AND ($iter{'code_type'}) === 'Patient Payment' ){
456 $line_total_pay = $line_total_pay + $iter{'pat_code'};
457 print "</span></td><td width=100><span class=text><center>" .text($iter{'pat_code'}). "</center>";
460 // end fee output
462 if (($iter{'ins_adjust_dollar'}) != 0 AND ($iter{'code_type'}) === 'Insurance Payment' ){
463 print "</span></td><td width=250><span class=text><center>" . xlt("Insurance Adjustment"). "</center>";
465 if (($iter{'pat_adjust_dollar'}) != 0 AND ($iter{'code_type'}) === 'Patient Payment' ){
466 print "</span></td><td width=250><span class=text><center>" . xlt("Patient Adjustment"). "</center>";
468 if (($iter{'ins_code'}) > 0 AND ($iter{'code_type'}) === 'Insurance Payment' ){
469 print "</span></td><td width=250><span class=text><center>" . xlt('Insurance Payment'). "</center>";
471 if (($iter{'pat_code'}) > 0 AND ($iter{'code_type'}) === 'Patient Payment' AND $iter{'paytype'} != 'PCP' ){
472 print "</span></td><td width=250><span class=text><center>" . xlt('Patient Payment'). "</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 Credit"). "</center>";
477 if (($iter{'pat_code'}) < 0 AND ($iter{'code_type'}) === 'Patient Payment' AND $iter{'paytype'} != 'PCP' ){
478 print "</span></td><td width=250><span class=text><center>" . xlt("Patient Credit"). "</center>";
480 if ($iter{'paytype'} == 'PCP') {
481 print "</span></td><td width=250><span class=text><center>" . xlt('COPAY'). "</center>";
483 if (($iter{'code_type'}) != 'Insurance Payment' AND ($iter{'code_type'}) != 'Patient Payment' AND $iter{'paytype'} != 'PCP') {
484 print "</span></td><td width=250><span class=text><center>" . text($iter{'code_type'}). "</center>";
486 print "</span></td><td width=100><span class=text><center>" . text($iter{'provider_id'}). "</center>";
487 print "</span></td><td width=100><span class=text><center>" . text($iter{'user'}). "</center>" ;
488 print "</span></td><td width=100><span class=text>";
489 print "</span></td><td width=100><span class=small><center>" . text(date("Y-m-d",strtotime($iter{'date'}))). "</center>";
490 print "</span></td>\n";
493 else
495 if (date("Y-m-d",strtotime($iter{'bill_date'})) == "1969-12-31") {
496 print "<td width=100><span class=text><center>" . text($iter{'units'}) . "</center>" ;
497 print "</span></td><td width=100><span class=text><center>" . text($iter{'fee'}) . "</center>";
498 if ($GLOBALS['language_default'] === 'English (Standard)'){
499 print "</span></td><td width=250><span class=text><center>" . text(ucwords(strtolower(substr($iter{'code_text'},0,38)))) . "</center>";
501 else
503 print "</span></td><td width=250><span class=text><center>" . text(substr($iter{'code_text'},0,38)) . "</center>";
505 print "</span></td><td width=100><span class=text><center>" . text($iter{'provider_id'}) . "</center>" ;
506 print "</span></td><td width=100><span class=text><center>" . text($iter{'user'}) . "</center>" ;
507 print "</span></td><td width=100><span class=text><center>" . xlt('Not Billed'). "</center>";
508 print "</span></td><td width=100><span class=small><center>" . text(date("Y-m-d",strtotime($iter{'date'}))). "</center>";
509 print "</span></td>\n";
511 else
513 if ($iter{'fee'} != 0) {
514 $line_total = $line_total + $iter{'fee'};
515 print "<td width=100><span class=text><center>" . text($iter{"units"}) . "</center>";
516 print "</span></td><td width=100><span class=text><center>" . text($iter{'fee'}) . "</center>";
517 if ($GLOBALS['language_default'] === 'English (Standard)'){
518 print "</span></td><td width=250><span class=text><center>" . text(ucwords(strtolower(substr($iter{'code_text'},0,38)))) . "</center>";
520 else
522 print "</span></td><td width=250><span class=text><center>" . text(substr($iter{'code_text'},0,38)) . "</center>";
524 print "</span></td><td width=100><span class=text><center>" . text($iter{'provider_id'}) . "</center>";
525 print "</span></td><td width=100><span class=text><center>" . text($iter{'user'}) . "</center>";
526 print "</span></td><td width=100><span class=small><center>" . text(date("Y-m-d",strtotime($iter{'bill_date'}))) . "</center>";
527 print "</span></td><td width=100><span class=small><center>" . text(date("Y-m-d",strtotime($iter{"date"}))). "</center>";
528 print "</span></td>\n";
533 $res_count++;
535 if ($res_count == $N) {
536 print "</tr><tr>\n";
537 $res_count = 0;
539 $itero = $iter;
541 if ($old_pid != $new_old_pid AND ($iter{'code_type'} != 'payment_info')) {
542 $new_old_pid = $old_pid;
547 // end totals only
551 // end for
555 if ($anypats == 0) {
556 ?><font size = 5 ><?php echo xlt('No Data to Process')?></font><?php
559 // TEST TO SEE IF THERE IS INFORMATION IN THE VARAIBLES THEN ADD TO AN ARRAY FOR PRINTING
561 if ($us0_fee != 0 || $us0_inspay != 0 || $us0_insadj != 0 || $us0_patadj != 0 || $us0_patpay != 0) {
562 $user_info['user'][$k] = $us0_user;
563 $user_info['fee'][$k] = $us0_fee;
564 $user_info['inspay'][$k] = $us0_inspay;
565 $user_info['insadj'][$k] = $us0_insadj;
566 $user_info['patadj'][$k] = $us0_patadj;
567 $user_info['patpay'][$k] = $us0_patpay;
568 ++$k;
570 if ($us1_fee != 0 || $us1_inspay != 0 || $us1_insadj != 0 || $us1_patadj != 0 || $us1_patpay != 0) {
571 $user_info['user'][$k] = $us1_user;
572 $user_info['fee'][$k] = $us1_fee;
573 $user_info['inspay'][$k] = $us1_inspay;
574 $user_info['insadj'][$k] = $us1_insadj;
575 $user_info['patadj'][$k] = $us1_patadj;
576 $user_info['patpay'][$k] = $us1_patpay;
577 ++$k;
579 if ($us2_fee != 0 || $us2_inspay != 0 || $us2_insadj != 0 || $us2_patadj != 0 || $us2_patpay != 0) {
580 $user_info['user'][$k] = $us2_user;
581 $user_info['fee'][$k] = $us2_fee;
582 $user_info['inspay'][$k] = $us2_inspay;
583 $user_info['insadj'][$k] = $us2_insadj;
584 $user_info['patadj'][$k] = $us2_patadj;
585 $user_info['patpay'][$k] = $us2_patpay;
586 ++$k;
588 if ($us3_fee != 0 || $us3_inspay != 0 || $us3_insadj != 0 || $us3_patadj != 0 || $us3_patpay != 0) {
589 $user_info['user'][$k] = $us3_user;
590 $user_info['fee'][$k] = $us3_fee;
591 $user_info['inspay'][$k] = $us3_inspay;
592 $user_info['insadj'][$k] = $us3_insadj;
593 $user_info['patadj'][$k] = $us3_patadj;
594 $user_info['patpay'][$k] = $us3_patpay;
595 ++$k;
597 if ($us4_fee != 0 || $us4_inspay != 0 || $us4_insadj != 0 || $us4_patadj != 0 || $us4_patpay != 0) {
598 $user_info['user'][$k] = $us4_user;
599 $user_info['fee'][$k] = $us4_fee;
600 $user_info['inspay'][$k] = $us4_inspay;
601 $user_info['insadj'][$k] = $us4_insadj;
602 $user_info['patadj'][$k] = $us4_patadj;
603 $user_info['patpay'][$k] = $us4_patpay;
604 ++$k;
606 if ($us5_fee != 0 || $us5_inspay != 0 || $us5_insadj != 0 || $us5_patadj != 0 || $us5_patpay != 0) {
607 $user_info['user'][$k] = $us5_user;
608 $user_info['fee'][$k] = $us5_fee;
609 $user_info['inspay'][$k] = $us5_inspay;
610 $user_info['insadj'][$k] = $us5_insadj;
611 $user_info['patadj'][$k] = $us5_patadj;
612 $user_info['patpay'][$k] = $us5_patpay;
613 ++$k;
615 if ($us6_fee != 0 || $us6_inspay != 0 || $us6_insadj != 0 || $us6_patadj != 0 || $us6_patpay != 0) {
616 $user_info['user'][$k] = $us6_user;
617 $user_info['fee'][$k] = $us6_fee;
618 $user_info['inspay'][$k] = $us6_inspay;
619 $user_info['insadj'][$k] = $us6_insadj;
620 $user_info['patadj'][$k] = $us6_patadj;
621 $user_info['patpay'][$k] = $us6_patpay;
622 ++$k;
624 if ($us7_fee != 0 || $us7_inspay != 0 || $us7_insadj != 0 || $us7_patadj != 0 || $us7_patpay != 0) {
625 $user_info['user'][$k] = $us7_user;
626 $user_info['fee'][$k] = $us7_fee;
627 $user_info['inspay'][$k] = $us7_inspay;
628 $user_info['insadj'][$k] = $us7_insadj;
629 $user_info['patadj'][$k] = $us7_patadj;
630 $user_info['patpay'][$k] = $us7_patpay;
631 ++$k;
633 if ($us8_fee != 0 || $us8_inspay != 0 || $us8_insadj != 0 || $us8_patadj != 0 || $us8_patpay != 0) {
634 $user_info['user'][$k] = $us8_user;
635 $user_info['fee'][$k] = $us8_fee;
636 $user_info['inspay'][$k] = $us8_inspay;
637 $user_info['insadj'][$k] = $us8_insadj;
638 $user_info['patadj'][$k] = $us8_patadj;
639 $user_info['patpay'][$k] = $us8_patpay;
640 ++$k;
642 if ($us9_fee != 0 || $us9_inspay != 0 || $us9_insadj != 0 || $us9_patadj != 0 || $us9_patpay != 0) {
643 $user_info['user'][$k] = $us9_user;
644 $user_info['fee'][$k] = $us9_fee;
645 $user_info['inspay'][$k] = $us9_inspay;
646 $user_info['insadj'][$k] = $us9_insadj;
647 $user_info['patadj'][$k] = $us9_patadj;
648 $user_info['patpay'][$k] = $us9_patpay;
649 ++$k;
651 if ($us10_fee != 0 || $us10_inspay != 0 || $us10_insadj != 0 || $us10_patadj != 0 || $us10_patpay != 0) {
652 $user_info['user'][$k] = $us10_user;
653 $user_info['fee'][$k] = $us10_fee;
654 $user_info['inspay'][$k] = $us10_inspay;
655 $user_info['insadj'][$k] = $us10_insadj;
656 $user_info['patadj'][$k] = $us10_patadj;
657 $user_info['patpay'][$k] = $us10_patpay;
658 ++$k;
660 if ($us11_fee != 0 || $us11_inspay != 0 || $us11_insadj != 0 || $us11_patadj != 0 || $us11_patpay != 0) {
661 $user_info['user'][$k] = $us11_user;
662 $user_info['fee'][$k] = $us11_fee;
663 $user_info['inspay'][$k] = $us11_inspay;
664 $user_info['insadj'][$k] = $us11_insadj;
665 $user_info['patadj'][$k] = $us11_patadj;
666 $user_info['patpay'][$k] = $us11_patpay;
667 ++$k;
669 if ($us12_fee != 0 || $us12_inspay != 0 || $us12_insadj != 0 || $us12_patadj != 0 || $us12_patpay != 0) {
670 $user_info['user'][$k] = $us12_user;
671 $user_info['fee'][$k] = $us12_fee;
672 $user_info['inspay'][$k] = $us12_inspay;
673 $user_info['insadj'][$k] = $us12_insadj;
674 $user_info['patadj'][$k] = $us12_patadj;
675 $user_info['patpay'][$k] = $us12_patpay;
676 ++$k;
678 if ($us13_fee != 0 || $us13_inspay != 0 || $us13_insadj != 0 || $us13_patadj != 0 || $us13_patpay != 0) {
679 $user_info['user'][$k] = $us13_user;
680 $user_info['fee'][$k] = $us13_fee;
681 $user_info['inspay'][$k] = $us13_inspay;
682 $user_info['insadj'][$k] = $us13_insadj;
683 $user_info['patadj'][$k] = $us13_patadj;
684 $user_info['patpay'][$k] = $us13_patpay;
685 ++$k;
687 if ($us14_fee != 0 || $us14_inspay != 0 || $us14_insadj != 0 || $us14_patadj != 0 || $us14_patpay != 0) {
688 $user_info['user'][$k] = $us14_user;
689 $user_info['fee'][$k] = $us14_fee;
690 $user_info['inspay'][$k] = $us14_inspay;
691 $user_info['insadj'][$k] = $us14_insadj;
692 $user_info['patadj'][$k] = $us14_patadj;
693 $user_info['patpay'][$k] = $us14_patpay;
694 ++$k;
696 if ($us15_fee != 0 || $us15_inspay != 0 || $us15_insadj != 0 || $us15_patadj != 0 || $us15_patpay != 0) {
697 $user_info['user'][$k] = $us15_user;
698 $user_info['fee'][$k] = $us15_fee;
699 $user_info['inspay'][$k] = $us15_inspay;
700 $user_info['insadj'][$k] = $us15_insadj;
701 $user_info['patadj'][$k] = $us15_patadj;
702 $user_info['patpay'][$k] = $us15_patpay;
703 ++$k;
705 if ($us16_fee != 0 || $us16_inspay != 0 || $us16_insadj != 0 || $us16_patadj != 0 || $us16_patpay != 0) {
706 $user_info['user'][$k] = $us16_user;
707 $user_info['fee'][$k] = $us16_fee;
708 $user_info['inspay'][$k] = $us16_inspay;
709 $user_info['insadj'][$k] = $us16_insadj;
710 $user_info['patadj'][$k] = $us16_patadj;
711 $user_info['patpay'][$k] = $us16_patpay;
712 ++$k;
714 if ($us17_fee != 0 || $us17_inspay != 0 || $us17_insadj != 0 || $us17_patadj != 0 || $us17_patpay != 0) {
715 $user_info['user'][$k] = $us17_user;
716 $user_info['fee'][$k] = $us17_fee;
717 $user_info['inspay'][$k] = $us17_inspay;
718 $user_info['insadj'][$k] = $us17_insadj;
719 $user_info['patadj'][$k] = $us17_patadj;
720 $user_info['patpay'][$k] = $us17_patpay;
721 ++$k;
723 if ($us18_fee != 0 || $us18_inspay != 0 || $us18_insadj != 0 || $us18_patadj != 0 || $us18_patpay != 0) {
724 $user_info['user'][$k] = $us18_user;
725 $user_info['fee'][$k] = $us18_fee;
726 $user_info['inspay'][$k] = $us18_inspay;
727 $user_info['insadj'][$k] = $us18_insadj;
728 $user_info['patadj'][$k] = $us18_patadj;
729 $user_info['patpay'][$k] = $us18_patpay;
730 ++$k;
732 if ($us19_fee != 0 || $us19_inspay != 0 || $us19_insadj != 0 || $us19_patadj != 0 || $us19_patpay != 0) {
733 $user_info['user'][$k] = $us19_user;
734 $user_info['fee'][$k] = $us19_fee;
735 $user_info['inspay'][$k] = $us19_inspay;
736 $user_info['insadj'][$k] = $us19_insadj;
737 $user_info['patadj'][$k] = $us19_patadj;
738 $user_info['patpay'][$k] = $us19_patpay;
739 ++$k;
742 if ($totals_only != 1) {
744 if ($line_total != 0) {
745 print "<td width=100><br><span class=text><b><center>" . xlt('Total') . "</b></center>";
746 Printf ("<br></span></td><td width=100><span class=text><center>"." %1\$.2f",text($line_total)). "</center></span></td>\n<br>";
747 print "</tr><tr>\n";
749 else
751 print "<td width=100><br><span class=text><b><center>" . xlt('Total') . "</b></center>";
752 Printf ("<br></span></td><td width=100><span class=text><center>"." %1\$.2f",text($line_total_pay)). "</center></td>\n<br>";
753 print "</tr><tr>\n";
756 if ($totals_only == 1) {
757 $from_date = oeFormatShortDate(substr($query_part_day,37,10));
758 $to_date = oeFormatShortDate(substr($query_part_day,63,10));
759 print "<br><br>";
761 ?><font size = 5 ><?php echo xlt('Totals for '). $from_date . ' ' . xlt('To') . ' ' . $to_date ?></font><?php
764 for ($i=1 ; $i<$k; ) {
765 print "<table border=1><tr>\n";
766 print "<br><br>";
768 Printf ("<td width=70><span class=text><b><center>". xlt("User") . ' ' . "</center></b><center>".text($user_info[user][$i])). "</center>";
769 Printf ("<td width=140><span class=text><b><center>". xlt("Charges") . ' ' . "</center></b><center>"." %1\$.2f",text($user_info[fee][$i])). "</center>";
770 Printf ("<td width=140><span class=text><b><center>". xlt("Insurance Adj").'. '."</center></b><center>"."%1\$.2f",text($user_info[insadj][$i])). "</center>";
771 Printf ("<td width=140><span class=text><b><center>". xlt("Insurance Payments") . ' ' . "</center></b><center>"."%1\$.2f",text($user_info[inspay][$i])). "</center>";
772 Printf ("<td width=140><span class=text><b><center>". xlt("Patient Adj").'. '."</center></b><center>"."%1\$.2f",text($user_info[patadj][$i])). "</center>";
773 Printf ("<td width=140><span class=text><b><center>". xlt("Patient Payments") . ' ' . "</center></b><center>"."%1\$.2f",text($user_info[patpay][$i])). "</center>";
775 $gtotal_fee = $gtotal_fee + $user_info[fee][$i];
776 $gtotal_insadj = $gtotal_insadj + $user_info[insadj][$i];
777 $gtotal_inspay = $gtotal_inspay + $user_info[inspay][$i];
778 $gtotal_patadj = $gtotal_patadj + $user_info[patadj][$i];
779 $gtotal_patpay = $gtotal_patpay + $user_info[patpay][$i];
781 ++$i;
783 print "</br></td>";
785 print "<table border=1><tr>\n";
786 print "<br><br>";
788 Printf ("<td width=70><span class=text><b><center>". xlt("Grand Totals") . ' ');
789 Printf ("<td width=140><span class=text><b><center>". xlt("Total Charges") . ' ' . "</center></b><center>"." %1\$.2f",text($gtotal_fee)). "</center>";
790 Printf ("<td width=140><span class=text><b><center>". xlt("Insurance Adj").'. '."</center></b><center>"."%1\$.2f",text($gtotal_insadj)). "</center>";
791 Printf ("<td width=140><span class=text><b><center>". xlt("Insurance Payments") . ' ' . "</center></b><center>"."%1\$.2f",text($gtotal_inspay)). "</center>";
792 Printf ("<td width=140><span class=text><b><center>". xlt("Patient Adj").'.'."</center></b><center>"."%1\$.2f",text($gtotal_patadj)). "</center>";
793 Printf ("<td width=140><span class=text><b><center>". xlt("Patient Payments") . ' ' . "</center></b><center>"."%1\$.2f",text($gtotal_patpay)). "</center>";
795 print "</br></td>";
796 print "</table>";
799 </body>
800 </html>