fix: quick fix to enforce support of x509 database connection on install (#6157)
[openemr.git] / interface / billing / print_billing_report.php
blob7c674d841977a324e782d993ef9bd746570ea67e
1 <?php
3 /*
4 * Print billing report.
6 * @package OpenEMR
7 * @link http://www.open-emr.org
8 * @author Julia Longtin
9 * @author Stephen Waite <stephen.waite@cmsvt.com>
10 * @copyright Copyright (c) 2012 Julia Longtin
11 * @copyright Copyright (c) 2018-2020 Stephen Waite <stephen.waite@cmsvt.com>
12 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 require_once("../globals.php");
16 require_once("$srcdir/patient.inc.php");
17 require_once("$srcdir/forms.inc.php");
18 require_once("$srcdir/report.inc.php");
20 use OpenEMR\Billing\BillingReport;
21 use OpenEMR\Core\Header;
23 //how many columns to use when displaying information
24 $COLS = 6;
26 //global variables:
27 if (!isset($_GET["mode"])) {
28 if (!isset($_GET["from_date"])) {
29 $from_date = date("Y-m-d");
30 } else {
31 $from_date = $_GET["from_date"];
34 if (!isset($_GET["to_date"])) {
35 $to_date = date("Y-m-d");
36 } else {
37 $to_date = $_GET["to_date"];
40 if (!isset($_GET["code_type"])) {
41 $code_type = "all";
42 } else {
43 $code_type = $_GET["code_type"];
46 if (!isset($_GET["unbilled"])) {
47 $unbilled = "on";
48 } else {
49 $unbilled = $_GET["unbilled"];
52 if (!isset($_GET["authorized"])) {
53 $my_authorized = "on";
54 } else {
55 $my_authorized = $_GET["authorized"];
57 } else {
58 $from_date = $_GET["from_date"];
59 $to_date = $_GET["to_date"];
60 $code_type = $_GET["code_type"];
61 $unbilled = $_GET["unbilled"];
62 $my_authorized = $_GET["authorized"];
67 <html>
68 <head>
70 <?php Header::setupHeader(); ?>
72 </head>
73 <body bgcolor="var(--white)" topmargin="0" rightmargin="0" leftmargin="2" bottommargin="0" marginwidth="2" marginheight="0">
75 <a href="javascript:window.close();" target="Main"><font class="title"><?php echo xlt('Billing Report')?></font></a>
76 <br />
78 <?php
79 if ($my_authorized == "on") {
80 $my_authorized = 1;
81 } else {
82 $my_authorized = "%";
85 if ($unbilled == "on") {
86 $unbilled = "0";
87 } else {
88 $unbilled = "%";
91 if ($code_type == "all") {
92 $code_type = "%";
95 $list = BillingReport::getBillsListBetween($code_type);
97 if (!isset($_GET["mode"])) {
98 if (!isset($_GET["from_date"])) {
99 $from_date = date("Y-m-d");
100 } else {
101 $from_date = $_GET["from_date"];
104 if (!isset($_GET["to_date"])) {
105 $to_date = date("Y-m-d");
106 } else {
107 $to_date = $_GET["to_date"];
110 if (!isset($_GET["code_type"])) {
111 $code_type = "all";
112 } else {
113 $code_type = $_GET["code_type"];
116 if (!isset($_GET["unbilled"])) {
117 $unbilled = "on";
118 } else {
119 $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 = 1;
137 } else {
138 $my_authorized = "%";
141 if ($unbilled == "on") {
142 $unbilled = "0";
143 } else {
144 $unbilled = "%";
147 if ($code_type == "all") {
148 $code_type = "%";
151 $list = BillingReport::getBillsListBetween($code_type);
153 if (isset($_GET["mode"]) && $_GET["mode"] == "bill") {
154 BillingReport::billCodesList($list);
157 $res_count = 0;
158 $N = 1;
160 $itero = array();
161 if ($ret = BillingReport::getBillsBetweenReport($code_type)) {
162 $old_pid = -1;
163 $first_time = 1;
164 $encid = 0;
165 foreach ($ret as $iter) {
166 if ($old_pid != $iter["pid"]) {
167 $name = getPatientData($iter["pid"]);
168 if (!$first_time) {
169 print "</tr></table>\n";
170 print "</td><td>";
171 print "<table border='0'><tr>\n"; // small table
172 } else {
173 print "<table border='0'><tr>\n"; // small table
174 $first_time = 0;
177 print "<tr><td colspan='5'><hr /><span class='font-weight-bold'>" . text($name["fname"]) . " " . text($name["lname"]) . "</span><br /><br />\n";
178 //==================================
181 print "<font class='font-weight-bold'>" . xlt("Patient Data") . ":</font><br />";
182 printRecDataOne($patient_data_array, getRecPatientData($iter["pid"]), $COLS);
184 print "<font class='font-weight-bold'>" . xlt("Employer Data") . ":</font><br />";
185 printRecDataOne($employer_data_array, getRecEmployerData($iter["pid"]), $COLS);
187 print "<font class='font-weight-bold'>" . xlt("Primary Insurance Data") . ":</font><br />";
188 printRecDataOne($insurance_data_array, getRecInsuranceData($iter["pid"], "primary"), $COLS);
190 print "<font class='font-weight-bold'>" . xlt("Secondary Insurance Data") . ":</font><br />";
191 printRecDataOne($insurance_data_array, getRecInsuranceData($iter["pid"], "secondary"), $COLS);
193 print "<font class='font-weight-bold'>" . xlt("Tertiary Insurance Data") . ":</font><br />";
194 printRecDataOne($insurance_data_array, getRecInsuranceData($iter["pid"], "tertiary"), $COLS);
196 //==================================
197 print "</td></tr><tr>\n";
198 $old_pid = $iter["pid"];
201 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";
202 $res_count++;
203 if ($res_count == $N) {
204 print "</tr><tr>\n";
205 $res_count = 0;
208 $itero = $iter;
211 print "</tr></table>\n"; // small table
215 </body>
216 </html>