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
10 // range, or all patients if no date range is entered.
12 require_once("../globals.php");
13 require_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'));
17 $from_date = fixDate($_POST['form_from_date'], '');
18 $to_date = fixDate($_POST['form_to_date'], '');
19 if (empty($to_date) && !empty($from_date)) $to_date = date('Y-12-31');
20 if (empty($from_date) && !empty($to_date)) $from_date = date('Y-01-01');
24 <?php
html_header_show();?
>
25 <title
><?php
xl('Patient List','e'); ?
></title
>
26 <script type
="text/javascript" src
="../../library/overlib_mini.js"></script
>
27 <script type
="text/javascript" src
="../../library/textformat.js"></script
>
28 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
29 <script language
="JavaScript">
30 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
32 <link rel
='stylesheet' href
='<?php echo $css_header ?>' type
='text/css'>
33 <style type
="text/css">
35 /* specifically include & exclude from printing */
37 #patlstreport_parameters {
41 #patlstreport_parameters_daterange {
47 /* specifically exclude some from the screen */
49 #patlstreport_parameters_daterange {
55 #patlstreport_parameters {
57 background
-color
: #ddf;
59 #patlstreport_parameters table {
61 border
-collapse
: collapse
;
63 #patlstreport_parameters table td {
67 #patlstreport_results {
71 #patlstreport_results table {
72 border
: 1px solid black
;
74 border
-collapse
: collapse
;
76 #patlstreport_results table thead {
77 display
: table
-header
-group
;
78 background
-color
: #ddd;
80 #patlstreport_results table th {
81 border
-bottom
: 1px solid black
;
83 #patlstreport_results table td {
86 border
-bottom
: 1px solid
#eee;
88 .patlstreport_totals td
{
89 background
-color
: #77ff77;
96 <body
class="body_top">
98 <!-- Required
for the popup date selectors
-->
99 <div id
="overDiv" style
="position:absolute; visibility:hidden; z-index:1000;"></div
>
103 <h2
><?php
xl('Patient List','e'); ?
></h2
>
105 <div id
="patlstreport_parameters_daterange">
106 <?php
echo date("d F Y", strtotime($form_from_date)) ." to ". date("d F Y", strtotime($form_to_date)); ?
>
109 <div id
="patlstreport_parameters">
111 <form name
='theform' method
='post' action
='patient_list.php'>
116 <?php
xl('Visits From','e'); ?
>:
117 <input type
='text' name
='form_from_date' id
="form_from_date" size
='10' value
='<?php echo $from_date ?>'
118 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
119 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
120 id
='img_from_date' border
='0' alt
='[?]' style
='cursor:pointer'
121 title
='<?php xl('Click here to choose a date
','e
'); ?>'>
122  
;<?php
xl('To','e'); ?
>:
123 <input type
='text' name
='form_to_date' id
="form_to_date" size
='10' value
='<?php echo $to_date ?>'
124 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
125 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
126 id
='img_to_date' border
='0' alt
='[?]' style
='cursor:pointer'
127 title
='<?php xl('Click here to choose a date
','e
'); ?>'>
129 <input type
='submit' name
='form_refresh' value
=<?php
xl('Refresh','e'); ?
>>
131 <input type
='button' value
='<?php xl('Print','e
'); ?>' onclick
='window.print()' />
135 </div
> <!-- end of parameters
-->
137 <div id
="patlstreport_results">
140 <th
> <?php
xl('Last Visit','e'); ?
> </th
>
141 <th
> <?php
xl('Patient','e'); ?
> </th
>
142 <th
> <?php
xl('ID','e'); ?
> </th
>
143 <th
> <?php
xl('Street','e'); ?
> </th
>
144 <th
> <?php
xl('City','e'); ?
> </th
>
145 <th
> <?php
xl('State','e'); ?
> </th
>
146 <th
> <?php
xl('Zip','e'); ?
> </th
>
147 <th
> <?php
xl('Home Phone','e'); ?
> </th
>
148 <th
> <?php
xl('Work Phone','e'); ?
> </th
>
152 if ($_POST['form_refresh']) {
156 "p.fname, p.mname, p.lname, p.street, p.city, p.state, " .
157 "p.postal_code, p.phone_home, p.phone_biz, p.pid, p.pubpid, " .
158 "count(e.date) AS ecount, max(e.date) AS edate, " .
159 "i1.date AS idate1, i2.date AS idate2, " .
160 "c1.name AS cname1, c2.name AS cname2 " .
161 "FROM patient_data AS p ";
162 if (!empty($from_date)) $query .=
163 "JOIN form_encounter AS e ON " .
164 "e.pid = p.pid AND " .
165 "e.date >= '$from_date 00:00:00' AND " .
166 "e.date <= '$to_date 23:59:59' ";
168 "LEFT OUTER JOIN form_encounter AS e ON e.pid = p.pid ";
170 "LEFT OUTER JOIN insurance_data AS i1 ON " .
171 "i1.pid = p.pid AND i1.type = 'primary' " .
172 "LEFT OUTER JOIN insurance_companies AS c1 ON " .
173 "c1.id = i1.provider " .
174 "LEFT OUTER JOIN insurance_data AS i2 ON " .
175 "i2.pid = p.pid AND i2.type = 'secondary' " .
176 "LEFT OUTER JOIN insurance_companies AS c2 ON " .
177 "c2.id = i2.provider " .
178 "GROUP BY p.lname, p.fname, p.mname, p.pid, i1.date, i2.date " .
179 "ORDER BY p.lname, p.fname, p.mname, p.pid, i1.date DESC, i2.date DESC";
180 $res = sqlStatement($query);
183 while ($row = sqlFetchArray($res)) {
184 if ($row['pid'] == $prevpid) continue;
185 $prevpid = $row['pid'];
192 $tdy = $row['edate'] ?
$row['edate'] : date('Y-m-d');
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);
202 <?php
echo substr($row['edate'], 0, 10) ?
>
205 <?php
echo $row['lname'] . ', ' . $row['fname'] . ' ' . $row['mname'] ?
>
208 <?php
echo $row['pubpid'] ?
>
211 <?php
echo $row['street'] ?
>
214 <?php
echo $row['city'] ?
>
217 <?php
echo $row['state'] ?
>
220 <?php
echo $row['postal_code'] ?
>
223 <?php
echo $row['phone_home'] ?
>
226 <?php
echo $row['phone_biz'] ?
>
234 <tr
class="patlstreport_totals">
236 <?php
xl('Total Number of Patients','e'); ?
>
238 <?php
echo $totalpts ?
>
247 </div
> <!-- end of results
-->
252 <!-- stuff
for the popup calendar
-->
253 <style type
="text/css">@import
url(../../library
/dynarch_calendar
.css
);</style
>
254 <script type
="text/javascript" src
="../../library/dynarch_calendar.js"></script
>
255 <script type
="text/javascript" src
="../../library/dynarch_calendar_en.js"></script
>
256 <script type
="text/javascript" src
="../../library/dynarch_calendar_setup.js"></script
>
257 <script language
="Javascript">
258 Calendar
.setup({inputField
:"form_from_date", ifFormat
:"%Y-%m-%d", button
:"img_from_date"});
259 Calendar
.setup({inputField
:"form_to_date", ifFormat
:"%Y-%m-%d", button
:"img_to_date"});