ongoing internationalization of date widget
[openemr.git] / interface / reports / custom_report_range.php
blobc5f6748b6516bce8aff3b7b816e600f6f577d12b
1 <?php
2 /**
4 * Superbill Report
6 * LICENSE: This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
17 * @package OpenEMR
18 * @author Brady Miller <brady.g.miller@gmail.com>
19 * @link http://www.open-emr.org
25 require_once(dirname(__file__)."/../globals.php");
26 require_once("$srcdir/forms.inc");
27 require_once("$srcdir/billing.inc");
28 require_once("$srcdir/patient.inc");
29 require_once("$srcdir/report.inc");
31 use OpenEMR\Services\FacilityService;
33 $facilityService = new FacilityService();
35 $startdate = $enddate = "";
36 if (empty($_POST['start']) || empty($_POST['end'])) {
37 // set some default dates
38 $startdate = date('Y-m-d', (time() - 30*24*60*60));
39 $enddate = date('Y-m-d', time());
40 } else {
41 // set dates
42 $startdate = $_POST['start'];
43 $enddate = $_POST['end'];
46 //Patient related stuff
47 if ($_POST["form_patient"]) {
48 $form_patient = isset($_POST['form_patient']) ? $_POST['form_patient'] : '';
51 $form_pid = isset($_POST['form_pid']) ? $_POST['form_pid'] : '';
52 if ($form_patient == '') {
53 $form_pid = '';
56 <html>
58 <head>
59 <?php html_header_show();?>
61 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
62 <link rel="stylesheet" href="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.min.css">
64 <style>
66 @media print {
67 .title {
68 visibility: hidden;
70 .pagebreak {
71 page-break-after: always;
72 border: none;
73 visibility: hidden;
76 #superbill_description {
77 visibility: hidden;
80 #report_parameters {
81 visibility: hidden;
83 #superbill_results {
84 margin-top: -30px;
88 @media screen {
89 .title {
90 visibility: visible;
92 #superbill_description {
93 visibility: visible;
95 .pagebreak {
96 width: 100%;
97 border: 2px dashed black;
99 #report_parameters {
100 visibility: visible;
103 #superbill_description {
104 margin: 10px;
106 #superbill_startingdate {
107 margin: 10px;
109 #superbill_endingdate {
110 margin: 10px;
113 #superbill_patientdata {
115 #superbill_patientdata h1 {
116 font-weight: bold;
117 font-size: 1.2em;
118 margin: 0px;
119 padding: 5px;
120 width: 100%;
121 background-color: #eee;
122 border: 1px solid black;
124 #superbill_insurancedata {
125 margin-top: 10px;
127 #superbill_insurancedata h1 {
128 font-weight: bold;
129 font-size: 1.2em;
130 margin: 0px;
131 padding: 5px;
132 width: 100%;
133 background-color: #eee;
134 border: 1px solid black;
136 #superbill_insurancedata h2 {
137 font-weight: bold;
138 font-size: 1.0em;
139 margin: 0px;
140 padding: 0px;
141 width: 100%;
142 background-color: #eee;
144 #superbill_billingdata {
145 margin-top: 10px;
147 #superbill_billingdata h1 {
148 font-weight: bold;
149 font-size: 1.2em;
150 margin: 0px;
151 padding: 5px;
152 width: 100%;
153 background-color: #eee;
154 border: 1px solid black;
156 #superbill_signature {
158 #superbill_logo {
160 </style>
161 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js?v=<?php echo $v_js_includes; ?>"></script>
162 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-3-1-1/index.js"></script>
163 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.full.min.js"></script>
165 <script language="Javascript">
166 $(document).ready(function() {
167 var win = top.printLogSetup ? top : opener.top;
168 win.printLogSetup(document.getElementById('printbutton'));
170 $('.datepicker').datetimepicker({
171 <?php $datetimepicker_timepicker = false; ?>
172 <?php $datetimepicker_showseconds = false; ?>
173 <?php $datetimepicker_formatInput = false; ?>
174 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
175 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
179 // CapMinds :: invokes find-patient popup.
180 function sel_patient() {
181 dlgopen('../main/calendar/find_patient_popup.php?pflag=0', '_blank', 500, 400);
184 // CapMinds :: callback by the find-patient popup.
185 function setpatient(pid, lname, fname, dob) {
186 var f = document.theform;
187 f.form_patient.value = lname + ', ' + fname;
188 f.form_pid.value = pid;
191 </script>
192 </head>
194 <body class="body_top">
196 <span class='title'><?php echo xlt('Reports'); ?> - <?php echo xlt('Superbill'); ?></span>
198 <div id="superbill_description" class='text'>
199 <?php echo xlt('Superbills, sometimes referred to as Encounter Forms or Routing Slips, are an essential part of most medical practices.'); ?>
200 </div>
202 <div id="report_parameters">
204 <form method="post" name="theform" id='theform' action="custom_report_range.php">
205 <input type='hidden' name='form_refresh' id='form_refresh' value=''/>
206 <table>
207 <tr>
208 <td width='650px'>
209 <div style='float:left'>
211 <table class='text'>
212 <tr>
213 <td class='label_custom'>
214 <?php echo xlt('Start Date'); ?>:
215 </td>
216 <td>
217 <input type='text' class='datepicker' name='start' id="form_from_date" size='10' value='<?php echo attr($startdate) ?>'
218 title='yyyy-mm-dd'>
219 </td>
220 <td class='label_custom'>
221 <?php echo xlt('End Date'); ?>:
222 </td>
223 <td>
224 <input type='text' class='datepicker' name='end' id="form_to_date" size='10' value='<?php echo attr($enddate) ?>'
225 title='yyyy-mm-dd'>
226 </td>
228 <td>
229 &nbsp;&nbsp;<span class='text'><?php echo xlt('Patient'); ?>: </span>
230 </td>
231 <td>
232 <input type='text' size='20' name='form_patient' style='width:100%;cursor:pointer;cursor:hand' value='<?php echo attr($form_patient) ? attr($form_patient) : xla('Click To Select'); ?>' onclick='sel_patient()' title='<?php echo xla('Click to select patient'); ?>' />
233 <input type='hidden' name='form_pid' value='<?php echo attr($form_pid); ?>' />
234 </td>
235 </tr>
236 <tr><td>
237 </tr>
238 </table>
240 </div>
242 </td>
243 <td align='left' valign='middle' height="100%">
244 <table style='border-left:1px solid; width:100%; height:100%' >
245 <tr>
246 <td>
247 <div style='margin-left:15px'>
248 <a href='#' class='css_button' onclick='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
249 <span>
250 <?php echo xlt('Submit'); ?>
251 </span>
252 </a>
254 <?php if ($_POST['form_refresh']) { ?>
255 <a href='#' class='css_button' id='printbutton'>
256 <span>
257 <?php echo xlt('Print'); ?>
258 </span>
259 </a>
260 <?php } ?>
261 </div>
262 </td>
263 </tr>
264 </table>
265 </td>
266 </tr>
267 </table>
268 </div> <!-- end of parameters -->
270 </form>
272 <div id="superbill_results">
274 <?php
275 if (!(empty($_POST['start']) || empty($_POST['end']))) {
276 $facility = $facilityService->getPrimaryBillingLocation();
279 <h2><?php text($facility['name'])?></h2>
280 <?php text($facility['street'])?><br>
281 <?php text($facility['city'])?>, <?php text($facility['state'])?> <?php text($facility['postal_code'])?><br>
283 </p>
284 <?php
285 $sqlBindArray = array();
286 $res_query = "select * from forms where " .
287 "form_name = 'New Patient Encounter' and " .
288 "date between ? and ? " ;
289 array_push($sqlBindArray, $startdate, $enddate);
290 if ($form_pid) {
291 $res_query.= " and pid=? ";
292 array_push($sqlBindArray, $form_pid);
295 $res_query.= " order by date DESC" ;
296 $res =sqlStatement($res_query, $sqlBindArray);
298 while ($result = sqlFetchArray($res)) {
299 if ($result{"form_name"} == "New Patient Encounter") {
300 $newpatient[] = $result{"form_id"}.":".$result{"encounter"};
301 $pids[] = $result{"pid"};
305 $N = 6;
307 function postToGet($newpatient, $pids)
309 $getstring="";
310 $serialnewpatient = serialize($newpatient);
311 $serialpids = serialize($pids);
312 $getstring = "newpatient=".urlencode($serialnewpatient)."&pids=".urlencode($serialpids);
314 return $getstring;
317 $iCounter = 0;
318 if (empty($newpatient)) {
319 $newpatient = array();
322 foreach ($newpatient as $patient) {
324 $inclookupres = sqlStatement("select distinct formdir from forms where pid='".$pids[$iCounter]."'");
325 while($result = sqlFetchArray($inclookupres)) {
326 include_once("{$GLOBALS['incdir']}/forms/" . $result{"formdir"} . "/report.php");
330 print "<div id='superbill_patientdata'>";
331 print "<h1>".xlt('Patient Data').":</h1>";
332 printRecDataOne($patient_data_array, getRecPatientData($pids[$iCounter]), $N);
333 print "</div>";
335 print "<div id='superbill_insurancedata'>";
336 print "<h1>".xlt('Insurance Data').":</h1>";
337 print "<h2>".xlt('Primary').":</h2>";
338 printRecDataOne($insurance_data_array, getRecInsuranceData($pids[$iCounter], "primary"), $N);
339 print "<h2>".xlt('Secondary').":</h2>";
340 printRecDataOne($insurance_data_array, getRecInsuranceData($pids[$iCounter], "secondary"), $N);
341 print "<h2>".xlt('Tertiary').":</h2>";
342 printRecDataOne($insurance_data_array, getRecInsuranceData($pids[$iCounter], "tertiary"), $N);
343 print "</div>";
345 print "<div id='superbill_billingdata'>";
346 print "<h1>".xlt('Billing Information').":</h1>";
347 if (count($patient) > 0) {
348 $billings = array();
349 echo "<table width='100%'>";
350 echo "<tr>";
351 echo "<td class='bold' width='10%'>".xlt('Date')."</td>";
352 echo "<td class='bold' width='20%'>".xlt('Provider')."</td>";
353 echo "<td class='bold' width='40%'>".xlt('Code')."</td>";
354 echo "<td class='bold' width='10%'>".xlt('Fee')."</td></tr>\n";
355 $total = 0.00;
356 $copays = 0.00;
357 //foreach ($patient as $be) {
359 $ta = explode(":", $patient);
360 $billing = getPatientBillingEncounter($pids[$iCounter], $ta[1]);
362 $billings[] = $billing;
363 foreach ($billing as $b) {
364 // grab the date to reformat it in the output
365 $bdate = strtotime($b['date']);
367 echo "<tr>\n";
368 echo "<td class='text' style='font-size: 0.8em'>" . oeFormatShortDate(date("Y-m-d", $bdate)) . "<BR>" . date("h:i a", $bdate) . "</td>";
369 echo "<td class='text'>" . text($b['provider_name']) . "</td>";
370 echo "<td class='text'>";
371 echo text($b['code_type']) . ":\t" . text($b['code']) . "&nbsp;". text($b['modifier']) . "&nbsp;&nbsp;&nbsp;" . text($b['code_text']) . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
372 echo "</td>\n";
373 echo "<td class='text'>";
374 echo oeFormatMoney($b['fee']);
375 echo "</td>\n";
376 echo "</tr>\n";
377 $total += $b['fee'];
380 // Calculate the copay for the encounter
381 $copays = getPatientCopay($pids[$iCounter], $ta[1]);
383 echo "<tr><td>&nbsp;</td></tr>";
384 echo "<tr><td class='bold' colspan=3 style='text-align:right'>".xlt('Sub-Total')."</td><td class='text'>" . oeFormatMoney($total + abs($copays)) . "</td></tr>";
385 echo "<tr><td class='bold' colspan=3 style='text-align:right'>".xlt('Copay Paid')."</td><td class='text'>" . oeFormatMoney(abs($copays)) . "</td></tr>";
386 echo "<tr><td class='bold' colspan=3 style='text-align:right'>".xlt('Total')."</td><td class='text'>" . oeFormatMoney($total) . "</td></tr>";
387 echo "</table>";
388 echo "<pre>";
389 //print_r($billings);
390 echo "</pre>";
393 echo "</div>";
395 ++$iCounter;
396 print "<br/><br/>".xlt('Physician Signature').": _______________________________________________";
397 print "<hr class='pagebreak' />";
401 </div>
403 </body>
405 </html>