Skip to content

Commit

Permalink
Updating Smoking + DataStore (#73)
Browse files Browse the repository at this point in the history
# *Update*

## ♻️ Current situation & Problem
*Dr. Aalami wanted different questions for smoking and the display on
scrollable was not great yet.*


## ⚙️ Release Notes 
*Changed the questions for smoking, fixed how social history is
presented.
Need to work on storing global vars right.*


## 📚 Documentation
*Please ensure that you properly document any additions in conformance
to [Spezi Documentation
Guide](https://github.com/StanfordSpezi/.github/blob/main/DOCUMENTATIONGUIDE.md).*
*You can use this section to describe your solution, but we encourage
contributors to document your reasoning and changes using in-line
documentation.*


## ✅ Testing
*Please ensure that the PR meets the testing requirements set by CodeCov
and that new functionality is appropriately tested.*
*This section describes important information about the tests and why
some elements might not be testable.*


## 📝 Code of Conduct & Contributing Guidelines 

By submitting creating this pull request, you agree to follow our [Code
of
Conduct](https://github.com/CS342/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/CS342/.github/blob/main/CONTRIBUTING.md):
- [ ] I agree to follow the [Code of
Conduct](https://github.com/CS342/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/CS342/.github/blob/main/CONTRIBUTING.md).
  • Loading branch information
zoyagarg authored Mar 12, 2024
1 parent 69592d8 commit 8a3fffd
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 180 deletions.
8 changes: 5 additions & 3 deletions Intake/Intake.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@ struct PatientData {
var sex: String
}

struct MenstrualHistoryItem {
struct MenstrualHistoryItem: Equatable {
var startDate: Date
var endDate: Date
var additionalDetails: String
}

struct SmokingHistoryItem {
var packYears: Double
var hasSmokedOrSmoking: Bool
var currentlySmoking: Bool
var smokedInThePast: Bool
var additionalDetails: String
}

Expand All @@ -43,7 +45,7 @@ class DataStore {
var chiefComplaint: String = ""
var generalData = PatientData(name: "", birthdate: "", age: "", sex: "")
var menstrualHistory = MenstrualHistoryItem(startDate: Date(), endDate: Date(), additionalDetails: "")
var smokingHistory = SmokingHistoryItem(packYears: 0.0, additionalDetails: "")
var smokingHistory = SmokingHistoryItem(hasSmokedOrSmoking: Bool(), currentlySmoking: Bool(), smokedInThePast: Bool(), additionalDetails: "")
}

@Observable
Expand Down
45 changes: 21 additions & 24 deletions Intake/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
},
"*Click the details to view/edit the reactions" : {

},
"%.2f" : {

},
"%@ - %@" : {
"localizations" : {
Expand Down Expand Up @@ -128,13 +125,13 @@
"Allergy Name" : {

},
"Auto-fill Intake Form" : {
"Are you currently smoking?" : {

},
"Back" : {
"Auto-fill Intake Form" : {

},
"Calculation" : {
"Back" : {

},
"Chat" : {
Expand Down Expand Up @@ -239,6 +236,9 @@
}
}
}
},
"Currently Smoking:" : {

},
"Date" : {

Expand All @@ -260,9 +260,6 @@
},
"DELETE_SURGERY" : {

},
"Do you currently smoke or have you smoked in the past?" : {

},
"Download your medical records from your health system." : {

Expand Down Expand Up @@ -293,6 +290,12 @@
},
"Get Started" : {

},
"Have you smoked in the past?" : {

},
"Have you smoked or are you currently smoking?" : {

},
"HEALTHKIT_PERMISSIONS_BUTTON" : {
"localizations" : {
Expand Down Expand Up @@ -340,12 +343,6 @@
},
"HOME_LOGO" : {

},
"How many days a year do you smoke?" : {

},
"How many packs do you smoke a day?" : {

},
"Inactive" : {

Expand Down Expand Up @@ -426,6 +423,9 @@
},
"Medications:" : {

},
"Menstrual History" : {

},
"Menstrual Information" : {

Expand Down Expand Up @@ -579,12 +579,6 @@
},
"Other important questions." : {

},
"Pack Years:" : {

},
"Pack years: %.2f" : {

},
"Past Medical History:" : {

Expand Down Expand Up @@ -728,12 +722,18 @@
},
"Skip" : {

},
"Smoked in the Past:" : {

},
"Smoking history" : {

},
"Smoking History" : {

},
"Smoking Status" : {

},
"Social History" : {

Expand All @@ -746,9 +746,6 @@
},
"Status" : {

},
"Submit" : {

},
"Submit your Form" : {

Expand Down
109 changes: 54 additions & 55 deletions Intake/ScrollablePDF.swift
Original file line number Diff line number Diff line change
Expand Up @@ -239,63 +239,62 @@ struct ScrollablePDF: View {
}

private struct MenstrualSection: View {
@Environment(DataStore.self) private var data
@Environment(NavigationPathWrapper.self) private var navigationPath
@Environment(DataStore.self) private var data

var body: some View {
Section(header: HeaderTitle(title: "Menstrual History", nextView: NavigationViews.menstrual)) {
List {
HStack {
Text("Start Date:")
Spacer()
// Display the start date from the menstrualHistory in your data store
Text(data.menstrualHistory.startDate, style: .date)
.foregroundColor(.secondary)
}
HStack {
Text("End Date:")
Spacer()
// Display the end date from the menstrualHistory in your data store
Text(data.menstrualHistory.endDate, style: .date)
.foregroundColor(.secondary)
}
HStack {
Text("Additional Details:")
Spacer()
// Display the additional details from the menstrualHistory in your data store
Text(data.menstrualHistory.additionalDetails)
.foregroundColor(.secondary)
}
}
}
}
}

private struct SmokingSection: View {
@Environment(DataStore.self) private var data
@Environment(NavigationPathWrapper.self) private var navigationPath
var body: some View {
Section(header: Text("Menstrual History")) {
VStack(alignment: .leading) {
HStack {
Text("Start Date:")
Spacer()
Text(data.menstrualHistory.startDate, style: .date)
.foregroundColor(.secondary)
}
HStack {
Text("End Date:")
Spacer()
Text(data.menstrualHistory.endDate, style: .date)
.foregroundColor(.secondary)
}
HStack {
Text("Additional Details:")
Spacer()
Text(data.menstrualHistory.additionalDetails)
.foregroundColor(.secondary)
}
}
}
}
}

var body: some View {
Section(header: HeaderTitle(title: "Smoking History", nextView: NavigationViews.smoking)) {
List {
HStack {
Text("Pack Years:")
Spacer()
// Display the pack years from the smokingHistory in your data store
Text("\(data.smokingHistory.packYears, specifier: "%.2f")")
.foregroundColor(.secondary)
}
HStack {
Text("Additional Details:")
Spacer()
// Display the additional details from the smokingHistory in your data store
Text(data.smokingHistory.additionalDetails)
.foregroundColor(.secondary)
}
}
}
}
}
private struct SmokingSection: View {
@Environment(DataStore.self) private var data

var body: some View {
Section(header: Text("Smoking History")) {
VStack(alignment: .leading) {
HStack {
Text("Currently Smoking:")
Spacer()
Text(data.smokingHistory.currentlySmoking ? "Yes" : "No")
.foregroundColor(.secondary)
}
HStack {
Text("Smoked in the Past:")
Spacer()
Text(data.smokingHistory.smokedInThePast ? "Yes" : "No")
.foregroundColor(.secondary)
}
HStack {
Text("Additional Details:")
Spacer()
Text(data.smokingHistory.additionalDetails)
.foregroundColor(.secondary)
}
}
}
}
}

@Environment(DataStore.self) private var data
@Environment(NavigationPathWrapper.self) private var navigationPath
Expand Down
3 changes: 2 additions & 1 deletion Intake/SocialHistory/MenstrualHistory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ struct SocialHistoryQuestionView: View {
VStack {
Form {
Section(header: Text("Menstrual Information").foregroundColor(.gray)) {
@Bindable var data = data
DatePicker("Last period's start date", selection: $startDate, in: ...Date(), displayedComponents: .date)
.datePickerStyle(DefaultDatePickerStyle())

Expand All @@ -37,6 +38,7 @@ struct SocialHistoryQuestionView: View {
}

Section(header: Text("Additional Symptoms").foregroundColor(.gray)) {
@Bindable var data = data
TextField("Ex: Heavy bleeding on second day, fatigue...", text: $additionalDetails)
}
}
Expand All @@ -45,7 +47,6 @@ struct SocialHistoryQuestionView: View {
fetchHealthKitData()
}
.onDisappear {
// Update the MenstrualHistoryItem in the data store right before the view disappears
data.menstrualHistory = MenstrualHistoryItem(startDate: startDate, endDate: endDate, additionalDetails: additionalDetails)
}
SubmitButton(nextView: NavigationViews.smoking)
Expand Down
Loading

0 comments on commit 8a3fffd

Please sign in to comment.