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

Add Loop Carbs foodType, absorptionTime to Reports for ISSUE #5701 #5702

Merged
merged 14 commits into from
Sep 12, 2020
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: 2 additions & 0 deletions lib/report_plugins/daytoday.js
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,8 @@ daytoday.report = function report_daytoday (datastorage, sorteddaystoshow, optio

if (treatment.carbs && options.carbs) {
var label = ' ' + treatment.carbs + ' g';
label += treatment.foodType ? ' ' + treatment.foodType : ''
label += treatment.absorptionTime ? ' ' + (Math.round(treatment.absorptionTime / 60.0 * 10) / 10) + 'h' : ''
if (treatment.protein) label += ' / ' + treatment.protein + ' g';
if (treatment.fat) label += ' / ' + treatment.fat + ' g';

Expand Down
26 changes: 23 additions & 3 deletions lib/report_plugins/treatments.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ treatments.report = function report_treatments(datastorage, sorteddaystoshow, op
.append($('<th>').css('width','150px').attr('align','left').append(translate('Event Type')))
.append($('<th>').css('width','150px').attr('align','left').append(translate('Blood Glucose')))
.append($('<th>').css('width','50px').attr('align','left').append(translate('Insulin')))
.append($('<th>').css('width','50px').attr('align','left').append(translate('Carbs')))
.append($('<th>').css('width','100px').attr('align','left').append(translate('Carbs/Food/Time')))
.append($('<th>').css('width','50px').attr('align','left').append(translate('Protein')))
.append($('<th>').css('width','50px').attr('align','left').append(translate('Fat')))
.append($('<th>').css('width','50px').attr('align','left').append(translate('Duration')))
Expand All @@ -316,17 +316,37 @@ treatments.report = function report_treatments(datastorage, sorteddaystoshow, op
}
for (var t=0; t<treatments.length; t++) {
var tr = treatments[t];
var carbs = tr.carbs ? tr.carbs : ''
carbs += tr.foodType ? ' ' + tr.foodType : ''
carbs += tr.absorptionTime ? ' ' + (Math.round(tr.absorptionTime / 60.0 * 10) / 10) + 'h' : ''
var correctionRangeText = '';
if (tr.correctionRange) {
var min = tr.correctionRange[0];
var max = tr.correctionRange[1];

if (client.settings.units === 'mmol') {
max = client.utils.roundBGToDisplayFormat(client.utils.scaleMgdl(max));
min = client.utils.roundBGToDisplayFormat(client.utils.scaleMgdl(min));
}

if (tr.correctionRange[0] === tr.correctionRange[1]) {
correctionRangeText = '' + min;
} else {
correctionRangeText = '' + min + ' - ' + max;
}
}
table.append($('<tr>').addClass('border_bottom')
.append($('<td>')
.append($('<img>').addClass('deleteTreatment').css('cursor','pointer').attr('title',translate('Delete record')).attr('src',icon_remove).attr('data',JSON.stringify(tr)).attr('day',day))
.append('&nbsp;')
.append($('<img>').addClass('editTreatment').css('cursor','pointer').attr('title',translate('Edit record')).attr('src',icon_edit).attr('data',JSON.stringify(tr)).attr('day',day))
)
.append($('<td>').append(new Date(tr.created_at).toLocaleTimeString().replace(/([\d]+:[\d]{2})(:[\d]{2})(.*)/, '$1$3')))
.append($('<td>').append(tr.eventType ? translate(client.careportal.resolveEventName(tr.eventType)) : ''))
.append($('<td>').append(tr.eventType ? translate(client.careportal.resolveEventName(tr.eventType)) + (tr.reason ? '<br>' + tr.reason : '') +
(tr.insulinNeedsScaleFactor ? '<br>' + tr.insulinNeedsScaleFactor * 100 + '%' : '') + (tr.correctionRange ? ' ' + correctionRangeText : '') : ''))
.append($('<td>').attr('align','center').append(tr.glucose ? tr.glucose + ' ('+translate(tr.glucoseType)+')' : ''))
.append($('<td>').attr('align','center').append(tr.insulin ? tr.insulin.toFixed(2) : ''))
.append($('<td>').attr('align','center').append(tr.carbs ? tr.carbs : ''))
.append($('<td>').attr('align','center').append(carbs))
.append($('<td>').attr('align','center').append(tr.protein ? tr.protein : ''))
.append($('<td>').attr('align','center').append(tr.fat ? tr.fat : ''))
.append($('<td>').attr('align','center').append(tr.duration ? tr.duration.toFixed(0) : ''))
Expand Down