specify glucoseUnit, DB++
This commit is contained in:
parent
2ef91e6814
commit
8ec346cd35
16 changed files with 2841 additions and 27 deletions
|
@ -26,6 +26,7 @@ import info.nightscout.androidaps.utils.HtmlHelper
|
||||||
import info.nightscout.androidaps.utils.T
|
import info.nightscout.androidaps.utils.T
|
||||||
import info.nightscout.androidaps.utils.Translator
|
import info.nightscout.androidaps.utils.Translator
|
||||||
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
|
||||||
|
import info.nightscout.androidaps.utils.extensions.fromConstant
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import io.reactivex.disposables.CompositeDisposable
|
import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.rxkotlin.plusAssign
|
import io.reactivex.rxkotlin.plusAssign
|
||||||
|
@ -184,7 +185,7 @@ class CareDialog : DialogFragmentWithDate() {
|
||||||
EventType.QUESTION -> TherapyEvent.Type.QUESTION
|
EventType.QUESTION -> TherapyEvent.Type.QUESTION
|
||||||
EventType.ANNOUNCEMENT -> TherapyEvent.Type.ANNOUNCEMENT
|
EventType.ANNOUNCEMENT -> TherapyEvent.Type.ANNOUNCEMENT
|
||||||
},
|
},
|
||||||
units = profileFunction.getUnits()
|
glucoseUnit = TherapyEvent.GlucoseUnit.fromConstant(profileFunction.getUnits())
|
||||||
)
|
)
|
||||||
|
|
||||||
val actions: LinkedList<String> = LinkedList()
|
val actions: LinkedList<String> = LinkedList()
|
||||||
|
|
|
@ -143,7 +143,8 @@ class FillDialog : DialogFragmentWithDate() {
|
||||||
disposable += repository.runTransactionForResult(InsertTherapyEventIfNewTransaction(
|
disposable += repository.runTransactionForResult(InsertTherapyEventIfNewTransaction(
|
||||||
timestamp = eventTime,
|
timestamp = eventTime,
|
||||||
type = TherapyEvent.Type.CANNULA_CHANGE,
|
type = TherapyEvent.Type.CANNULA_CHANGE,
|
||||||
note = notes
|
note = notes,
|
||||||
|
glucoseUnit = TherapyEvent.GlucoseUnit.MGDL
|
||||||
)).subscribe({ result ->
|
)).subscribe({ result ->
|
||||||
result.inserted.forEach { nsUpload.uploadEvent(it) }
|
result.inserted.forEach { nsUpload.uploadEvent(it) }
|
||||||
}, {
|
}, {
|
||||||
|
@ -156,7 +157,8 @@ class FillDialog : DialogFragmentWithDate() {
|
||||||
disposable += repository.runTransactionForResult(InsertTherapyEventIfNewTransaction(
|
disposable += repository.runTransactionForResult(InsertTherapyEventIfNewTransaction(
|
||||||
timestamp = eventTime + 1000,
|
timestamp = eventTime + 1000,
|
||||||
type = TherapyEvent.Type.INSULIN_CHANGE,
|
type = TherapyEvent.Type.INSULIN_CHANGE,
|
||||||
note = notes
|
note = notes,
|
||||||
|
glucoseUnit = TherapyEvent.GlucoseUnit.MGDL
|
||||||
)).subscribe({ result ->
|
)).subscribe({ result ->
|
||||||
result.inserted.forEach { nsUpload.uploadEvent(it) }
|
result.inserted.forEach { nsUpload.uploadEvent(it) }
|
||||||
}, {
|
}, {
|
||||||
|
|
|
@ -658,7 +658,8 @@ open class LoopPlugin @Inject constructor(
|
||||||
timestamp = dateUtil._now(),
|
timestamp = dateUtil._now(),
|
||||||
type = TherapyEvent.Type.APS_OFFLINE,
|
type = TherapyEvent.Type.APS_OFFLINE,
|
||||||
duration = T.mins(durationInMinutes.toLong()).msecs(),
|
duration = T.mins(durationInMinutes.toLong()).msecs(),
|
||||||
enteredBy = "openaps://" + "AndroidAPS"
|
enteredBy = "openaps://" + "AndroidAPS",
|
||||||
|
glucoseUnit = TherapyEvent.GlucoseUnit.MGDL
|
||||||
)).subscribe({ result ->
|
)).subscribe({ result ->
|
||||||
result.inserted.forEach { nsUpload.uploadEvent(it) }
|
result.inserted.forEach { nsUpload.uploadEvent(it) }
|
||||||
}, {
|
}, {
|
||||||
|
|
|
@ -29,6 +29,7 @@ import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||||
|
import info.nightscout.androidaps.utils.extensions.toConstant
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
import info.nightscout.androidaps.utils.rx.AapsSchedulers
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
|
@ -205,9 +206,8 @@ class OpenHumansUploader @Inject constructor(
|
||||||
put("nsId", therapyEvent.interfaceIDs.nightscoutId)
|
put("nsId", therapyEvent.interfaceIDs.nightscoutId)
|
||||||
put("eventType", therapyEvent.type.text)
|
put("eventType", therapyEvent.type.text)
|
||||||
put("glucose", therapyEvent.glucose)
|
put("glucose", therapyEvent.glucose)
|
||||||
put("units", therapyEvent.units)
|
put("units", therapyEvent.glucoseUnit.toConstant())
|
||||||
put("glucoseType", therapyEvent.glucoseType?.text)
|
put("glucoseType", therapyEvent.glucoseType?.text)
|
||||||
put("units", therapyEvent.units)
|
|
||||||
put("duration", therapyEvent.duration)
|
put("duration", therapyEvent.duration)
|
||||||
put("isDeletion", deleted)
|
put("isDeletion", deleted)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.general.tidepool.elements
|
||||||
import com.google.gson.annotations.Expose
|
import com.google.gson.annotations.Expose
|
||||||
import info.nightscout.androidaps.data.Profile
|
import info.nightscout.androidaps.data.Profile
|
||||||
import info.nightscout.androidaps.database.entities.TherapyEvent
|
import info.nightscout.androidaps.database.entities.TherapyEvent
|
||||||
|
import info.nightscout.androidaps.utils.extensions.toConstant
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
class BloodGlucoseElement(therapyEvent: TherapyEvent)
|
class BloodGlucoseElement(therapyEvent: TherapyEvent)
|
||||||
|
@ -20,8 +21,8 @@ class BloodGlucoseElement(therapyEvent: TherapyEvent)
|
||||||
init {
|
init {
|
||||||
type = "cbg"
|
type = "cbg"
|
||||||
subType = "manual" // TODO
|
subType = "manual" // TODO
|
||||||
value = if (therapyEvent.glucose != null && therapyEvent.units != null)
|
value = if (therapyEvent.glucose != null)
|
||||||
Profile.toMgdl(therapyEvent.glucose!!, therapyEvent.units).toInt()
|
Profile.toMgdl(therapyEvent.glucose!!, therapyEvent.glucoseUnit.toConstant()).toInt()
|
||||||
else 0
|
else 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.activities.RequestDexcomPermissionActivity
|
import info.nightscout.androidaps.activities.RequestDexcomPermissionActivity
|
||||||
import info.nightscout.androidaps.database.AppRepository
|
import info.nightscout.androidaps.database.AppRepository
|
||||||
import info.nightscout.androidaps.database.entities.GlucoseValue
|
import info.nightscout.androidaps.database.entities.GlucoseValue
|
||||||
|
import info.nightscout.androidaps.database.entities.TherapyEvent
|
||||||
import info.nightscout.androidaps.database.transactions.CgmSourceTransaction
|
import info.nightscout.androidaps.database.transactions.CgmSourceTransaction
|
||||||
import info.nightscout.androidaps.interfaces.BgSourceInterface
|
import info.nightscout.androidaps.interfaces.BgSourceInterface
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase
|
import info.nightscout.androidaps.interfaces.PluginBase
|
||||||
|
@ -122,8 +123,11 @@ class DexcomPlugin @Inject constructor(
|
||||||
val timestamp = it.getLong("timestamp") * 1000
|
val timestamp = it.getLong("timestamp") * 1000
|
||||||
val now = DateUtil.now()
|
val now = DateUtil.now()
|
||||||
if (timestamp > now - T.months(1).msecs() && timestamp < now) {
|
if (timestamp > now - T.months(1).msecs() && timestamp < now) {
|
||||||
calibrations.add(CgmSourceTransaction.Calibration(it.getLong("timestamp") * 1000,
|
calibrations.add(CgmSourceTransaction.Calibration(
|
||||||
it.getInt("meterValue").toDouble()))
|
timestamp = it.getLong("timestamp") * 1000,
|
||||||
|
value = it.getInt("meterValue").toDouble(),
|
||||||
|
glucoseUnit = TherapyEvent.GlucoseUnit.MGDL
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,7 +137,7 @@ class DexcomPlugin @Inject constructor(
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
dexcomPlugin.disposable += repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, calibrations, sensorStartTime)).subscribe({ result ->
|
dexcomPlugin.disposable += repository.runTransactionForResult(CgmSourceTransaction(glucoseValues, calibrations, sensorStartTime)).subscribe({ result ->
|
||||||
result.inserted.forEach {
|
result.inserted.forEach {
|
||||||
broadcastToXDrip(it)
|
broadcastToXDrip(it)
|
||||||
if (sp.getBoolean(R.string.key_dexcomg5_nsupload, false)) {
|
if (sp.getBoolean(R.string.key_dexcomg5_nsupload, false)) {
|
||||||
|
|
|
@ -141,7 +141,7 @@ class EversensePlugin @Inject constructor(
|
||||||
type = TherapyEvent.Type.FINGER_STICK_BG_VALUE,
|
type = TherapyEvent.Type.FINGER_STICK_BG_VALUE,
|
||||||
glucose = calibrationGlucoseLevels[i].toDouble(),
|
glucose = calibrationGlucoseLevels[i].toDouble(),
|
||||||
glucoseType = TherapyEvent.MeterType.FINGER,
|
glucoseType = TherapyEvent.MeterType.FINGER,
|
||||||
units = Constants.MGDL,
|
glucoseUnit = TherapyEvent.GlucoseUnit.MGDL,
|
||||||
enteredBy = "AndroidAPS-Eversense"
|
enteredBy = "AndroidAPS-Eversense"
|
||||||
)).subscribe({ result ->
|
)).subscribe({ result ->
|
||||||
result.inserted.forEach { nsUpload.uploadEvent(it) }
|
result.inserted.forEach { nsUpload.uploadEvent(it) }
|
||||||
|
|
|
@ -13,7 +13,7 @@ import java.util.Date;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import dagger.android.HasAndroidInjector;
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.core.R;
|
import info.nightscout.androidaps.core.R;
|
||||||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||||
import info.nightscout.androidaps.data.IobTotal;
|
import info.nightscout.androidaps.data.IobTotal;
|
||||||
|
@ -471,11 +471,14 @@ public class NSUpload {
|
||||||
data.put("eventType", event.getType().getText());
|
data.put("eventType", event.getType().getText());
|
||||||
data.put("created_at", event.getTimestamp());
|
data.put("created_at", event.getTimestamp());
|
||||||
data.put("enteredBy", event.getEnteredBy());
|
data.put("enteredBy", event.getEnteredBy());
|
||||||
if (event.getUnits() != null) data.put("units", event.getUnits());
|
if (event.getGlucoseUnit() == TherapyEvent.GlucoseUnit.MGDL)
|
||||||
|
data.put("units", Constants.MGDL);
|
||||||
|
else data.put("units", Constants.MMOL);
|
||||||
if (event.getDuration() != 0) data.put("duration", T.msecs(event.getDuration()).mins());
|
if (event.getDuration() != 0) data.put("duration", T.msecs(event.getDuration()).mins());
|
||||||
if (event.getNote() != null) data.put("notes", event.getNote());
|
if (event.getNote() != null) data.put("notes", event.getNote());
|
||||||
if (event.getGlucose() != null) data.put("glucose", event.getGlucose());
|
if (event.getGlucose() != null) data.put("glucose", event.getGlucose());
|
||||||
if (event.getGlucoseType() != null) data.put("glucoseType", event.getGlucoseType().getText());
|
if (event.getGlucoseType() != null)
|
||||||
|
data.put("glucoseType", event.getGlucoseType().getText());
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
aapsLogger.error("Unhandled exception", e);
|
aapsLogger.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,11 +31,20 @@ fun TherapyEvent.getHoursFromStart(): Double {
|
||||||
return (System.currentTimeMillis() - timestamp) / (60 * 60 * 1000.0)
|
return (System.currentTimeMillis() - timestamp) / (60 * 60 * 1000.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun TherapyEvent.GlucoseUnit.toConstant(): String =
|
||||||
|
if (this == TherapyEvent.GlucoseUnit.MGDL) Constants.MGDL
|
||||||
|
else Constants.MMOL
|
||||||
|
|
||||||
|
fun TherapyEvent.GlucoseUnit.Companion.fromConstant(units: String): TherapyEvent.GlucoseUnit =
|
||||||
|
if (units == Constants.MGDL) TherapyEvent.GlucoseUnit.MGDL
|
||||||
|
else TherapyEvent.GlucoseUnit.MMOL
|
||||||
|
|
||||||
fun therapyEventFromNsMbg(mbg: NSMbg) =
|
fun therapyEventFromNsMbg(mbg: NSMbg) =
|
||||||
TherapyEvent(
|
TherapyEvent(
|
||||||
type = TherapyEvent.Type.NS_MBG,
|
type = TherapyEvent.Type.NS_MBG,
|
||||||
timestamp = mbg.date,
|
timestamp = mbg.date,
|
||||||
glucose = mbg.mbg
|
glucose = mbg.mbg,
|
||||||
|
glucoseUnit = TherapyEvent.GlucoseUnit.MGDL
|
||||||
).also {
|
).also {
|
||||||
it.interfaceIDs.nightscoutId = mbg.id()
|
it.interfaceIDs.nightscoutId = mbg.id()
|
||||||
}
|
}
|
||||||
|
@ -52,7 +61,7 @@ fun therapyEventFromNsIdForInvalidating(nsId: String): TherapyEvent =
|
||||||
)!!
|
)!!
|
||||||
|
|
||||||
fun therapyEventFromJson(jsonObject: JSONObject): TherapyEvent? {
|
fun therapyEventFromJson(jsonObject: JSONObject): TherapyEvent? {
|
||||||
val units = JsonHelper.safeGetString(jsonObject, "units", Constants.MGDL)
|
val glucoseUnit = if (JsonHelper.safeGetString(jsonObject, "units", Constants.MGDL) == Constants.MGDL) TherapyEvent.GlucoseUnit.MGDL else TherapyEvent.GlucoseUnit.MMOL
|
||||||
val timestamp = JsonHelper.safeGetLongAllowNull(jsonObject, "mills", null) ?: return null
|
val timestamp = JsonHelper.safeGetLongAllowNull(jsonObject, "mills", null) ?: return null
|
||||||
val type = TherapyEvent.Type.fromString(JsonHelper.safeGetString(jsonObject, "eventType", TherapyEvent.Type.NONE.text))
|
val type = TherapyEvent.Type.fromString(JsonHelper.safeGetString(jsonObject, "eventType", TherapyEvent.Type.NONE.text))
|
||||||
val duration = JsonHelper.safeGetLong(jsonObject, "duration")
|
val duration = JsonHelper.safeGetLong(jsonObject, "duration")
|
||||||
|
@ -66,7 +75,7 @@ fun therapyEventFromJson(jsonObject: JSONObject): TherapyEvent? {
|
||||||
val te = TherapyEvent(
|
val te = TherapyEvent(
|
||||||
timestamp = timestamp,
|
timestamp = timestamp,
|
||||||
duration = TimeUnit.MINUTES.toMillis(duration),
|
duration = TimeUnit.MINUTES.toMillis(duration),
|
||||||
units = units,
|
glucoseUnit = glucoseUnit,
|
||||||
type = type,
|
type = type,
|
||||||
glucose = glucose,
|
glucose = glucose,
|
||||||
glucoseType = glucoseType,
|
glucoseType = glucoseType,
|
||||||
|
|
|
@ -183,7 +183,8 @@ open class DanaRS_Packet_APS_History_Events(
|
||||||
disposable += repository.runTransactionForResult(InsertTherapyEventIfNewTransaction(
|
disposable += repository.runTransactionForResult(InsertTherapyEventIfNewTransaction(
|
||||||
timestamp = datetime,
|
timestamp = datetime,
|
||||||
type = TherapyEvent.Type.INSULIN_CHANGE,
|
type = TherapyEvent.Type.INSULIN_CHANGE,
|
||||||
note = resourceHelper.gs(R.string.danarspump)
|
note = resourceHelper.gs(R.string.danarspump),
|
||||||
|
glucoseUnit = TherapyEvent.GlucoseUnit.MGDL
|
||||||
)).subscribe({ result ->
|
)).subscribe({ result ->
|
||||||
result.inserted.forEach { nsUpload.uploadEvent(it) }
|
result.inserted.forEach { nsUpload.uploadEvent(it) }
|
||||||
}, {
|
}, {
|
||||||
|
@ -219,7 +220,8 @@ open class DanaRS_Packet_APS_History_Events(
|
||||||
disposable += repository.runTransactionForResult(InsertTherapyEventIfNewTransaction(
|
disposable += repository.runTransactionForResult(InsertTherapyEventIfNewTransaction(
|
||||||
timestamp = datetime,
|
timestamp = datetime,
|
||||||
type = TherapyEvent.Type.CANNULA_CHANGE,
|
type = TherapyEvent.Type.CANNULA_CHANGE,
|
||||||
note = resourceHelper.gs(R.string.danarspump)
|
note = resourceHelper.gs(R.string.danarspump),
|
||||||
|
glucoseUnit = TherapyEvent.GlucoseUnit.MGDL
|
||||||
)).subscribe({ result ->
|
)).subscribe({ result ->
|
||||||
result.inserted.forEach { nsUpload.uploadEvent(it) }
|
result.inserted.forEach { nsUpload.uploadEvent(it) }
|
||||||
}, {
|
}, {
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -6,7 +6,7 @@ import androidx.room.TypeConverters
|
||||||
import info.nightscout.androidaps.database.daos.*
|
import info.nightscout.androidaps.database.daos.*
|
||||||
import info.nightscout.androidaps.database.entities.*
|
import info.nightscout.androidaps.database.entities.*
|
||||||
|
|
||||||
const val DATABASE_VERSION = 4
|
const val DATABASE_VERSION = 5
|
||||||
|
|
||||||
@Database(version = DATABASE_VERSION,
|
@Database(version = DATABASE_VERSION,
|
||||||
entities = [APSResult::class, Bolus::class, BolusCalculatorResult::class, Carbs::class,
|
entities = [APSResult::class, Bolus::class, BolusCalculatorResult::class, Carbs::class,
|
||||||
|
|
|
@ -58,6 +58,12 @@ class Converters {
|
||||||
@TypeConverter
|
@TypeConverter
|
||||||
fun toGlucoseUnit(glucoseUnit: String?) = glucoseUnit?.let { ProfileSwitch.GlucoseUnit.valueOf(it) }
|
fun toGlucoseUnit(glucoseUnit: String?) = glucoseUnit?.let { ProfileSwitch.GlucoseUnit.valueOf(it) }
|
||||||
|
|
||||||
|
@TypeConverter
|
||||||
|
fun fromTherapyGlucoseUnit(glucoseUnit: TherapyEvent.GlucoseUnit?) = glucoseUnit?.name
|
||||||
|
|
||||||
|
@TypeConverter
|
||||||
|
fun toTherapyGlucoseUnit(glucoseUnit: String?) = glucoseUnit?.let { TherapyEvent.GlucoseUnit.valueOf(it) }
|
||||||
|
|
||||||
@TypeConverter
|
@TypeConverter
|
||||||
fun fromPumpType(pumpType: InterfaceIDs.PumpType?) = pumpType?.name
|
fun fromPumpType(pumpType: InterfaceIDs.PumpType?) = pumpType?.name
|
||||||
|
|
||||||
|
|
|
@ -35,9 +35,15 @@ data class TherapyEvent(
|
||||||
var enteredBy: String? = null,
|
var enteredBy: String? = null,
|
||||||
var glucose: Double? = null,
|
var glucose: Double? = null,
|
||||||
var glucoseType: MeterType? = null,
|
var glucoseType: MeterType? = null,
|
||||||
var units: String? = null
|
var glucoseUnit: GlucoseUnit,
|
||||||
) : TraceableDBEntry, DBEntryWithTimeAndDuration {
|
) : TraceableDBEntry, DBEntryWithTimeAndDuration {
|
||||||
|
|
||||||
|
enum class GlucoseUnit {
|
||||||
|
MGDL,
|
||||||
|
MMOL;
|
||||||
|
companion object { }
|
||||||
|
}
|
||||||
|
|
||||||
enum class MeterType(val text: String) {
|
enum class MeterType(val text: String) {
|
||||||
@SerializedName("Finger")
|
@SerializedName("Finger")
|
||||||
FINGER("Finger"),
|
FINGER("Finger"),
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package info.nightscout.androidaps.database.transactions
|
package info.nightscout.androidaps.database.transactions
|
||||||
|
|
||||||
import info.nightscout.androidaps.database.entities.GlucoseValue
|
import info.nightscout.androidaps.database.entities.GlucoseValue
|
||||||
|
import info.nightscout.androidaps.database.entities.ProfileSwitch
|
||||||
import info.nightscout.androidaps.database.entities.TherapyEvent
|
import info.nightscout.androidaps.database.entities.TherapyEvent
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -56,7 +57,8 @@ class CgmSourceTransaction(
|
||||||
database.therapyEventDao.insertNewEntry(TherapyEvent(
|
database.therapyEventDao.insertNewEntry(TherapyEvent(
|
||||||
timestamp = it.timestamp,
|
timestamp = it.timestamp,
|
||||||
type = TherapyEvent.Type.FINGER_STICK_BG_VALUE,
|
type = TherapyEvent.Type.FINGER_STICK_BG_VALUE,
|
||||||
glucose = it.value
|
glucose = it.value,
|
||||||
|
glucoseUnit = it.glucoseUnit
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,7 +66,8 @@ class CgmSourceTransaction(
|
||||||
if (database.therapyEventDao.findByTimestamp(TherapyEvent.Type.SENSOR_CHANGE, it) == null) {
|
if (database.therapyEventDao.findByTimestamp(TherapyEvent.Type.SENSOR_CHANGE, it) == null) {
|
||||||
database.therapyEventDao.insertNewEntry(TherapyEvent(
|
database.therapyEventDao.insertNewEntry(TherapyEvent(
|
||||||
timestamp = it,
|
timestamp = it,
|
||||||
type = TherapyEvent.Type.SENSOR_CHANGE
|
type = TherapyEvent.Type.SENSOR_CHANGE,
|
||||||
|
glucoseUnit = TherapyEvent.GlucoseUnit.MGDL
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,7 +86,8 @@ class CgmSourceTransaction(
|
||||||
|
|
||||||
data class Calibration(
|
data class Calibration(
|
||||||
val timestamp: Long,
|
val timestamp: Long,
|
||||||
val value: Double
|
val value: Double,
|
||||||
|
val glucoseUnit: TherapyEvent.GlucoseUnit
|
||||||
)
|
)
|
||||||
|
|
||||||
class TransactionResult {
|
class TransactionResult {
|
||||||
|
|
|
@ -6,8 +6,8 @@ class InsertTherapyEventIfNewTransaction(
|
||||||
val therapyEvent: TherapyEvent
|
val therapyEvent: TherapyEvent
|
||||||
) : Transaction<InsertTherapyEventIfNewTransaction.TransactionResult>() {
|
) : Transaction<InsertTherapyEventIfNewTransaction.TransactionResult>() {
|
||||||
|
|
||||||
constructor(timestamp: Long, type: TherapyEvent.Type, duration: Long = 0, note: String? = null, enteredBy: String? = null, glucose: Double? = null, glucoseType: TherapyEvent.MeterType? = null, units: String? = null) :
|
constructor(timestamp: Long, type: TherapyEvent.Type, duration: Long = 0, note: String? = null, enteredBy: String? = null, glucose: Double? = null, glucoseType: TherapyEvent.MeterType? = null, glucoseUnit: TherapyEvent.GlucoseUnit) :
|
||||||
this(TherapyEvent(timestamp = timestamp, type = type, duration = duration, note = note, enteredBy = enteredBy, glucose = glucose, glucoseType = glucoseType, units = units))
|
this(TherapyEvent(timestamp = timestamp, type = type, duration = duration, note = note, enteredBy = enteredBy, glucose = glucose, glucoseType = glucoseType, glucoseUnit = glucoseUnit))
|
||||||
|
|
||||||
override fun run(): TransactionResult {
|
override fun run(): TransactionResult {
|
||||||
val result = TransactionResult()
|
val result = TransactionResult()
|
||||||
|
|
Loading…
Reference in a new issue