added gacl config files to upgrade instructions
[openemr.git] / interface / reports / custom_report_range.php
blob1378a2c92e0f59e5d96087a3412680e97d49f780
1 <?php
2 include_once(dirname(__file__)."/../globals.php");
4 include_once("$srcdir/forms.inc");
5 include_once("$srcdir/billing.inc");
6 include_once("$srcdir/pnotes.inc");
7 include_once("$srcdir/patient.inc");
8 include_once("$srcdir/report.inc");
9 include_once("$srcdir/classes/Document.class.php");
10 include_once("$srcdir/classes/Note.class.php");
12 $startdate = $enddate = "";
13 if(empty($_POST['start']) || empty($_POST['end'])) {
14 // set some default dates
15 $startdate = date('Ymd', (time() - 30*24*60*60));
16 $enddate = date('Ymd', time());
20 <html>
22 <head>
23 <?php html_header_show();?>
25 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
26 <style>
27 @media print {
28 .pagebreak {
29 page-break-after: always;
30 border: none;
31 visibility: hidden;
35 @media screen {
36 .pagebreak {
37 width: 100%;
38 border: 2px dashed black;
41 #superbill_description {
42 margin: 10px;
44 #superbill_startingdate {
45 margin: 10px;
47 #superbill_endingdate {
48 margin: 10px;
51 #superbill_patientdata {
53 #superbill_patientdata h1 {
54 font-weight: bold;
55 font-size: 1.2em;
56 margin: 0px;
57 padding: 5px;
58 width: 100%;
59 background-color: #eee;
60 border: 1px solid black;
62 #superbill_insurancedata {
63 margin-top: 10px;
65 #superbill_insurancedata h1 {
66 font-weight: bold;
67 font-size: 1.2em;
68 margin: 0px;
69 padding: 5px;
70 width: 100%;
71 background-color: #eee;
72 border: 1px solid black;
74 #superbill_insurancedata h2 {
75 font-weight: bold;
76 font-size: 1.0em;
77 margin: 0px;
78 padding: 0px;
79 width: 100%;
80 background-color: #eee;
82 #superbill_billingdata {
83 margin-top: 10px;
85 #superbill_billingdata h1 {
86 font-weight: bold;
87 font-size: 1.2em;
88 margin: 0px;
89 padding: 5px;
90 width: 100%;
91 background-color: #eee;
92 border: 1px solid black;
94 #superbill_signature {
96 #superbill_logo {
98 </style>
100 </head>
102 <body class="body_top">
104 <?php if(empty($_POST['start']) || empty($_POST['end'])) { ?>
105 <form method="post" action="custom_report_range.php">
106 <div id="superbill_description">
107 Superbills, sometimes referred to as Encounter Forms or Routing Slips, are an essential part of most medical practices.
108 </div>
109 <div id="superbill_startingdate">
110 <?php xl('Start Date','e'); ?>: <input type="text" name="start" id="start" value="<?php echo $startdate; ?>" size="10"/>
111 <img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22' id='img_from_date' border='0' alt='[?]' style='cursor:pointer' title='<?php xl('Click here to choose a date','e'); ?>'>
112 (format=YYYYMMDD)
113 </div>
114 <div id="superbill_endingdate">
115 <?php xl('End Date','e'); ?>: <input type="text" name="end" id="end" value="<?php echo $enddate; ?>" size="10"/>
116 <img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22' id='img_to_date' border='0' alt='[?]' style='cursor:pointer' title='<?php xl('Click here to choose a date','e'); ?>'>
117 (format=YYYYMMDD)
118 </div>
119 <input type="submit" value="Submit"/>
120 </form>
122 <?php
123 } else {
124 $sql = "select * from facility where billing_location = 1";
125 $db = $GLOBALS['adodb']['db'];
126 $results = $db->Execute($sql);
127 $facility = array();
128 if (!$results->EOF) {
129 $facility = $results->fields;
132 <h2><?php $facility['name']?></h2>
133 <?php $facility['street']?><br>
134 <?php $facility['city']?>, <?php $facility['state']?> <?php $facility['postal_code']?><br>
136 </p>
137 <?php
140 $res = sqlStatement("select * from forms where " .
141 "form_name = 'New Patient Encounter' and " .
142 "date between '$start' and '$end' " .
143 "order by date DESC");
144 while($result = sqlFetchArray($res)) {
145 if ($result{"form_name"} == "New Patient Encounter") {
146 $newpatient[] = $result{"form_id"}.":".$result{"encounter"};
147 $pids[] = $result{"pid"};
150 $N = 6;
153 function postToGet($newpatient, $pids) {
154 $getstring="";
155 $serialnewpatient = serialize($newpatient);
156 $serialpids = serialize($pids);
157 $getstring = "newpatient=".urlencode($serialnewpatient)."&pids=".urlencode($serialpids);
159 return $getstring;
162 $iCounter = 0;
163 if(empty($newpatient)){ $newpatient = array(); }
164 foreach($newpatient as $patient){
166 $inclookupres = sqlStatement("select distinct formdir from forms where pid='".$pids[$iCounter]."'");
167 while($result = sqlFetchArray($inclookupres)) {
168 include_once("{$GLOBALS['incdir']}/forms/" . $result{"formdir"} . "/report.php");
172 print "<div id='superbill_patientdata'>";
173 print "<h1>".xl('Patient Data').":</h1>";
174 printRecDataOne($patient_data_array, getRecPatientData ($pids[$iCounter]), $N);
175 print "</div>";
177 print "<div id='superbill_insurancedata'>";
178 print "<h1>".xl('Insurance Data').":</h1>";
179 print "<h2>".xl('Primary').":</h2>";
180 printRecDataOne($insurance_data_array, getRecInsuranceData ($pids[$iCounter],"primary"), $N);
181 print "<h2>".xl('Secondary').":</h2>";
182 printRecDataOne($insurance_data_array, getRecInsuranceData ($pids[$iCounter],"secondary"), $N);
183 print "<h2>".xl('Tertiary').":</h2>";
184 printRecDataOne($insurance_data_array, getRecInsuranceData ($pids[$iCounter],"tertiary"), $N);
185 print "</div>";
187 print "<div id='superbill_billingdata'>";
188 print "<h1>".xl('Billing Information').":</h1>";
189 if (count($patient) > 0) {
190 $billings = array();
191 echo "<table width='100%'>";
192 echo "<tr>";
193 echo "<td class='bold' width='10%'>".xl('Date')."</td>";
194 echo "<td class='bold' width='20%'>".xl('Provider')."</td>";
195 echo "<td class='bold' width='40%'>".xl('Code')."</td>";
196 echo "<td class='bold' width='10%'>".xl('Fee')."</td></tr>\n";
197 $total = 0.00;
198 $copays = 0.00;
199 //foreach ($patient as $be) {
201 $ta = split(":",$patient);
202 $billing = getPatientBillingEncounter($pids[$iCounter],$ta[1]);
204 $billings[] = $billing;
205 foreach ($billing as $b) {
206 // grab the date to reformat it in the output
207 $bdate = strtotime($b['date']);
209 echo "<tr>\n";
210 echo "<td class='text' style='font-size: 0.8em'>" . date("Y-m-d",$bdate)."<BR>".date("h:i a", $bdate) . "</td>";
211 echo "<td class='text'>" . $b['provider_name'] . "</td>";
212 echo "<td class='text'>";
213 echo $b['code_type'] . ":\t" . $b['code'] . "&nbsp;". $b['modifier'] . "&nbsp;&nbsp;&nbsp;" . $b['code_text'] . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
214 echo "</td>\n";
215 echo "<td class='text'>";
216 echo $b['fee'];
217 echo "</td>\n";
218 echo "</tr>\n";
219 $total += $b['fee'];
220 if ($b['code_type'] == "COPAY") {
221 $copays += $b['fee'];
225 //}
226 echo "<tr><td>&nbsp;</td></tr>";
227 echo "<tr><td class='bold' colspan=3 style='text-align:right'>".xl('Sub-Total')."</td><td class='text'>" . sprintf("%0.2f",$total + abs($copays)) . "</td></tr>";
228 echo "<tr><td class='bold' colspan=3 style='text-align:right'>".xl('Paid')."</td><td class='text'>" . sprintf("%0.2f",abs($copays)) . "</td></tr>";
229 echo "<tr><td class='bold' colspan=3 style='text-align:right'>".xl('Total')."</td><td class='text'>" . sprintf("%0.2f",$total) . "</td></tr>";
230 echo "</table>";
231 echo "<pre>";
232 //print_r($billings);
233 echo "</pre>";
235 echo "</div>";
237 ++$iCounter;
238 print "<br/><br/>".xl('Physician Signature').": _______________________________________________";
239 print "<hr class='pagebreak' />";
253 </body>
255 <?php if(empty($_POST['start']) || empty($_POST['end'])) : ?>
256 <!-- stuff for the popup calendar -->
257 <style type="text/css">@import url(../../library/dynarch_calendar.css);</style>
258 <script type="text/javascript" src="../../library/dynarch_calendar.js"></script>
259 <script type="text/javascript" src="../../library/dynarch_calendar_en.js"></script>
260 <script type="text/javascript" src="../../library/dynarch_calendar_setup.js"></script>
261 <script language="Javascript">
262 Calendar.setup({inputField:"start", ifFormat:"%Y%m%d", button:"img_from_date"});
263 Calendar.setup({inputField:"end", ifFormat:"%Y%m%d", button:"img_to_date"});
264 </script>
265 <?php endif; ?>
266 </html>