diff --git a/Intake/Export/ExportView.swift b/Intake/Export/ExportView.swift index 7ab6d82..9741258 100644 --- a/Intake/Export/ExportView.swift +++ b/Intake/Export/ExportView.swift @@ -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) @@ -75,7 +77,7 @@ struct ExportView: View { } HStack { Text("Sex:").fontWeight(.bold) - Text(data.generalData.name) + Text(data.generalData.sex) } Spacer() @@ -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) } @@ -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) } } } @@ -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) } } } @@ -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() } @@ -222,7 +247,6 @@ struct ExportView: View { } pdf.beginPDFPage(nil) - pdf.translateBy(x: 50, y: -50) context(pdf) @@ -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) + } } @@ -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() diff --git a/Intake/Resources/Localizable.xcstrings b/Intake/Resources/Localizable.xcstrings index e97d446..9d4c585 100644 --- a/Intake/Resources/Localizable.xcstrings +++ b/Intake/Resources/Localizable.xcstrings @@ -22,9 +22,6 @@ }, "%@ Reactions" : { - }, - "0 pack years" : { - }, "ACCOUNT_NEXT" : { "localizations" : { @@ -100,6 +97,9 @@ }, "Additional Symptoms" : { + }, + "Additional Symptoms:" : { + }, "Age" : { @@ -242,9 +242,6 @@ }, "Currently Smoking:" : { - }, - "Date" : { - }, "Date of Birth" : { @@ -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" : { @@ -665,9 +662,6 @@ }, "Review of Systems" : { - }, - "Review of Systems:" : { - }, "Review summary of your medical history." : { @@ -733,15 +727,15 @@ }, "Smoked in the Past:" : { - }, - "Smoking history" : { - }, "Smoking History" : { }, "Smoking Status" : { + }, + "Smoking Status:" : { + }, "Social History" : { diff --git a/Intake/ScrollablePDF.swift b/Intake/ScrollablePDF.swift index 2da1fb6..a19586d 100644 --- a/Intake/ScrollablePDF.swift +++ b/Intake/ScrollablePDF.swift @@ -278,7 +278,9 @@ struct ScrollablePDF: View { SurgerySection() MedicationSection() AllergySection() - MenstrualSection() + if data.generalData.sex == "Female" { + MenstrualSection() + } SmokingSection() } .navigationTitle("Patient Form") diff --git a/Intake/SocialHistory/MenstrualHistory.swift b/Intake/SocialHistory/MenstrualHistory.swift index 8b89c69..110c288 100644 --- a/Intake/SocialHistory/MenstrualHistory.swift +++ b/Intake/SocialHistory/MenstrualHistory.swift @@ -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 - } - }*/ }