add SMB flag to treatments
This commit is contained in:
parent
6de154d16d
commit
066283a4b0
4 changed files with 28 additions and 13 deletions
|
@ -29,4 +29,5 @@ public class DetailedBolusInfo {
|
||||||
public Context context = null; // context for progress dialog
|
public Context context = null; // context for progress dialog
|
||||||
public boolean addToTreatments = true;
|
public boolean addToTreatments = true;
|
||||||
public long pumpId = 0; // id of record if comming from pump history (not a newly created treatment)
|
public long pumpId = 0; // id of record if comming from pump history (not a newly created treatment)
|
||||||
|
public boolean isSMB = false; // is a Super-MicroBolus
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
public static final String DATABASE_CAREPORTALEVENTS = "CareportalEvents";
|
public static final String DATABASE_CAREPORTALEVENTS = "CareportalEvents";
|
||||||
public static final String DATABASE_PROFILESWITCHES = "ProfileSwitches";
|
public static final String DATABASE_PROFILESWITCHES = "ProfileSwitches";
|
||||||
|
|
||||||
private static final int DATABASE_VERSION = 7;
|
private static final int DATABASE_VERSION = 8;
|
||||||
|
|
||||||
private static Long earliestDataChange = null;
|
private static Long earliestDataChange = null;
|
||||||
|
|
||||||
|
@ -113,6 +113,11 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
@Override
|
@Override
|
||||||
public void onUpgrade(SQLiteDatabase database, ConnectionSource connectionSource, int oldVersion, int newVersion) {
|
public void onUpgrade(SQLiteDatabase database, ConnectionSource connectionSource, int oldVersion, int newVersion) {
|
||||||
try {
|
try {
|
||||||
|
if (oldVersion == 7 && newVersion == 8) {
|
||||||
|
log.debug("Upgrading database from v7 to v8");
|
||||||
|
TableUtils.dropTable(connectionSource, Treatment.class, true);
|
||||||
|
TableUtils.createTableIfNotExists(connectionSource, Treatment.class);
|
||||||
|
} else {
|
||||||
log.info(DatabaseHelper.class.getName(), "onUpgrade");
|
log.info(DatabaseHelper.class.getName(), "onUpgrade");
|
||||||
TableUtils.dropTable(connectionSource, TempTarget.class, true);
|
TableUtils.dropTable(connectionSource, TempTarget.class, true);
|
||||||
TableUtils.dropTable(connectionSource, Treatment.class, true);
|
TableUtils.dropTable(connectionSource, Treatment.class, true);
|
||||||
|
@ -124,6 +129,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
TableUtils.dropTable(connectionSource, CareportalEvent.class, true);
|
TableUtils.dropTable(connectionSource, CareportalEvent.class, true);
|
||||||
TableUtils.dropTable(connectionSource, ProfileSwitch.class, true);
|
TableUtils.dropTable(connectionSource, ProfileSwitch.class, true);
|
||||||
onCreate(database, connectionSource);
|
onCreate(database, connectionSource);
|
||||||
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("Can't drop databases", e);
|
log.error("Can't drop databases", e);
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
@ -683,6 +689,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
treatment.insulin = trJson.has("insulin") ? trJson.getDouble("insulin") : 0d;
|
treatment.insulin = trJson.has("insulin") ? trJson.getDouble("insulin") : 0d;
|
||||||
treatment.pumpId = trJson.has("pumpId") ? trJson.getLong("pumpId") : 0;
|
treatment.pumpId = trJson.has("pumpId") ? trJson.getLong("pumpId") : 0;
|
||||||
treatment._id = trJson.getString("_id");
|
treatment._id = trJson.getString("_id");
|
||||||
|
treatment.isSMB = trJson.getBoolean("isSMB");
|
||||||
if (trJson.has("eventType")) {
|
if (trJson.has("eventType")) {
|
||||||
treatment.mealBolus = !trJson.get("eventType").equals("Correction Bolus");
|
treatment.mealBolus = !trJson.get("eventType").equals("Correction Bolus");
|
||||||
double carbs = treatment.carbs;
|
double carbs = treatment.carbs;
|
||||||
|
|
|
@ -47,6 +47,8 @@ public class Treatment implements DataPointWithLabelInterface {
|
||||||
public double carbs = 0d;
|
public double carbs = 0d;
|
||||||
@DatabaseField
|
@DatabaseField
|
||||||
public boolean mealBolus = true; // true for meal bolus , false for correction bolus
|
public boolean mealBolus = true; // true for meal bolus , false for correction bolus
|
||||||
|
@DatabaseField
|
||||||
|
public boolean isSMB = false;
|
||||||
|
|
||||||
@DatabaseField
|
@DatabaseField
|
||||||
public int insulinInterfaceID = InsulinInterface.FASTACTINGINSULIN;
|
public int insulinInterfaceID = InsulinInterface.FASTACTINGINSULIN;
|
||||||
|
@ -79,6 +81,7 @@ public class Treatment implements DataPointWithLabelInterface {
|
||||||
"date= " + date +
|
"date= " + date +
|
||||||
", date= " + DateUtil.dateAndTimeString(date) +
|
", date= " + DateUtil.dateAndTimeString(date) +
|
||||||
", isValid= " + isValid +
|
", isValid= " + isValid +
|
||||||
|
", isSMB= " + isSMB +
|
||||||
", _id= " + _id +
|
", _id= " + _id +
|
||||||
", pumpId= " + pumpId +
|
", pumpId= " + pumpId +
|
||||||
", insulin= " + insulin +
|
", insulin= " + insulin +
|
||||||
|
@ -110,6 +113,8 @@ public class Treatment implements DataPointWithLabelInterface {
|
||||||
return false;
|
return false;
|
||||||
if (pumpId != other.pumpId)
|
if (pumpId != other.pumpId)
|
||||||
return false;
|
return false;
|
||||||
|
if (isSMB != other.isSMB)
|
||||||
|
return false;
|
||||||
if (!Objects.equals(_id, other._id))
|
if (!Objects.equals(_id, other._id))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
|
@ -122,6 +127,7 @@ public class Treatment implements DataPointWithLabelInterface {
|
||||||
carbs = t.carbs;
|
carbs = t.carbs;
|
||||||
mealBolus = t.mealBolus;
|
mealBolus = t.mealBolus;
|
||||||
pumpId = t.pumpId;
|
pumpId = t.pumpId;
|
||||||
|
isSMB = t.isSMB;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------- DataPointInterface --------------------
|
// ----------------- DataPointInterface --------------------
|
||||||
|
|
|
@ -252,6 +252,7 @@ public class NSUpload {
|
||||||
if (detailedBolusInfo.carbs != 0d) data.put("carbs", (int) detailedBolusInfo.carbs);
|
if (detailedBolusInfo.carbs != 0d) data.put("carbs", (int) detailedBolusInfo.carbs);
|
||||||
data.put("created_at", DateUtil.toISOString(detailedBolusInfo.date));
|
data.put("created_at", DateUtil.toISOString(detailedBolusInfo.date));
|
||||||
data.put("date", detailedBolusInfo.date);
|
data.put("date", detailedBolusInfo.date);
|
||||||
|
data.put("isSMB", detailedBolusInfo.isSMB);
|
||||||
if (detailedBolusInfo.pumpId != 0)
|
if (detailedBolusInfo.pumpId != 0)
|
||||||
data.put("pumpId", detailedBolusInfo.pumpId);
|
data.put("pumpId", detailedBolusInfo.pumpId);
|
||||||
if (detailedBolusInfo.glucose != 0d)
|
if (detailedBolusInfo.glucose != 0d)
|
||||||
|
|
Loading…
Reference in a new issue