glp-companion/lib/features/medication/domain/entities/dose_entry.dart

46 lines
1.4 KiB
Dart

import 'injection_site.dart';
/// Immutable record of a single GLP-1 administration event.
///
/// The entity is pure Dart (no framework imports) so it can be shared by the
/// pharmacokinetic use cases, the drift-backed repository, and the Riverpod
/// presentation layer without leaking infrastructure concerns into the
/// domain.
class DoseEntry {
DoseEntry({
this.id,
required this.compoundName,
required this.doseMg,
required this.administeredAt,
DateTime? scheduledAt,
this.injectionSite,
this.notes,
}) : scheduledAt = scheduledAt ?? administeredAt;
/// Database primary key; `null` until the entry has been persisted.
final int? id;
/// Commercial or compounded agonist name (e.g. `Tirzepatide`).
final String compoundName;
/// Total injected quantity in milligrams.
final double doseMg;
/// When the dose was actually administered. Drives the pharmacokinetic
/// decay calculation (`t_i` in C(t)).
final DateTime administeredAt;
/// Titration-schedule anchor the dose was prescribed for. Defaults to
/// [administeredAt] for immediately logged injections.
final DateTime scheduledAt;
/// Rotation quadrant used for this injection; `null` for legacy rows that
/// predate site tracking.
final InjectionSite? injectionSite;
/// Free-form clinician/patient notes.
final String? notes;
/// Whether a rotation quadrant was recorded.
bool get hasInjectionSite => injectionSite != null;
}