2 // Copyright (C) 2006-2010 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");
14 require_once("$srcdir/formatting.inc.php");
16 // $from_date = fixDate($_POST['form_from_date'], date('Y-01-01'));
17 // $to_date = fixDate($_POST['form_to_date'], date('Y-12-31'));
18 $from_date = fixDate($_POST['form_from_date'], '');
19 $to_date = fixDate($_POST['form_to_date'], '');
20 if (empty($to_date) && !empty($from_date)) $to_date = date('Y-12-31');
21 if (empty($from_date) && !empty($to_date)) $from_date = date('Y-01-01');
25 <?php
html_header_show();?
>
26 <title
><?php
xl('Patient List','e'); ?
></title
>
27 <script type
="text/javascript" src
="../../library/overlib_mini.js"></script
>
28 <script type
="text/javascript" src
="../../library/textformat.js"></script
>
29 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
30 <script type
="text/javascript" src
="../../library/js/jquery.1.3.2.js"></script
>
32 <script language
="JavaScript">
33 var mypcc
= '<?php echo $GLOBALS['phone_country_code
'] ?>';
35 <link rel
='stylesheet' href
='<?php echo $css_header ?>' type
='text/css'>
36 <style type
="text/css">
38 /* specifically include & exclude from printing */
44 #report_parameters_daterange {
49 #report_results table {
54 /* specifically exclude some from the screen */
56 #report_parameters_daterange {
69 <body
class="body_top">
71 <!-- Required
for the popup date selectors
-->
72 <div id
="overDiv" style
="position:absolute; visibility:hidden; z-index:1000;"></div
>
74 <span
class='title'><?php
xl('Report','e'); ?
> - <?php
xl('Patient List','e'); ?
></span
>
76 <div id
="report_parameters_daterange">
77 <?php
echo date("d F Y", strtotime($form_from_date)) ." to ". date("d F Y", strtotime($form_to_date)); ?
>
80 <form name
='theform' id
='theform' method
='post' action
='patient_list.php'>
82 <div id
="report_parameters">
84 <input type
='hidden' name
='form_refresh' id
='form_refresh' value
=''/>
89 <div style
='float:left'>
94 <?php
xl('Visits From','e'); ?
>:
97 <input type
='text' name
='form_from_date' id
="form_from_date" size
='10' value
='<?php echo $form_from_date ?>'
98 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
99 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
100 id
='img_from_date' border
='0' alt
='[?]' style
='cursor:pointer'
101 title
='<?php xl('Click here to choose a date
','e
'); ?>'>
104 <?php
xl('To','e'); ?
>:
107 <input type
='text' name
='form_to_date' id
="form_to_date" size
='10' value
='<?php echo $form_to_date ?>'
108 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
109 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
110 id
='img_to_date' border
='0' alt
='[?]' style
='cursor:pointer'
111 title
='<?php xl('Click here to choose a date
','e
'); ?>'>
119 <td align
='left' valign
='middle' height
="100%">
120 <table style
='border-left:1px solid; width:100%; height:100%' >
123 <div style
='margin-left:15px'>
124 <a href
='#' class='css_button' onclick
='$("#form_refresh").attr("value","true"); $("#theform").submit();'>
126 <?php
xl('Submit','e'); ?
>
130 <?php
if ($_POST['form_refresh']) { ?
>
131 <a href
='#' class='css_button' onclick
='window.print()'>
133 <?php
xl('Print','e'); ?
>
144 </div
> <!-- end of parameters
-->
147 if ($_POST['form_refresh']) {
151 <div id
="report_results">
154 <th
> <?php
xl('Last Visit','e'); ?
> </th
>
155 <th
> <?php
xl('Patient','e'); ?
> </th
>
156 <th
> <?php
xl('ID','e'); ?
> </th
>
157 <th
> <?php
xl('Street','e'); ?
> </th
>
158 <th
> <?php
xl('City','e'); ?
> </th
>
159 <th
> <?php
xl('State','e'); ?
> </th
>
160 <th
> <?php
xl('Zip','e'); ?
> </th
>
161 <th
> <?php
xl('Home Phone','e'); ?
> </th
>
162 <th
> <?php
xl('Work Phone','e'); ?
> </th
>
169 "p.fname, p.mname, p.lname, p.street, p.city, p.state, " .
170 "p.postal_code, p.phone_home, p.phone_biz, p.pid, p.pubpid, " .
171 "count(e.date) AS ecount, max(e.date) AS edate, " .
172 "i1.date AS idate1, i2.date AS idate2, " .
173 "c1.name AS cname1, c2.name AS cname2 " .
174 "FROM patient_data AS p ";
175 if (!empty($from_date)) $query .=
176 "JOIN form_encounter AS e ON " .
177 "e.pid = p.pid AND " .
178 "e.date >= '$from_date 00:00:00' AND " .
179 "e.date <= '$to_date 23:59:59' ";
181 "LEFT OUTER JOIN form_encounter AS e ON e.pid = p.pid ";
183 "LEFT OUTER JOIN insurance_data AS i1 ON " .
184 "i1.pid = p.pid AND i1.type = 'primary' " .
185 "LEFT OUTER JOIN insurance_companies AS c1 ON " .
186 "c1.id = i1.provider " .
187 "LEFT OUTER JOIN insurance_data AS i2 ON " .
188 "i2.pid = p.pid AND i2.type = 'secondary' " .
189 "LEFT OUTER JOIN insurance_companies AS c2 ON " .
190 "c2.id = i2.provider " .
191 "GROUP BY p.lname, p.fname, p.mname, p.pid, i1.date, i2.date " .
192 "ORDER BY p.lname, p.fname, p.mname, p.pid, i1.date DESC, i2.date DESC";
193 $res = sqlStatement($query);
196 while ($row = sqlFetchArray($res)) {
197 if ($row['pid'] == $prevpid) continue;
198 $prevpid = $row['pid'];
205 $tdy = $row['edate'] ?
$row['edate'] : date('Y-m-d');
206 $ageInMonths = (substr($tdy,0,4)*12) +
substr($tdy,5,2) -
207 (substr($dob,0,4)*12) - substr($dob,5,2);
208 $dayDiff = substr($tdy,8,2) - substr($dob,8,2);
209 if ($dayDiff < 0) --$ageInMonths;
210 $age = intval($ageInMonths/12);
215 <?php
echo oeFormatShortDate(substr($row['edate'], 0, 10)) ?
>
218 <?php
echo htmlspecialchars( $row['lname'] . ', ' . $row['fname'] . ' ' . $row['mname'] ) ?
>
221 <?php
echo $row['pubpid'] ?
>
224 <?php
echo $row['street'] ?
>
227 <?php
echo $row['city'] ?
>
230 <?php
echo $row['state'] ?
>
233 <?php
echo $row['postal_code'] ?
>
236 <?php
echo $row['phone_home'] ?
>
239 <?php
echo $row['phone_biz'] ?
>
247 <tr
class="report_totals">
249 <?php
xl('Total Number of Patients','e'); ?
>
251 <?php
echo $totalpts ?
>
260 </div
> <!-- end of results
-->
263 <?php
echo xl('Please input search criteria above, and click Submit to view results.', 'e' ); ?
>
270 <!-- stuff
for the popup calendar
-->
271 <style type
="text/css">@import
url(../../library
/dynarch_calendar
.css
);</style
>
272 <script type
="text/javascript" src
="../../library/dynarch_calendar.js"></script
>
273 <?php
include_once("{$GLOBALS['srcdir']}/dynarch_calendar_en.inc.php"); ?
>
274 <script type
="text/javascript" src
="../../library/dynarch_calendar_setup.js"></script
>
275 <script language
="Javascript">
276 Calendar
.setup({inputField
:"form_from_date", ifFormat
:"%Y-%m-%d", button
:"img_from_date"});
277 Calendar
.setup({inputField
:"form_to_date", ifFormat
:"%Y-%m-%d", button
:"img_to_date"});