class SupplementIntake { final int? id; final int supplementId; final DateTime takenAt; final double dosageTaken; // Total dosage amount taken final int unitsTaken; // Number of units taken final String? notes; SupplementIntake({ this.id, required this.supplementId, required this.takenAt, required this.dosageTaken, required this.unitsTaken, this.notes, }); Map toMap() { return { 'id': id, 'supplementId': supplementId, 'takenAt': takenAt.toIso8601String(), 'dosageTaken': dosageTaken, 'unitsTaken': unitsTaken, 'notes': notes, }; } factory SupplementIntake.fromMap(Map map) { return SupplementIntake( id: map['id'], supplementId: map['supplementId'], takenAt: DateTime.parse(map['takenAt']), dosageTaken: map['dosageTaken'], unitsTaken: map['unitsTaken'] ?? 1, // Default for backwards compatibility notes: map['notes'], ); } SupplementIntake copyWith({ int? id, int? supplementId, DateTime? takenAt, double? dosageTaken, int? unitsTaken, String? notes, }) { return SupplementIntake( id: id ?? this.id, supplementId: supplementId ?? this.supplementId, takenAt: takenAt ?? this.takenAt, dosageTaken: dosageTaken ?? this.dosageTaken, unitsTaken: unitsTaken ?? this.unitsTaken, notes: notes ?? this.notes, ); } }