Skip to content

Commit fa18074

Browse files
Simplify the vitals auditing feature
1 parent ec83924 commit fa18074

File tree

7 files changed

+75
-260
lines changed

7 files changed

+75
-260
lines changed

docs/StudentHealthTracking.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,12 @@ sent.
6363
View the **Cause of Death Report** and the **Student Health Report** by navigating to the Reports module and clicking
6464
on the appropriate report title.
6565

66-
## Student Vitals Dashlet
67-
A new dashlet is available to track the number of days students are in a given Vitals status. This dashlet leverages
68-
the Contacts Audit table to populate a pie chart summarizing the number of days all Students in a given Super Group (or all Super Groups)
69-
are in each Vital status.
66+
## Common Student Injuries dashlet
67+
A new dashlet is available to track the number of times Students are injured over time. This dashlet leverages
68+
the Contacts Audit table to populate a pie chart summarizing the number of times Students for in a given Super Group (or all Super Groups) enter a non-active Vital Status.
7069

7170
This dashlet displays use of the Sucrose charts in a custom dashlet and is available in Home, List Views, and Record Views.
7271

73-
There is also an accompanying API enpoint for retrieve the data from the Student records and shows use of Sugar Query in joins
74-
and union queries. For more information on the endpoint see <instnace>/rest/v11/help.
72+
There is also an accompanying API endpoint for retrieve the data from the Student records and shows use of Doctrine QueryBuilder in a complex parameterized query that can't be created using SugarQuery APIs. For more information on the endpoint see <instnace>/rest/v11/help.
7573

7674
The pull request for the Student vitals dashlet can be viewed in [#27](https://github.com/sugarcrm/school/pull/27).
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22

3-
$app_strings['LBL_STUDENT_VITAL_CHART_DESC'] = 'Pie Chart grouping combined days in vitals status';
4-
$app_strings['LBL_STUDENT_VITAL_CHART'] = 'Student Vitals Chart';
3+
$app_strings['LBL_STUDENT_VITAL_CHART_DESC'] = 'Pie Chart shows most common student body problems over time';
4+
$app_strings['LBL_STUDENT_VITAL_CHART'] = 'Student Body Problems';
55
$app_strings['LBL_VITALS_DASHLET_SELECT_TEAM'] = 'Select Super Group to view data on';
6-
$app_strings['LBL_VITALS_DASHLET_SELECT_DATE_RANGE'] = 'Select Date Range';
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
$app_list_strings['problems_list'] = array (
4+
'injured' => 'Injuries',
5+
'comatose' => 'Comas',
6+
'deceased' => 'Deaths',
7+
);

package/src/custom/clients/base/api/StudentVitalsApi.php

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
<?php
22

33

4-
use Sugarcrm\Sugarcrm\ProcessManager\Registry;
5-
6-
74
class StudentVitalsApi extends SugarApi
85
{
96
public function registerApiRest()
@@ -33,41 +30,53 @@ public function getStudentVitalData($api, $args)
3330
{
3431

3532
global $app_list_strings;
36-
require_once('custom/include/ProfessorM/StudentVitalHelper.php');
3733
$supergroup = $args['supergroup'];
38-
$helper = new \Sugarcrm\ProfessorM\Helpers\StudentVitalHelper();
39-
$status_data = $helper->getStudentVitalsByDays($supergroup);
34+
$helper = new \Sugarcrm\Sugarcrm\custom\inc\ProfessorM\StudentVitalHelper();
35+
$status_data = $helper->countStudentIncidents($supergroup);
36+
4037

4138
// Sort if we have an array
4239
if (is_array($status_data)) {
4340
arsort($status_data);
4441
}
45-
$chart_data = array(
46-
47-
);
42+
$chart_data = array();
4843

44+
$seriesIdx = 1;
4945
foreach ($status_data as $key => $value) {
46+
if (!empty($key)) {
5047

51-
$chart_data[] = array(
52-
"key" => $app_list_strings['vitals_list'][$key],
53-
"values" => array(
54-
array("x"=> 1, "y"=> $value),
55-
)
56-
);
48+
$app_list_strings['problems_list'][$key];
5749

50+
$chart_data[] = array(
51+
"key" => $app_list_strings['problems_list'][$key],
52+
"value" => $value,
53+
"total" => $value,
54+
"seriesIndex" => $seriesIdx++
55+
);
56+
}
57+
58+
}
59+
60+
$title = '';
61+
if($supergroup != 'all') {
62+
$sg = BeanFactory::retrieveBean("Accounts", $supergroup);
63+
$title = "$sg->name Student Problems";
64+
} else {
65+
$title = "All Student Problems";
5866
}
67+
5968
$data = array(
6069
"properties" => array(
61-
"title" => "Student Vitals Days Count",
70+
"title" => $title,
71+
"seriesName" => "Problems"
6272
),
6373
"data"=> $chart_data
6474

6575

6676
);
6777

6878

69-
70-
return json_encode($data);
79+
return $data;
7180

7281
}
7382

package/src/custom/clients/base/views/student-vital-chart/student-vital-chart.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@
3737
(total == 0) ? total = 1 : '';
3838
var percentage = value/total * 100;
3939
return '<h3>' + this.chart.fmtKey()(eo) + '</h3>' +
40-
'<p>' + value + ' days</p>' +
40+
'<p>' + value + '</p>' +
4141
'<p>' + percentage.toFixed(2) + '%</p>';
4242
}, this))
4343
.strings({
44-
noData: app.lang.get('LBL_CHART_NO_DATA')
44+
noData: app.lang.get('No Problems')
4545
});
4646
},
4747

@@ -80,13 +80,12 @@
8080
renderChart: function() {
8181
var self = this;
8282
if (!self.isChartReady()) {
83-
8483
return;
8584
}
8685

87-
8886
d3sugar.select(this.el).select('svg#' + this.cid)
8987
.datum(self.chartCollection)
88+
.transition().duration(500)
9089
.call(self.chart);
9190

9291
this.chart_loaded = _.isFunction(this.chart.update);
@@ -123,7 +122,7 @@
123122

124123
this.total = 1;
125124
this.hasData = true;
126-
this.chartCollection = $.parseJSON(data);
125+
this.chartCollection = data;
127126

128127
},
129128

package/src/custom/clients/base/views/student-vital-chart/student-vital-chart.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
'label' => 'LBL_STUDENT_VITAL_CHART',
77
'description' => 'LBL_STUDENT_VITAL_CHART_DESC',
88
'config' => array(
9-
'date_range' => 'all',
109
'supergroup' => 'all',
1110
),
1211
'preview' => array(
@@ -36,13 +35,6 @@
3635
'span' => 6,
3736
'options' => array('all' => 'All'),
3837
),
39-
array(
40-
'name' => 'vitals_dashlet_date_range',
41-
'label' => 'LBL_VITALS_DASHLET_SELECT_DATE_RANGE',
42-
'type' => 'enum',
43-
'span' => 6,
44-
'options' => array('all' => 'All Time', 'ThisYear' => 'This Year', 'LastYear' => 'Last Year'),
45-
),
4638
),
4739
),
4840
),

0 commit comments

Comments
 (0)