Bugfixes: Vitals Import (German columns + decimal values) #23

Merged
Lars merged 6 commits from develop into main 2026-03-23 16:52:28 +01:00
Owner

Bugfixes

Import-Zaehlung korrigiert

  • Fix: Uebersprungene Eintraege wurden als "updated" gezaehlt
  • Jetzt korrekt: skipped wenn WHERE-Klausel Update verhindert

Deutsche Spaltennamen

  • Apple Health: Unterstuetzung fuer deutsche Spalten (Ruhepuls, Herzfrequenzvariabilitaet, VO2 max, etc.)
  • Omron: Spalten mit Einheiten (Systolisch (mmHg), Diastolisch (mmHg), Puls (bpm))

Dezimalwerte-Parsing

  • Problem: Apple Health exportiert Vitalwerte mit Dezimalstellen (HRV = 37.95 ms)
  • Fix: safe_int() und safe_float() Funktionen mit robustem Parsing

Error-Details in Response

  • Import zeigt jetzt detaillierte Fehlermeldungen im Frontend
  • Rote Box bei Fehlern mit ersten 10 Error-Details

Testing

  • Tested on dev.mitai.jinkendo.de
  • Apple Health Import: 31 Zeilen erfolgreich
  • Omron Import: Funktioniert mit deutschen Spalten

Generated with Claude Code

## Bugfixes ### Import-Zaehlung korrigiert - Fix: Uebersprungene Eintraege wurden als "updated" gezaehlt - Jetzt korrekt: skipped wenn WHERE-Klausel Update verhindert ### Deutsche Spaltennamen - Apple Health: Unterstuetzung fuer deutsche Spalten (Ruhepuls, Herzfrequenzvariabilitaet, VO2 max, etc.) - Omron: Spalten mit Einheiten (Systolisch (mmHg), Diastolisch (mmHg), Puls (bpm)) ### Dezimalwerte-Parsing - Problem: Apple Health exportiert Vitalwerte mit Dezimalstellen (HRV = 37.95 ms) - Fix: safe_int() und safe_float() Funktionen mit robustem Parsing ### Error-Details in Response - Import zeigt jetzt detaillierte Fehlermeldungen im Frontend - Rote Box bei Fehlern mit ersten 10 Error-Details ## Testing - Tested on dev.mitai.jinkendo.de - Apple Health Import: 31 Zeilen erfolgreich - Omron Import: Funktioniert mit deutschen Spalten --- Generated with Claude Code
Lars added 6 commits 2026-03-23 16:52:11 +01:00
fix: correct import skipped count when manual entries exist
All checks were successful
Deploy Development / deploy (push) Successful in 54s
Build Test / lint-backend (push) Successful in 1s
Build Test / build-frontend (push) Successful in 14s
7dcab1d7a3
Problem: Import reported all entries as "updated" even when skipped
due to WHERE clause (source != 'manual')

Root cause: RETURNING returns NULL when WHERE clause prevents update,
but code counted NULL as "updated" instead of "skipped"

Fix:
- Check if result is None → skipped (WHERE prevented update)
- Check if xmax = 0 → inserted (new row)
- Otherwise → updated (existing row modified)

Affects:
- vitals_baseline.py: Apple Health import
- blood_pressure.py: Omron import

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
debug: add logging to Apple Health import to diagnose skipped rows
All checks were successful
Deploy Development / deploy (push) Successful in 49s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 13s
6a7b78c3eb
Logs:
- CSV column names from first row
- Rows skipped due to missing date
- Rows skipped due to no vitals data
- Shows which fields were found/missing

Helps diagnose CSV format mismatches.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
fix: support German column names in CSV imports
All checks were successful
Deploy Development / deploy (push) Successful in 44s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s
f506a55d7b
Problem: Import expected English column names, but German Apple Health/Omron
exports use German names with units.

Fixed:
- Apple Health: Support both English and German column names
  - "Start" OR "Datum/Uhrzeit"
  - "Resting Heart Rate" OR "Ruhepuls (count/min)"
  - "Heart Rate Variability" OR "Herzfrequenzvariabilität (ms)"
  - "VO2 Max" OR "VO2 max (ml/(kg·min))"
  - "Oxygen Saturation" OR "Blutsauerstoffsättigung (%)"
  - "Respiratory Rate" OR "Atemfrequenz (count/min)"

- Omron: Support column names with/without units
  - "Systolisch (mmHg)" OR "Systolisch"
  - "Diastolisch (mmHg)" OR "Diastolisch"
  - "Puls (bpm)" OR "Puls"
  - "Unregelmäßiger Herzschlag festgestellt" OR "Unregelmäßiger Herzschlag"
  - "Mögliches AFib" OR "Vorhofflimmern"

Added debug logging for both imports to show detected columns.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
debug: add detailed error logging with traceback for import failures
All checks were successful
Deploy Development / deploy (push) Successful in 45s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 12s
4b024e6d0f
fix: return error details in import response for debugging
All checks were successful
Deploy Development / deploy (push) Successful in 50s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 14s
6b64cf31c4
Problem: Errors during import were logged but not visible to user.

Changes:
- Backend: Collect error messages and return in response (first 10 errors)
- Frontend: Display error details in import result box
- UI: Red background when errors > 0, shows detailed error messages

Now users can see exactly which rows failed and why.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
fix: handle decimal values in Apple Health vitals import
All checks were successful
Deploy Development / deploy (push) Successful in 50s
Build Test / lint-backend (push) Successful in 1s
Build Test / build-frontend (push) Successful in 13s
6f035e3706
Problem: Import failed with "invalid literal for int() with base 10: '37.95'"
because Apple Health exports HRV and other vitals with decimal values.

Root cause: Code used int() directly on string values with decimals.

Fix:
- Added safe_int(): parses decimals as float first, then rounds to int
- Added safe_float(): robust float parsing with error handling
- Applied to all vital value parsing: RHR, HRV, VO2 Max, SpO2, resp rate

Example: '37.95' → float(37.95) → int(38) ✓

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Lars merged commit 5a6a140dfd into main 2026-03-23 16:52:28 +01:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Lars/mitai-jinkendo#23
No description provided.