- Split behavioral inputs into two screens (Habits + Lifestyle) - Added 5 new modifiable factors: diet quality, processed food, drug use, social connection, and stress level - Updated hazard ratios for all new factors based on meta-analyses - Model version bumped to 1.1 - Simplified welcome screen with clearer value proposition - Updated tests for expanded behavioral model Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
145 lines
4.8 KiB
Dart
145 lines
4.8 KiB
Dart
import 'enums.dart';
|
|
|
|
class BehavioralInputs {
|
|
// Screen 1: Basic behaviors
|
|
final SmokingStatus smoking;
|
|
final int cigarettesPerDay;
|
|
final AlcoholLevel alcohol;
|
|
final double sleepHours;
|
|
final bool sleepConsistent;
|
|
final ActivityLevel activity;
|
|
|
|
// Screen 2: Lifestyle factors
|
|
final DietQuality diet;
|
|
final ProcessedFoodLevel processedFood;
|
|
final DrugUse drugUse;
|
|
final SocialConnection social;
|
|
final StressLevel stress;
|
|
final DrivingExposure driving;
|
|
final WorkHoursLevel workHours;
|
|
|
|
const BehavioralInputs({
|
|
required this.smoking,
|
|
this.cigarettesPerDay = 0,
|
|
required this.alcohol,
|
|
required this.sleepHours,
|
|
required this.sleepConsistent,
|
|
required this.activity,
|
|
required this.diet,
|
|
required this.processedFood,
|
|
required this.drugUse,
|
|
required this.social,
|
|
required this.stress,
|
|
required this.driving,
|
|
required this.workHours,
|
|
});
|
|
|
|
static const optimal = BehavioralInputs(
|
|
smoking: SmokingStatus.never,
|
|
cigarettesPerDay: 0,
|
|
alcohol: AlcoholLevel.none,
|
|
sleepHours: 7.5,
|
|
sleepConsistent: true,
|
|
activity: ActivityLevel.high,
|
|
diet: DietQuality.excellent,
|
|
processedFood: ProcessedFoodLevel.rarely,
|
|
drugUse: DrugUse.none,
|
|
social: SocialConnection.strong,
|
|
stress: StressLevel.low,
|
|
driving: DrivingExposure.low,
|
|
workHours: WorkHoursLevel.normal,
|
|
);
|
|
|
|
/// Create partial inputs from screen 1 (with defaults for screen 2)
|
|
factory BehavioralInputs.fromScreen1({
|
|
required SmokingStatus smoking,
|
|
int cigarettesPerDay = 0,
|
|
required AlcoholLevel alcohol,
|
|
required double sleepHours,
|
|
required bool sleepConsistent,
|
|
required ActivityLevel activity,
|
|
}) {
|
|
return BehavioralInputs(
|
|
smoking: smoking,
|
|
cigarettesPerDay: cigarettesPerDay,
|
|
alcohol: alcohol,
|
|
sleepHours: sleepHours,
|
|
sleepConsistent: sleepConsistent,
|
|
activity: activity,
|
|
diet: DietQuality.fair,
|
|
processedFood: ProcessedFoodLevel.frequent,
|
|
drugUse: DrugUse.none,
|
|
social: SocialConnection.moderate,
|
|
stress: StressLevel.moderate,
|
|
driving: DrivingExposure.low,
|
|
workHours: WorkHoursLevel.normal,
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
'smoking': smoking.name,
|
|
'cigarettesPerDay': cigarettesPerDay,
|
|
'alcohol': alcohol.name,
|
|
'sleepHours': sleepHours,
|
|
'sleepConsistent': sleepConsistent,
|
|
'activity': activity.name,
|
|
'diet': diet.name,
|
|
'processedFood': processedFood.name,
|
|
'drugUse': drugUse.name,
|
|
'social': social.name,
|
|
'stress': stress.name,
|
|
'driving': driving.name,
|
|
'workHours': workHours.name,
|
|
};
|
|
|
|
factory BehavioralInputs.fromJson(Map<String, dynamic> json) =>
|
|
BehavioralInputs(
|
|
smoking: SmokingStatus.values.byName(json['smoking'] as String),
|
|
cigarettesPerDay: json['cigarettesPerDay'] as int? ?? 0,
|
|
alcohol: AlcoholLevel.values.byName(json['alcohol'] as String),
|
|
sleepHours: (json['sleepHours'] as num).toDouble(),
|
|
sleepConsistent: json['sleepConsistent'] as bool,
|
|
activity: ActivityLevel.values.byName(json['activity'] as String),
|
|
diet: DietQuality.values.byName(json['diet'] as String? ?? 'fair'),
|
|
processedFood: ProcessedFoodLevel.values
|
|
.byName(json['processedFood'] as String? ?? 'frequent'),
|
|
drugUse: DrugUse.values.byName(json['drugUse'] as String? ?? 'none'),
|
|
social: SocialConnection.values
|
|
.byName(json['social'] as String? ?? 'moderate'),
|
|
stress:
|
|
StressLevel.values.byName(json['stress'] as String? ?? 'moderate'),
|
|
driving: DrivingExposure.values.byName(json['driving'] as String),
|
|
workHours: WorkHoursLevel.values.byName(json['workHours'] as String),
|
|
);
|
|
|
|
BehavioralInputs copyWith({
|
|
SmokingStatus? smoking,
|
|
int? cigarettesPerDay,
|
|
AlcoholLevel? alcohol,
|
|
double? sleepHours,
|
|
bool? sleepConsistent,
|
|
ActivityLevel? activity,
|
|
DietQuality? diet,
|
|
ProcessedFoodLevel? processedFood,
|
|
DrugUse? drugUse,
|
|
SocialConnection? social,
|
|
StressLevel? stress,
|
|
DrivingExposure? driving,
|
|
WorkHoursLevel? workHours,
|
|
}) =>
|
|
BehavioralInputs(
|
|
smoking: smoking ?? this.smoking,
|
|
cigarettesPerDay: cigarettesPerDay ?? this.cigarettesPerDay,
|
|
alcohol: alcohol ?? this.alcohol,
|
|
sleepHours: sleepHours ?? this.sleepHours,
|
|
sleepConsistent: sleepConsistent ?? this.sleepConsistent,
|
|
activity: activity ?? this.activity,
|
|
diet: diet ?? this.diet,
|
|
processedFood: processedFood ?? this.processedFood,
|
|
drugUse: drugUse ?? this.drugUse,
|
|
social: social ?? this.social,
|
|
stress: stress ?? this.stress,
|
|
driving: driving ?? this.driving,
|
|
workHours: workHours ?? this.workHours,
|
|
);
|
|
}
|