Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

care site entropy #457

Merged
merged 2 commits into from
Sep 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ define(['jquery', 'knockout', 'ohdsi.util', 'appConfig', 'webapi/AuthAPI', 'atla
}, {
name: "Entropy",
reportKey: "Entropy",
analyses: [2031]
analyses: [2031, 2032]
}]);
/*
self.reports = ko.observableArray([
Expand Down
10 changes: 10 additions & 0 deletions js/components/report-manager.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@
</div>

<div id="reportEntropy" data-bind="if: model.currentReport() == 'Entropy' && !model.loadingReport()">
<div class="tab-pane" id="care_site_div">
<table id="care_site_table" class="display">
<thead>
<tr>
<th>Care Site</th>
</tr>
</thead>
</table>
</div>

<div class="pad-10 report">
<div class="reportHeading"><i class="fa fa-area-chart"></i> Entropy Report (<span data-bind="text:$component.model.reportSourceKey()"></span>)</div>
<div class="reportSectionHeading">Entropy by Date</div>
Expand Down
88 changes: 65 additions & 23 deletions js/components/report-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ define(['knockout', 'text!./report-manager.html', 'd3', 'atlascharts', 'colorbre
data: 'ethP'
}];

self.careSiteDatatable;

self.reportTriggerRunSuscription = self.model.reportTriggerRun.subscribe(function (newValue) {
if (newValue) {
self.runReport();
Expand Down Expand Up @@ -1853,31 +1855,71 @@ define(['knockout', 'text!./report-manager.html', 'd3', 'atlascharts', 'colorbre
break; // Data Completeness report
case 'Entropy':
$.ajax({
url: config.services[0].url + 'cohortresults/' + self.model.reportSourceKey() + '/' + self.model.reportCohortDefinitionId() + '/entropy',
//url: config.services[0].url + 'cohortresults/' + self.model.reportSourceKey() + '/' + self.model.reportCohortDefinitionId() + '/entropy',
url: config.services[0].url + 'cohortresults/' + self.model.reportSourceKey() + '/' + self.model.reportCohortDefinitionId() + '/allentropy',
success: function (data) {
self.model.currentReport(self.model.reportReportName());
self.model.loadingReport(false);

var entropyData = self.normalizeArray(data, true);
if (!entropyData.empty) {
var byDateSeries = self.mapDateDataToSeries(entropyData, {

dateField: 'date',
yValue: 'entropy',
yPercent: 'entropy'
});

var prevalenceByDate = new atlascharts.line();
prevalenceByDate.render(byDateSeries, "#entropyByDate", 400, 200, {
xScale: d3.scaleTime().domain(d3.extent(byDateSeries[0].values, function (d) {
return d.xValue;
})),
xFormat: d3.timeFormat("%Y/%m/%d"),
tickFormat: d3.timeFormat("%Y"),
xLabel: "Date",
yLabel: "Entropy"
});

var all_map_data = data.map(function(d) {
return d.insitution;
});
var care_site_array = [];
for(var i = 0; i < all_map_data.length; i++)
{
if (care_site_array.indexOf(all_map_data[i]) == -1){
care_site_array.push(all_map_data[i]);
}
}
var care_site_data = care_site_array.map(function(d) {
return {'institution': d};
});

self.careSiteDatatable = $('#care_site_table').DataTable({
order: [],
dom: 'Clfrtip',
data: care_site_data,
columns: [
{
data: 'institution'
}
],
pageLength: 5,
lengthChange: false,
deferRender: true,
destroy: true
});

$(document).on('click', '#care_site_table tbody tr', function () {
$('#care_site_table tbody tr.selected').removeClass('selected');
$(this).addClass('selected');

var institution_id = self.careSiteDatatable.data()[self.careSiteDatatable.row(this)[0]].institution;

var entropyData = self.normalizeArray(data.filter(function(d){ return d.insitution == institution_id; }), true);
if (!entropyData.empty) {
var byDateSeries = self.mapDateDataToSeries(entropyData, {

dateField: 'date',
yValue: 'entropy',
yPercent: 'entropy'
});

var prevalenceByDate = new atlascharts.line();
prevalenceByDate.render(byDateSeries, "#entropyByDate", 400, 200, {
xScale: d3.scaleTime().domain(d3.extent(byDateSeries[0].values, function (d) {
return d.xValue;
})),
xFormat: d3.timeFormat("%Y/%m/%d"),
yFormat: d3.format(".3f"),
tickFormat: d3.timeFormat("%Y"),
xLabel: "Date",
yLabel: "Entropy"
});
}
});

$('#care_site_table tbody tr:eq(0)').click();
}
});
break; // Entropy report
Expand Down Expand Up @@ -2569,7 +2611,7 @@ define(['knockout', 'text!./report-manager.html', 'd3', 'atlascharts', 'colorbre
yLabel: "% Persons",
seriesName: "recordType",
showLegend: true,
colors: d3.scale.category10(),
colors: d3.scaleOrdinal(d3.schemeCategory10),
tooltips: [
{
label: 'Series',
Expand Down Expand Up @@ -2862,7 +2904,7 @@ define(['knockout', 'text!./report-manager.html', 'd3', 'atlascharts', 'colorbre
if (data && !data.empty) {
for (var i = 0; i < data[options.dateField].length; i++) {
series.values.push({
xValue: new Date(data[options.dateField][i]),
xValue: new Date(new Date(data[options.dateField][i]).getTime() + (new Date().getTimezoneOffset() + 60) * 60000), //offset timezone for date of "yyyy-mm-dd"
yValue: data[options.yValue][i],
yPercent: data[options.yPercent][i]
});
Expand Down