Another fix to upgrade clickoptions in windows
[openemr.git] / interface / billing / print_billing_report.php
blob421142e4fe79fb792e13ebbffc479aa3b0b4a5c6
1 <?php
2 /* Copyright (C) 2012 Julia Longtin */
4 $fake_register_globals=false;
5 $sanitize_all_escapes=true;
7 include_once("../globals.php");
9 include_once("$srcdir/patient.inc");
10 include_once("$srcdir/../interface/reports/report.inc.php");
11 include_once("$srcdir/billrep.inc");
12 include_once("$srcdir/forms.inc");
13 include_once("$srcdir/billing.inc");
14 include_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"];
26 if (!isset($_GET["to_date"])) {
27 $to_date = date("Y-m-d");
28 } else {
29 $to_date = $_GET["to_date"];
31 if (!isset($_GET["code_type"])) {
32 $code_type="all";
33 } else {
34 $code_type = $_GET["code_type"];
36 if (!isset($_GET["unbilled"])) {
37 $unbilled = "on";
38 } else {
39 $unbilled = $_GET["unbilled"];
41 if (!isset($_GET["authorized"])) {
42 $my_authorized = "on";
43 } else {
44 $my_authorized = $_GET["authorized"];
46 } else {
47 $from_date = $_GET["from_date"];
48 $to_date = $_GET["to_date"];
49 $code_type = $_GET["code_type"];
50 $unbilled = $_GET["unbilled"];
51 $my_authorized = $_GET["authorized"];
56 <html>
57 <head>
58 <?php html_header_show();?>
60 <link rel=stylesheet href="<?php echo $css_header;?>" type="text/css">
62 </head>
63 <body bgcolor="#ffffff" topmargin=0 rightmargin=0 leftmargin=2 bottommargin=0 marginwidth=2 marginheight=0>
65 <a href="javascript:window.close();" target=Main><font class=title><?php echo xlt('Billing Report')?></font></a>
66 <br>
68 <?php
69 if ($my_authorized == "on" ) {
70 $my_authorized = 1;
71 } else {
72 $my_authorized = "%";
74 if ($unbilled == "on") {
75 $unbilled = "0";
76 } else {
77 $unbilled = "%";
79 if ($code_type == "all") {
80 $code_type = "%";
83 $list = getBillsListBetween($code_type);
85 if (!isset($_GET["mode"])) {
86 if (!isset($_GET["from_date"])) {
87 $from_date=date("Y-m-d");
88 } else {
89 $from_date = $_GET["from_date"];
91 if (!isset($_GET["to_date"])) {
92 $to_date = date("Y-m-d");
93 } else {
94 $to_date = $_GET["to_date"];
96 if (!isset($_GET["code_type"])) {
97 $code_type="all";
98 } else {
99 $code_type = $_GET["code_type"];
101 if (!isset($_GET["unbilled"])) {
102 $unbilled = "on";
103 } else {
104 $unbilled = $_GET["unbilled"];
106 if (!isset($_GET["authorized"])) {
107 $my_authorized = "on";
108 } else {
109 $my_authorized = $_GET["authorized"];
111 } else {
112 $from_date = $_GET["from_date"];
113 $to_date = $_GET["to_date"];
114 $code_type = $_GET["code_type"];
115 $unbilled = $_GET["unbilled"];
116 $my_authorized = $_GET["authorized"];
119 if ($my_authorized == "on" ) {
120 $my_authorized = 1;
121 } else {
122 $my_authorized = "%";
124 if ($unbilled == "on") {
125 $unbilled = "0";
126 } else {
127 $unbilled = "%";
129 if ($code_type == "all") {
130 $code_type = "%";
133 $list = getBillsListBetween($code_type);
135 if (isset($_GET["mode"]) && $_GET["mode"] == "bill") {
136 billCodesList($list);
139 $res_count = 0;
140 $N = 1;
142 $itero = array();
143 if ($ret = getBillsBetweenReport($code_type)) {
144 $old_pid = -1;
145 $first_time = 1;
146 $encid = 0;
147 foreach ($ret as $iter) {
148 if ($old_pid != $iter{"pid"}) {
149 $name = getPatientData($iter{"pid"});
150 if (!$first_time) {
151 print "</tr></table>\n";
152 print "</td><td>";
153 print "<table border=0><tr>\n"; // small table
154 } else {
155 print "<table border=0><tr>\n"; // small table
156 $first_time=0;
158 print "<tr><td colspan=5><hr><span class=bold>" . text($name{"fname"}) . " " . text($name{"lname"}) . "</span><br><br>\n";
159 //==================================
162 print "<font class=bold>" . xlt("Patient Data") . ":</font><br>";
163 printRecDataOne($patient_data_array, getRecPatientData ($iter{"pid"}), $COLS);
165 print "<font class=bold>" . xlt("Employer Data") . ":</font><br>";
166 printRecDataOne($employer_data_array, getRecEmployerData ($iter{"pid"}), $COLS);
168 print "<font class=bold>" . xlt("Primary Insurance Data") . ":</font><br>";
169 printRecDataOne($insurance_data_array, getRecInsuranceData ($iter{"pid"},"primary"), $COLS);
171 print "<font class=bold>" . xlt("Secondary Insurance Data") . ":</font><br>";
172 printRecDataOne($insurance_data_array, getRecInsuranceData ($iter{"pid"},"secondary"), $COLS);
174 print "<font class=bold>" . xlt("Tertiary Insurance Data") . ":</font><br>";
175 printRecDataOne($insurance_data_array, getRecInsuranceData ($iter{"pid"},"tertiary"), $COLS);
177 //==================================
178 print "</td></tr><tr>\n";
179 $old_pid = $iter{"pid"};
182 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";
183 $res_count++;
184 if ($res_count == $N) {
185 print "</tr><tr>\n";
186 $res_count = 0;
188 $itero = $iter;
190 print "</tr></table>\n"; // small table
195 </body>
196 </html>