Skip to content

Commit

Permalink
Copied nightscout#5442 - Duplicated @c-robertson's work
Browse files Browse the repository at this point in the history
  • Loading branch information
inventor96 committed Jan 21, 2021
1 parent fe9e512 commit b1ac0fa
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 22 deletions.
12 changes: 11 additions & 1 deletion lib/client/careportal.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function init (client, $) {
submitHooks = {};

_.forEach(careportal.allEventTypes, function each (event) {
inputMatrix[event.val] = _.pick(event, ['otp','remoteCarbs', 'remoteAbsorption', 'remoteBolus', 'bg', 'insulin', 'carbs', 'protein', 'fat', 'prebolus', 'duration', 'percent', 'absolute', 'profile', 'split', 'reasons', 'targets']);
inputMatrix[event.val] = _.pick(event, ['otp','remoteCarbs', 'remoteAbsorption', 'remoteBolus', 'bg', 'insulin', 'carbs', 'protein', 'fat', 'prebolus', 'duration', 'percent', 'absolute', 'profile', 'split', 'sensor', 'reasons', 'targets']);
submitHooks[event.val] = event.submitHook;
});
}
Expand Down Expand Up @@ -92,6 +92,8 @@ function init (client, $) {
$('#proteinGivenLabel').css('display', displayType(inputMatrix[eventType]['protein']));
$('#fatGivenLabel').css('display', displayType(inputMatrix[eventType]['fat']));

$('#sensorInfo').css('display', displayType(inputMatrix[eventType]['sensor']));

$('#durationLabel').css('display', displayType(inputMatrix[eventType]['duration']));
$('#percentLabel').css('display', displayType(inputMatrix[eventType]['percent'] && $('#absolute').val() === ''));
$('#absoluteLabel').css('display', displayType(inputMatrix[eventType]['absolute'] && $('#percent').val() === ''));
Expand All @@ -115,6 +117,8 @@ function init (client, $) {
resetIfHidden(inputMatrix[eventType]['carbs'], '#carbsGiven');
resetIfHidden(inputMatrix[eventType]['protein'], '#proteinGiven');
resetIfHidden(inputMatrix[eventType]['fat'], '#fatGiven');
resetIfHidden(inputMatrix[eventType]['sensor'], '#sensorCode');
resetIfHidden(inputMatrix[eventType]['sensor'], '#transmitterId');
resetIfHidden(inputMatrix[eventType]['duration'], '#duration');
resetIfHidden(inputMatrix[eventType]['absolute'], '#absolute');
resetIfHidden(inputMatrix[eventType]['percent'], '#percent');
Expand Down Expand Up @@ -213,6 +217,8 @@ function init (client, $) {
$('#carbsGiven').val('');
$('#proteinGiven').val('');
$('#fatGiven').val('');
$('#sensorCode').val('');
$('#transmitterId').val('');
$('#insulinGiven').val('');
$('#duration').val('');
$('#percent').val('');
Expand Down Expand Up @@ -244,6 +250,8 @@ function init (client, $) {
, carbs: $('#carbsGiven').val()
, protein: $('#proteinGiven').val()
, fat: $('#fatGiven').val()
, sensorCode: $('#sensorCode').val()
, transmitterId: $('#transmitterId').val()
, insulin: $('#insulinGiven').val()
, duration: times.msecs(parse_duration($('#duration').val())).mins < 1 ? $('#duration').val() : times.msecs(parse_duration($('#duration').val())).mins
, percent: $('#percent').val()
Expand Down Expand Up @@ -415,6 +423,8 @@ function init (client, $) {
pushIf(data.carbs, translate('Carbs Given') + ': ' + data.carbs);
pushIf(data.protein, translate('Protein Given') + ': ' + data.protein);
pushIf(data.fat, translate('Fat Given') + ': ' + data.fat);
pushIf(data.sensorCode, translate('Sensor Code') + ': ' + data.sensorCode);
pushIf(data.transmitterId, translate('Transmitter ID') + ': ' + data.transmitterId);
pushIf(data.insulin, translate('Insulin Given') + ': ' + data.insulin);
pushIf(data.eventType === 'Combo Bolus', translate('Combo Bolus') + ': ' + data.splitNow + '% : ' + data.splitExt + '%');
pushIf(data.duration, translate('Duration') + ': ' + data.duration + ' ' + translate('mins'));
Expand Down
42 changes: 21 additions & 21 deletions lib/plugins/careportal.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,87 +15,87 @@ function init() {
return [
{ val: '<none>'
, name: '<none>'
, bg: true, insulin: true, carbs: true, protein: false, fat: false, prebolus: false, duration: false, percent: false, absolute: false, profile: false, split: false
, bg: true, insulin: true, carbs: true, protein: false, fat: false, prebolus: false, duration: false, percent: false, absolute: false, profile: false, split: false, sensor: false
}
, { val: 'BG Check'
, name: 'BG Check'
, bg: true, insulin: false, carbs: false, protein: false, fat: false, prebolus: false, duration: false, percent: false, absolute: false, profile: false, split: false
, bg: true, insulin: false, carbs: false, protein: false, fat: false, prebolus: false, duration: false, percent: false, absolute: false, profile: false, split: false, sensor: false
}
, { val: 'Snack Bolus'
, name: 'Snack Bolus'
, bg: true, insulin: true, carbs: true, protein: true, fat: true, prebolus: true, duration: false, percent: false, absolute: false, profile: false, split: false
, bg: true, insulin: true, carbs: true, protein: true, fat: true, prebolus: true, duration: false, percent: false, absolute: false, profile: false, split: false, sensor: false
}
, { val: 'Meal Bolus'
, name: 'Meal Bolus'
, bg: true, insulin: true, carbs: true, protein: true, fat: true, prebolus: true, duration: false, percent: false, absolute: false, profile: false, split: false
, bg: true, insulin: true, carbs: true, protein: true, fat: true, prebolus: true, duration: false, percent: false, absolute: false, profile: false, split: false, sensor: false
}
, { val: 'Correction Bolus'
, name: 'Correction Bolus'
, bg: true, insulin: true, carbs: false, protein: false, fat: false, prebolus: false, duration: false, percent: false, absolute: false, profile: false, split: false
, bg: true, insulin: true, carbs: false, protein: false, fat: false, prebolus: false, duration: false, percent: false, absolute: false, profile: false, split: false, sensor: false
}
, { val: 'Carb Correction'
, name: 'Carb Correction'
, bg: true, insulin: false, carbs: true, protein: true, fat: true, prebolus: false, duration: false, percent: false, absolute: false, profile: false, split: false
, bg: true, insulin: false, carbs: true, protein: true, fat: true, prebolus: false, duration: false, percent: false, absolute: false, profile: false, split: false, sensor: false
}
, { val: 'Combo Bolus'
, name: 'Combo Bolus'
, bg: true, insulin: true, carbs: true, protein: true, fat: true, prebolus: true, duration: true, percent: false, absolute: false, profile: false, split: true
, bg: true, insulin: true, carbs: true, protein: true, fat: true, prebolus: true, duration: true, percent: false, absolute: false, profile: false, split: true, sensor: false
}
, { val: 'Announcement'
, name: 'Announcement'
, bg: true, insulin: false, carbs: false, protein: false, fat: false, prebolus: false, duration: false, percent: false, absolute: false, profile: false, split: false
, bg: true, insulin: false, carbs: false, protein: false, fat: false, prebolus: false, duration: false, percent: false, absolute: false, profile: false, split: false, sensor: false
}
, { val: 'Note'
, name: 'Note'
, bg: true, insulin: false, carbs: false, protein: false, fat: false, prebolus: false, duration: true, percent: false, absolute: false, profile: false, split: false
, bg: true, insulin: false, carbs: false, protein: false, fat: false, prebolus: false, duration: true, percent: false, absolute: false, profile: false, split: false, sensor: false
}
, { val: 'Question'
, name: 'Question'
, bg: true, insulin: false, carbs: false, protein: false, fat: false, prebolus: false, duration: false, percent: false, absolute: false, profile: false, split: false
, bg: true, insulin: false, carbs: false, protein: false, fat: false, prebolus: false, duration: false, percent: false, absolute: false, profile: false, split: false, sensor: false
}
, { val: 'Exercise'
, name: 'Exercise'
, bg: false, insulin: false, carbs: false, protein: false, fat: false, prebolus: false, duration: true, percent: false, absolute: false, profile: false, split: false
, bg: false, insulin: false, carbs: false, protein: false, fat: false, prebolus: false, duration: true, percent: false, absolute: false, profile: false, split: false, sensor: false
}
, { val: 'Site Change'
, name: 'Pump Site Change'
, bg: true, insulin: true, carbs: false, protein: false, fat: false, prebolus: false, duration: false, percent: false, absolute: false, profile: false, split: false
, bg: true, insulin: true, carbs: false, protein: false, fat: false, prebolus: false, duration: false, percent: false, absolute: false, profile: false, split: false, sensor: false
}
, { val: 'Sensor Start'
, name: 'CGM Sensor Start'
, bg: true, insulin: false, carbs: false, protein: false, fat: false, prebolus: false, duration: false, percent: false, absolute: false, profile: false, split: false
, bg: true, insulin: false, carbs: false, protein: false, fat: false, prebolus: false, duration: false, percent: false, absolute: false, profile: false, split: false, sensor: true
}
, { val: 'Sensor Change'
, name: 'CGM Sensor Insert'
, bg: true, insulin: false, carbs: false, protein: false, fat: false, prebolus: false, duration: false, percent: false, absolute: false, profile: false, split: false
, bg: true, insulin: false, carbs: false, protein: false, fat: false, prebolus: false, duration: false, percent: false, absolute: false, profile: false, split: false, sensor: false
}
, { val: 'Sensor Stop'
, name: 'CGM Sensor Stop'
, bg: true, insulin: false, carbs: false, prebolus: false, duration: false, percent: false, absolute: false, profile: false, split: false
, bg: true, insulin: false, carbs: false, prebolus: false, duration: false, percent: false, absolute: false, profile: false, split: false, sensor: false
}
, { val: 'Pump Battery Change'
, name: 'Pump Battery Change'
, bg: true, insulin: false, carbs: false, protein: false, fat: false, prebolus: false, duration: false, percent: false, absolute: false, profile: false, split: false
, bg: true, insulin: false, carbs: false, protein: false, fat: false, prebolus: false, duration: false, percent: false, absolute: false, profile: false, split: false, sensor: false
}
, { val: 'Insulin Change'
, name: 'Insulin Cartridge Change'
, bg: true, insulin: false, carbs: false, protein: false, fat: false, prebolus: false, duration: false, percent: false, absolute: false, profile: false, split: false
, bg: true, insulin: false, carbs: false, protein: false, fat: false, prebolus: false, duration: false, percent: false, absolute: false, profile: false, split: false, sensor: false
}
, { val: 'Temp Basal Start'
, name: 'Temp Basal Start'
, bg: true, insulin: false, carbs: false, protein: false, fat: false, prebolus: false, duration: true, percent: true, absolute: true, profile: false, split: false
, bg: true, insulin: false, carbs: false, protein: false, fat: false, prebolus: false, duration: true, percent: true, absolute: true, profile: false, split: false, sensor: false
}
, { val: 'Temp Basal End'
, name: 'Temp Basal End'
, bg: true, insulin: false, carbs: false, protein: false, fat: false, prebolus: false, duration: true, percent: false, absolute: false, profile: false, split: false
, bg: true, insulin: false, carbs: false, protein: false, fat: false, prebolus: false, duration: true, percent: false, absolute: false, profile: false, split: false, sensor: false
}
, { val: 'Profile Switch'
, name: 'Profile Switch'
, bg: true, insulin: false, carbs: false, protein: false, fat: false, prebolus: false, duration: true, percent: false, absolute: false, profile: true, split: false
, bg: true, insulin: false, carbs: false, protein: false, fat: false, prebolus: false, duration: true, percent: false, absolute: false, profile: true, split: false, sensor: false
}
, { val: 'D.A.D. Alert'
, name: 'D.A.D. Alert'
, bg: true, insulin: false, carbs: false, protein: false, fat: false, prebolus: false, duration: false, percent: false, absolute: false, profile: false, split: false
, bg: true, insulin: false, carbs: false, protein: false, fat: false, prebolus: false, duration: false, percent: false, absolute: false, profile: false, split: false, sensor: false
}
];

Expand Down
12 changes: 12 additions & 0 deletions views/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,18 @@
</label>
</fieldset>

<fieldset id="sensorInfo">
<legend class="translate">Sensor</legend>
<label id="sensorCodeLabel" for="sensorCode" class="left-column short-label">
<span class="translate">Sensor Code</span>
<input type="text" id="sensorCode" />
</label>
<label id="txIdLabel" for="transmitterId" class="left-column short-label">
<span class="translate">Tx ID</span>
<input type="text" id="transmitterId" />
</label>
</fieldset>

<label id="insulinGivenLabel" for="insulinGiven" class="left-column short-label">
<span class="translate">Insulin Given</span>
<input type="number" step="any" min="0" id="insulinGiven" placeholder="Amount in units" class="titletranslate" pattern="[0-9.,]*">
Expand Down

0 comments on commit b1ac0fa

Please sign in to comment.