Added Lithuanian language
[openemr.git] / interface / reports / custom_report_range.php
blob650e270a1bc0ef4919375a8b5bb76fa63910a1d7
1 <?php
2 // This program is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU General Public License
4 // as published by the Free Software Foundation; either version 2
5 // of the License, or (at your option) any later version.
7 require_once(dirname(__file__)."/../globals.php");
8 require_once("$srcdir/forms.inc");
9 require_once("$srcdir/billing.inc");
10 require_once("$srcdir/patient.inc");
11 require_once("$srcdir/report.inc");
12 require_once("$srcdir/classes/Document.class.php");
13 require_once("$srcdir/classes/Note.class.php");
14 require_once("$srcdir/formatting.inc.php");
16 $startdate = $enddate = "";
17 if(empty($_POST['start']) || empty($_POST['end'])) {
18 // set some default dates
19 $startdate = date('Y-m-d', (time() - 30*24*60*60));
20 $enddate = date('Y-m-d', time());
22 else {
23 // set dates
24 $startdate = $_POST['start'];
25 $enddate = $_POST['end'];
28 <html>
30 <head>
31 <?php html_header_show();?>
33 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
34 <style>
36 @media print {
37 .title {
38 visibility: hidden;
40 .pagebreak {
41 page-break-after: always;
42 border: none;
43 visibility: hidden;
46 #superbill_description {
47 visibility: hidden;
50 #report_parameters {
51 visibility: hidden;
53 #superbill_results {
54 margin-top: -30px;
58 @media screen {
59 .title {
60 visibility: visible;
62 #superbill_description {
63 visibility: visible;
65 .pagebreak {
66 width: 100%;
67 border: 2px dashed black;
69 #report_parameters {
70 visibility: visible;
73 #superbill_description {
74 margin: 10px;
76 #superbill_startingdate {
77 margin: 10px;
79 #superbill_endingdate {
80 margin: 10px;
83 #superbill_patientdata {
85 #superbill_patientdata 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_insurancedata {
95 margin-top: 10px;
97 #superbill_insurancedata h1 {
98 font-weight: bold;
99 font-size: 1.2em;
100 margin: 0px;
101 padding: 5px;
102 width: 100%;
103 background-color: #eee;
104 border: 1px solid black;
106 #superbill_insurancedata h2 {
107 font-weight: bold;
108 font-size: 1.0em;
109 margin: 0px;
110 padding: 0px;
111 width: 100%;
112 background-color: #eee;
114 #superbill_billingdata {
115 margin-top: 10px;
117 #superbill_billingdata h1 {
118 font-weight: bold;
119 font-size: 1.2em;
120 margin: 0px;
121 padding: 5px;
122 width: 100%;
123 background-color: #eee;
124 border: 1px solid black;
126 #superbill_signature {
128 #superbill_logo {
130 </style>
132 </head>
134 <body class="body_top">
136 <span class='title'><?php xl('Reports','e'); ?> - <?php xl('Superbill','e'); ?></span>
138 <div id="superbill_description" class='text'>
139 <?php xl('Superbills, sometimes referred to as Encounter Forms or Routing Slips, are an essential part of most medical practices.','e'); ?>
140 </div>
142 <div id="report_parameters">
144 <form method="post" id='theform' action="custom_report_range.php">
145 <input type='hidden' name='form_refresh' id='form_refresh' value=''/>
146 <table>
147 <tr>
148 <td width='450px'>
149 <div style='float:left'>
151 <table class='text'>
152 <tr>
153 <td class='label'>
154 <?php xl('Start Date','e'); ?>:
155 </td>
156 <td>
157 <input type='text' name='start' id="form_from_date" size='10' value='<?php echo $startdate ?>'
158 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' title='yyyy-mm-dd'>
159 <img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22'
160 id='img_from_date' border='0' alt='[?]' style='cursor:pointer'
161 title='<?php xl('Click here to choose a date','e'); ?>'>
162 </td>
163 <td class='label'>
164 <?php xl('End Date','e'); ?>:
165 </td>
166 <td>
167 <input type='text' name='end' id="form_to_date" size='10' value='<?php echo $enddate ?>'
168 onkeyup='datekeyup(this,mypcc)' onblur='dateblur(this,mypcc)' title='yyyy-mm-dd'>
169 <img src='../pic/show_calendar.gif' align='absbottom' width='24' height='22'
170 id='img_to_date' border='0' alt='[?]' style='cursor:pointer'
171 title='<?php xl('Click here to choose a date','e'); ?>'>
172 </td>
173 </tr>
174 </table>
176 </div>
178 </td>
179 <td align='left' valign='middle' height="100%">
180 <table style='border-left:1px solid; width:100%; height:100%' >
181 <tr>
182 <td>
183 <div style='margin-left:15px'>
184 <a href='#' class='css_button' onclick='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
185 <span>
186 <?php xl('Submit','e'); ?>
187 </span>
188 </a>
190 <?php if ($_POST['form_refresh']) { ?>
191 <a href='#' class='css_button' onclick='window.print()'>
192 <span>
193 <?php xl('Print','e'); ?>
194 </span>
195 </a>
196 <?php } ?>
197 </div>
198 </td>
199 </tr>
200 </table>
201 </td>
202 </tr>
203 </table>
204 </div> <!-- end of parameters -->
206 </form>
208 <div id="superbill_results">
210 <?php
211 if( !(empty($_POST['start']) || empty($_POST['end']))) {
212 $sql = "select * from facility where billing_location = 1";
213 $db = $GLOBALS['adodb']['db'];
214 $results = $db->Execute($sql);
215 $facility = array();
216 if (!$results->EOF) {
217 $facility = $results->fields;
220 <h2><?php $facility['name']?></h2>
221 <?php $facility['street']?><br>
222 <?php $facility['city']?>, <?php $facility['state']?> <?php $facility['postal_code']?><br>
224 </p>
225 <?php
228 $res = sqlStatement("select * from forms where " .
229 "form_name = 'New Patient Encounter' and " .
230 "date between '$startdate' and '$enddate' " .
231 "order by date DESC");
232 while($result = sqlFetchArray($res)) {
233 if ($result{"form_name"} == "New Patient Encounter") {
234 $newpatient[] = $result{"form_id"}.":".$result{"encounter"};
235 $pids[] = $result{"pid"};
238 $N = 6;
240 function postToGet($newpatient, $pids) {
241 $getstring="";
242 $serialnewpatient = serialize($newpatient);
243 $serialpids = serialize($pids);
244 $getstring = "newpatient=".urlencode($serialnewpatient)."&pids=".urlencode($serialpids);
246 return $getstring;
249 $iCounter = 0;
250 if(empty($newpatient)){ $newpatient = array(); }
251 foreach($newpatient as $patient){
253 $inclookupres = sqlStatement("select distinct formdir from forms where pid='".$pids[$iCounter]."'");
254 while($result = sqlFetchArray($inclookupres)) {
255 include_once("{$GLOBALS['incdir']}/forms/" . $result{"formdir"} . "/report.php");
259 print "<div id='superbill_patientdata'>";
260 print "<h1>".xl('Patient Data').":</h1>";
261 printRecDataOne($patient_data_array, getRecPatientData ($pids[$iCounter]), $N);
262 print "</div>";
264 print "<div id='superbill_insurancedata'>";
265 print "<h1>".xl('Insurance Data').":</h1>";
266 print "<h2>".xl('Primary').":</h2>";
267 printRecDataOne($insurance_data_array, getRecInsuranceData ($pids[$iCounter],"primary"), $N);
268 print "<h2>".xl('Secondary').":</h2>";
269 printRecDataOne($insurance_data_array, getRecInsuranceData ($pids[$iCounter],"secondary"), $N);
270 print "<h2>".xl('Tertiary').":</h2>";
271 printRecDataOne($insurance_data_array, getRecInsuranceData ($pids[$iCounter],"tertiary"), $N);
272 print "</div>";
274 print "<div id='superbill_billingdata'>";
275 print "<h1>".xl('Billing Information').":</h1>";
276 if (count($patient) > 0) {
277 $billings = array();
278 echo "<table width='100%'>";
279 echo "<tr>";
280 echo "<td class='bold' width='10%'>".xl('Date')."</td>";
281 echo "<td class='bold' width='20%'>".xl('Provider')."</td>";
282 echo "<td class='bold' width='40%'>".xl('Code')."</td>";
283 echo "<td class='bold' width='10%'>".xl('Fee')."</td></tr>\n";
284 $total = 0.00;
285 $copays = 0.00;
286 //foreach ($patient as $be) {
288 $ta = split(":",$patient);
289 $billing = getPatientBillingEncounter($pids[$iCounter],$ta[1]);
291 $billings[] = $billing;
292 foreach ($billing as $b) {
293 // grab the date to reformat it in the output
294 $bdate = strtotime($b['date']);
296 echo "<tr>\n";
297 echo "<td class='text' style='font-size: 0.8em'>" . oeFormatShortDate(date("Y-m-d",$bdate)) . "<BR>" . date("h:i a", $bdate) . "</td>";
298 echo "<td class='text'>" . $b['provider_name'] . "</td>";
299 echo "<td class='text'>";
300 echo $b['code_type'] . ":\t" . $b['code'] . "&nbsp;". $b['modifier'] . "&nbsp;&nbsp;&nbsp;" . $b['code_text'] . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
301 echo "</td>\n";
302 echo "<td class='text'>";
303 echo oeFormatMoney($b['fee']);
304 echo "</td>\n";
305 echo "</tr>\n";
306 $total += $b['fee'];
307 if ($b['code_type'] == "COPAY") {
308 $copays += $b['fee'];
312 echo "<tr><td>&nbsp;</td></tr>";
313 echo "<tr><td class='bold' colspan=3 style='text-align:right'>".xl('Sub-Total')."</td><td class='text'>" . oeFormatMoney($total + abs($copays)) . "</td></tr>";
314 echo "<tr><td class='bold' colspan=3 style='text-align:right'>".xl('Paid')."</td><td class='text'>" . oeFormatMoney(abs($copays)) . "</td></tr>";
315 echo "<tr><td class='bold' colspan=3 style='text-align:right'>".xl('Total')."</td><td class='text'>" . oeFormatMoney($total) . "</td></tr>";
316 echo "</table>";
317 echo "<pre>";
318 //print_r($billings);
319 echo "</pre>";
321 echo "</div>";
323 ++$iCounter;
324 print "<br/><br/>".xl('Physician Signature').": _______________________________________________";
325 print "<hr class='pagebreak' />";
329 </div>
331 </body>
333 <!-- stuff for the popup calendar -->
334 <style type="text/css">@import url(../../library/dynarch_calendar.css);</style>
335 <script type="text/javascript" src="../../library/dynarch_calendar.js"></script>
336 <?php include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?>
337 <script type="text/javascript" src="../../library/dynarch_calendar_setup.js"></script>
338 <script type="text/javascript" src="../../library/js/jquery.1.3.2.js"></script>
340 <script language="Javascript">
341 Calendar.setup({inputField:"form_from_date", ifFormat:"%Y-%m-%d", button:"img_from_date"});
342 Calendar.setup({inputField:"form_to_date", ifFormat:"%Y-%m-%d", button:"img_to_date"});
343 </script>
344 </html>