-
Notifications
You must be signed in to change notification settings - Fork 4
/
surveyResponses.php
94 lines (82 loc) · 2.82 KB
/
surveyResponses.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
use \Vanderbilt\CareerDevLibrary\Download;
use \Vanderbilt\CareerDevLibrary\Links;
use \Vanderbilt\FlightTrackerExternalModule\CareerDev;
require_once(dirname(__FILE__)."/charts/baseWeb.php");
require_once(dirname(__FILE__)."/classes/Autoload.php");
$fields = array_unique(array_merge(CareerDev::$followupFields, array("check_date", "initial_survey_complete")));
$redcapData = Download::fields($token, $server, $fields);
$firstNames = Download::firstnames($token, $server);
$lastNames = Download::lastnames($token, $server);
$origDate = "pre 2018-09";
$surveyCompletes = array();
foreach ($redcapData as $row) {
if ($row['initial_survey_complete'] == '2') {
if (!isset($row['record_id'])) {
$surveyCompletes[$row['record_id']] = array();
}
if ($row['check_date']) {
$surveyCompletes[$row['record_id']]["initial_survey"] = $row['check_date'];
} else {
$surveyCompletes[$row['record_id']]["initial_survey"] = $origDate;
}
}
if ($row['redcap_repeat_instrument'] == "followup") {
if (!isset($row['record_id'])) {
$surveyCompletes[$row['record_id']] = array();
}
if ($row['followup_date']) {
$surveyCompletes[$row['record_id']]["followup"] = $row['followup_date'];
} else {
$surveyCompletes[$row['record_id']]["followup"] = $origDate;
}
}
}
?>
<style>
.red { color: red; }
</style>
<h1>Survey Completion Dates</h1>
<table class='centered'>
<tr class='even'>
<th>Name</th>
<th>Initial Survey Completion</th>
<th>Followup Survey Completion</th>
<th>Latest Any Survey Completion</th>
</tr>
<?php
$i = 1;
foreach ($firstNames as $recordId => $firstName) {
$rowClass = "even";
if ($i % 2 == 1) {
$rowClass = "odd";
}
$lastName = $lastNames[$recordId];
echo "<tr class='$rowClass'>\n";
echo "<td style='text-align: left;'>".Links::makeRecordHomeLink($pid, $recordId, "$firstName $lastName")."</td>\n";
if (isset($surveyCompletes[$recordId]) && isset($surveyCompletes[$recordId]["initial_survey"])) {
echo "<td class='centered'>".$surveyCompletes[$recordId]["initial_survey"]."</td>\n";
} else {
echo "<td class='red centered'>Missing</td>\n";
}
if (isset($surveyCompletes[$recordId]) && isset($surveyCompletes[$recordId]["followup"])) {
echo "<td class='centered'>".$surveyCompletes[$recordId]["followup"]."</td>\n";
} else {
echo "<td class='centered'></td>\n";
}
if (isset($surveyCompletes[$recordId])) {
if (isset($surveyCompletes[$recordId]["followup"])) {
echo "<td class='centered'>".$surveyCompletes[$recordId]["followup"]."</td>\n";
} else if (isset($surveyCompletes[$recordId]['initial_survey'])) {
echo "<td class='centered'>".$surveyCompletes[$recordId]["initial_survey"]."</td>\n";
} else {
echo "<td class='red centered'>Missing</td>";
}
} else {
echo "<td class='red centered'>Missing</td>\n";
}
echo "</tr>\n";
$i++;
}
?>
</table>