generated from StanfordSpezi/SpeziTemplateApplication
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
342 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
6.0.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// | ||
// Baby.swift | ||
// Feedbridge | ||
// | ||
// Created by Calvin Xu on 1/30/25. | ||
// | ||
import Foundation | ||
|
||
/// Represents a baby and their associated health tracking data | ||
struct Baby: Identifiable, Codable { | ||
/// Unique identifier for the baby | ||
var id: String = UUID().uuidString | ||
|
||
/// Baby's full name | ||
var name: String | ||
|
||
/// Baby's date of birth | ||
var dateOfBirth: Date | ||
|
||
/// Collection of all feeding records | ||
var feedEntries: [FeedEntry] | ||
|
||
/// Collection of all weight measurements | ||
var weightEntries: [WeightEntry] | ||
|
||
/// Collection of all stool records | ||
var stoolEntries: [StoolEntry] | ||
|
||
/// Collection of all wet diaper records | ||
var wetDiaperEntries: [WetDiaperEntry] | ||
|
||
/// Collection of all dehydration check records | ||
var dehydrationChecks: [DehydrationCheck] | ||
|
||
/// Calculate baby's age in months (rounded down) | ||
var ageInMonths: Int { | ||
Calendar.current.dateComponents([.month], from: dateOfBirth, to: Date()).month ?? 0 | ||
} | ||
|
||
/// Get the most recent weight entry | ||
var currentWeight: WeightEntry? { | ||
weightEntries.max(by: { $0.dateTime < $1.dateTime }) | ||
} | ||
|
||
/// Get the most recent dehydration check | ||
var latestDehydrationCheck: DehydrationCheck? { | ||
dehydrationChecks.max(by: { $0.dateTime < $1.dateTime }) | ||
} | ||
|
||
/// Check if there are any active medical alerts | ||
var hasActiveAlerts: Bool { | ||
latestDehydrationCheck?.dehydrationAlert == true || | ||
wetDiaperEntries.last?.dehydrationAlert == true || | ||
stoolEntries.last?.medicalAlert == true | ||
} | ||
|
||
/// Initialize a new baby with required information | ||
init(name: String, dateOfBirth: Date) { | ||
self.name = name | ||
self.dateOfBirth = dateOfBirth | ||
self.feedEntries = [] | ||
self.weightEntries = [] | ||
self.stoolEntries = [] | ||
self.wetDiaperEntries = [] | ||
self.dehydrationChecks = [] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// DehydrationCheck.swift | ||
// Feedbridge | ||
// | ||
// Created by Calvin Xu on 1/30/25. | ||
// | ||
import Foundation | ||
|
||
/// Stores dehydration-related information | ||
struct DehydrationCheck: Identifiable, Codable { | ||
var id: String = UUID().uuidString | ||
|
||
/// Date and time of the check | ||
var dateTime: Date | ||
|
||
/// True if skin elasticity is reduced (e.g., "tenting" over abdomen) | ||
var poorSkinElasticity: Bool | ||
|
||
/// True if lips or tongue are dry | ||
var dryMucousMembranes: Bool | ||
|
||
/// Whether a medical alert has been triggered | ||
var dehydrationAlert: Bool { | ||
poorSkinElasticity || dryMucousMembranes | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// FeedEntry.swift | ||
// Feedbridge | ||
// | ||
// Created by Calvin Xu on 1/30/25. | ||
// | ||
import Foundation | ||
|
||
/// Represents method of feeding | ||
enum FeedType: String, Codable { | ||
case directBreastfeeding | ||
case bottle | ||
} | ||
|
||
/// Represents the type of milk used | ||
enum MilkType: String, Codable { | ||
case breastmilk | ||
case formula | ||
} | ||
|
||
/// Stores feeding-related data | ||
struct FeedEntry: Identifiable, Codable { | ||
/// Use UUID to generate a unique identifier for Firebase | ||
var id: String = UUID().uuidString | ||
|
||
/// Date and time of the feed | ||
var dateTime: Date | ||
|
||
/// Type of feeding (direct breastfeeding or bottle) | ||
var feedType: FeedType | ||
|
||
/// Type of milk used if feedType = .bottle | ||
var milkType: MilkType? | ||
|
||
/// Duration of direct breastfeeding in minutes | ||
var feedTimeInMinutes: Int? | ||
|
||
/// Bottle feed volume in milliliters | ||
var feedVolumeInML: Double? | ||
|
||
/// Initialize for direct breastfeeding | ||
init(directBreastfeeding minutes: Int, dateTime: Date = Date()) { | ||
self.dateTime = dateTime | ||
self.feedType = .directBreastfeeding | ||
self.feedTimeInMinutes = minutes | ||
self.milkType = nil | ||
self.feedVolumeInML = nil | ||
} | ||
|
||
/// Initialize for bottle feeding | ||
init(bottle volumeML: Double, milkType: MilkType, dateTime: Date = Date()) { | ||
self.dateTime = dateTime | ||
self.feedType = .bottle | ||
self.milkType = milkType | ||
self.feedVolumeInML = volumeML | ||
self.feedTimeInMinutes = nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// | ||
// Guardian.swift | ||
// Feedbridge | ||
// | ||
// Created by Calvin Xu on 1/30/25. | ||
// | ||
import Foundation | ||
|
||
/// Represents a guardian (parent or caregiver) who takes care of babies | ||
struct Guardian: Identifiable, Codable { | ||
/// Unique identifier for the guardian | ||
var id: String = UUID().uuidString | ||
|
||
/// Guardian's full name | ||
var name: String | ||
|
||
/// Guardian's email address | ||
var email: String | ||
|
||
/// Guardian's phone number | ||
var phoneNumber: String | ||
|
||
/// Collection of babies under this guardian's care | ||
var babies: [Baby] | ||
|
||
/// Get all babies with active medical alerts | ||
var babiesWithAlerts: [Baby] { | ||
babies.filter { $0.hasActiveAlerts } | ||
} | ||
|
||
/// Initialize a new guardian with required information | ||
init(name: String, email: String, phoneNumber: String) { | ||
self.name = name | ||
self.email = email | ||
self.phoneNumber = phoneNumber | ||
self.babies = [] | ||
} | ||
|
||
/// Add a baby to the guardian's care | ||
mutating func addBaby(_ baby: Baby) { | ||
babies.append(baby) | ||
} | ||
|
||
/// Remove a baby from the guardian's care | ||
mutating func removeBaby(withId id: String) { | ||
babies.removeAll { $0.id == id } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// StoolEntry.swift | ||
// Feedbridge | ||
// | ||
// Created by Calvin Xu on 1/30/25. | ||
// | ||
import Foundation | ||
|
||
/// Represents stool volume classifications | ||
enum StoolVolume: String, Codable { | ||
case light | ||
case medium | ||
case heavy | ||
} | ||
|
||
/// Represents color variations for stool entries | ||
enum StoolColor: String, Codable { | ||
case black | ||
case darkGreen | ||
case green | ||
case brown | ||
case yellow | ||
case beige | ||
} | ||
|
||
/// Stores stool data | ||
struct StoolEntry: Identifiable, Codable { | ||
var id: String = UUID().uuidString | ||
|
||
/// Date and time of the stool event | ||
var dateTime: Date | ||
|
||
/// Volume classification | ||
var volume: StoolVolume | ||
|
||
/// Color of the stool | ||
var color: StoolColor | ||
|
||
/// Whether a medical alert should be displayed | ||
var medicalAlert: Bool { | ||
color == .beige | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// WeightEntry.swift | ||
// Feedbridge | ||
// | ||
// Created by Calvin Xu on 1/30/25. | ||
// | ||
import Foundation | ||
|
||
/// Stores weight measurements (accepts grams, kilograms, or pounds and ounces) | ||
struct WeightEntry: Identifiable, Codable { | ||
var id: String = UUID().uuidString | ||
|
||
/// Date and time the weight was measured | ||
var dateTime: Date | ||
|
||
/// Weight in grams (primary storage) | ||
var weightInGrams: Double | ||
|
||
var asKilograms: Measurement<UnitMass> { | ||
Measurement(value: weightInGrams, unit: UnitMass.grams).converted(to: .kilograms) | ||
} | ||
|
||
var asPounds: Measurement<UnitMass> { | ||
Measurement(value: weightInGrams, unit: UnitMass.grams).converted(to: .pounds) | ||
} | ||
|
||
init(grams: Double, dateTime: Date = Date()) { | ||
self.dateTime = dateTime | ||
self.weightInGrams = grams | ||
} | ||
|
||
init(kilograms: Double, dateTime: Date = Date()) { | ||
let measurement = Measurement(value: kilograms, unit: UnitMass.kilograms) | ||
self.dateTime = dateTime | ||
self.weightInGrams = measurement.converted(to: .grams).value | ||
} | ||
|
||
init(pounds: Double, ounces: Double = 0, dateTime: Date = Date()) { | ||
let totalPounds = pounds + (ounces / 16.0) | ||
let measurement = Measurement(value: totalPounds, unit: UnitMass.pounds) | ||
self.dateTime = dateTime | ||
self.weightInGrams = measurement.converted(to: .grams).value | ||
} | ||
} |
Oops, something went wrong.