continued bug fixes (#1876)
[openemr.git] / interface / billing / print_billing_report.php
blob8640cf11f6f4f8ae2fc52593bcf9cb7d3f3f12e2
1 <?php
2 /* Copyright (C) 2012 Julia Longtin */
7 require_once("../globals.php");
9 require_once("$srcdir/patient.inc");
10 require_once("$srcdir/../interface/reports/report.inc.php");
11 require_once("$srcdir/billrep.inc");
12 require_once("$srcdir/forms.inc");
13 require_once("$srcdir/billing.inc");
14 require_once("$srcdir/report.inc");
16 //how many columns to use when displaying information
17 $COLS=6;
19 //global variables:
20 if (!isset($_GET["mode"])) {
21 if (!isset($_GET["from_date"])) {
22 $from_date=date("Y-m-d");
23 } else {
24 $from_date = $_GET["from_date"];
27 if (!isset($_GET["to_date"])) {
28 $to_date = date("Y-m-d");
29 } else {
30 $to_date = $_GET["to_date"];
33 if (!isset($_GET["code_type"])) {
34 $code_type="all";
35 } else {
36 $code_type = $_GET["code_type"];
39 if (!isset($_GET["unbilled"])) {
40 $unbilled = "on";
41 } else {
42 $unbilled = $_GET["unbilled"];
45 if (!isset($_GET["authorized"])) {
46 $my_authorized = "on";
47 } else {
48 $my_authorized = $_GET["authorized"];
50 } else {
51 $from_date = $_GET["from_date"];
52 $to_date = $_GET["to_date"];
53 $code_type = $_GET["code_type"];
54 $unbilled = $_GET["unbilled"];
55 $my_authorized = $_GET["authorized"];
60 <html>
61 <head>
62 <?php html_header_show();?>
64 <link rel=stylesheet href="<?php echo $css_header;?>" type="text/css">
66 </head>
67 <body bgcolor="#ffffff" topmargin=0 rightmargin=0 leftmargin=2 bottommargin=0 marginwidth=2 marginheight=0>
69 <a href="javascript:window.close();" target=Main><font class=title><?php echo xlt('Billing Report')?></font></a>
70 <br>
72 <?php
73 if ($my_authorized == "on") {
74 $my_authorized = 1;
75 } else {
76 $my_authorized = "%";
79 if ($unbilled == "on") {
80 $unbilled = "0";
81 } else {
82 $unbilled = "%";
85 if ($code_type == "all") {
86 $code_type = "%";
89 $list = getBillsListBetween($code_type);
91 if (!isset($_GET["mode"])) {
92 if (!isset($_GET["from_date"])) {
93 $from_date=date("Y-m-d");
94 } else {
95 $from_date = $_GET["from_date"];
98 if (!isset($_GET["to_date"])) {
99 $to_date = date("Y-m-d");
100 } else {
101 $to_date = $_GET["to_date"];
104 if (!isset($_GET["code_type"])) {
105 $code_type="all";
106 } else {
107 $code_type = $_GET["code_type"];
110 if (!isset($_GET["unbilled"])) {
111 $unbilled = "on";
112 } else {
113 $unbilled = $_GET["unbilled"];
116 if (!isset($_GET["authorized"])) {
117 $my_authorized = "on";
118 } else {
119 $my_authorized = $_GET["authorized"];
121 } else {
122 $from_date = $_GET["from_date"];
123 $to_date = $_GET["to_date"];
124 $code_type = $_GET["code_type"];
125 $unbilled = $_GET["unbilled"];
126 $my_authorized = $_GET["authorized"];
129 if ($my_authorized == "on") {
130 $my_authorized = 1;
131 } else {
132 $my_authorized = "%";
135 if ($unbilled == "on") {
136 $unbilled = "0";
137 } else {
138 $unbilled = "%";
141 if ($code_type == "all") {
142 $code_type = "%";
145 $list = getBillsListBetween($code_type);
147 if (isset($_GET["mode"]) && $_GET["mode"] == "bill") {
148 billCodesList($list);
151 $res_count = 0;
152 $N = 1;
154 $itero = array();
155 if ($ret = getBillsBetweenReport($code_type)) {
156 $old_pid = -1;
157 $first_time = 1;
158 $encid = 0;
159 foreach ($ret as $iter) {
160 if ($old_pid != $iter{"pid"}) {
161 $name = getPatientData($iter{"pid"});
162 if (!$first_time) {
163 print "</tr></table>\n";
164 print "</td><td>";
165 print "<table border=0><tr>\n"; // small table
166 } else {
167 print "<table border=0><tr>\n"; // small table
168 $first_time=0;
171 print "<tr><td colspan=5><hr><span class=bold>" . text($name{"fname"}) . " " . text($name{"lname"}) . "</span><br><br>\n";
172 //==================================
175 print "<font class=bold>" . xlt("Patient Data") . ":</font><br>";
176 printRecDataOne($patient_data_array, getRecPatientData($iter{"pid"}), $COLS);
178 print "<font class=bold>" . xlt("Employer Data") . ":</font><br>";
179 printRecDataOne($employer_data_array, getRecEmployerData($iter{"pid"}), $COLS);
181 print "<font class=bold>" . xlt("Primary Insurance Data") . ":</font><br>";
182 printRecDataOne($insurance_data_array, getRecInsuranceData($iter{"pid"}, "primary"), $COLS);
184 print "<font class=bold>" . xlt("Secondary Insurance Data") . ":</font><br>";
185 printRecDataOne($insurance_data_array, getRecInsuranceData($iter{"pid"}, "secondary"), $COLS);
187 print "<font class=bold>" . xlt("Tertiary Insurance Data") . ":</font><br>";
188 printRecDataOne($insurance_data_array, getRecInsuranceData($iter{"pid"}, "tertiary"), $COLS);
190 //==================================
191 print "</td></tr><tr>\n";
192 $old_pid = $iter{"pid"};
195 print "<td width=100><span class=text>" . text($iter{"code_type"}) . ": </span></td><td width=100><span class=text>" . text($iter{"code"}) . "</span></td><td width=100><span class=small>(" . text(date("Y-m-d", strtotime($iter{"date"}))) . ")</span></td>\n";
196 $res_count++;
197 if ($res_count == $N) {
198 print "</tr><tr>\n";
199 $res_count = 0;
202 $itero = $iter;
205 print "</tr></table>\n"; // small table
209 </body>
210 </html>