Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
f2292de
Added HKVisualizations
Priyankas007 Feb 6, 2025
ac9dbaa
Added health visualizations
Priyankas007 Feb 10, 2025
7d2c720
Merge branch 'main' into priyanka
Priyankas007 Feb 12, 2025
d16a297
Updated tests
Priyankas007 Feb 12, 2025
dd1aa5a
Managing pull conflicts
Priyankas007 Feb 12, 2025
3bada05
Managing commit conflicts
Priyankas007 Feb 12, 2025
bae5d19
Merge branch 'priyanka' of https://github.com/CS342/2025-NeutroFeverG…
Priyankas007 Feb 12, 2025
a9f1d89
Merge branch 'main' into priyanka
Priyankas007 Feb 12, 2025
5964595
Fixed login issues
Priyankas007 Feb 12, 2025
ee7795b
Merge branch 'priyanka' of https://github.com/CS342/2025-NeutroFeverG…
Priyankas007 Feb 12, 2025
e050cf5
Recovered visualizations
Priyankas007 Feb 12, 2025
f39feb5
Fixed build issues
Priyankas007 Feb 12, 2025
5eafb1f
Disabled mock data feature flag
Priyankas007 Feb 12, 2025
db63d88
Removed orphaned doc comment
Priyankas007 Feb 12, 2025
801aca0
Disabled orphaned_doc_comment link warning
Priyankas007 Feb 13, 2025
70f2e15
Added onboarding to scheme
Priyankas007 Feb 13, 2025
0cd97e2
Removed failing UI test
Priyankas007 Feb 13, 2025
e8ff374
Updated HKVisualiztion UI
Priyankas007 Feb 13, 2025
7d8311b
Update HKMockData
Priyankas007 Feb 13, 2025
aa6248d
Merge branch 'main' into priyanka_ui
Priyankas007 Feb 13, 2025
2d697a4
Resolved lint errors
Priyankas007 Feb 13, 2025
40260c8
Merge branch 'priyanka_ui' of https://github.com/CS342/2025-NeutroFev…
Priyankas007 Feb 13, 2025
5e31f74
Edited onboarding tests
Priyankas007 Feb 13, 2025
5e80541
Updating project file
Priyankas007 Feb 13, 2025
25b61f2
Resolving periphery issues
Priyankas007 Feb 13, 2025
554fb15
Resolved lint issues
Priyankas007 Feb 13, 2025
0e1d589
Resolved lint issues
Priyankas007 Feb 13, 2025
14df79b
Resolved lint errors
Priyankas007 Feb 13, 2025
73b6fae
Readded onboarding to scheme in hopes that it will solve my errors :')
Priyankas007 Feb 13, 2025
2209771
Removed onboarding tests
Priyankas007 Feb 14, 2025
25bb5ad
Resolving ui testing errors
Priyankas007 Feb 14, 2025
0dab389
Resolved periphery errors
Priyankas007 Feb 14, 2025
d093542
Updated bodyTemperature
Priyankas007 Feb 22, 2025
bbe9e7c
Updated dashboard
Priyankas007 Feb 22, 2025
d955655
Deleted UI tests
Priyankas007 Feb 22, 2025
5828281
Merge branch 'main' into priyanka_ui
Priyankas007 Feb 22, 2025
6418944
Resolved periphery errors
Priyankas007 Feb 22, 2025
e3e5bd4
Merge branch 'priyanka_ui' of https://github.com/CS342/2025-NeutroFev…
Priyankas007 Feb 22, 2025
92630b2
Resolved periphery error
Priyankas007 Feb 22, 2025
f87edf1
Merge branch 'main' into priyanka_ui
Priyankas007 Feb 24, 2025
b3d5f0a
Resolved periphery errors
Priyankas007 Feb 24, 2025
a873fb2
Resolved lint errors
Priyankas007 Feb 24, 2025
403f46b
Resolved periphery errors
Priyankas007 Feb 24, 2025
a3fd8fc
Resolved function arguments error
Priyankas007 Feb 24, 2025
dd1a7cb
Removed failing contributions test
Priyankas007 Feb 24, 2025
edba2ae
Resolved UI test issues
Priyankas007 Feb 24, 2025
95b60ce
Added onboarding schema
Priyankas007 Feb 24, 2025
f87a82b
Commented out all UI tests
Priyankas007 Feb 24, 2025
342d439
Merge branch 'main' into priyanka_ui
Priyankas007 Mar 10, 2025
1d29743
Updated visualizations page account settings and added as homepage
Priyankas007 Mar 10, 2025
e1eeb16
Attempting to fix account issue
Priyankas007 Mar 11, 2025
e18ac8d
Removed visualizations from folder
Priyankas007 Mar 11, 2025
8c6fca0
Debug AccountButton
Priyankas007 Mar 12, 2025
a98fe3b
Updated account
Priyankas007 Mar 12, 2025
1661aa4
Merge branch 'main' into priyanka_ui
Priyankas007 Mar 12, 2025
cb7de21
add bluetooth folder in ref
dusixian Mar 12, 2025
ccadce7
Merge branch 'main' into priyanka_ui
Priyankas007 Mar 12, 2025
33f4073
Cleaned comments
Priyankas007 Mar 12, 2025
cc35311
Merge branch 'priyanka_ui' of https://github.com/CS342/2025-NeutroFev…
Priyankas007 Mar 12, 2025
5ae642e
Update comments
Priyankas007 Mar 12, 2025
2d453a4
Updated comments
Priyankas007 Mar 12, 2025
cfc1905
Removed unused functions
Priyankas007 Mar 12, 2025
ae06d91
Removed lint ignore on flags
Priyankas007 Mar 12, 2025
d0f4d5a
Added methods to extract ANC data
Priyankas007 Mar 12, 2025
0d0bb02
Merge branch 'main' into priyanka_anc_viz
Priyankas007 Mar 12, 2025
e99b6a8
Fixed ANC updates
Priyankas007 Mar 12, 2025
3902ce4
Merge branch 'priyanka_anc_viz' of https://github.com/CS342/2025-Neut…
Priyankas007 Mar 12, 2025
eb41120
Fixed anc update functionality
Priyankas007 Mar 12, 2025
fa5431e
Fixed data reading issue
Priyankas007 Mar 12, 2025
98cf536
ANC plot updates
Priyankas007 Mar 12, 2025
a2bc829
Fix scope error
Priyankas007 Mar 12, 2025
fbdfc30
build fail fix
viraj28m Mar 12, 2025
4d2a400
linter fixes
viraj28m Mar 12, 2025
43bdc49
Merge branch 'main' into priyanka_anc_viz
Priyankas007 Mar 12, 2025
dd8ce05
Merge branch 'main' into priyanka_anc_viz
Priyankas007 Mar 13, 2025
bbaa83c
Merge branch 'main' into priyanka_anc_viz
mmervecerit Mar 14, 2025
8bc5f0c
Update HKVisualization.swift
mmervecerit Mar 14, 2025
96ebe13
Update HKVisualization.swift
mmervecerit Mar 15, 2025
5d52816
Update HKVisualizationHKTests.swift
mmervecerit Mar 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion NeutroFeverGuard/DataType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ struct BloodPressureEntry {
- Lab values: include the number associated with the lab name above
*/

struct LabEntry: Codable {
struct LabEntry: Codable, Equatable {
var date: Date
var values: [LabTestType: Double]

Expand Down
65 changes: 63 additions & 2 deletions NeutroFeverGuard/HKVisualization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,15 @@
}

struct HKVisualization: View {
// swiftlint:disable closure_body_length
@Environment(LabResultsManager.self) private var labResultsManager

Check failure on line 92 in NeutroFeverGuard/HKVisualization.swift

View workflow job for this annotation

GitHub Actions / Build and Test / Test using xcodebuild or run fastlane

generic parameter 'T' could not be inferred

Check failure on line 92 in NeutroFeverGuard/HKVisualization.swift

View workflow job for this annotation

GitHub Actions / Build and Test / Test using xcodebuild or run fastlane

cannot find 'LabResultsManager' in scope
@State var bodyTemperatureData: [HKData] = []
@State var heartRateData: [HKData] = []
@State var oxygenSaturationData: [HKData] = []
@State var heartRateScatterData: [HKData] = []
@State var oxygenSaturationScatterData: [HKData] = []
@State var bodyTemperatureScatterData: [HKData] = []
@State var neutrophilData: [HKData] = []
@State var neutrophilScatterData: [HKData] = []

var vizList: some View {
self.readAllHKData()
Expand Down Expand Up @@ -145,7 +147,21 @@
.foregroundColor(.gray)
}
}
}
Section {
if !neutrophilData.isEmpty {
HKVisualizationItem(
data: neutrophilData,
xName: "Date",
yName: "Neutrophil Count",
title: "Neutrophil Count Over Past Week",
threshold: 500, // Adjust the threshold if necessary
scatterData: neutrophilScatterData
)
} else {
Text("No neutrophil count data available.")
.foregroundColor(.gray)
}
} }
}

@Environment(Account.self) private var account: Account?
Expand All @@ -164,6 +180,8 @@
.onAppear {
// Ensure that data up-to-date when the view is activated.
self.readAllHKData(ensureUpdate: true)
labResultsManager.loadLabResults()
loadNeutrophilData() // Ensure this is called
}
.toolbar {
if account != nil {
Expand All @@ -173,6 +191,49 @@
}
}

private func loadNeutrophilData() {
let rawData = labResultsManager.getAllAncValues().filter {
$0.date >= Calendar.current.date(byAdding: .day, value: -7, to: Date()) ?? Date()
}

// Convert to HKData for bar plot
neutrophilData = rawData.map { record in
HKData(
date: record.date,
sumValue: record.ancValue,
avgValue: record.ancValue,
minValue: record.ancValue,
maxValue: record.ancValue
)
}

// Create scatter data (with some random variation to separate points)
neutrophilScatterData = rawData.map { record in
HKData(
date: record.date,
sumValue: record.ancValue + Double.random(in: -0.5...0.5), // Add slight variation for visualization
avgValue: -1.0,
minValue: -1.0,
maxValue: -1.0
)
}

print("✅ Converted neutrophil data: \(neutrophilData)")
print("✅ Scatter neutrophil data: \(neutrophilScatterData)")
}

private func getNeutrophilCountsForPastWeek() -> [(date: Date, ancValue: Double)] {
let oneWeekAgo = Calendar.current.date(byAdding: .day, value: -7, to: Date()) ?? Date()
let allValues = labResultsManager.getAllAncValues()

print("🔍 All ANC Values: \(allValues)")

let filteredValues = allValues.filter { $0.date >= oneWeekAgo }
print("✅ Filtered ANC Values: \(filteredValues)")

return filteredValues
}

func readAllHKData(ensureUpdate: Bool = false) {
if FeatureFlags.mockVizData {
loadMockDataNew()
Expand Down
16 changes: 15 additions & 1 deletion NeutroFeverGuard/LabResultsManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class LabResultsManager: Module, EnvironmentAccessible {
loadLabResults() // Refresh lab results
}

private func loadLabResults() {
func loadLabResults() {
var results: [LabEntry] = []

do {
Expand Down Expand Up @@ -120,6 +120,20 @@ class LabResultsManager: Module, EnvironmentAccessible {
}
return (neutrophils / 100.0) * wbc
}

func getAllAncValues() -> [(date: Date, ancValue: Double)] {
var ancValues: [(date: Date, ancValue: Double)] = []

for record in labRecords {
if let neutrophils = record.values[.neutrophils],
let wbc = record.values[.whiteBloodCell] {
let ancValue = (neutrophils / 100.0) * wbc
ancValues.append((date: record.date, ancValue: ancValue))
}
}

return ancValues
}

func getANCStatus() -> (text: String, color: Color) {
guard let ancValue = getAncValue() else {
Expand Down
9 changes: 9 additions & 0 deletions NeutroFeverGuard/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,12 @@
}
}
}
},
"Neutrophil Count" : {

},
"Neutrophil Count Over Past Week" : {

},
"Next" : {
"localizations" : {
Expand Down Expand Up @@ -691,6 +697,9 @@
},
"No medications recorded" : {

},
"No neutrophil count data available." : {

},
"No oxygen saturation data available." : {
"localizations" : {
Expand Down
1 change: 1 addition & 0 deletions NeutroFeverGuardUITests/HKVisualizationHKTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ class HKVisualizationHKTests: XCTestCase {
XCTAssertTrue(app.staticTexts["No heart rate data available."].waitForExistence(timeout: 2))
XCTAssertTrue(app.staticTexts["No body temperature data available."].waitForExistence(timeout: 2))
XCTAssertTrue(app.staticTexts["No oxygen saturation data available."].waitForExistence(timeout: 2))
XCTAssertTrue(app.staticTexts["No neutrophil count data available."].waitForExistence(timeout: 2))
}
}
Loading