3 * This report lists patients that were seen within a given date
6 * Copyright (C) 2006-2015 Rod Roark <rod@sunsetsystems.com>
7 * Copyright (C) 2017 Brady Miller <brady.g.miller@gmail.com>
9 * LICENSE: This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
21 * @author Rod Roark <rod@sunsetsystems.com>
22 * @author Brady Miller <brady.g.miller@gmail.com>
23 * @link http://www.open-emr.org
26 require_once("../globals.php");
27 require_once("$srcdir/patient.inc");
29 $from_date = fixDate($_POST['form_from_date'], date('Y-01-01'));
30 $to_date = fixDate($_POST['form_to_date'], date('Y-12-31'));
32 if ($_POST['form_labels']) {
33 header("Pragma: public");
35 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
36 header("Content-Type: application/force-download");
37 header("Content-Disposition: attachment; filename=labels.txt");
38 header("Content-Description: File Transfer");
44 <?php
html_header_show();?
>
45 <style type
="text/css">
46 /* specifically include & exclude from printing */
52 #report_parameters_daterange {
61 /* specifically exclude some from the screen */
63 #report_parameters_daterange {
69 <title
><?php
xl('Front Office Receipts','e'); ?
></title
>
71 <script type
="text/javascript" src
="../../library/textformat.js?v=<?php echo $v_js_includes; ?>"></script
>
72 <script type
="text/javascript" src
="../../library/dialog.js?v=<?php echo $v_js_includes; ?>"></script
>
73 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-3-1-1/index.js"></script
>
74 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.full.min.js"></script
>
76 <script language
="JavaScript">
78 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
80 $
(document
).ready(function() {
81 var win
= top
.printLogSetup ? top
: opener
.top
;
82 win
.printLogSetup(document
.getElementById('printbutton'));
84 $
('.datepicker').datetimepicker({
85 <?php
$datetimepicker_timepicker = false; ?
>
86 <?php
$datetimepicker_showseconds = false; ?
>
87 <?php
$datetimepicker_formatInput = false; ?
>
88 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
89 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
95 <link rel
=stylesheet href
="<?php echo $css_header;?>" type
="text/css">
96 <link rel
="stylesheet" href
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-datetimepicker-2-5-4/build/jquery.datetimepicker.min.css">
98 <style type
="text/css">
100 /* specifically include & exclude from printing */
106 #report_parameters_daterange {
112 /* specifically exclude some from the screen */
114 #report_parameters_daterange {
123 <body
class="body_top">
125 <!-- Required
for the popup date selectors
-->
126 <div id
="overDiv" style
="position:absolute; visibility:hidden; z-index:1000;"></div
>
128 <span
class='title'><?php
xl('Report','e'); ?
> - <?php
xl('Unique Seen Patients','e'); ?
></span
>
130 <div id
="report_parameters_daterange">
131 <?php
echo date("d F Y", strtotime($form_from_date)) ." to ". date("d F Y", strtotime($form_to_date)); ?
>
134 <form name
='theform' method
='post' action
='unique_seen_patients_report.php' id
='theform'>
136 <div id
="report_parameters">
137 <input type
='hidden' name
='form_refresh' id
='form_refresh' value
=''/>
138 <input type
='hidden' name
='form_labels' id
='form_labels' value
=''/>
143 <div style
='float:left'>
147 <td
class='label_custom'>
148 <?php
xl('Visits From','e'); ?
>:
151 <input type
='text' class='datepicker' name
='form_from_date' id
="form_from_date" size
='10' value
='<?php echo $form_from_date ?>'
154 <td
class='label_custom'>
155 <?php
xl('To','e'); ?
>:
158 <input type
='text' class='datepicker' name
='form_to_date' id
="form_to_date" size
='10' value
='<?php echo $form_to_date ?>'
167 <td align
='left' valign
='middle' height
="100%">
168 <table style
='border-left:1px solid; width:100%; height:100%' >
171 <div style
='margin-left:15px'>
172 <a href
='#' class='css_button' onclick
='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
174 <?php
xl('Submit','e'); ?
>
178 <?php
if ($_POST['form_refresh']) { ?
>
179 <a href
='#' class='css_button' id
='printbutton'>
181 <?php
xl('Print','e'); ?
>
184 <a href
='#' class='css_button' onclick
='$("#form_labels").attr("value","true"); $("#theform").submit();'>
186 <?php
xl('Labels','e'); ?
>
197 </div
> <!-- end of parameters
-->
199 <div id
="report_results">
203 <th
> <?php
xl('Last Visit','e'); ?
> </th
>
204 <th
> <?php
xl('Patient','e'); ?
> </th
>
205 <th align
='right'> <?php
xl('Visits','e'); ?
> </th
>
206 <th align
='right'> <?php
xl('Age','e'); ?
> </th
>
207 <th
> <?php
xl('Sex','e'); ?
> </th
>
208 <th
> <?php
xl('Race','e'); ?
> </th
>
209 <th
> <?php
xl('Primary Insurance','e'); ?
> </th
>
210 <th
> <?php
xl('Secondary Insurance','e'); ?
> </th
>
214 } // end not generating labels
216 if ($_POST['form_refresh'] ||
$_POST['form_labels']) {
220 "p.pid, p.fname, p.mname, p.lname, p.DOB, p.sex, p.ethnoracial, " .
221 "p.street, p.city, p.state, p.postal_code, " .
222 "count(e.date) AS ecount, max(e.date) AS edate, " .
223 "i1.date AS idate1, i2.date AS idate2, " .
224 "c1.name AS cname1, c2.name AS cname2 " .
225 "FROM patient_data AS p " .
226 "JOIN form_encounter AS e ON " .
227 "e.pid = p.pid AND " .
228 "e.date >= '$from_date 00:00:00' AND " .
229 "e.date <= '$to_date 23:59:59' " .
230 "LEFT OUTER JOIN insurance_data AS i1 ON " .
231 "i1.pid = p.pid AND i1.type = 'primary' " .
232 "LEFT OUTER JOIN insurance_companies AS c1 ON " .
233 "c1.id = i1.provider " .
234 "LEFT OUTER JOIN insurance_data AS i2 ON " .
235 "i2.pid = p.pid AND i2.type = 'secondary' " .
236 "LEFT OUTER JOIN insurance_companies AS c2 ON " .
237 "c2.id = i2.provider " .
238 "GROUP BY p.lname, p.fname, p.mname, p.pid, i1.date, i2.date " .
239 "ORDER BY p.lname, p.fname, p.mname, p.pid, i1.date DESC, i2.date DESC";
240 $res = sqlStatement($query);
243 while ($row = sqlFetchArray($res)) {
244 if ($row['pid'] == $prevpid) continue;
245 $prevpid = $row['pid'];
250 $tdy = $row['edate'];
251 $ageInMonths = (substr($tdy,0,4)*12) +
substr($tdy,5,2) -
252 (substr($dob,0,4)*12) - substr($dob,5,2);
253 $dayDiff = substr($tdy,8,2) - substr($dob,8,2);
254 if ($dayDiff < 0) --$ageInMonths;
255 $age = intval($ageInMonths/12);
258 if ($_POST['form_labels']) {
259 echo '"' . $row['lname'] . ', ' . $row['fname'] . ' ' . $row['mname'] . '","' .
260 $row['street'] . '","' . $row['city'] . '","' . $row['state'] . '","' .
261 $row['postal_code'] . '"' . "\n";
267 <?php
echo oeFormatShortDate(substr($row['edate'], 0, 10)) ?
>
270 <?php
echo $row['lname'] . ', ' . $row['fname'] . ' ' . $row['mname'] ?
>
272 <td style
="text-align:center">
273 <?php
echo $row['ecount'] ?
>
279 <?php
echo $row['sex'] ?
>
282 <?php
echo $row['ethnoracial'] ?
>
285 <?php
echo $row['cname1'] ?
>
288 <?php
echo $row['cname2'] ?
>
296 if (!$_POST['form_labels']) {
298 <tr
class='report_totals'>
300 <?php
xl('Total Number of Patients','e'); ?
>
302 <td style
="padding-left: 20px;">
303 <?php
echo $totalpts ?
>
305 <td colspan
='5'> 
;</td
>
310 } // end refresh or labels
312 if (!$_POST['form_labels']) {