Skip to content

Commit

Permalink
Add Loop Carbs foodType, absorptionTime to Reports for ISSUE #5701 (#…
Browse files Browse the repository at this point in the history
…5702)

* add carb foodType, absorptionTime to reports
  • Loading branch information
kskandispersonal authored Sep 12, 2020
1 parent 5aef245 commit be422f0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
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

0 comments on commit be422f0

Please sign in to comment.