Skip to content

Commit

Permalink
Fixing Gender on Patient Info + Menstrual View + Fixing Allergy Nav v…
Browse files Browse the repository at this point in the history
…iew (#74)

# * Checking off our to-do items *

## ♻️ Current situation & Problem
*Fixed Gender Storing on patient struct. 
* Fixed scrollable 
* fixed nav on allergy based on gender 
* fixed environment variables for social history so it updates
dynamically

## ⚙️ Release Notes 
* remember to use .task for dynamic updates 

## 📚 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 13, 2024
1 parent 8a3fffd commit 352cad1
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 14 deletions.
10 changes: 8 additions & 2 deletions Intake/Allergy Records/AllergyRecords.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,14 @@ struct AllergyList: View {
if loaded.allergyData {
VStack {
allergyForm
SubmitButton(nextView: NavigationViews.menstrual)
.padding()
/**/
if data.generalData.sex == "Female" {
SubmitButton(nextView: NavigationViews.menstrual)
.padding()
} else {
SubmitButton(nextView: NavigationViews.smoking)
.padding()
}
}
.sheet(isPresented: $showingChat, content: chatSheetView)
} else {
Expand Down
14 changes: 11 additions & 3 deletions Intake/General Data View/PatientInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct PatientInfo: View {
@State private var fullName: String = ""
@State private var firstName: String = ""
@State private var birthdate: String = ""
@State private var gender: String = ""
@State private var gender: String = "female"
@State private var sexOption: String = ""
@State private var birthdateDateFormat = Date()

Expand Down Expand Up @@ -111,16 +111,17 @@ struct PatientInfo: View {
.pickerStyle(MenuPickerStyle())
}
}

Spacer()
SubmitButtonWithAction(nextView: .medical, onButtonTap: {
updateData()
})
}
.onAppear {
.task {
loadData()
}
}

@MainActor
private func loadData() {
if let patient = fhirStore.patient {
fullName = getInfo(patient: patient, field: "name").filter { !$0.isNumber }
Expand All @@ -134,6 +135,7 @@ struct PatientInfo: View {
if let dob = dateFormatter.date(from: birthdate) {
birthdateDateFormat = dob
}
gender.capitalizeFirstLetter()
sexOption = gender
data.generalData = PatientData(name: fullName, birthdate: birthdate, age: age, sex: gender)
}
Expand All @@ -151,6 +153,12 @@ struct PatientInfo: View {
}
}

extension String {
mutating func capitalizeFirstLetter() {
self = prefix(1).capitalized + dropFirst()
}
}


struct PatientInfo_Previews: PreviewProvider {
static var previews: some View {
Expand Down
6 changes: 3 additions & 3 deletions Intake/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@
},
"Allergy Name" : {

},
"Are you currently smoking or have you smoked in the past?" : {

},
"Are you currently smoking?" : {

Expand Down Expand Up @@ -293,9 +296,6 @@
},
"Have you smoked in the past?" : {

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

},
"HEALTHKIT_PERMISSIONS_BUTTON" : {
"localizations" : {
Expand Down
18 changes: 12 additions & 6 deletions Intake/SocialHistory/MenstrualHistory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct SocialHistoryQuestionView: View {
@State private var showMaleSlide = false
@Environment(NavigationPathWrapper.self) private var navigationPath
@Environment(DataStore.self) private var data

// do this ONLY in nav before this
var body: some View {
NavigationView {
VStack {
Expand All @@ -43,18 +43,24 @@ struct SocialHistoryQuestionView: View {
}
}
.navigationTitle("Social History")
.onAppear {
fetchHealthKitData()
.task {
startDate = data.menstrualHistory.startDate
endDate = data.menstrualHistory.endDate
additionalDetails = data.menstrualHistory.additionalDetails
}
/*.task {
fetchHealthKitData()
}*/
.onDisappear {
data.menstrualHistory = MenstrualHistoryItem(startDate: startDate, endDate: endDate, additionalDetails: additionalDetails)
data.menstrualHistory = MenstrualHistoryItem(startDate: startDate, endDate: endDate, additionalDetails: additionalDetails)
}
SubmitButton(nextView: NavigationViews.smoking)
.padding()
}
}
}

/* Show View based on DataStore ! */
/*
private func fetchHealthKitData() {
let infoToRead = Set([HKObjectType.characteristicType(forIdentifier: .biologicalSex)].compactMap { $0 })

Expand Down Expand Up @@ -82,5 +88,5 @@ struct SocialHistoryQuestionView: View {
case .notSet: return false
@unknown default: return false
}
}
}*/
}

0 comments on commit 352cad1

Please sign in to comment.