2 // Copyright (C) 2006, 2008 Rod Roark <rod@sunsetsystems.com>
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 // This report lists patients that were seen within a given date
12 include_once("../globals.php");
13 include_once("$srcdir/patient.inc");
15 $from_date = fixDate($_POST['form_from_date'], date('Y-01-01'));
16 $to_date = fixDate($_POST['form_to_date'], date('Y-12-31'));
18 if ($_POST['form_labels']) {
19 header("Pragma: public");
21 header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
22 header("Content-Type: application/force-download");
23 header("Content-Disposition: attachment; filename=labels.txt");
24 header("Content-Description: File Transfer");
30 <?php
html_header_show();?
>
31 <title
><?php
xl('Front Office Receipts','e'); ?
></title
>
33 <script type
="text/javascript" src
="../../library/overlib_mini.js"></script
>
34 <script type
="text/javascript" src
="../../library/textformat.js"></script
>
35 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
36 <script language
="JavaScript">
37 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
40 <link rel
=stylesheet href
="<?php echo $css_header;?>" type
="text/css">
41 <style type
="text/css">
43 /* specifically include & exclude from printing */
45 #unipatreport_parameters {
49 #unipatreport_parameters_daterange {
55 /* specifically exclude some from the screen */
57 #unipatreport_parameters_daterange {
63 #unipatreport_parameters {
65 background
-color
: #ddf;
67 #unipatreport_parameters table {
69 border
-collapse
: collapse
;
71 #unipatreport_parameters table td {
75 #unipatreport_results {
79 #unipatreport_results table {
80 border
: 1px solid black
;
82 border
-collapse
: collapse
;
84 #unipatreport_results table thead {
85 display
: table
-header
-group
;
86 background
-color
: #ddd;
88 #unipatreport_results table th {
89 border
-bottom
: 1px solid black
;
91 #unipatreport_results table td {
94 border
-bottom
: 1px solid
#eee;
96 .unipatreport_totals td
{
97 background
-color
: #77ff77;
103 <body
class="body_top">
105 <!-- Required
for the popup date selectors
-->
106 <div id
="overDiv" style
="position:absolute; visibility:hidden; z-index:1000;"></div
>
110 <h2
><?php
xl('Unique Seen Patients','e'); ?
></h2
>
112 <div id
="unipatreport_parameters_daterange">
113 <?php
echo date("d F Y", strtotime($form_from_date)) ." to ". date("d F Y", strtotime($form_to_date)); ?
>
116 <div id
="unipatreport_parameters">
117 <form name
='theform' method
='post' action
='unique_seen_patients_report.php'>
121 <?php
xl('Visits From','e'); ?
>:
122 <input type
='text' name
='form_from_date' id
="form_from_date" size
='10' value
='<?php echo $from_date ?>'
123 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
124 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
125 id
='img_from_date' border
='0' alt
='[?]' style
='cursor:pointer'
126 title
='<?php xl('Click here to choose a date
','e
'); ?>'>
127  
;<?php
xl('To','e'); ?
>:
128 <input type
='text' name
='form_to_date' id
="form_to_date" size
='10' value
='<?php echo $to_date ?>'
129 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
130 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
131 id
='img_to_date' border
='0' alt
='[?]' style
='cursor:pointer'
132 title
='<?php xl('Click here to choose a date
','e
'); ?>'>
134 <input type
='submit' name
='form_refresh' value
=<?php
xl('Refresh','e'); ?
>>  
;
135 <input type
='submit' name
='form_labels' value
=<?php
xl('Labels','e'); ?
>>
139 </div
> <!-- end of parameters
-->
141 <div id
="unipatreport_results">
145 <th
> <?php
xl('Last Visit','e'); ?
> </th
>
146 <th
> <?php
xl('Patient','e'); ?
> </th
>
147 <th align
='right'> <?php
xl('Visits','e'); ?
> </th
>
148 <th align
='right'> <?php
xl('Age','e'); ?
> </th
>
149 <th
> <?php
xl('Sex','e'); ?
> </th
>
150 <th
> <?php
xl('Race','e'); ?
> </th
>
151 <th
> <?php
xl('Primary Insurance','e'); ?
> </th
>
152 <th
> <?php
xl('Secondary Insurance','e'); ?
> </th
>
156 } // end not generating labels
158 if ($_POST['form_refresh'] ||
$_POST['form_labels']) {
162 "p.pid, p.fname, p.mname, p.lname, p.DOB, p.sex, p.ethnoracial, " .
163 "p.street, p.city, p.state, p.postal_code, " .
164 "count(e.date) AS ecount, max(e.date) AS edate, " .
165 "i1.date AS idate1, i2.date AS idate2, " .
166 "c1.name AS cname1, c2.name AS cname2 " .
167 "FROM patient_data AS p " .
168 "JOIN form_encounter AS e ON " .
169 "e.pid = p.pid AND " .
170 "e.date >= '$from_date 00:00:00' AND " .
171 "e.date <= '$to_date 23:59:59' " .
172 "LEFT OUTER JOIN insurance_data AS i1 ON " .
173 "i1.pid = p.pid AND i1.type = 'primary' " .
174 "LEFT OUTER JOIN insurance_companies AS c1 ON " .
175 "c1.id = i1.provider " .
176 "LEFT OUTER JOIN insurance_data AS i2 ON " .
177 "i2.pid = p.pid AND i2.type = 'secondary' " .
178 "LEFT OUTER JOIN insurance_companies AS c2 ON " .
179 "c2.id = i2.provider " .
180 "GROUP BY p.lname, p.fname, p.mname, p.pid, i1.date, i2.date " .
181 "ORDER BY p.lname, p.fname, p.mname, p.pid, i1.date DESC, i2.date DESC";
182 $res = sqlStatement($query);
185 while ($row = sqlFetchArray($res)) {
186 if ($row['pid'] == $prevpid) continue;
187 $prevpid = $row['pid'];
192 $tdy = $row['edate'];
193 $ageInMonths = (substr($tdy,0,4)*12) +
substr($tdy,5,2) -
194 (substr($dob,0,4)*12) - substr($dob,5,2);
195 $dayDiff = substr($tdy,8,2) - substr($dob,8,2);
196 if ($dayDiff < 0) --$ageInMonths;
197 $age = intval($ageInMonths/12);
200 if ($_POST['form_labels']) {
201 echo '"' . $row['lname'] . ', ' . $row['fname'] . ' ' . $row['mname'] . '","' .
202 $row['street'] . '","' . $row['city'] . '","' . $row['state'] . '","' .
203 $row['postal_code'] . '"' . "\n";
209 <?php
echo substr($row['edate'], 0, 10) ?
>
212 <?php
echo $row['lname'] . ', ' . $row['fname'] . ' ' . $row['mname'] ?
>
214 <td style
="text-align:center">
215 <?php
echo $row['ecount'] ?
>
221 <?php
echo $row['sex'] ?
>
224 <?php
echo $row['ethnoracial'] ?
>
227 <?php
echo $row['cname1'] ?
>
230 <?php
echo $row['cname2'] ?
>
238 if (!$_POST['form_labels']) {
240 <tr
class='unipatreport_totals'>
242 <?php
xl('Total Number of Patients','e'); ?
>
244 <td style
="padding-left: 20px;">
245 <?php
echo $totalpts ?
>
247 <td colspan
='5'> 
;</td
>
252 } // end refresh or labels
254 if (!$_POST['form_labels']) {
263 <!-- stuff
for the popup calendar
-->
264 <style type
="text/css">@import
url(../../library
/dynarch_calendar
.css
);</style
>
265 <script type
="text/javascript" src
="../../library/dynarch_calendar.js"></script
>
266 <script type
="text/javascript" src
="../../library/dynarch_calendar_en.js"></script
>
267 <script type
="text/javascript" src
="../../library/dynarch_calendar_setup.js"></script
>
268 <script language
="Javascript">
269 Calendar
.setup({inputField
:"form_from_date", ifFormat
:"%Y-%m-%d", button
:"img_from_date"});
270 Calendar
.setup({inputField
:"form_to_date", ifFormat
:"%Y-%m-%d", button
:"img_to_date"});