diff --git a/pump/omnipod/common/src/main/res/values/strings.xml b/pump/omnipod/common/src/main/res/values/strings.xml index 9ff1f6371160..703f5e4c7f90 100644 --- a/pump/omnipod/common/src/main/res/values/strings.xml +++ b/pump/omnipod/common/src/main/res/values/strings.xml @@ -46,6 +46,7 @@ LOT Number Sequence Number Pod Expires + Pod Hard End Last Connection Last Bolus Temp Basal Rate diff --git a/pump/omnipod/dash/src/main/kotlin/app/aaps/pump/omnipod/dash/ui/compose/DashOverviewViewModel.kt b/pump/omnipod/dash/src/main/kotlin/app/aaps/pump/omnipod/dash/ui/compose/DashOverviewViewModel.kt index 986cec4c0669..d5718a9dcda9 100644 --- a/pump/omnipod/dash/src/main/kotlin/app/aaps/pump/omnipod/dash/ui/compose/DashOverviewViewModel.kt +++ b/pump/omnipod/dash/src/main/kotlin/app/aaps/pump/omnipod/dash/ui/compose/DashOverviewViewModel.kt @@ -66,6 +66,7 @@ import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.stateIn import kotlinx.coroutines.launch import java.time.Duration +import java.time.Instant import java.time.ZonedDateTime import java.util.Date import java.util.Locale @@ -184,6 +185,7 @@ class DashOverviewViewModel @Inject constructor( add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_firmware_version), value = PLACEHOLDER)) add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_time_on_pod), value = PLACEHOLDER)) add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_pod_expiry_date), value = PLACEHOLDER)) + add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_pod_hard_end_date), value = PLACEHOLDER)) add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_pod_status), value = buildPodStatusText(), level = buildPodStatusLevel())) add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_last_connection), value = PLACEHOLDER)) add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_last_bolus), value = PLACEHOLDER)) @@ -237,6 +239,16 @@ class DashOverviewViewModel @Inject constructor( } add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_pod_expiry_date), value = expiryValue, level = expiryLevel)) + // Hard end date (+8 hours after expiry) + val hardEndAt = expiresAt?.toInstant()?.plus(Duration.ofHours(8)) + val hardEndValue = hardEndAt?.let { dateUtil.dateAndTimeString(it.toEpochMilli()) } ?: PLACEHOLDER + val hardEndLevel = when { + hardEndAt != null && Instant.now().isAfter(hardEndAt) -> StatusLevel.CRITICAL + hardEndAt != null && Instant.now().isAfter(hardEndAt.minus(Duration.ofHours(4))) -> StatusLevel.WARNING + else -> StatusLevel.NORMAL + } + add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_pod_hard_end_date), value = hardEndValue, level = hardEndLevel)) + // Pod status add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_pod_status), value = buildPodStatusText(), level = buildPodStatusLevel())) diff --git a/pump/omnipod/eros/src/main/java/app/aaps/pump/omnipod/eros/ui/compose/ErosOverviewViewModel.kt b/pump/omnipod/eros/src/main/java/app/aaps/pump/omnipod/eros/ui/compose/ErosOverviewViewModel.kt index 284f9c21bcdd..71b51b25de78 100644 --- a/pump/omnipod/eros/src/main/java/app/aaps/pump/omnipod/eros/ui/compose/ErosOverviewViewModel.kt +++ b/pump/omnipod/eros/src/main/java/app/aaps/pump/omnipod/eros/ui/compose/ErosOverviewViewModel.kt @@ -179,6 +179,7 @@ class ErosOverviewViewModel @Inject constructor( add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_firmware_version), value = PLACEHOLDER)) add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_time_on_pod), value = PLACEHOLDER)) add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_pod_expiry_date), value = PLACEHOLDER)) + add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_pod_hard_end_date), value = PLACEHOLDER)) add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_pod_status), value = buildPodStatusText(), level = buildPodStatusLevel())) add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_last_connection), value = buildLastConnection().first, level = buildLastConnection().second)) add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_last_bolus), value = PLACEHOLDER)) @@ -209,6 +210,12 @@ class ErosOverviewViewModel @Inject constructor( val expiryLevel = if (expiresAt != null && DateTime.now().isAfter(expiresAt)) StatusLevel.CRITICAL else StatusLevel.NORMAL add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_pod_expiry_date), value = expiryValue, level = expiryLevel)) + // Hard end date (+8 hours after expiry) + val hardEndAt = expiresAt?.plusHours(8) + val hardEndValue = hardEndAt?.let { dateUtil.dateAndTimeString(it.millis) } ?: PLACEHOLDER + val hardEndLevel = if (hardEndAt != null && DateTime.now().isAfter(hardEndAt)) StatusLevel.CRITICAL else StatusLevel.NORMAL + add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_pod_hard_end_date), value = hardEndValue, level = hardEndLevel)) + // Pod status add(PumpInfoRow(label = rh.gs(CommonR.string.omnipod_common_overview_pod_status), value = buildPodStatusText(), level = buildPodStatusLevel()))