Add total delivered to dash history
This commit is contained in:
parent
7faa34aa50
commit
2826854b7c
|
@ -3,6 +3,7 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.history
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType
|
import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType.SET_BOLUS
|
import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType.SET_BOLUS
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType.SET_TEMPORARY_BASAL
|
import info.nightscout.androidaps.plugins.pump.omnipod.common.definition.OmnipodCommandType.SET_TEMPORARY_BASAL
|
||||||
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.definition.PodConstants.Companion.POD_PULSE_BOLUS_UNITS
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.CommandConfirmationDenied
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.CommandConfirmationDenied
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.CommandConfirmationSuccess
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.CommandConfirmationSuccess
|
||||||
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.CommandSendingFailure
|
import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.state.CommandSendingFailure
|
||||||
|
@ -57,6 +58,7 @@ class DashHistory @Inject constructor(
|
||||||
tempBasalRecord: TempBasalRecord? = null,
|
tempBasalRecord: TempBasalRecord? = null,
|
||||||
bolusRecord: BolusRecord? = null,
|
bolusRecord: BolusRecord? = null,
|
||||||
basalProfileRecord: BasalValuesRecord? = null,
|
basalProfileRecord: BasalValuesRecord? = null,
|
||||||
|
totalAmountDeliveredRecord: Double? = null,
|
||||||
resolveResult: ResolvedResult? = null,
|
resolveResult: ResolvedResult? = null,
|
||||||
resolvedAt: Long? = null
|
resolvedAt: Long? = null
|
||||||
): Single<Long> = Single.defer {
|
): Single<Long> = Single.defer {
|
||||||
|
@ -79,6 +81,7 @@ class DashHistory @Inject constructor(
|
||||||
tempBasalRecord = tempBasalRecord,
|
tempBasalRecord = tempBasalRecord,
|
||||||
bolusRecord = bolusRecord,
|
bolusRecord = bolusRecord,
|
||||||
basalProfileRecord = basalProfileRecord,
|
basalProfileRecord = basalProfileRecord,
|
||||||
|
totalAmountDelivered = totalAmountDeliveredRecord,
|
||||||
initialResult = initialResult,
|
initialResult = initialResult,
|
||||||
resolvedResult = resolveResult,
|
resolvedResult = resolveResult,
|
||||||
resolvedAt = resolvedAt
|
resolvedAt = resolvedAt
|
||||||
|
@ -99,18 +102,23 @@ class DashHistory @Inject constructor(
|
||||||
logger.error(LTag.PUMP, "HistoryId not found to for updating from state")
|
logger.error(LTag.PUMP, "HistoryId not found to for updating from state")
|
||||||
return@defer Completable.complete()
|
return@defer Completable.complete()
|
||||||
}
|
}
|
||||||
when (podState.getCommandConfirmationFromState()) {
|
|
||||||
CommandSendingFailure ->
|
val setTotalAmountDelivered = dao.setTotalAmountDelivered(historyId, podState.pulsesDelivered?.times(POD_PULSE_BOLUS_UNITS))
|
||||||
|
|
||||||
|
val commandConfirmation = when (podState.getCommandConfirmationFromState()) {
|
||||||
|
CommandSendingFailure ->
|
||||||
dao.setInitialResult(historyId, InitialResult.FAILURE_SENDING)
|
dao.setInitialResult(historyId, InitialResult.FAILURE_SENDING)
|
||||||
CommandSendingNotConfirmed ->
|
CommandSendingNotConfirmed ->
|
||||||
dao.setInitialResult(historyId, InitialResult.SENT)
|
dao.setInitialResult(historyId, InitialResult.SENT)
|
||||||
CommandConfirmationDenied ->
|
CommandConfirmationDenied ->
|
||||||
markFailure(historyId)
|
markFailure(historyId)
|
||||||
CommandConfirmationSuccess ->
|
CommandConfirmationSuccess ->
|
||||||
dao.setInitialResult(historyId, InitialResult.SENT)
|
dao.setInitialResult(historyId, InitialResult.SENT)
|
||||||
.andThen(markSuccess(historyId))
|
.andThen(markSuccess(historyId))
|
||||||
NoActiveCommand ->
|
NoActiveCommand ->
|
||||||
Completable.complete()
|
Completable.complete()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Completable.concat(listOf(setTotalAmountDelivered, commandConfirmation))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ data class HistoryRecord(
|
||||||
val commandType: OmnipodCommandType,
|
val commandType: OmnipodCommandType,
|
||||||
val initialResult: InitialResult,
|
val initialResult: InitialResult,
|
||||||
val record: Record?,
|
val record: Record?,
|
||||||
|
val totalAmountDelivered: Double?,
|
||||||
val resolvedResult: ResolvedResult?,
|
val resolvedResult: ResolvedResult?,
|
||||||
val resolvedAt: Long?
|
val resolvedAt: Long?
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -18,7 +18,7 @@ abstract class DashHistoryDatabase : RoomDatabase() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
const val VERSION = 3
|
const val VERSION = 4
|
||||||
|
|
||||||
fun build(context: Context) =
|
fun build(context: Context) =
|
||||||
Room.databaseBuilder(
|
Room.databaseBuilder(
|
||||||
|
|
|
@ -36,4 +36,7 @@ abstract class HistoryRecordDao {
|
||||||
|
|
||||||
@Query("UPDATE historyrecords SET initialResult = :initialResult WHERE id = :id ")
|
@Query("UPDATE historyrecords SET initialResult = :initialResult WHERE id = :id ")
|
||||||
abstract fun setInitialResult(id: Long, initialResult: InitialResult): Completable
|
abstract fun setInitialResult(id: Long, initialResult: InitialResult): Completable
|
||||||
|
|
||||||
|
@Query("UPDATE historyrecords SET totalAmountDelivered = :totalAmountDelivered WHERE id = :id ")
|
||||||
|
abstract fun setTotalAmountDelivered(id: Long, totalAmountDelivered: Double?): Completable
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ data class HistoryRecordEntity(
|
||||||
@Embedded(prefix = "tempBasalRecord_") val tempBasalRecord: TempBasalRecord?,
|
@Embedded(prefix = "tempBasalRecord_") val tempBasalRecord: TempBasalRecord?,
|
||||||
@Embedded(prefix = "bolusRecord_") val bolusRecord: BolusRecord?,
|
@Embedded(prefix = "bolusRecord_") val bolusRecord: BolusRecord?,
|
||||||
@Embedded(prefix = "basalprofile_") val basalProfileRecord: BasalValuesRecord?,
|
@Embedded(prefix = "basalprofile_") val basalProfileRecord: BasalValuesRecord?,
|
||||||
|
val totalAmountDelivered: Double?,
|
||||||
val resolvedResult: ResolvedResult?,
|
val resolvedResult: ResolvedResult?,
|
||||||
val resolvedAt: Long?
|
val resolvedAt: Long?
|
||||||
)
|
)
|
||||||
|
|
|
@ -13,6 +13,7 @@ class HistoryMapper {
|
||||||
initialResult = entity.initialResult,
|
initialResult = entity.initialResult,
|
||||||
commandType = entity.commandType,
|
commandType = entity.commandType,
|
||||||
record = entity.bolusRecord ?: entity.tempBasalRecord ?: entity.basalProfileRecord,
|
record = entity.bolusRecord ?: entity.tempBasalRecord ?: entity.basalProfileRecord,
|
||||||
|
totalAmountDelivered = entity.totalAmountDelivered,
|
||||||
resolvedResult = entity.resolvedResult,
|
resolvedResult = entity.resolvedResult,
|
||||||
resolvedAt = entity.resolvedAt
|
resolvedAt = entity.resolvedAt
|
||||||
)
|
)
|
||||||
|
|
|
@ -213,6 +213,7 @@ class DashPodHistoryActivity : TranslatedDaggerAppCompatActivity() {
|
||||||
holder.timeView.text = DateTimeUtil.toStringFromTimeInMillis(it.displayTimestamp())
|
holder.timeView.text = DateTimeUtil.toStringFromTimeInMillis(it.displayTimestamp())
|
||||||
setValue(it, holder.valueView)
|
setValue(it, holder.valueView)
|
||||||
setType(it, holder.typeView)
|
setType(it, holder.typeView)
|
||||||
|
setAmount(it, holder.amountView)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,6 +298,12 @@ class DashPodHistoryActivity : TranslatedDaggerAppCompatActivity() {
|
||||||
setTextViewColor(check_result = false, valueView, historyEntry)
|
setTextViewColor(check_result = false, valueView, historyEntry)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun setAmount(historyEntry: HistoryRecord, amountView: TextView) {
|
||||||
|
amountView.text = historyEntry.totalAmountDelivered?.let { rh.gs(R.string.omnipod_common_history_total_delivered, it) ?: "" }
|
||||||
|
// Set some color
|
||||||
|
setTextViewColor(check_result = false, amountView, historyEntry)
|
||||||
|
}
|
||||||
|
|
||||||
override fun getItemCount(): Int {
|
override fun getItemCount(): Int {
|
||||||
return historyList.size
|
return historyList.size
|
||||||
}
|
}
|
||||||
|
@ -306,6 +313,7 @@ class DashPodHistoryActivity : TranslatedDaggerAppCompatActivity() {
|
||||||
val timeView: TextView = itemView.findViewById(R.id.omnipod_history_time)
|
val timeView: TextView = itemView.findViewById(R.id.omnipod_history_time)
|
||||||
val typeView: TextView = itemView.findViewById(R.id.omnipod_history_source)
|
val typeView: TextView = itemView.findViewById(R.id.omnipod_history_source)
|
||||||
val valueView: TextView = itemView.findViewById(R.id.omnipod_history_description)
|
val valueView: TextView = itemView.findViewById(R.id.omnipod_history_description)
|
||||||
|
val amountView: TextView = itemView.findViewById(R.id.omnipod_history_amount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,18 +14,36 @@
|
||||||
android:text="@string/omnipod_dash_history_item_date"
|
android:text="@string/omnipod_dash_history_item_date"
|
||||||
android:textSize="12sp" />
|
android:textSize="12sp" />
|
||||||
|
|
||||||
<TextView
|
<RelativeLayout
|
||||||
android:id="@+id/omnipod_history_source"
|
android:layout_width="0dp"
|
||||||
android:layout_width="132dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_weight="1">
|
||||||
android:text="@string/omnipod_dash_history_item_source"
|
|
||||||
android:textSize="12sp" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/omnipod_history_description"
|
android:id="@+id/omnipod_history_source"
|
||||||
android:layout_width="fill_parent"
|
android:layout_width="132dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/omnipod_dash_history_item_description"
|
android:text="@string/omnipod_dash_history_item_source"
|
||||||
android:textSize="12sp" />
|
android:layout_alignParentTop="true"
|
||||||
|
android:textSize="12sp" />
|
||||||
|
|
||||||
</LinearLayout>
|
<TextView
|
||||||
|
android:id="@+id/omnipod_history_description"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/omnipod_dash_history_item_description"
|
||||||
|
android:layout_toEndOf="@id/omnipod_history_source"
|
||||||
|
android:textSize="12sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/omnipod_history_amount"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/omnipod_dash_history_item_amount"
|
||||||
|
android:layout_below="@+id/omnipod_history_description"
|
||||||
|
android:layout_toEndOf="@id/omnipod_history_source"
|
||||||
|
android:textSize="12sp" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
<!-- Omnipod Dash - History -->
|
<!-- Omnipod Dash - History -->
|
||||||
<string name="omnipod_dash_history_title">Pod History</string>
|
<string name="omnipod_dash_history_title">Pod History</string>
|
||||||
<string name="omnipod_dash_history_item_description">Description</string>
|
<string name="omnipod_dash_history_item_description">Description</string>
|
||||||
|
<string name="omnipod_dash_history_item_amount">Amount</string>
|
||||||
<string name="omnipod_dash_history_item_source">Source</string>
|
<string name="omnipod_dash_history_item_source">Source</string>
|
||||||
<string name="omnipod_dash_history_item_date">Date</string>
|
<string name="omnipod_dash_history_item_date">Date</string>
|
||||||
<string name="omnipod_dash_history_type">Type:</string>
|
<string name="omnipod_dash_history_type">Type:</string>
|
||||||
|
@ -47,6 +48,7 @@
|
||||||
<string name="omnipod_common_history_tbr_value">Rate: %1$.2f U, duration: %2$d minutes</string>
|
<string name="omnipod_common_history_tbr_value">Rate: %1$.2f U, duration: %2$d minutes</string>
|
||||||
<string name="omnipod_common_history_bolus_value">%1$.2f U</string>
|
<string name="omnipod_common_history_bolus_value">%1$.2f U</string>
|
||||||
<string name="omnipod_common_alert_delivery_suspended">Insulin delivery is suspended</string>
|
<string name="omnipod_common_alert_delivery_suspended">Insulin delivery is suspended</string>
|
||||||
|
<string name="omnipod_common_history_total_delivered">Total delivered: %1$.2f U</string>
|
||||||
<string name="omnipod_dash_connection_lost">Lost connection to pod</string>
|
<string name="omnipod_dash_connection_lost">Lost connection to pod</string>
|
||||||
<string name="omnipod_dash_bolus_already_in_progress">Another bolus is being delivered</string>
|
<string name="omnipod_dash_bolus_already_in_progress">Another bolus is being delivered</string>
|
||||||
<string name="omnipod_dash_not_enough_insulin">Not enough insulin left in the reservoir</string>
|
<string name="omnipod_dash_not_enough_insulin">Not enough insulin left in the reservoir</string>
|
||||||
|
@ -60,6 +62,7 @@
|
||||||
<string name="failed_to_set_the_new_basal_profile">Failed to set the new basal profile. Delivery suspended</string>
|
<string name="failed_to_set_the_new_basal_profile">Failed to set the new basal profile. Delivery suspended</string>
|
||||||
<string name="setting_basal_profile_might_have_failed">Setting basal profile might have failed. Delivery might be suspended! Please manually refresh the Pod status from the Omnipod tab and resume delivery if needed.</string>
|
<string name="setting_basal_profile_might_have_failed">Setting basal profile might have failed. Delivery might be suspended! Please manually refresh the Pod status from the Omnipod tab and resume delivery if needed.</string>
|
||||||
<string name="bolus_delivery_status_uncertain">Bolus delivery status uncertain. Refresh pod status to confirm or deny.</string>
|
<string name="bolus_delivery_status_uncertain">Bolus delivery status uncertain. Refresh pod status to confirm or deny.</string>
|
||||||
|
<string name="temp_basal_out_of_sync">Temp basal status not as expected! If a temp basal was previously running, it has been cancelled. Please check delivered insulin and pod history</string>
|
||||||
<string name="checking_delivery_status">Checking delivery status</string>
|
<string name="checking_delivery_status">Checking delivery status</string>
|
||||||
<string name="setting_temp_basal_might_have_basal_failed">Setting temp basal might have basal failed. If a temp basal was previously running, it has been cancelled. Please manually refresh the Pod status from the Omnipod tab.</string>
|
<string name="setting_temp_basal_might_have_basal_failed">Setting temp basal might have basal failed. If a temp basal was previously running, it has been cancelled. Please manually refresh the Pod status from the Omnipod tab.</string>
|
||||||
<string name="cancel_temp_basal_result_is_uncertain">Cancel temp basal result is uncertain</string>
|
<string name="cancel_temp_basal_result_is_uncertain">Cancel temp basal result is uncertain</string>
|
||||||
|
|
Loading…
Reference in a new issue