Skip to content
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
8 changes: 8 additions & 0 deletions bin/oref0-autotune-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ if (!module.parent) {
return console.error("Could not parse input data: ", e);
}

// Pump profile has an up to date copy of useCustomPeakTime from preferences
// If the preferences file has useCustomPeakTime use the previous autotune dia and PeakTime.
// Otherwise, use data from pump profile.
if (!pumpprofile_data.useCustomPeakTime) {
previous_autotune_data.dia = pumpprofile_data.dia;
previous_autotune_data.insulinPeakTime = pumpprofile_data.insulinPeakTime;
}

var inputs = {
preppedGlucose: prepped_glucose_data
, previousAutotune: previous_autotune_data
Expand Down
11 changes: 11 additions & 0 deletions bin/oref0-autotune-prep.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,17 @@ if (!module.parent) {
}
}

// get insulin curve from pump profile that is maintained
profile_data.curve = pumpprofile_data.curve;

// Pump profile has an up to date copy of useCustomPeakTime from preferences
// If the preferences file has useCustomPeakTime use the previous autotune dia and PeakTime.
// Otherwise, use data from pump profile.
if (!pumpprofile_data.useCustomPeakTime) {
profile_data.dia = pumpprofile_data.dia;
profile_data.insulinPeakTime = pumpprofile_data.insulinPeakTime;
}

try {
var glucose_data = JSON.parse(fs.readFileSync(glucose_input, 'utf8'));
} catch (e) {
Expand Down
110 changes: 108 additions & 2 deletions tests/command-behavior.tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,15 @@ test-ns-status () {

test-autotune-core () {
# Run autotune-core and capture output
../bin/oref0-autotune-core.js autotune.data.json profile.json profile.json 2>stderr_output 1>stdout_output
../bin/oref0-autotune-core.js autotune.data.json profile.json pumpprofile.json 2>stderr_output 1>stdout_output

ERROR_LINE_COUNT=$( cat stderr_output | wc -l )
ERROR_LINES=$( cat stderr_output )
cat stderr_output | grep -q CRTotalCarbs || fail_test "oref0-autotune-core didn't contain expected stderr output"

# Make sure output has accurate carb ratio data
cat stdout_output | jq .carb_ratio | grep -q 22.142 || fail_test "oref0-autotune-core didn't contain expected carb_ratio output"
cat stdout_output | jq .dia | grep -q 7 || fail_test "oref0-autotune-core didn't contain expected dia output"
cat stdout_output | jq .insulinPeakTime | grep -q 85 || fail_test "oref0-autotune-core didn't contain expected insulinPeakTime output"

# If we made it here, the test passed
echo "oref0-autotune-core test passed"
Expand Down Expand Up @@ -582,6 +583,111 @@ EOT
"useCustomPeakTime": true,
"wide_bg_target_range": false
}
EOT

# Make a dummy pumpprofile.json
cat >pumpprofile.json <<EOT
{
"A52_risk_enable": false,
"adv_target_adjustments": false,
"allowSMB_with_high_temptarget": false,
"autosens_max": 1.2,
"autosens_min": 0.8,
"autotune_isf_adjustmentFraction": 0,
"basalprofile": [
{
"i": 0,
"minutes": 0,
"rate": 0.63,
"start": "00:00:00"
}
],
"bg_targets": {
"first": 0,
"targets": [
{
"high": 110,
"i": 0,
"low": 110,
"max_bg": 110,
"min_bg": 110,
"offset": 0,
"start": "00:00:00",
"x": 0
}
],
"units": "mg/dL",
"user_preferred_units": "mg/dL"
},
"bolussnooze_dia_divisor": 2,
"carb_ratio": 22.142,
"carb_ratios": {
"first": 1,
"schedule": [
{
"i": 0,
"offset": 0,
"ratio": 20,
"start": "00:00:00",
"x": 0
}
],
"units": "grams"
},
"carbsReqThreshold": 1,
"csf": 3.815,
"current_basal": 0.65,
"current_basal_safety_multiplier": 4,
"curve": "rapid-acting",
"dia": 8,
"enableSMB_after_carbs": false,
"enableSMB_always": true,
"enableSMB_with_COB": true,
"enableSMB_with_temptarget": true,
"enableUAM": true,
"exercise_mode": false,
"half_basal_exercise_target": 160,
"high_temptarget_raises_sensitivity": false,
"insulinPeakTime": 90,
"isfProfile": {
"first": 1,
"sensitivities": [
{
"endOffset": 1440,
"i": 0,
"offset": 0,
"sensitivity": 100,
"start": "00:00:00",
"x": 0
}
],
"units": "mg/dL",
"user_preferred_units": "mg/dL"
},
"low_temptarget_lowers_sensitivity": false,
"maxCOB": 120,
"maxSMBBasalMinutes": 30,
"max_basal": 2.8,
"max_bg": 110,
"max_daily_basal": 0.75,
"max_daily_safety_multiplier": 3,
"max_iob": 7,
"min_5m_carbimpact": 8,
"min_bg": 110,
"model": "723",
"offline_hotspot": false,
"out_units": "mg/dL",
"remainingCarbsCap": 90,
"remainingCarbsFraction": 1,
"resistance_lowers_target": false,
"rewind_resets_autosens": true,
"sens": 100,
"sensitivity_raises_target": true,
"suspend_zeros_iob": true,
"unsuspend_if_no_temp": false,
"useCustomPeakTime": true,
"wide_bg_target_range": false
}
EOT

# Make a dummy basal_profile.json
Expand Down