3 * This report lists patients that were seen within a given date
7 * @link http://www.open-emr.org
8 * @author Rod Roark <rod@sunsetsystems.com>
9 * @author Brady Miller <brady.g.miller@gmail.com>
10 * @copyright Copyright (c) 2006-2015 Rod Roark <rod@sunsetsystems.com>
11 * @copyright Copyright (c) 2017 Brady Miller <brady.g.miller@gmail.com>
12 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
15 use OpenEMR\Core\Header
;
17 require_once("../globals.php");
18 require_once("$srcdir/patient.inc");
20 $form_from_date = (!empty($_POST['form_from_date'])) ?
DateToYYYYMMDD($_POST['form_from_date']) : date('Y-01-01');
21 $form_to_date = (!empty($_POST['form_to_date'])) ?
DateToYYYYMMDD($_POST['form_to_date']) : date('Y-12-31');
23 if ($_POST['form_labels']) {
24 header("Pragma: public");
26 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
27 header("Content-Type: application/force-download");
28 header("Content-Disposition: attachment; filename=labels.txt");
29 header("Content-Description: File Transfer");
35 <style type
="text/css">
36 /* specifically include & exclude from printing */
42 #report_parameters_daterange {
51 /* specifically exclude some from the screen */
53 #report_parameters_daterange {
59 <title
><?php
echo xlt('Front Office Receipts'); ?
></title
>
61 <?php Header
::setupHeader('datetime-picker'); ?
>
63 <script language
="JavaScript">
65 $
(document
).ready(function() {
66 var win
= top
.printLogSetup ? top
: opener
.top
;
67 win
.printLogSetup(document
.getElementById('printbutton'));
69 $
('.datepicker').datetimepicker({
70 <?php
$datetimepicker_timepicker = false; ?
>
71 <?php
$datetimepicker_showseconds = false; ?
>
72 <?php
$datetimepicker_formatInput = true; ?
>
73 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
74 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
80 <style type
="text/css">
82 /* specifically include & exclude from printing */
88 #report_parameters_daterange {
94 /* specifically exclude some from the screen */
96 #report_parameters_daterange {
105 <body
class="body_top">
107 <!-- Required
for the popup date selectors
-->
108 <div id
="overDiv" style
="position:absolute; visibility:hidden; z-index:1000;"></div
>
110 <span
class='title'><?php
echo xlt('Report'); ?
> - <?php
echo xlt('Unique Seen Patients'); ?
></span
>
112 <div id
="report_parameters_daterange">
113 <?php
echo oeFormatShortDate($form_from_date) ." " . xlt("to") . " ". oeFormatShortDate($form_to_date); ?
>
116 <form name
='theform' method
='post' action
='unique_seen_patients_report.php' id
='theform' onsubmit
='return top.restoreSession()'>
118 <div id
="report_parameters">
119 <input type
='hidden' name
='form_refresh' id
='form_refresh' value
=''/>
120 <input type
='hidden' name
='form_labels' id
='form_labels' value
=''/>
125 <div style
='float:left'>
129 <td
class='control-label'>
130 <?php
echo xlt('Visits From'); ?
>:
133 <input type
='text' class='datepicker form-control' name
='form_from_date' id
="form_from_date" size
='10' value
='<?php echo oeFormatShortDate($form_from_date); ?>'>
135 <td
class='control-label'>
136 <?php
echo xlt('To'); ?
>:
139 <input type
='text' class='datepicker form-control' name
='form_to_date' id
="form_to_date" size
='10' value
='<?php echo oeFormatShortDate($form_to_date); ?>'>
147 <td align
='left' valign
='middle' height
="100%">
148 <table style
='border-left:1px solid; width:100%; height:100%' >
151 <div
class="text-center">
152 <div
class="btn-group" role
="group">
153 <a href
='#' class='btn btn-default btn-save' onclick
='$("#form_refresh").attr("value","true"); $("#form_labels").val(""); $("#theform").submit();'>
154 <?php
echo xlt('Submit'); ?
>
156 <?php
if ($_POST['form_refresh']) { ?
>
157 <a href
='#' class='btn btn-default btn-print' id
='printbutton'>
158 <?php
echo xlt('Print'); ?
>
160 <a href
='#' class='btn btn-default btn-transmit' onclick
='$("#form_labels").attr("value","true"); $("#theform").submit();'>
161 <?php
echo xlt('Labels'); ?
>
172 </div
> <!-- end of parameters
-->
174 <div id
="report_results">
178 <th
> <?php
echo xlt('Last Visit'); ?
> </th
>
179 <th
> <?php
echo xlt('Patient'); ?
> </th
>
180 <th align
='right'> <?php
echo xlt('Visits'); ?
> </th
>
181 <th align
='right'> <?php
echo xlt('Age'); ?
> </th
>
182 <th
> <?php
echo xlt('Sex'); ?
> </th
>
183 <th
> <?php
echo xlt('Race'); ?
> </th
>
184 <th
> <?php
echo xlt('Primary Insurance'); ?
> </th
>
185 <th
> <?php
echo xlt('Secondary Insurance'); ?
> </th
>
189 } // end not generating labels
191 if ($_POST['form_refresh'] ||
$_POST['form_labels']) {
195 "p.pid, p.fname, p.mname, p.lname, p.DOB, p.sex, p.ethnoracial, " .
196 "p.street, p.city, p.state, p.postal_code, " .
197 "count(e.date) AS ecount, max(e.date) AS edate, " .
198 "i1.date AS idate1, i2.date AS idate2, " .
199 "c1.name AS cname1, c2.name AS cname2 " .
200 "FROM patient_data AS p " .
201 "JOIN form_encounter AS e ON " .
202 "e.pid = p.pid AND " .
205 "LEFT OUTER JOIN insurance_data AS i1 ON " .
206 "i1.pid = p.pid AND i1.type = 'primary' " .
207 "LEFT OUTER JOIN insurance_companies AS c1 ON " .
208 "c1.id = i1.provider " .
209 "LEFT OUTER JOIN insurance_data AS i2 ON " .
210 "i2.pid = p.pid AND i2.type = 'secondary' " .
211 "LEFT OUTER JOIN insurance_companies AS c2 ON " .
212 "c2.id = i2.provider " .
213 "GROUP BY p.lname, p.fname, p.mname, p.pid, i1.date, i2.date " .
214 "ORDER BY p.lname, p.fname, p.mname, p.pid, i1.date DESC, i2.date DESC";
215 $res = sqlStatement($query, array($form_from_date . ' 00:00:00', $form_to_date . ' 23:59:59'));
218 while ($row = sqlFetchArray($res)) {
219 if ($row['pid'] == $prevpid) {
223 $prevpid = $row['pid'];
228 $tdy = $row['edate'];
229 $ageInMonths = (substr($tdy, 0, 4)*12) +
substr($tdy, 5, 2) -
230 (substr($dob, 0, 4)*12) - substr($dob, 5, 2);
231 $dayDiff = substr($tdy, 8, 2) - substr($dob, 8, 2);
236 $age = intval($ageInMonths/12);
239 if ($_POST['form_labels']) {
240 echo '"' . $row['lname'] . ', ' . $row['fname'] . ' ' . $row['mname'] . '","' .
241 $row['street'] . '","' . $row['city'] . '","' . $row['state'] . '","' .
242 $row['postal_code'] . '"' . "\n";
243 } else { // not labels
247 <?php
echo oeFormatShortDate(substr($row['edate'], 0, 10)) ?
>
250 <?php
echo text($row['lname']) . ', ' . text($row['fname']) . ' ' . text($row['mname']); ?
>
252 <td style
="text-align:center">
253 <?php
echo text($row['ecount']); ?
>
256 <?php
echo text($age); ?
>
259 <?php
echo text($row['sex']); ?
>
262 <?php
echo text($row['ethnoracial']); ?
>
265 <?php
echo text($row['cname1']); ?
>
268 <?php
echo text($row['cname2']); ?
>
276 if (!$_POST['form_labels']) {
278 <tr
class='report_totals'>
280 <?php
echo xlt('Total Number of Patients'); ?
>
282 <td style
="padding-left: 20px;">
283 <?php
echo text($totalpts); ?
>
285 <td colspan
='5'> 
;</td
>
290 } // end refresh or labels
292 if (!$_POST['form_labels']) {