dump db version
[openemr.git] / interface / billing / print_billing_report.php
blobc1bb4dcb3567335fb71b2af002b58dfbd6d480ae
1 <?php
2 /*
3 * Print billing report.
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author Julia Longtin
8 * @author Stephen Waite <stephen.waite@cmsvt.com>
9 * @copyright Copyright (c) 2012 Julia Longtin
10 * @copyright Copyright (c) 2018 Stephen Waite <stephen.waite@cmsvt.com>
11 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
14 require_once("../globals.php");
15 require_once("$srcdir/patient.inc");
16 require_once("$srcdir/../interface/reports/report.inc.php");
17 require_once("$srcdir/billrep.inc");
18 require_once("$srcdir/forms.inc");
19 require_once("$srcdir/report.inc");
21 //how many columns to use when displaying information
22 $COLS=6;
24 //global variables:
25 if (!isset($_GET["mode"])) {
26 if (!isset($_GET["from_date"])) {
27 $from_date=date("Y-m-d");
28 } else {
29 $from_date = $_GET["from_date"];
32 if (!isset($_GET["to_date"])) {
33 $to_date = date("Y-m-d");
34 } else {
35 $to_date = $_GET["to_date"];
38 if (!isset($_GET["code_type"])) {
39 $code_type="all";
40 } else {
41 $code_type = $_GET["code_type"];
44 if (!isset($_GET["unbilled"])) {
45 $unbilled = "on";
46 } else {
47 $unbilled = $_GET["unbilled"];
50 if (!isset($_GET["authorized"])) {
51 $my_authorized = "on";
52 } else {
53 $my_authorized = $_GET["authorized"];
55 } else {
56 $from_date = $_GET["from_date"];
57 $to_date = $_GET["to_date"];
58 $code_type = $_GET["code_type"];
59 $unbilled = $_GET["unbilled"];
60 $my_authorized = $_GET["authorized"];
65 <html>
66 <head>
67 <?php html_header_show();?>
69 <link rel=stylesheet href="<?php echo $css_header;?>" type="text/css">
71 </head>
72 <body bgcolor="#ffffff" topmargin=0 rightmargin=0 leftmargin=2 bottommargin=0 marginwidth=2 marginheight=0>
74 <a href="javascript:window.close();" target=Main><font class=title><?php echo xlt('Billing Report')?></font></a>
75 <br>
77 <?php
78 if ($my_authorized == "on") {
79 $my_authorized = 1;
80 } else {
81 $my_authorized = "%";
84 if ($unbilled == "on") {
85 $unbilled = "0";
86 } else {
87 $unbilled = "%";
90 if ($code_type == "all") {
91 $code_type = "%";
94 $list = getBillsListBetween($code_type);
96 if (!isset($_GET["mode"])) {
97 if (!isset($_GET["from_date"])) {
98 $from_date=date("Y-m-d");
99 } else {
100 $from_date = $_GET["from_date"];
103 if (!isset($_GET["to_date"])) {
104 $to_date = date("Y-m-d");
105 } else {
106 $to_date = $_GET["to_date"];
109 if (!isset($_GET["code_type"])) {
110 $code_type="all";
111 } else {
112 $code_type = $_GET["code_type"];
115 if (!isset($_GET["unbilled"])) {
116 $unbilled = "on";
117 } else {
118 $unbilled = $_GET["unbilled"];
121 if (!isset($_GET["authorized"])) {
122 $my_authorized = "on";
123 } else {
124 $my_authorized = $_GET["authorized"];
126 } else {
127 $from_date = $_GET["from_date"];
128 $to_date = $_GET["to_date"];
129 $code_type = $_GET["code_type"];
130 $unbilled = $_GET["unbilled"];
131 $my_authorized = $_GET["authorized"];
134 if ($my_authorized == "on") {
135 $my_authorized = 1;
136 } else {
137 $my_authorized = "%";
140 if ($unbilled == "on") {
141 $unbilled = "0";
142 } else {
143 $unbilled = "%";
146 if ($code_type == "all") {
147 $code_type = "%";
150 $list = getBillsListBetween($code_type);
152 if (isset($_GET["mode"]) && $_GET["mode"] == "bill") {
153 billCodesList($list);
156 $res_count = 0;
157 $N = 1;
159 $itero = array();
160 if ($ret = getBillsBetweenReport($code_type)) {
161 $old_pid = -1;
162 $first_time = 1;
163 $encid = 0;
164 foreach ($ret as $iter) {
165 if ($old_pid != $iter{"pid"}) {
166 $name = getPatientData($iter{"pid"});
167 if (!$first_time) {
168 print "</tr></table>\n";
169 print "</td><td>";
170 print "<table border=0><tr>\n"; // small table
171 } else {
172 print "<table border=0><tr>\n"; // small table
173 $first_time=0;
176 print "<tr><td colspan=5><hr><span class=bold>" . text($name{"fname"}) . " " . text($name{"lname"}) . "</span><br><br>\n";
177 //==================================
180 print "<font class=bold>" . xlt("Patient Data") . ":</font><br>";
181 printRecDataOne($patient_data_array, getRecPatientData($iter{"pid"}), $COLS);
183 print "<font class=bold>" . xlt("Employer Data") . ":</font><br>";
184 printRecDataOne($employer_data_array, getRecEmployerData($iter{"pid"}), $COLS);
186 print "<font class=bold>" . xlt("Primary Insurance Data") . ":</font><br>";
187 printRecDataOne($insurance_data_array, getRecInsuranceData($iter{"pid"}, "primary"), $COLS);
189 print "<font class=bold>" . xlt("Secondary Insurance Data") . ":</font><br>";
190 printRecDataOne($insurance_data_array, getRecInsuranceData($iter{"pid"}, "secondary"), $COLS);
192 print "<font class=bold>" . xlt("Tertiary Insurance Data") . ":</font><br>";
193 printRecDataOne($insurance_data_array, getRecInsuranceData($iter{"pid"}, "tertiary"), $COLS);
195 //==================================
196 print "</td></tr><tr>\n";
197 $old_pid = $iter{"pid"};
200 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";
201 $res_count++;
202 if ($res_count == $N) {
203 print "</tr><tr>\n";
204 $res_count = 0;
207 $itero = $iter;
210 print "</tr></table>\n"; // small table
214 </body>
215 </html>