2 // Copyright (C) 2010 Medical Information Integration, LLC
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License
5 // as published by the Free Software Foundation; either version 2
6 // of the License, or (at your option) any later version.
9 $sanitize_all_escapes=true;
11 //STOP FAKE REGISTER GLOBALS
12 $fake_register_globals=false;
14 require_once("../globals.php");
15 require_once("$srcdir/patient.inc");
16 require_once("$srcdir/options.inc.php");
17 require_once("../drugs/drugs.inc.php");
19 $form_payment_method = htmlspecialchars($_POST['form_method'], ENT_QUOTES
);
20 $form_facility = htmlspecialchars($_POST['form_facility'], ENT_QUOTES
);
21 $form_use_date = htmlspecialchars($_POST['form_use_date'], ENT_QUOTES
);
22 $form_from_date = htmlspecialchars(fixDate( $_POST['form_from_date'], date('Y-01-01')), ENT_QUOTES
);
23 $form_to_date = htmlspecialchars(fixDate( $_POST['form_to_date'], date('Y-m-d')), ENT_QUOTES
);
25 // patient_data.language = race
26 // payments.dtime = DOS
28 $sqlBindArray = array();
31 SELECT concat( patient_data.fname, ' ', patient_data.lname ) AS patient_name,
34 DATE_FORMAT( FROM_DAYS( DATEDIFF( NOW( ) , patient_data.DOB ) ) , '%Y' ) +0 AS age,
36 payments.dtime AS DOS,
38 patient_data.state AS county,
39 patient_data.ethnoracial AS race,
40 patient_data.postal_code AS zip,
41 payments.method AS method,
42 payments.amount1 + payments.amount2 AS total_amount
47 where patient_data.pid = payments.pid
48 and payments.user = users.username
49 and users.facility_id = facility.id
50 and payments.dtime >= ?
51 and payments.dtime <= DATE_ADD(?, INTERVAL 1 DAY)";
53 array_push($sqlBindArray, $form_from_date, $form_to_date);
55 if($form_payment_method != '-- All --'){
56 $sql .= " and payments.method = ?";
57 array_push($sqlBindArray, $form_payment_method);
60 if ( strlen($form_facility) > 0 ){
61 $sql .= " and facility.id = ?";
62 array_push($sqlBindArray, $form_facility);
67 if ($_POST['form_refresh'] == "export"){
68 $result = sqlStatement($sql, $sqlBindArray);
70 $out = "First/Last Name, Sex, Age, Race, DOB, DOS, City, County, Zip, Payment Method\n";
72 while($row = sqlFetchArray($result)){
73 $out .= "{$row['patient_name']}, {$row['sex']}, {$row['age']}, {$row['race']}, {$row['DOB']}, {$row['DOS']}, {$row['city']}, {$row['county']}, {$row['zip']}, {$row['method']}\n";
76 $dt_str = date("Ymd");
78 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
79 header("Content-Length: " . strlen($out));
80 header("Content-type: text/x-csv");
81 header("Content-type: application/csv");
82 header("Content-Disposition: attachment; filename=payment_summary_".$dt_str.".csv");
89 <?php
html_header_show();?
>
91 <?php
echo htmlspecialchars(xl('Clinical Reports'), ENT_QUOTES
) ?
>
93 <script type
="text/javascript" src
="../../library/overlib_mini.js"></script
>
94 <script type
="text/javascript" src
="../../library/textformat.js"></script
>
95 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
96 <script type
="text/javascript" src
="../../library/js/jquery.1.3.2.js"></script
>
97 <script language
="JavaScript">
99 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
101 // The OnClick handler for receipt display.
102 function show_receipt(payid
) {
103 // dlgopen('../patient_file/front_payment.php?receipt=1&payid=' + payid, '_blank', 550, 400);
108 <link rel
='stylesheet' href
='<?php echo $css_header ?>' type
='text/css'>
109 <style type
="text/css">
110 /* specifically include & exclude from printing */
116 #report_parameters_daterange {
120 #report_results table {
125 /* specifically exclude some from the screen */
127 #report_parameters_daterange {
133 <?php
if($type != 'Prescription' ||
$type == '') {
140 <script language
="javascript" type
="text/javascript">
141 function checkType(){
142 if($
('#type').val() == 'Prescription'){
143 $
('.optional_area').css("display", "inline");
146 $
('.optional_area').css("display", "none");
152 <body
class="body_top">
154 <!-- Required
for the popup date selectors
-->
155 <div id
="overDiv" style
="position:absolute; visibility:hidden; z-index:1000;"></div
>
157 <?php
echo htmlspecialchars(xl('Report - Facility/Prov Payment Summary'), ENT_QUOTES
) ?
>
159 <!-- Search can be done using age range
, gender
, and ethnicity filters
.
160 Search options
include diagnosis
, procedure
, prescription
, medical history
, and lab results
.
162 <div id
="report_parameters_daterange"> <?php
echo date("d F Y", strtotime($form_from_date)) ." to ". date("d F Y", strtotime($form_to_date)); ?
> </div
>
163 <form method
='post' id
='theform' action
='<?php echo $_SERVER['REQUEST_URI
'] ?>'>
164 <div id
="report_parameters">
165 <input type
='hidden' name
='form_refresh' id
='form_refresh' value
=''/>
168 <td width
='630px'><div style
='float:left'>
171 <td
class='label'> <?php
echo htmlspecialchars(xl('Payment Method'), ENT_QUOTES
) ?
>: </td
>
172 <td
><select name
='form_method'>
174 $payment_methods = array(
175 htmlspecialchars(xl('-- All --'), ENT_QUOTES
),
176 htmlspecialchars(xl('Cash'), ENT_QUOTES
),
177 htmlspecialchars(xl('Check'), ENT_QUOTES
),
178 htmlspecialchars(xl('MC'), ENT_QUOTES
),
179 htmlspecialchars(xl('VISA'), ENT_QUOTES
),
180 htmlspecialchars(xl('AMEX'), ENT_QUOTES
),
181 htmlspecialchars(xl('DISC'), ENT_QUOTES
),
182 htmlspecialchars(xl('Other'), ENT_QUOTES
));
184 foreach ($payment_methods as $value) {
185 echo " <option value='$value'";
186 if ($value == $form_payment_method) echo " selected";
187 echo ">$value</option>\n";
191 <td
><?php
echo htmlspecialchars(xl('Facility'), ENT_QUOTES
) ?
>: </td
>
192 <td colspan
="3"><?php
193 // Build a drop-down list of facilities.
195 $query = "SELECT id, name FROM facility ORDER BY name";
196 $fres = sqlStatement($query);
197 echo " <select name='form_facility'>\n";
198 echo " <option value=''>-- " . htmlspecialchars(xl('All Facilities'), ENT_QUOTES
) . " --\n";
199 while ($frow = sqlFetchArray($fres)) {
200 $facid = $frow['id'];
201 echo " <option value='$facid'";
202 if ($facid == $form_facility) echo " selected";
203 echo ">" . htmlspecialchars($frow['name'], ENT_QUOTES
) . "\n";
210 <td
><select name
='form_use_edate'>
212 <?php
echo htmlspecialchars(xl('Payment Date'), ENT_QUOTES
) ?
>
214 <option value
='1'<?php
if ($form_use_edate) echo ' selected' ?
>>
215 <?php
echo htmlspecialchars(xl('Invoice Date'), ENT_QUOTES
) ?
>
218 <td
><?php
echo htmlspecialchars(xl('From'), ENT_QUOTES
) ?
>:</td
>
220 <table border
="0" cellpadding
="0" cellspacing
="0">
223 <input type
='text' name
='form_from_date' id
="form_from_date" size
='10' value
='<?php echo $form_from_date ?>' onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
226 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22' id
='img_from_date' border
='0' alt
='[?]' style
='cursor:pointer' title
='<?php echo htmlspecialchars(xl('Click here to choose a date
'), ENT_QUOTES) ?>'>
231 <td
class='label'><?php
echo htmlspecialchars(xl('To'), ENT_QUOTES
) ?
>: </td
>
233 <table border
="0" cellpadding
="0" cellspacing
="0">
236 <input type
='text' name
='form_to_date' id
="form_to_date" size
='10' value
='<?php echo $form_to_date ?>' onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
239 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22' id
='img_to_date' border
='0' alt
='[?]' style
='cursor:pointer' title
='<?php echo htmlspecialchars(xl('Click here to choose a date
'), ENT_QUOTES); ?>'>
247 <td align
='left' valign
='middle' height
="100%"><table style
='border-left:1px solid; width:100%; height:100%' >
249 <td
><div style
='margin-left:15px'> <a href
='#' class='css_button' onclick
='$("#form_refresh").attr("value","true"); $("#theform").submit();'> <span
>
250 <?php
echo htmlspecialchars(xl('Submit'), ENT_QUOTES
) ?
>
252 <?php
if ($_POST['form_refresh'] ||
$_POST['form_orderby'] ) { ?
>
253 <a href
='#' class='css_button' onclick
='window.print()'> <span
>
254 <?php
echo htmlspecialchars(xl('Print'), ENT_QUOTES
) ?
>
257 <?php
if ($_POST['form_refresh']) { ?
>
258 <a href
='#' class='css_button' onclick
='$("#form_refresh").attr("value","export"); $("#theform").submit();'> <span
>
259 <?php
echo htmlspecialchars(xl('Export'), ENT_QUOTES
) ?
>
268 <!-- end of parameters
-->
272 // SQL scripts for the various searches
273 if ($_POST['form_refresh']) {
274 $result = sqlStatement($sql, $sqlBindArray);
276 if(sqlNumRows($result) > 0){
278 <div id
="report_results">
281 <th
><?php
echo htmlspecialchars(xl('First/Last Name'), ENT_QUOTES
) ?
></th
>
282 <th
> <?php
echo htmlspecialchars(xl('Sex'), ENT_QUOTES
) ?
></th
>
283 <th
> <?php
echo htmlspecialchars(xl('Age'), ENT_QUOTES
) ?
></th
>
284 <th
> <?php
echo htmlspecialchars(xl('Race'), ENT_QUOTES
) ?
></th
>
285 <th
> <?php
echo htmlspecialchars(xl('DOB'), ENT_QUOTES
) ?
></th
>
286 <th
> <?php
echo htmlspecialchars(xl('DOS'), ENT_QUOTES
) ?
></th
>
287 <th
> <?php
echo htmlspecialchars(xl('City'), ENT_QUOTES
) ?
></th
>
288 <th
> <?php
echo htmlspecialchars(xl('County'), ENT_QUOTES
) ?
></th
>
289 <th
> <?php
echo htmlspecialchars(xl('Zip'), ENT_QUOTES
) ?
></th
>
290 <th
> <?php
echo htmlspecialchars(xl('Payment Amount'), ENT_QUOTES
) ?
></th
>
291 <th
> <?php
echo htmlspecialchars(xl('Payment Method'), ENT_QUOTES
) ?
></th
>
296 while($row = sqlFetchArray($result)){
297 $total +
= (float)$row['total_amount'];
300 <td
><?php
echo htmlspecialchars($row['patient_name'], ENT_QUOTES
); ?
>
302 <td
><?php
echo htmlspecialchars($row['sex'], ENT_QUOTES
) ?
>
304 <td
><?php
echo htmlspecialchars($row['age'], ENT_QUOTES
) ?
>
306 <td
><?php
echo htmlspecialchars($row['race'], ENT_QUOTES
) ?
>
308 <td
><?php
echo htmlspecialchars($row['DOB'], ENT_QUOTES
) ?
>
310 <td
><?php
echo htmlspecialchars($row['DOS'], ENT_QUOTES
) ?
>
312 <td
><?php
echo htmlspecialchars($row['city'], ENT_QUOTES
) ?
>
314 <td
><?php
echo htmlspecialchars($row['county'], ENT_QUOTES
) ?
>
316 <td
><?php
echo htmlspecialchars($row['zip'], ENT_QUOTES
) ?
>
318 <td
><?php
echo htmlspecialchars($row['total_amount'], ENT_QUOTES
) ?
>
320 <td
><?php
echo htmlspecialchars($row['method'], ENT_QUOTES
) ?
>
326 <tr style
="border: 2px solid #000;">
335 <td
><strong
><?php
echo htmlspecialchars(xl('Total Amount'), ENT_QUOTES
) ?
></strong
> 
;</td
>
336 <td
><?php
echo htmlspecialchars(number_format($total, 2), ENT_QUOTES
) ?
> 
;</td
>
342 <!-- end of results
-->
351 <div
class='text'> <?php
echo htmlspecialchars(xl('Please input search criteria above, and click Submit to view results.'), ENT_QUOTES
) ?
> </div
>
358 <!-- stuff
for the popup calendar
-->
359 <style type
="text/css">
360 @import
url(../../library
/dynarch_calendar
.css
);
362 <script type
="text/javascript" src
="../../library/dynarch_calendar.js"></script
>
363 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
364 <script type
="text/javascript" src
="../../library/dynarch_calendar_setup.js"></script
>
365 <script language
="Javascript">
366 Calendar
.setup({inputField
:"form_from_date", ifFormat
:"%Y-%m-%d", button
:"img_from_date"});
367 Calendar
.setup({inputField
:"form_to_date", ifFormat
:"%Y-%m-%d", button
:"img_to_date"});