Local-first Flutter app that identifies the single behavioral change most likely to extend lifespan using hazard-based modeling. Features: - Risk engine with hazard ratios from meta-analyses - 50 countries mapped to 4 mortality groups - 6 modifiable factors: smoking, alcohol, sleep, activity, driving, work hours - SQLite local storage (no cloud, no accounts) - Muted clinical UI theme - 23 unit tests for risk engine Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
58 lines
1.5 KiB
Dart
58 lines
1.5 KiB
Dart
import 'enums.dart';
|
|
|
|
class UserProfile {
|
|
final int age;
|
|
final Sex sex;
|
|
final String country;
|
|
final double heightCm;
|
|
final double weightKg;
|
|
final Set<Diagnosis> diagnoses;
|
|
|
|
const UserProfile({
|
|
required this.age,
|
|
required this.sex,
|
|
required this.country,
|
|
required this.heightCm,
|
|
required this.weightKg,
|
|
this.diagnoses = const {},
|
|
});
|
|
|
|
double get bmi => weightKg / ((heightCm / 100) * (heightCm / 100));
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'age': age,
|
|
'sex': sex.name,
|
|
'country': country,
|
|
'heightCm': heightCm,
|
|
'weightKg': weightKg,
|
|
'diagnoses': diagnoses.map((d) => d.name).toList(),
|
|
};
|
|
|
|
factory UserProfile.fromJson(Map<String, dynamic> json) => UserProfile(
|
|
age: json['age'] as int,
|
|
sex: Sex.values.byName(json['sex'] as String),
|
|
country: json['country'] as String,
|
|
heightCm: (json['heightCm'] as num).toDouble(),
|
|
weightKg: (json['weightKg'] as num).toDouble(),
|
|
diagnoses: (json['diagnoses'] as List<dynamic>)
|
|
.map((d) => Diagnosis.values.byName(d as String))
|
|
.toSet(),
|
|
);
|
|
|
|
UserProfile copyWith({
|
|
int? age,
|
|
Sex? sex,
|
|
String? country,
|
|
double? heightCm,
|
|
double? weightKg,
|
|
Set<Diagnosis>? diagnoses,
|
|
}) =>
|
|
UserProfile(
|
|
age: age ?? this.age,
|
|
sex: sex ?? this.sex,
|
|
country: country ?? this.country,
|
|
heightCm: heightCm ?? this.heightCm,
|
|
weightKg: weightKg ?? this.weightKg,
|
|
diagnoses: diagnoses ?? this.diagnoses,
|
|
);
|
|
}
|