2 // This module is for team sports use and reports on various attributes
3 // of injuries for a given time period and reporting key.
5 include_once("../globals.php");
6 include_once("../../library/patient.inc");
7 include_once("../../library/acl.inc");
8 include_once("../forms/football_injury_audit/fia.inc.php");
10 // Might want something different here.
12 // if (! acl_check('acct', 'rep')) die("Unauthorized access.");
14 $from_date = fixDate($_POST['form_from_date']);
15 $to_date = fixDate($_POST['form_to_date'], date('Y-m-d'));
16 $form_by = $_POST['form_by']; // this is a scalar
17 $form_show = $_POST['form_show']; // this is an array
18 $form_squads = $_POST['form_squads']; // this is an array
20 // One of these is chosen as the left column, or Y-axis, of the report.
23 1 => xl('Activity Type'),
24 2 => xl('Body Region'),
25 3 => xl('Footwear Type'),
26 4 => xl('Game Period'),
27 5 => xl('Injury Mechanism'),
28 6 => xl('Injury Type'),
30 8 => xl('Playing Position'),
31 9 => xl('Sanction Type'),
32 10 => xl('Surface Type'),
33 11 => xl('Training Type')
36 // A reported value is either scalar, or an array listed horizontally. If
37 // multiple items are chosen then each starts in the next available column.
40 1 => array('Number of Injuries'),
41 2 => array('Days/Games Missed'),
42 3 => array('Body Region'),
43 4 => array('Injury Type'),
44 5 => array('Issue Title'),
47 $arr_regions_osi10 = array(
49 'B' => xl('Pelvis and buttock'),
51 'D' => xl('Thoracic spine'),
54 'G' => xl('Hip and groin'),
56 'I' => xl('Congenital'),
57 'J' => xl('Paedeatric'),
59 'L' => xl('Lumbar spine'),
60 'M' => xl('Medical problem'),
62 'O' => xl('Trunk and abdomen'),
63 'Q' => xl('Lower leg'),
65 'S' => xl('Shoulder'),
67 'U' => xl('Upper arm'),
68 'V' => xl('Disabled'),
69 'W' => xl('Wrist and hand'),
70 'X' => xl('Location unspecified'),
71 'Y' => xl('Post surgical'),
72 'Z' => xl('No presenting illness/injury'),
75 $arr_regions_osics = array(
76 'A' => xl('Ankle + heel'),
77 'B' => xl('Buttock + S.I.'),
79 'D' => xl('Thoracic spine'),
82 'G' => xl('Hip + groin'),
85 'L' => xl('Lumbar spine'),
86 'M' => xl('Medical problem'),
88 'O' => xl('Abdominal'),
89 'P' => xl('Hand + fingers'),
90 'Q' => xl('Lower leg'),
92 'S' => xl('Shoulder + clavicle'),
93 'T' => xl('Thigh + hamstring'),
94 'U' => xl('Upper arm'),
96 'X' => xl('Multiple areas'),
97 'Z' => xl('Area not specified')
100 $arr_regions_ucsmc = array(
101 'AN' => xl('Ankle + heel'),
102 'AR' => xl('Upper arm'),
103 'BL' => xl('Medical problem'),
104 'CV' => xl('Medical problem'),
105 'DE' => xl('Medical problem'),
107 'EN' => xl('Medical problem'),
108 'EV' => xl('Environmental'),
109 'FA' => xl('Forearm'),
110 'FE' => xl('Fluid and electrolyte problem'),
112 'GI' => xl('Abdominal'),
113 'GU' => xl('Medical problem'),
114 'HA' => xl('Hand + fingers'),
116 'HI' => xl('Hip + groin'),
117 'ID' => xl('Medical problem'),
119 'LE' => xl('Lower leg'),
120 'LP' => xl('Lumbar spine'),
122 'NS' => xl('Medical problem'),
123 'PS' => xl('Medical problem'),
124 'RE' => xl('Medical problem'),
125 'RM' => xl('Medical problem'),
126 'SH' => xl('Shoulder + clavicle'),
127 'TH' => xl('Thigh + hamstring'),
128 'TR' => xl('Thoracic spine'),
132 $arr_types_osi10 = array(
133 'A' => xl('Arthritis'),
134 'C' => xl('Cartilage injury'),
135 'D' => xl('Joint dislocations'),
136 'F' => xl('Fracture'),
137 'G' => xl('Synovitis, impingement, bursitis'),
138 'H' => xl('Bruising/haematoma'),
139 'J' => xl('Joint sprains'),
140 'K' => xl('Laceration/abrasion'),
141 'M' => xl('Muscle injury'),
142 'N' => xl('Nerve injury'),
143 'O' => xl('Organ injury'),
144 'S' => xl('Stress fracture'),
145 'T' => xl('Tendon injury'),
146 'V' => xl('Vascular injury'),
147 'W' => xl('Whiplash'),
148 'X' => xl('Non specific injury'),
149 'Y' => xl('Other stress/Over use injury'),
150 'Z' => xl('Other injury not elsewhere specified'),
153 $arr_types_osics = array(
154 'A' => xl('Arthritis / degen joint disease'),
155 'B' => xl('Developmental abnormality'),
156 'C' => xl('Cartilage / chondral / disc damage'),
157 'D' => xl('Dislocation'),
159 'F' => xl('Fracture'),
160 'G' => xl('Avulsion / avulsion fracture'),
161 'H' => xl('Haematoma / bruising'),
162 'I' => xl('Infection / Abscess'),
163 'J' => xl('Minor joint strain +/- synovitis'),
164 'K' => xl('Laceration / skin condition'),
165 'L' => xl('Ligament tear or sprain'),
166 'M' => xl('Strain of muscle'),
167 'N' => xl('Neural condition / nerve damage'),
168 'O' => xl('Visceral damage/trauma/surgery'),
169 'P' => xl('Chronic synovitis / effusion / joint pain / gout'),
170 'Q' => xl('Old fracture non / malunion'),
171 'R' => xl('Rupture'),
172 'S' => xl('Stress fracture'),
173 'T' => xl('Tendonitis / osis / bursitis'),
174 'U' => xl('Instability / subluxation'),
175 'V' => xl('Vascular condition'),
176 'X' => xl('Medical problem'),
177 'Y' => xl('Trigger point / compartment syndrome / DOMS / cramp'),
178 'Z' => xl('Undiagnosed')
181 $arr_types_ucsmc = array(
182 '01' => xl('Ligament tear or sprain'),
183 '02' => xl('Ligament tear or sprain'),
184 '03' => xl('Ligament tear or sprain'),
185 '07' => xl('Strain of muscle'),
186 '09' => xl('Rupture'),
187 '10' => xl('Dislocation'),
188 '11' => xl('Instability / subluxation'),
189 '12' => xl('Instability / subluxation'),
190 '13' => xl('Fracture'),
191 '14' => xl('Avulsion / avulsion fracture'),
192 '15' => xl('Old fracture non / malunion'),
193 '16' => xl('Fracture'),
194 '17' => xl('Cartilage / chondral / disc damage'),
195 '18' => xl('Stress fracture'),
196 '23' => xl('Haematoma / bruising'),
197 '24' => xl('Laceration / skin condition'),
198 '25' => xl('Haematoma / bruising'),
199 '26' => xl('Tendonitis / osis / bursitis'),
200 '27' => xl('Tendonitis / osis / bursitis'),
201 '28' => xl('Tendonitis / osis / bursitis'),
202 '29' => xl('Tendonitis / osis / bursitis'),
203 '33' => xl('Arthritis / degen joint diseas'),
204 '36' => xl('Trigger point / compartment syndrome / DOMS / cramp'),
205 '38' => xl('Infection / Abscess'),
206 '39' => xl('Medical problem'),
207 '40' => xl('Cartilage / chondral / disc damage'),
208 '42' => xl('Tumour'),
209 '44' => xl('Neural condition / nerve damage')
215 <?php
html_header_show();?
>
216 <title
><?php
xl('Football Injury Report','e'); ?
></title
>
217 <style type
="text/css">@import
url(../../library
/dynarch_calendar
.css
);</style
>
218 <style type
="text/css">
219 body
{ font
-family
:sans
-serif
; font
-size
:10pt
; font
-weight
:normal
}
220 .dehead
{ color
:#000000; font-family:sans-serif; font-size:10pt; font-weight:bold }
221 .detail
{ color
:#000000; font-family:sans-serif; font-size:10pt; font-weight:normal }
223 <script type
="text/javascript" src
="../../library/textformat.js"></script
>
224 <script type
="text/javascript" src
="../../library/dynarch_calendar.js"></script
>
225 <script type
="text/javascript" src
="../../library/dynarch_calendar_en.js"></script
>
226 <script type
="text/javascript" src
="../../library/dynarch_calendar_setup.js"></script
>
227 <script language
="JavaScript">
228 var mypcc
= '<? echo $GLOBALS['phone_country_code
'] ?>';
232 <body leftmargin
='0' topmargin
='0' marginwidth
='0' marginheight
='0'>
236 <h2
><?
xl('Football Injury Report','e'); ?
></h2
>
238 <form name
='theform' method
='post' action
='football_injury_report.php'>
240 <table border
='0' cellspacing
='0' cellpadding
='2'>
243 <td valign
='top' nowrap
>
247 <select name
='form_by' title
='Left column of report'>
249 foreach ($arr_by as $key => $value) {
250 echo " <option value='$key'";
251 if ($key == $form_by) echo " selected";
252 echo ">" . $value . "</option>\n";
257 <td valign
='top' rowspan
='3' nowrap
>
259 <input type
='submit' name
='form_refresh' value
='<?php xl('Show
','e
'); ?>' title
='<?php xl('Click to generate the report
','e
'); ?>'> :
261 <td valign
='top' rowspan
='3'>
262 <select name
='form_show[]' size
='4' multiple
263 title
='<?php xl('Hold down Ctrl to select multiple items
','e
'); ?>'>
265 foreach ($arr_show as $key => $value) {
266 echo " <option value='$key'";
267 if (is_array($form_show) && in_array($key, $form_show)) echo " selected";
268 echo ">" . $value[0] . "</option>\n";
273 <td valign
='top' rowspan
='3' nowrap
>
277 <td valign
='top' rowspan
='3'>
278 <select name
='form_squads[]' size
='4' multiple
279 title
='<?php xl('Hold down Ctrl to select multiple squads
','e
'); ?>'>
281 $squads = acl_get_squads();
283 foreach ($squads as $key => $value) {
284 echo " <option value='$key'";
285 if (!is_array($form_squads) ||
in_array($key, $form_squads)) echo " selected";
286 echo ">" . $value[3] . "</option>\n";
294 <td valign
='top' nowrap
>
297 <td valign
='top' nowrap
>
298 <input type
='text' name
='form_from_date' id
='form_from_date' size
='10' value
='<?php echo $from_date ?>'
299 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='Start date yyyy-mm-dd'>
300 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
301 id
='img_from_date' border
='0' alt
='[?]' style
='cursor:pointer'
302 title
='<?php xl('Click here to choose a date
','e
'); ?>'>
306 <td valign
='top' nowrap
>
309 <td valign
='top' nowrap
>
310 <input type
='text' name
='form_to_date' id
='form_to_date' size
='10' value
='<?php echo $to_date ?>'
311 onkeyup
='datekeyup(this,mypcc)' onblur
='dateblur(this,mypcc)' title
='End date yyyy-mm-dd'>
312 <img src
='../pic/show_calendar.gif' align
='absbottom' width
='24' height
='22'
313 id
='img_to_date' border
='0' alt
='[?]' style
='cursor:pointer'
314 title
='<?php xl('Click here to choose a date
','e
'); ?>'>
326 if ($_POST['form_refresh']) {
328 // fetch all the issues that are medical problems and corresponding FIA
329 // data. We are reporting only values from issues (though often by FIA
330 // fields), so it seems we want to retain one array row per issue and
331 // discard extra FIA forms.
333 $squadmatches = '1 = 2'; // an always-false condition
334 foreach ($form_squads as $squad)
335 $squadmatches .= " OR pd.squad = '$squad'";
337 /*****************************************************************
338 $query = "SELECT lists.id AS listid, lists.diagnosis, lists.pid, " .
339 "lists.extrainfo AS gmissed, lists.begdate, lists.enddate, " .
340 "lists.returndate, lists.title, fia.*, pd.lname, pd.fname, pd.mname " .
342 "JOIN patient_data AS pd ON pd.pid = lists.pid AND ( $squadmatches ) " .
343 "JOIN issue_encounter AS ie ON ie.list_id = lists.id " .
344 "JOIN forms ON forms.pid = ie.pid AND forms.encounter = ie.encounter " .
345 "AND forms.formdir = 'football_injury_audit' " .
346 "JOIN form_football_injury_audit as fia ON fia.id = forms.form_id " .
347 "WHERE ( lists.enddate IS NULL OR lists.enddate >= '$from_date' ) AND " .
348 "lists.begdate <= '$to_date' AND " .
349 "lists.type = 'medical_problem' AND lists.title NOT LIKE '%Illness%'" .
350 "ORDER BY lists.pid, lists.begdate";
351 *****************************************************************/
352 $query = "SELECT lists.id AS listid, lists.diagnosis, lists.pid, " .
353 "lists.extrainfo AS gmissed, lists.begdate, lists.enddate, " .
354 "lists.returndate, lists.title, lfi.*, pd.lname, pd.fname, pd.mname " .
356 "JOIN lists_football_injury AS lfi ON lfi.id = lists.id " .
357 "JOIN patient_data AS pd ON pd.pid = lists.pid AND ( $squadmatches ) " .
358 "WHERE ( lists.enddate IS NULL OR lists.enddate >= '$from_date' ) AND " .
359 "lists.begdate <= '$to_date' AND lists.type = 'football_injury' " .
360 "ORDER BY lists.pid, lists.begdate";
361 /****************************************************************/
363 $res = sqlStatement($query);
366 $arr_my_body_regions = array();
367 $arr_my_injury_types = array();
368 $arr_my_issue_titles = array();
374 while ($row = sqlFetchArray($res)) {
376 // // Throw away extra injury forms.
377 // if ($row['listid'] == $last_listid) continue;
378 // $last_listid = $rows['listid'];
380 // Determine the primary diagnosis.
382 if (!empty($row['diagnosis'])) {
383 $relcodes = explode(';', $row['diagnosis']);
384 foreach ($relcodes as $codestring) {
385 if ($codestring === '') continue;
386 list($codetype, $code) = explode(':', $codestring);
387 if (empty($code)) $code = $codetype;
393 $body_region = 'Undiagnosed';
394 if (preg_match('/^(.)...$/', $diagnosis, $matches)) {
395 $body_region = $arr_regions_osi10[$matches[1]];
397 else if (preg_match('/^(.)..$/', $diagnosis, $matches)) {
398 $body_region = $arr_regions_osics[$matches[1]];
400 else if (preg_match('/^(..)\...\...$/', $diagnosis, $matches)) {
401 $body_region = $arr_regions_ucsmc[$matches[1]];
404 $injury_type = 'Undiagnosed';
405 if (preg_match('/^.(.)..$/', $diagnosis, $matches)) {
406 $injury_type = $arr_types_osi10[$matches[1]];
408 else if (preg_match('/^.(.).$/', $diagnosis, $matches)) {
409 $injury_type = $arr_types_osics[$matches[1]];
411 else if (preg_match('/^..\...\.(..)$/', $diagnosis, $matches)) {
412 $injury_type = $arr_types_ucsmc[$matches[1]];
415 $issue_title = trim($row['title']);
417 $key = 'Unspecified';
419 if ($form_by == '1') { // Activity Type
420 if ($row['fimech_tackling'] ||
$row['fimech_tackled'] ||
421 $row['fimech_collision'] ||
$row['fimech_kicked'] ||
422 $row['fimech_elbow'] ||
$row['fimech_othercon'])
426 $key = 'Non-contact';
430 else if ($form_by == '2') { // Body Region
434 else if ($form_by == '3') { // Footwear Type
435 if ($row['fifootwear']) $key = $arr_footwear[$row['fifootwear']];
438 else if ($form_by == '4') { // Game Period
439 if ($row['fiinjmin']) {
440 $key = 15 * (int)(($row['fiinjmin'] +
14) / 15);
444 else if ($form_by == '5') { // Injury Mechanism
445 foreach ($arr_activity as $imkey => $imvalue) {
446 if ($row["fimech_$imkey"]) {
453 else if ($form_by == '6') { // Injury Type
457 else if ($form_by == '7') { // Player
458 $key = trim($row['lname'] . ', ' . $row['fname'] . ' ' . $row['mname']);
461 else if ($form_by == '8') { // Playing Position
462 if ($row['fiposition']) $key = $arr_position[$row['fiposition']];
465 else if ($form_by == '9') { // Referee Sanction Type
466 foreach ($arr_sanction as $imkey => $imvalue) {
467 if ($row["fimech_$imkey"]) {
474 else if ($form_by == '10') { // Surface Type
475 if ($row['fisurface']) $key = $arr_surface[$row['fisurface']];
478 else if ($form_by == '11') { // Training Type
479 if ($row['fiinjtime']) $key = $arr_injtime[$row['fiinjtime']];
482 // OK we now have the reporting key for this issue.
484 // If first instance of this key, initialize its arrays.
485 if (! $areport[$key]) {
486 $areport[$key] = array();
487 $areport[$key]['inj'] = 0; // number of injuries
488 $areport[$key]['dmissed'] = 0; // days missed
489 $areport[$key]['gmissed'] = 0; // games missed
490 $areport[$key]['br'] = array(); // body region array
491 $areport[$key]['it'] = array(); // injury type array
492 $areport[$key]['ti'] = array(); // issue title array
495 // Compute days missed. Force non-overlap of multiple issues for the
496 // same player. This logic assumes sorting on begdate within pid.
498 $begsecs = strtotime($row['begdate']);
499 $endsecs = $row['returndate'] ?
strtotime($row['returndate']) : time();
500 if ($row['pid'] == $last_pid) {
501 if ($begsecs < $last_endsecs) {
502 $begsecs = $last_endsecs;
506 $last_pid = $row['pid'];
509 if ($begsecs > $endsecs) $begsecs = $endsecs;
510 if ($last_endsecs < $endsecs) $last_endsecs = $endsecs;
511 $daysmissed = round(($endsecs - $begsecs) / (60 * 60 * 24));
513 // Store values that we might want to report on.
514 $areport[$key]['inj'] +
= 1; // count number of injuries
515 $areport[$key]['dmissed'] +
= $daysmissed; // count days missed
516 $areport[$key]['gmissed'] +
= $row['gmissed']; // count games missed
517 $areport[$key]['br'][$body_region] +
= 1; // count injuries to this body part
518 $areport[$key]['it'][$injury_type] +
= 1; // count injuries of this type
519 $areport[$key]['ti'][$issue_title] +
= 1; // count injuries with this title
521 // These track all body regions and injury types encountered.
522 $arr_my_body_regions[$body_region] +
= 1;
523 $arr_my_injury_types[$injury_type] +
= 1;
524 $arr_my_issue_titles[$issue_title] +
= 1;
528 // Sort everything by key for reporting.
530 ksort($arr_my_body_regions);
531 ksort($arr_my_injury_types);
532 ksort($arr_my_issue_titles);
535 <table border
='0' cellpadding
='1' cellspacing
='2' width
='98%'>
537 <tr bgcolor
="#dddddd">
539 <?php
echo $arr_by[$form_by]; ?
>
543 // Generate headings for values to be shown.
544 foreach ($form_show as $value) {
545 if ($value == '1') { // Number of injuries
546 echo " <td class='dehead' align='right'>Injuries</td>\n";
548 else if ($value == '2') { // days and games missed
549 echo " <td class='dehead' align='right'>Days Missed</td>\n";
550 echo " <td class='dehead' align='right'>Games Missed</td>\n";
552 else if ($value == '3') { // body region
553 foreach ($arr_my_body_regions as $br => $nothing) {
554 echo " <td class='dehead' align='right'>$br</td>\n";
557 else if ($value == '4') { // injury type
558 foreach ($arr_my_injury_types as $it => $nothing) {
559 echo " <td class='dehead' align='right'>$it</td>\n";
562 else if ($value == '5') { // issue titles
563 foreach ($arr_my_issue_titles as $ti => $nothing) {
564 echo " <td class='dehead' align='right'>$ti</td>\n";
573 foreach ($areport as $key => $varr) {
574 $bgcolor = (++
$encount & 1) ?
"#ddddff" : "#ffdddd";
576 echo " <tr bgcolor='$bgcolor'>\n";
577 echo " <td class='detail'>$key</td>\n";
579 // Generate data for this row.
580 foreach ($form_show as $value) {
581 if ($value == '1') { // Number of injuries
582 echo " <td class='detail' align='right'>" . $areport[$key]['inj'] . "</td>\n";
584 else if ($value == '2') { // days and games missed
585 echo " <td class='detail' align='right'>" . $areport[$key]['dmissed'] . "</td>\n";
586 echo " <td class='detail' align='right'>" . $areport[$key]['gmissed'] . "</td>\n";
588 else if ($value == '3') { // body region
589 foreach ($arr_my_body_regions as $body_region => $nothing) {
590 echo " <td class='detail' align='right'>" . $areport[$key]['br'][$body_region] . "</td>\n";
593 else if ($value == '4') { // injury type
594 foreach ($arr_my_injury_types as $injury_type => $nothing) {
595 echo " <td class='detail' align='right'>" . $areport[$key]['it'][$injury_type] . "</td>\n";
598 else if ($value == '5') { // issue title
599 foreach ($arr_my_issue_titles as $issue_title => $nothing) {
600 echo " <td class='detail' align='right'>" . $areport[$key]['ti'][$issue_title] . "</td>\n";
611 <?php
} // end of if ($_POST['form_refresh']) ?>
616 <script language
='JavaScript'>
617 Calendar
.setup({inputField
:"form_from_date", ifFormat
:"%Y-%m-%d", button
:"img_from_date"});
618 Calendar
.setup({inputField
:"form_to_date", ifFormat
:"%Y-%m-%d", button
:"img_to_date"});