Blood test spreadsheets: ferritin, Hb, iron in the health section

- sources/labs.py reads .xlsx/.csv sheets with a Date column; columns are
  recognised by header (ferritin, Hb, serum iron, transferrin saturation),
  with the lab's reference range and the user's Min/Max target. Formula
  cells are skipped.
- Importing a sheet from disk remembers it in settings "lab_files"; every
  dashboard build reads it again. Editable in the app's settings.
- Dashboard: ferritin chart (log scale, main lab as a line, a second lab
  as points, target range dashed), results table and a finding.
- openpyxl added as a dependency and to the installer bundle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Riaan Doorduin
2026-11-15 13:20:25 +02:00
parent c6a1eb199d
commit 0d3da5f2df
11 changed files with 224 additions and 16 deletions

View File

@@ -128,7 +128,7 @@ details[open] > summary { margin-bottom: 10px }
<h2>Add data</h2>
<div id="drop">
<b>Drop files or folders here</b>
<span class="muted">Garmin or Strava export zips, a copied watch <code>GARMIN</code> folder, or .fit .tcx .gpx .trk files</span>
<span class="muted">Garmin or Strava export zips, a copied watch <code>GARMIN</code> folder, or .fit .tcx .gpx .trk files, or a blood test spreadsheet (.xlsx)</span>
<div class="row" style="justify-content:center;margin-top:12px">
<button class="job" onclick="ui.chooseFiles()">Choose files…</button>
<button class="job" onclick="ui.chooseFolder()">Choose a folder…</button>
@@ -182,6 +182,7 @@ details[open] > summary { margin-bottom: 10px }
<label>Sex<select id="sSex"><option value="">Not set</option><option value="M">Male</option><option value="F">Female</option></select></label>
<label>Home time zone<input id="sTz" list="tzList"></label>
<label class="wide">Also copy the dashboard to (one path per line, e.g. a OneDrive folder)<textarea id="sCopies"></textarea></label>
<label class="wide">Blood test spreadsheets, read again at every update (.xlsx or .csv, one path per line; a Date column plus e.g. Ferritin, Hb)<textarea id="sLabs"></textarea></label>
</div>
<div class="row" style="margin-top:10px"><button class="primary" onclick="ui.saveSettings()">Save settings</button><span class="note">Rebuild the dashboard afterwards to apply.</span></div>
</details>
@@ -232,7 +233,7 @@ const ui = {
$('openDash').disabled = !L.dashboard;
const s = L.settings;
if (!$('settingsBox').open) { $('sName').value = s.name || ''; $('sBirth').value = s.birth_year || ''; $('sSex').value = s.sex || ''; $('sTz').value = s.home_tz || 'UTC';
$('sCopies').value = (s.copy_dashboard_to || []).join('\n') }
$('sCopies').value = (s.copy_dashboard_to || []).join('\n'); $('sLabs').value = (s.lab_files || []).join('\n') }
},
busy(name) {
$('busy').textContent = name ? `Working: ${name}…` : ''; $('busy').classList.toggle('hidden', !name);
@@ -253,7 +254,7 @@ const ui = {
},
async open() { ui.render(await ui.call('open_library', $('openPath').value.trim())) },
async saveSettings() {
const st = await ui.call('save_settings', $('sName').value.trim(), $('sBirth').value, $('sSex').value, $('sTz').value.trim() || 'UTC', $('sCopies').value);
const st = await ui.call('save_settings', $('sName').value.trim(), $('sBirth').value, $('sSex').value, $('sTz').value.trim() || 'UTC', $('sCopies').value, $('sLabs').value);
$('settingsBox').open = false; ui.render(st); ui.log('Settings saved.');
},
async login() {