same notes for boluses
This commit is contained in:
parent
1e55890ff7
commit
126c90024b
6 changed files with 20 additions and 5 deletions
|
@ -107,7 +107,8 @@ class DetailedBolusInfo {
|
||||||
Bolus(
|
Bolus(
|
||||||
timestamp = bolusTimestamp ?: timestamp,
|
timestamp = bolusTimestamp ?: timestamp,
|
||||||
amount = insulin,
|
amount = insulin,
|
||||||
type = bolusType.toDBbBolusType()
|
type = bolusType.toDBbBolusType(),
|
||||||
|
notes = notes,
|
||||||
)
|
)
|
||||||
else null
|
else null
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ fun Bolus.toJson(isAdd: Boolean, dateUtil: DateUtil): JSONObject =
|
||||||
.put("created_at", dateUtil.toISOString(timestamp))
|
.put("created_at", dateUtil.toISOString(timestamp))
|
||||||
.put("date", timestamp)
|
.put("date", timestamp)
|
||||||
.put("type", type.name)
|
.put("type", type.name)
|
||||||
|
.put("notes", notes)
|
||||||
.put("isValid", isValid)
|
.put("isValid", isValid)
|
||||||
.put("isSMB", type == Bolus.Type.SMB).also {
|
.put("isSMB", type == Bolus.Type.SMB).also {
|
||||||
if (interfaceIDs.pumpId != null) it.put("pumpId", interfaceIDs.pumpId)
|
if (interfaceIDs.pumpId != null) it.put("pumpId", interfaceIDs.pumpId)
|
||||||
|
@ -55,6 +56,7 @@ fun bolusFromJson(jsonObject: JSONObject): Bolus? {
|
||||||
val amount = JsonHelper.safeGetDoubleAllowNull(jsonObject, "insulin") ?: return null
|
val amount = JsonHelper.safeGetDoubleAllowNull(jsonObject, "insulin") ?: return null
|
||||||
val type = Bolus.Type.fromString(JsonHelper.safeGetString(jsonObject, "type"))
|
val type = Bolus.Type.fromString(JsonHelper.safeGetString(jsonObject, "type"))
|
||||||
val isValid = JsonHelper.safeGetBoolean(jsonObject, "isValid", true)
|
val isValid = JsonHelper.safeGetBoolean(jsonObject, "isValid", true)
|
||||||
|
val notes = JsonHelper.safeGetStringAllowNull(jsonObject, "notes", null)
|
||||||
val id = JsonHelper.safeGetStringAllowNull(jsonObject, "_id", null) ?: return null
|
val id = JsonHelper.safeGetStringAllowNull(jsonObject, "_id", null) ?: return null
|
||||||
val pumpId = JsonHelper.safeGetLongAllowNull(jsonObject, "pumpId", null)
|
val pumpId = JsonHelper.safeGetLongAllowNull(jsonObject, "pumpId", null)
|
||||||
val pumpType = InterfaceIDs.PumpType.fromString(JsonHelper.safeGetStringAllowNull(jsonObject, "pumpType", null))
|
val pumpType = InterfaceIDs.PumpType.fromString(JsonHelper.safeGetStringAllowNull(jsonObject, "pumpType", null))
|
||||||
|
@ -67,7 +69,8 @@ fun bolusFromJson(jsonObject: JSONObject): Bolus? {
|
||||||
timestamp = timestamp,
|
timestamp = timestamp,
|
||||||
amount = amount,
|
amount = amount,
|
||||||
type = type,
|
type = type,
|
||||||
isValid = isValid
|
notes = notes,
|
||||||
|
isValid = isValid,
|
||||||
).also {
|
).also {
|
||||||
it.interfaceIDs.nightscoutId = id
|
it.interfaceIDs.nightscoutId = id
|
||||||
it.interfaceIDs.pumpId = pumpId
|
it.interfaceIDs.pumpId = pumpId
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"formatVersion": 1,
|
"formatVersion": 1,
|
||||||
"database": {
|
"database": {
|
||||||
"version": 22,
|
"version": 22,
|
||||||
"identityHash": "8e5c513355bfdf0d24e72eedc263f0c3",
|
"identityHash": "09121464fb795b3c37bb1c2c2c3ea481",
|
||||||
"entities": [
|
"entities": [
|
||||||
{
|
{
|
||||||
"tableName": "apsResults",
|
"tableName": "apsResults",
|
||||||
|
@ -193,7 +193,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"tableName": "boluses",
|
"tableName": "boluses",
|
||||||
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `version` INTEGER NOT NULL, `dateCreated` INTEGER NOT NULL, `isValid` INTEGER NOT NULL, `referenceId` INTEGER, `timestamp` INTEGER NOT NULL, `utcOffset` INTEGER NOT NULL, `amount` REAL NOT NULL, `type` TEXT NOT NULL, `isBasalInsulin` INTEGER NOT NULL, `nightscoutSystemId` TEXT, `nightscoutId` TEXT, `pumpType` TEXT, `pumpSerial` TEXT, `temporaryId` INTEGER, `pumpId` INTEGER, `startId` INTEGER, `endId` INTEGER, `insulinLabel` TEXT, `insulinEndTime` INTEGER, `peak` INTEGER, FOREIGN KEY(`referenceId`) REFERENCES `boluses`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION )",
|
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `version` INTEGER NOT NULL, `dateCreated` INTEGER NOT NULL, `isValid` INTEGER NOT NULL, `referenceId` INTEGER, `timestamp` INTEGER NOT NULL, `utcOffset` INTEGER NOT NULL, `amount` REAL NOT NULL, `type` TEXT NOT NULL, `notes` TEXT, `isBasalInsulin` INTEGER NOT NULL, `nightscoutSystemId` TEXT, `nightscoutId` TEXT, `pumpType` TEXT, `pumpSerial` TEXT, `temporaryId` INTEGER, `pumpId` INTEGER, `startId` INTEGER, `endId` INTEGER, `insulinLabel` TEXT, `insulinEndTime` INTEGER, `peak` INTEGER, FOREIGN KEY(`referenceId`) REFERENCES `boluses`(`id`) ON UPDATE NO ACTION ON DELETE NO ACTION )",
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"fieldPath": "id",
|
"fieldPath": "id",
|
||||||
|
@ -249,6 +249,12 @@
|
||||||
"affinity": "TEXT",
|
"affinity": "TEXT",
|
||||||
"notNull": true
|
"notNull": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "notes",
|
||||||
|
"columnName": "notes",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldPath": "isBasalInsulin",
|
"fieldPath": "isBasalInsulin",
|
||||||
"columnName": "isBasalInsulin",
|
"columnName": "isBasalInsulin",
|
||||||
|
@ -3593,7 +3599,7 @@
|
||||||
"views": [],
|
"views": [],
|
||||||
"setupQueries": [
|
"setupQueries": [
|
||||||
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||||
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '8e5c513355bfdf0d24e72eedc263f0c3')"
|
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '09121464fb795b3c37bb1c2c2c3ea481')"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -73,6 +73,7 @@ open class DatabaseModule {
|
||||||
private val migration21to22 = object : Migration(21,22) {
|
private val migration21to22 = object : Migration(21,22) {
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(database: SupportSQLiteDatabase) {
|
||||||
database.execSQL("ALTER TABLE `carbs` ADD COLUMN `notes` TEXT")
|
database.execSQL("ALTER TABLE `carbs` ADD COLUMN `notes` TEXT")
|
||||||
|
database.execSQL("ALTER TABLE `boluses` ADD COLUMN `notes` TEXT")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,7 @@ data class Bolus(
|
||||||
override var utcOffset: Long = TimeZone.getDefault().getOffset(timestamp).toLong(),
|
override var utcOffset: Long = TimeZone.getDefault().getOffset(timestamp).toLong(),
|
||||||
var amount: Double,
|
var amount: Double,
|
||||||
var type: Type,
|
var type: Type,
|
||||||
|
var notes: String? = null,
|
||||||
var isBasalInsulin: Boolean = false,
|
var isBasalInsulin: Boolean = false,
|
||||||
@Embedded
|
@Embedded
|
||||||
var insulinConfiguration: InsulinConfiguration? = null
|
var insulinConfiguration: InsulinConfiguration? = null
|
||||||
|
@ -55,6 +56,7 @@ data class Bolus(
|
||||||
utcOffset == other.utcOffset &&
|
utcOffset == other.utcOffset &&
|
||||||
amount == other.amount &&
|
amount == other.amount &&
|
||||||
type == other.type &&
|
type == other.type &&
|
||||||
|
notes == notes &&
|
||||||
isBasalInsulin == other.isBasalInsulin
|
isBasalInsulin == other.isBasalInsulin
|
||||||
|
|
||||||
fun onlyNsIdAdded(previous: Bolus): Boolean =
|
fun onlyNsIdAdded(previous: Bolus): Boolean =
|
||||||
|
|
|
@ -15,6 +15,7 @@ class InsertOrUpdateBolusTransaction(
|
||||||
timestamp: Long,
|
timestamp: Long,
|
||||||
amount: Double,
|
amount: Double,
|
||||||
type: Bolus.Type,
|
type: Bolus.Type,
|
||||||
|
notes: String? = null,
|
||||||
isBasalInsulin: Boolean = false,
|
isBasalInsulin: Boolean = false,
|
||||||
insulinConfiguration: InsulinConfiguration? = null,
|
insulinConfiguration: InsulinConfiguration? = null,
|
||||||
interfaceIDs_backing: InterfaceIDs? = null
|
interfaceIDs_backing: InterfaceIDs? = null
|
||||||
|
@ -22,6 +23,7 @@ class InsertOrUpdateBolusTransaction(
|
||||||
timestamp = timestamp,
|
timestamp = timestamp,
|
||||||
amount = amount,
|
amount = amount,
|
||||||
type = type,
|
type = type,
|
||||||
|
notes = notes,
|
||||||
isBasalInsulin = isBasalInsulin,
|
isBasalInsulin = isBasalInsulin,
|
||||||
insulinConfiguration = insulinConfiguration,
|
insulinConfiguration = insulinConfiguration,
|
||||||
interfaceIDs_backing = interfaceIDs_backing
|
interfaceIDs_backing = interfaceIDs_backing
|
||||||
|
|
Loading…
Reference in a new issue