2 // This module is for team sports use and reports on absences by
3 // injury type (diagnosis) for a given time period.
5 include_once("../globals.php");
6 include_once("../../library/patient.inc");
7 include_once("../../library/acl.inc");
9 // Might want something different here.
11 // if (! acl_check('acct', 'rep')) die("Unauthorized access.");
13 $from_date = fixDate($_POST['form_from_date']);
14 $to_date = fixDate($_POST['form_to_date'], date('Y-m-d'));
15 $form_by = $_POST['form_by'];
19 <title
>Absences by Diagnosis
</title
>
20 <script type
="text/javascript" src
="../../library/overlib_mini.js"></script
>
21 <script type
="text/javascript" src
="../../library/calendar.js"></script
>
22 <script type
="text/javascript" src
="../../library/textformat.js"></script
>
23 <script language
="JavaScript">
24 var mypcc
= '<? echo $GLOBALS['phone_country_code
'] ?>';
28 <body leftmargin
='0' topmargin
='0' marginwidth
='0' marginheight
='0'>
30 <!-- Required
for the popup date selectors
-->
31 <div id
="overDiv" style
="position:absolute; visibility:hidden; z-index:1000;"></div
>
35 <h2
>Days
and Games Missed
</h2
>
37 <form name
='theform' method
='post' action
='absences_report.php'>
39 <table border
='0' cellpadding
='3'>
44 <input type
='radio' name
='form_by' value
='d'
45 <?
echo ($form_by == 'p') ?
'' : 'checked' ?
> />Diagnosis
 
;
46 <input type
='radio' name
='form_by' value
='p'
47 <?
echo ($form_by == 'p') ?
'checked' : '' ?
> />Player
 
;
49 <input type
='text' name
='form_from_date' size
='10' value
='<? echo $from_date ?>'
50 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
51 <a href
="javascript:show_calendar('theform.form_from_date')"
52 title
="Click here to choose a date"
53 ><img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22' border
='0'></a
>
55 <input type
='text' name
='form_to_date' size
='10' value
='<? echo $to_date ?>'
56 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='yyyy-mm-dd'>
57 <a href
="javascript:show_calendar('theform.form_to_date')"
58 title
="Click here to choose a date"
59 ><img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22' border
='0'></a
>
61 <input type
='submit' name
='form_refresh' value
='Refresh'>
72 <table border
='0' cellpadding
='1' cellspacing
='2' width
='98%'>
74 <tr bgcolor
="#dddddd">
75 <?
if ($form_by == 'p') { ?
>
87 <td
class='dehead' align
='right'>
90 <td
class='dehead' align
='right'>
93 <td
class='dehead' align
='right'>
98 if ($_POST['form_refresh']) {
99 $form_doctor = $_POST['form_doctor'];
100 $from_date = fixDate($_POST['form_from_date']);
101 $to_date = fixDate($_POST['form_to_date'], date('Y-m-d'));
103 if ($form_by == 'p') {
104 $query = "SELECT patient_data.lname, patient_data.fname, patient_data.mname, " .
105 "count(*) AS count, " .
106 "SUM(lists.extrainfo) AS gmissed, " .
107 "SUM(TO_DAYS(LEAST(IFNULL(lists.enddate,CURRENT_DATE),'$to_date')) - TO_DAYS(GREATEST(lists.begdate,'$from_date'))) AS dmissed " .
108 "FROM lists, patient_data WHERE " .
109 "(lists.enddate IS NULL OR lists.enddate >= '$from_date') AND lists.begdate <= '$to_date' AND " .
110 "patient_data.pid = lists.pid " .
111 "GROUP BY lname, fname, mname";
114 $query = "SELECT lists.diagnosis, codes.code_text, count(*) AS count, " .
115 "SUM(lists.extrainfo) AS gmissed, " .
116 "SUM(TO_DAYS(LEAST(IFNULL(lists.enddate,CURRENT_DATE),'$to_date')) - TO_DAYS(GREATEST(lists.begdate,'$from_date'))) AS dmissed " .
118 "LEFT OUTER JOIN codes " .
119 "ON codes.code = lists.diagnosis AND " .
120 "(codes.code_type = 2 OR codes.code_type = 4 OR codes.code_type = 5 OR codes.code_type = 8) " .
122 "(lists.enddate IS NULL OR lists.enddate >= '$from_date') AND lists.begdate <= '$to_date' " .
123 "GROUP BY lists.diagnosis";
126 echo "<!-- $query -->\n"; // debugging
128 $res = sqlStatement($query);
130 while ($row = sqlFetchArray($res)) {
134 <?
if ($form_by == 'p') { ?
>
136 <?
echo $row['lname'] . ', ' . $row['fname'] . ' ' . $row['mname'] ?
>
140 <?
echo $row['diagnosis'] ?
>
143 <?
echo $row['code_text'] ?
>
146 <td
class='detail' align
='right'>
147 <?
echo $row['count'] ?
>
149 <td
class='detail' align
='right'>
150 <?
echo $row['dmissed'] ?
>
152 <td
class='detail' align
='right'>
153 <?
echo $row['gmissed'] ?
>