Merge pull request #1290 from MarkMpn/temp-basal-rate
Autotune compatibility change
This commit is contained in:
commit
76625e2a70
1 changed files with 9 additions and 2 deletions
|
@ -57,6 +57,7 @@ public class NSUpload {
|
||||||
data.put("eventType", CareportalEvent.TEMPBASAL);
|
data.put("eventType", CareportalEvent.TEMPBASAL);
|
||||||
data.put("duration", temporaryBasal.durationInMinutes);
|
data.put("duration", temporaryBasal.durationInMinutes);
|
||||||
data.put("absolute", temporaryBasal.absoluteRate);
|
data.put("absolute", temporaryBasal.absoluteRate);
|
||||||
|
data.put("rate", temporaryBasal.absoluteRate);
|
||||||
if (temporaryBasal.pumpId != 0)
|
if (temporaryBasal.pumpId != 0)
|
||||||
data.put("pumpId", temporaryBasal.pumpId);
|
data.put("pumpId", temporaryBasal.pumpId);
|
||||||
data.put("created_at", DateUtil.toISOString(temporaryBasal.date));
|
data.put("created_at", DateUtil.toISOString(temporaryBasal.date));
|
||||||
|
@ -81,12 +82,16 @@ public class NSUpload {
|
||||||
try {
|
try {
|
||||||
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
||||||
boolean useAbsolute = SP.getBoolean("ns_sync_use_absolute", false);
|
boolean useAbsolute = SP.getBoolean("ns_sync_use_absolute", false);
|
||||||
|
Profile profile = ProfileFunctions.getInstance().getProfile(temporaryBasal.date);
|
||||||
|
double absoluteRate = 0;
|
||||||
|
if (profile != null) {
|
||||||
|
absoluteRate = profile.getBasal(temporaryBasal.date) * temporaryBasal.percentRate / 100d;
|
||||||
|
}
|
||||||
if (useAbsolute) {
|
if (useAbsolute) {
|
||||||
TemporaryBasal t = temporaryBasal.clone();
|
TemporaryBasal t = temporaryBasal.clone();
|
||||||
t.isAbsolute = true;
|
t.isAbsolute = true;
|
||||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
|
||||||
if (profile != null) {
|
if (profile != null) {
|
||||||
t.absoluteRate = profile.getBasal(temporaryBasal.date) * temporaryBasal.percentRate / 100d;
|
t.absoluteRate = absoluteRate;
|
||||||
uploadTempBasalStartAbsolute(t, null);
|
uploadTempBasalStartAbsolute(t, null);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -95,6 +100,8 @@ public class NSUpload {
|
||||||
data.put("eventType", CareportalEvent.TEMPBASAL);
|
data.put("eventType", CareportalEvent.TEMPBASAL);
|
||||||
data.put("duration", temporaryBasal.durationInMinutes);
|
data.put("duration", temporaryBasal.durationInMinutes);
|
||||||
data.put("percent", temporaryBasal.percentRate - 100);
|
data.put("percent", temporaryBasal.percentRate - 100);
|
||||||
|
if (profile != null)
|
||||||
|
data.put("rate", absoluteRate);
|
||||||
if (temporaryBasal.pumpId != 0)
|
if (temporaryBasal.pumpId != 0)
|
||||||
data.put("pumpId", temporaryBasal.pumpId);
|
data.put("pumpId", temporaryBasal.pumpId);
|
||||||
data.put("created_at", DateUtil.toISOString(temporaryBasal.date));
|
data.put("created_at", DateUtil.toISOString(temporaryBasal.date));
|
||||||
|
|
Loading…
Reference in a new issue