2 // Copyright (C) 2006 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'));
20 <title
><?
xl('Front Office Receipts','e'); ?
></title
>
21 <link rel
='stylesheet' href
='<?php echo $css_header ?>' type
='text/css'>
22 <script type
="text/javascript" src
="../../library/overlib_mini.js"></script
>
23 <script type
="text/javascript" src
="../../library/calendar.js"></script
>
24 <script type
="text/javascript" src
="../../library/textformat.js"></script
>
25 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
26 <script language
="JavaScript">
27 var mypcc
= '<? echo $GLOBALS['phone_country_code
'] ?>';
31 <body leftmargin
='0' topmargin
='0' marginwidth
='0' marginheight
='0'>
33 <!-- Required
for the popup date selectors
-->
34 <div id
="overDiv" style
="position:absolute; visibility:hidden; z-index:1000;"></div
>
38 <h2
><?
xl('Unique Seen Patients','e'); ?
></h2
>
40 <form name
='theform' method
='post' action
='unique_seen_patients_report.php'>
42 <table border
='0' cellpadding
='3'>
46 <?
xl('Visits From','e'); ?
>:
47 <input type
='text' name
='form_from_date' size
='10' value
='<? echo $from_date ?>'
48 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
49 <a href
="javascript:show_calendar('theform.form_from_date')"
50 title
=".xl('Click here to choose a date')."
51 ><img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22' border
='0'></a
>
52  
;<?
xl('To','e'); ?
>:
53 <input type
='text' name
='form_to_date' size
='10' value
='<? echo $to_date ?>'
54 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
55 <a href
="javascript:show_calendar('theform.form_to_date')"
56 title
=".xl('Click here to choose a date')."
57 ><img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22' border
='0'></a
>
59 <input type
='submit' name
='form_refresh' value
=<?
xl('Refresh','e'); ?
>>
70 <table border
='0' cellpadding
='1' cellspacing
='3' width
='98%'>
72 <tr bgcolor
="#dddddd">
74 <?
xl('Last Visit','e'); ?
>
77 <?
xl('Patient','e'); ?
>
79 <td
class='dehead' align
='right'>
80 <?
xl('Visits','e'); ?
>
82 <td
class='dehead' align
='right'>
92 <?
xl('Primary Insurance','e'); ?
>
95 <?
xl('Secondary Insurance','e'); ?
>
99 if ($_POST['form_refresh']) {
103 "p.fname, p.mname, p.lname, p.DOB, p.sex, p.ethnoracial, " .
104 "count(e.date) AS ecount, max(e.date) AS edate, " .
105 "c1.name AS cname1, c2.name AS cname2 " .
106 "FROM patient_data AS p " .
107 "JOIN form_encounter AS e ON " .
108 "e.pid = p.pid AND " .
109 "e.date >= '$from_date 00:00:00' AND " .
110 "e.date <= '$to_date 23:59:59' " .
111 "LEFT OUTER JOIN insurance_data AS i1 ON " .
112 "i1.pid = p.pid AND i1.type = 'primary' " .
113 "LEFT OUTER JOIN insurance_companies AS c1 ON " .
114 "c1.id = i1.provider " .
115 "LEFT OUTER JOIN insurance_data AS i2 ON " .
116 "i2.pid = p.pid AND i2.type = 'secondary' " .
117 "LEFT OUTER JOIN insurance_companies AS c2 ON " .
118 "c2.id = i2.provider " .
119 "GROUP BY p.lname, p.fname, p.mname, p.pid " .
120 "ORDER BY p.lname, p.fname, p.mname, p.pid";
122 // echo "<!-- $query -->\n"; // debugging
123 $res = sqlStatement($query);
125 while ($row = sqlFetchArray($res)) {
129 $tdy = $row['edate'];
130 $ageInMonths = (substr($tdy,0,4)*12) +
substr($tdy,5,2) -
131 (substr($dob,0,4)*12) - substr($dob,5,2);
132 $dayDiff = substr($tdy,8,2) - substr($dob,8,2);
133 if ($dayDiff < 0) --$ageInMonths;
134 $age = intval($ageInMonths/12);
139 <?php
echo substr($row['edate'], 0, 10) ?
>
142 <?php
echo $row['lname'] . ', ' . $row['fname'] . ' ' . $row['mname'] ?
>
144 <td
class='detail' align
='right'>
145 <?php
echo $row['ecount'] ?
>
147 <td
class='detail' align
='right'>
151 <?php
echo $row['sex'] ?
>
154 <?php
echo $row['ethnoracial'] ?
>
157 <?php
echo $row['cname1'] ?
>
160 <?php
echo $row['cname2'] ?
>
169 <td
class='dehead' colspan
='8'>
175 <td
class='dehead' colspan
='3'>
176 <?
xl('Total Number of Patients','e'); ?
>
178 <td
class='detail' colspan
='4'>
179 <?php
echo $totalpts ?
>