Add pump profile fetching and Insulineprofiel page
willemjan/glucose-dashboard/pipeline/head This commit looks good
willemjan/glucose-dashboard/pipeline/head This commit looks good
Fetch and parse the latest-used Nightscout profile (basal schedule, ISF, carb ratio, DIA, targets) and show it as a new dashboard page: a list of basal/ISF/carb-ratio segments plus a bar chart of basal rate by hour of day. This is the data foundation for treatment overlays on the glucose charts and the redesigned PDF report in follow-up PRs.
This commit is contained in:
+21
-1
@@ -14,7 +14,8 @@ import pandas as pd
|
||||
import plotly.graph_objects as go
|
||||
import streamlit as st
|
||||
|
||||
from nightscout_client import fetch_entries_range, fetch_treatments_range
|
||||
from nightscout_client import fetch_entries_range, fetch_profile, fetch_treatments_range
|
||||
from profile_data import parse_profile
|
||||
from reporting import (
|
||||
HIGH,
|
||||
LOW,
|
||||
@@ -57,6 +58,11 @@ PALETTE = {
|
||||
"tir_in_range": "#0ca30c",
|
||||
"tir_high": "#fab219",
|
||||
"tir_very_high": "#c76f0a",
|
||||
"basal": "#7b5ea3",
|
||||
"bolus_food": "#1baf7a",
|
||||
"bolus_correction": "#2a78d6",
|
||||
"bolus_smb": "#898781",
|
||||
"target": "#52514e",
|
||||
},
|
||||
"dark": {
|
||||
"glucose": "#3987e5",
|
||||
@@ -76,6 +82,11 @@ PALETTE = {
|
||||
"tir_in_range": "#0ca30c",
|
||||
"tir_high": "#fab219",
|
||||
"tir_very_high": "#d9852e",
|
||||
"basal": "#9b7ec2",
|
||||
"bolus_food": "#199e70",
|
||||
"bolus_correction": "#3987e5",
|
||||
"bolus_smb": "#898781",
|
||||
"target": "#c3c2b7",
|
||||
},
|
||||
}
|
||||
|
||||
@@ -129,6 +140,15 @@ def load_range_data(start: date, end: date):
|
||||
return glucose, treatments
|
||||
|
||||
|
||||
@st.cache_data(ttl=21600, show_spinner="Profiel ophalen van Nightscout...")
|
||||
def load_profile() -> dict:
|
||||
"""Gecachete profiel-fetch. Langere TTL dan load_range_data (6 uur i.p.v.
|
||||
1 uur): een pompprofiel wijzigt zelden, in tegenstelling tot glucose-/
|
||||
behandeldata van een lopende periode."""
|
||||
raw = fetch_profile()
|
||||
return parse_profile(raw)
|
||||
|
||||
|
||||
def add_threshold_lines(fig: go.Figure, colors: dict, row: int | None = None) -> None:
|
||||
"""Teken de 4 klinische drempellijnen (3.0/3.9/10.0/13.9 mmol/L) op een grafiek.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user