Overview
MiTensión divides each day into three distinct periods to help users track blood pressure readings at different times. The app allows up to 3 measurements per period, following medical best practices for blood pressure monitoring.The Three Periods
The day is divided into three time-based periods:Morning
Mañana00:01 - 12:30(1 - 750 minutes)
Afternoon
Tarde12:31 - 19:00(751 - 1140 minutes)
Night
Noche19:01 - 00:00(1141 - 1440 minutes)
Period Determination Logic
The app calculates which period it is based on the current time using a minutes-since-midnight approach:Calculation Method
The time is converted to “minutes since midnight” for efficient range checking. For example, 14:30 becomes 870 minutes (14 × 60 + 30).
Time Ranges Explained
Morning Period (Mañana): 00:01 - 12:30
Morning Period (Mañana): 00:01 - 12:30
The morning period starts one minute after midnight and extends until 12:30 PM.Time Range in Minutes: 1 - 750Why this range?
- Captures early morning readings (important for baseline BP)
- Extends past noon to accommodate late risers
- Ends at 12:30 to split the day naturally
- 06:00 → 360 minutes → Morning
- 12:00 → 720 minutes → Morning
- 12:30 → 750 minutes → Morning
Afternoon Period (Tarde): 12:31 - 19:00
Afternoon Period (Tarde): 12:31 - 19:00
The afternoon period covers the middle of the day through early evening.Time Range in Minutes: 751 - 1140Why this range?
- Captures post-lunch readings
- Covers typical working hours
- Ends before evening routines begin
- 12:31 → 751 minutes → Afternoon
- 15:30 → 930 minutes → Afternoon
- 19:00 → 1140 minutes → Afternoon
Night Period (Noche): 19:01 - 00:00
Night Period (Noche): 19:01 - 00:00
The night period covers the evening through midnight.Time Range in Minutes: 1141 - 1440 (and 0 for midnight)Why this range?
- Captures evening readings before bed
- Important for tracking nighttime blood pressure
- Resets at midnight for the new day
- 19:01 → 1141 minutes → Night
- 22:00 → 1320 minutes → Night
- 00:00 → 0 minutes → Night (edge case)
Period for Historical Timestamps
When displaying historical data, the app determines which period a timestamp belongs to:This function uses the same logic as
obtenerPeriodoActual() but applies it to any timestamp, allowing the app to correctly categorize historical measurements.Timestamp Range Calculation
The app can calculate the exact timestamp range for each period on the current day:Range Examples
| Period | Start Time | End Time | Usage |
|---|---|---|---|
| Morning | 00:01 | 12:30 | Query morning measurements |
| Afternoon | 12:31 | 19:00 | Query afternoon measurements |
| Night | 19:01 | 00:00 (next day) | Query night measurements |
Time Until Next Period
The app calculates how much time remains until the next period begins:"2h y 30m"- 2 hours and 30 minutes until next period"45m"- 45 minutes until next period"un momento"- Less than a minute remaining
Measurement Limits Per Period
MiTensión enforces a limit of 3 measurements per period:This follows medical guidelines for blood pressure monitoring, which recommend taking 2-3 readings with brief intervals between them.
Period Full Handling
When a user tries to add a measurement to a full period, the app:- Displays an error message:
"Ya has completado los 3 registros para este período" - Shows how long until the next period:
"El siguiente período empieza en {time}" - Prevents adding the measurement
Implementation Reference
The period tracking system is implemented across two files:PeriodoDelDia.kt
Defines the enum and current period detection:Located at
app/src/main/java/com/fxn/mitension/util/PeriodoDelDia.kt:5TimeUtils.kt
Provides utility functions for:- Timestamp range calculation (
obtenerRangoTimestamps) - Time remaining calculation (
obtenerTiempoRestanteParaSiguientePeriodo) - Period determination from timestamps (
obtenerPeriodoParaTimestamp)
Located at
app/src/main/java/com/fxn/mitension/util/TimeUtils.ktLocalized Period Names
The app uses Spanish names for periods, defined instrings.xml:
- Current period indicator
- Measurement entry screens
- Calendar detail views
- Notification messages
UI Integration
Title Display
The measurement screen shows the current period and count:"Mañana - Medición 2/3"
Notification Text
Reminder notifications reference the current period:"Aún te faltan 2 mediciones para completar el período de la Tarde."
Best Practices
When to take measurements
When to take measurements
- Morning: Shortly after waking up, before medications
- Afternoon: Mid-day or after lunch
- Night: Before bedtime, after relaxing
Why three periods?
Why three periods?
The three-period system provides:
- Comprehensive coverage of the 24-hour cycle
- Flexibility for different schedules
- Medical relevance for tracking BP fluctuations
- User-friendly divisions that match daily routines
Period transition handling
Period transition handling
The app automatically detects period transitions. If you’re in the middle of entering a measurement when the period changes, the new measurement will be recorded in the new period.