Skip to content

Commit

Permalink
Added a specific rendering for BG Check events on the Day to Day repo…
Browse files Browse the repository at this point in the history
…rt. (#6530)

Added an option to hide BG Check and other events on the Day to Day report.

Co-authored-by: Sulka Haro <[email protected]>
  • Loading branch information
yodax and sulkaharo authored Feb 2, 2021
1 parent d762694 commit 6643eb9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
4 changes: 3 additions & 1 deletion lib/report/reportclient.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,9 @@ var init = function init () {
options.cob = true;
options.openAps = true;
}

options.bgcheck = $('#rp_optionsbgcheck').is(':checked');
options.othertreatments = $('#rp_optionsothertreatments').is(':checked');

const reportStorage = require('./reportstorage');
reportStorage.saveProps(options);
var matchesneeded = 0;
Expand Down
4 changes: 3 additions & 1 deletion lib/report/reportstorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ const defaultValues = {
predicted: false,
openAps: false,
insulindistribution: true,
predictedTruncate: true
predictedTruncate: true,
bgcheck: true,
othertreatments: false
};
let cachedProps;

Expand Down
15 changes: 13 additions & 2 deletions lib/report_plugins/daytoday.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ daytoday.html = function html (client) {
`<label><input type="checkbox" id="rp_optionspredicted" ${reportStorage.getValue('predicted') ? "checked" : ""}><span style="color:sienna;opacity:0.5">${translate('Predictions')}</span></label>` +
`<label><input type="checkbox" id="rp_optionsopenaps" ${reportStorage.getValue('openAps') ? "checked" : ""}><span style="color:sienna;opacity:0.5">${translate('OpenAPS')}</span></label>` +
`<label><input type="checkbox" id="rp_optionsdistribution" ${reportStorage.getValue('insulindistribution') ? "checked" : ""}><span style="color:blue;opacity:0.5">${translate('Insulin distribution')}</span></label>` +
`<label><input type="checkbox" id="rp_optionsbgcheck" ${reportStorage.getValue('bgcheck') ? "checked" : ""}><span style="color:#ff0000;opacity:0.5">${translate('BG Check')}</span></label>` +
`<label><input type="checkbox" id="rp_optionsothertreatments" ${reportStorage.getValue('othertreatments') ? "checked" : ""}>${translate('View all treatments')}</span></label>` +
'&nbsp;' + translate('Size') +
' <select id="rp_size">' +
' <option x="800" y="250">800x250px</option>' +
Expand Down Expand Up @@ -873,7 +875,16 @@ daytoday.report = function report_daytoday (datastorage, sorteddaystoshow, optio
.attr('y', yScale2(client.utils.scaleMgdl(414)) + padding.top)
.attr('x', xScale2(treatment.mills + times.mins(treatment.duration).msecs / 2) + padding.left)
.text(treatment.reason);
} else if (!treatment.duration) {
} else if (treatment.eventType === 'BG Check' && !treatment.duration && options.bgcheck) {
context.append('circle')
.attr('cx', xScale2(treatment.mills) + padding.left)
.attr('cy', yScale2(scaledTreatmentBG(treatment, data.sgv)) + padding.top)
.attr('fill', 'red')
.style('opacity', 1)
.attr('stroke-width', 1)
.attr('stroke', 'darkred')
.attr('r', 4);
} else if (!treatment.duration && options.othertreatments) {
// other treatments without duration
context.append('circle')
.attr('cx', xScale2(treatment.mills) + padding.left)
Expand All @@ -890,7 +901,7 @@ daytoday.report = function report_daytoday (datastorage, sorteddaystoshow, optio
.attr('y', yScale2(scaledTreatmentBG(treatment, data.sgv)) + padding.top - 10)
.attr('x', xScale2(treatment.mills) + padding.left + 10)
.text(translate(client.careportal.resolveEventName(treatment.eventType)));
} else if (treatment.duration) {
} else if (treatment.duration && options.othertreatments) {
// other treatments with duration
context.append('rect')
.attr('x', xScale2(treatment.mills) + padding.left)
Expand Down

0 comments on commit 6643eb9

Please sign in to comment.