Skip to content

Commit

Permalink
PDF format + random changes (#77)
Browse files Browse the repository at this point in the history
# *Fixing the PDF*

## ♻️ Current situation & Problem
* Include social history when appropriate 
* Reformat so it looks professional (all left, secondary colors)
* Fix length issues
* Reformat patient responses

## ⚙️ Release Notes 
*Add a bullet point list summary of the feature and possible migration
guides if this is a breaking change so this section can be added to the
release notes.*
*Include code snippets that provide examples of the feature implemented
or links to the documentation if it appends or changes the public
interface.*


## 📚 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 committed Mar 14, 2024
1 parent ff294b3 commit 14e0ee7
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 92 deletions.
79 changes: 55 additions & 24 deletions Intake/Export/ExportView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ struct ExportView: View {
print("PDF data changed")
}
}

@ViewBuilder
// swiftlint:disable attributes
private var wrappedBody: some View {
VStack {
Text("MEDICAL HISTORY").fontWeight(.bold)
VStack(alignment: .leading) {
Text("MEDICAL HISTORY")
.fontWeight(.bold)

Spacer()
.frame(height: 20)
Expand All @@ -75,7 +77,7 @@ struct ExportView: View {
}
HStack {
Text("Sex:").fontWeight(.bold)
Text(data.generalData.name)
Text(data.generalData.sex)
}

Spacer()
Expand Down Expand Up @@ -103,7 +105,6 @@ struct ExportView: View {
ForEach(data.conditionData, id: \.id) { item in
HStack {
Text(item.condition)
Spacer()
Text(item.active ? "Active" : "Inactive")
.foregroundColor(.secondary)
}
Expand Down Expand Up @@ -139,7 +140,7 @@ struct ExportView: View {
ForEach(Array(data.medicationData), id: \.id) { item in
HStack {
Text(item.type.localizedDescription)
Text(item.dosage.localizedDescription)
Text(item.dosage.localizedDescription).foregroundColor(.secondary)
}
}
}
Expand All @@ -155,9 +156,9 @@ struct ExportView: View {
} else {
ForEach(data.allergyData, id: \.id) { item in
VStack(alignment: .leading) {
Text(item.allergy).fontWeight(.bold)
Text(item.allergy)
ForEach(item.reaction, id: \.id) { reactionItem in
Text(reactionItem.reaction)
Text(reactionItem.reaction).foregroundColor(.secondary)
}
}
}
Expand All @@ -166,30 +167,54 @@ struct ExportView: View {

Spacer()
.frame(height: 20)

VStack(alignment: .leading) {
if data.generalData.sex == "Female" {
Text("Menstrual History").fontWeight(.bold)
HStack {
Text("Last Menstrual Period:").fontWeight(.bold)
Text("\(formatDate(data.menstrualHistory.startDate)) - \(formatDate(data.menstrualHistory.endDate))")
}
HStack {
Text("Additional Symptoms:").fontWeight(.bold)
Text(data.menstrualHistory.additionalDetails)
}
}
}

VStack(alignment: .leading) {
Text("Review of Systems:").fontWeight(.bold)
Text("Smoking History").fontWeight(.bold)
HStack {
Text("Smoking Status:")
Text(data.smokingHistory.hasSmokedOrSmoking ? "Yes" : "No")
}
HStack {
Text("Currently Smoking:")
Text(data.smokingHistory.currentlySmoking ? "Yes" : "No")
}
HStack {
Text("Last Menstrural Period")
Text("Date")
Text("Smoked in the Past:")
Text(data.smokingHistory.smokedInThePast ? "Yes" : "No")
}

HStack {
Text("Smoking history")
Text("0 pack years")
Text("Additional Symptoms:")
Text(data.smokingHistory.additionalDetails)
}
}
}
}
// swiftlint:enable:closure_body_length
Spacer()
}
.if(isSharing, transform: { view in
view
.padding()
})
}

@MainActor
private func shareButtonTapped() async {
self.pdfData = await self.exportToPDF()
self.isSharing = true
self.pdfData = await self.exportToPDF()
}


Expand Down Expand Up @@ -222,7 +247,6 @@ struct ExportView: View {
}

pdf.beginPDFPage(nil)
pdf.translateBy(x: 50, y: -50)

context(pdf)

Expand All @@ -233,6 +257,20 @@ struct ExportView: View {
}
}
}

func formatDate(_ date: Date) -> String {
let formatter = DateFormatter()
formatter.dateStyle = .medium // Choose your style
formatter.timeStyle = .none
return formatter.string(from: date)
}

func todayDateString() -> String {
let today = Date()
let formatter = DateFormatter()
formatter.dateStyle = .long
return formatter.string(from: today)
}
}


Expand Down Expand Up @@ -261,13 +299,6 @@ struct ShareSheet: UIViewControllerRepresentable {
func updateUIViewController(_ uiViewController: UIActivityViewController, context: Context) {}
}

func todayDateString() -> String {
let today = Date()
let formatter = DateFormatter()
formatter.dateStyle = .long
return formatter.string(from: today)
}

struct ExportView_Previews: PreviewProvider {
static var previews: some View {
ExportView()
Expand Down
20 changes: 7 additions & 13 deletions Intake/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
},
"%@ Reactions" : {

},
"0 pack years" : {

},
"ACCOUNT_NEXT" : {
"localizations" : {
Expand Down Expand Up @@ -100,6 +97,9 @@
},
"Additional Symptoms" : {

},
"Additional Symptoms:" : {

},
"Age" : {

Expand Down Expand Up @@ -242,9 +242,6 @@
},
"Currently Smoking:" : {

},
"Date" : {

},
"Date of Birth" : {

Expand Down Expand Up @@ -370,7 +367,7 @@
"It looks like an unexpected view was appended to the NavigationPath!" : {

},
"Last Menstrural Period" : {
"Last Menstrual Period:" : {

},
"Last period's end date" : {
Expand Down Expand Up @@ -665,9 +662,6 @@
},
"Review of Systems" : {

},
"Review of Systems:" : {

},
"Review summary of your medical history." : {

Expand Down Expand Up @@ -733,15 +727,15 @@
},
"Smoked in the Past:" : {

},
"Smoking history" : {

},
"Smoking History" : {

},
"Smoking Status" : {

},
"Smoking Status:" : {

},
"Social History" : {

Expand Down
4 changes: 3 additions & 1 deletion Intake/ScrollablePDF.swift
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,9 @@ struct ScrollablePDF: View {
SurgerySection()
MedicationSection()
AllergySection()
MenstrualSection()
if data.generalData.sex == "Female" {
MenstrualSection()
}
SmokingSection()
}
.navigationTitle("Patient Form")
Expand Down
81 changes: 27 additions & 54 deletions Intake/SocialHistory/MenstrualHistory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,65 +27,38 @@ struct SocialHistoryQuestionView: View {
var body: some View {
NavigationView {
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())

DatePicker("Last period's end date", selection: $endDate, in: ...Date(), displayedComponents: .date)
.datePickerStyle(DefaultDatePickerStyle())
if data.generalData.sex == "Female" {
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())

DatePicker("Last period's end date", selection: $endDate, in: ...Date(), displayedComponents: .date)
.datePickerStyle(DefaultDatePickerStyle())
}

Section(header: Text("Additional Symptoms").foregroundColor(.gray)) {
@Bindable var data = data
TextField("Ex: Heavy bleeding on second day, fatigue...", text: $additionalDetails)
}
}
Section(header: Text("Additional Symptoms").foregroundColor(.gray)) {
@Bindable var data = data
TextField("Ex: Heavy bleeding on second day, fatigue...", text: $additionalDetails)
.navigationTitle("Social History")
.task {
startDate = data.menstrualHistory.startDate
endDate = data.menstrualHistory.endDate
additionalDetails = data.menstrualHistory.additionalDetails
}
}
.navigationTitle("Social History")
.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)
}
SubmitButton(nextView: NavigationViews.smoking)
.padding()
}
}
}
/* Show View based on DataStore ! */
/*
private func fetchHealthKitData() {
let infoToRead = Set([HKObjectType.characteristicType(forIdentifier: .biologicalSex)].compactMap { $0 })
Task {
do {
try await healthStore.requestAuthorization(toShare: [], read: infoToRead)
if let bioSex = try? healthStore.biologicalSex() {
DispatchQueue.main.async {
self.isFemale = getIsFemaleBiologicalSex(biologicalSex: bioSex.biologicalSex)
self.showMaleSlide = !self.isFemale
/*.task {
fetchHealthKitData()
}*/
.onDisappear {
data.menstrualHistory = MenstrualHistoryItem(startDate: startDate, endDate: endDate, additionalDetails: additionalDetails)
}
SubmitButton(nextView: NavigationViews.smoking)
.padding()
}
} catch {
print("HealthKit authorization failed: \(error.localizedDescription)")
}
}
}
private func getIsFemaleBiologicalSex(biologicalSex: HKBiologicalSex) -> Bool {
switch biologicalSex {
case .female: return true
case .male: return false
case .other: return true
case .notSet: return false
@unknown default: return false
}
}*/
}

0 comments on commit 14e0ee7

Please sign in to comment.