Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scrollable pdf changes #61

Merged
merged 21 commits into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
61 changes: 34 additions & 27 deletions Intake/Allergy Records/AddAllergy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import SpeziFHIR
import SwiftUI


struct EditAllergyView: View {
@State private var index: Int
@Environment(DataStore.self) private var data
Expand All @@ -27,25 +26,7 @@
TextField("Allergy Name", text: $data.allergyData[index].allergy)
.textFieldStyle(RoundedBorderTextFieldStyle())
.padding([.horizontal, .top])
Form { // Use Form instead of List
Section(header: headerTitle) {
ForEach($data.allergyData[index].reaction) { $item in
HStack {
TextField("Reactions", text: $item.reaction)
}
}
.onDelete(perform: delete)
Button(action: {
data.allergyData[index].reaction.append(ReactionItem(reaction: ""))
}) {
HStack {
Image(systemName: "plus.circle.fill")
.accessibilityLabel(Text("ADD_REACTION"))
Text("Add Field")
}
}
}
}
ReactionSectionView(index: index)

Check warning on line 29 in Intake/Allergy Records/AddAllergy.swift

View check run for this annotation

Codecov / codecov/patch

Intake/Allergy Records/AddAllergy.swift#L29

Added line #L29 was not covered by tests
Spacer()
saveButton
}
Expand All @@ -67,20 +48,46 @@
.padding()
}

init(index: Int, showingReaction: Binding<Bool>) {
self._index = State(initialValue: index)
self._showingReaction = showingReaction
}

Check warning on line 54 in Intake/Allergy Records/AddAllergy.swift

View check run for this annotation

Codecov / codecov/patch

Intake/Allergy Records/AddAllergy.swift#L51-L54

Added lines #L51 - L54 were not covered by tests
}

struct ReactionSectionView: View {
@Environment(DataStore.self) private var data
var index: Int

var body: some View {
Form { // Use Form instead of List
Section(header: headerTitle) {
@Bindable var data = data
ForEach($data.allergyData[index].reaction) { $item in
HStack {
TextField("Reactions", text: $item.reaction)
}
}
.onDelete(perform: delete)
Button(action: {
data.allergyData[index].reaction.append(ReactionItem(reaction: ""))
}) {
HStack {
Image(systemName: "plus.circle.fill")
.accessibilityLabel(Text("ADD_REACTION"))
Text("Add Field")
}
}
}
}
}

Check warning on line 82 in Intake/Allergy Records/AddAllergy.swift

View check run for this annotation

Codecov / codecov/patch

Intake/Allergy Records/AddAllergy.swift#L61-L82

Added lines #L61 - L82 were not covered by tests

private var headerTitle: some View {
HStack {
Text("Reactions")
Spacer()
EditButton()
}
}


init(index: Int, showingReaction: Binding<Bool>) {
self._index = State(initialValue: index)
self._showingReaction = showingReaction
}

func delete(at offsets: IndexSet) {
data.allergyData[index].reaction.remove(atOffsets: offsets)
}
Expand Down
15 changes: 8 additions & 7 deletions Intake/Allergy Records/ReactionPDF.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,17 @@
@Binding private var showingReaction: Bool
var body: some View {
NavigationView {
VStack {
Form {
ForEach(data.allergyData[index].reaction) { item in
Text(item.reaction)
}
}
ReactionSectionView(index: index)
// VStack {
// Form {
// ForEach(data.allergyData[index].reaction) { item in
// Text(item.reaction)
// }
// }

Check warning on line 31 in Intake/Allergy Records/ReactionPDF.swift

View check run for this annotation

Codecov / codecov/patch

Intake/Allergy Records/ReactionPDF.swift#L25-L31

Added lines #L25 - L31 were not covered by tests
// .navigationTitle("Medical History")
//// .navigationTitle("\(data.allergyData[index].allergy) Reactions")
// .navigationBarItems(trailing: EditButton())
}
// }

Check warning on line 35 in Intake/Allergy Records/ReactionPDF.swift

View check run for this annotation

Codecov / codecov/patch

Intake/Allergy Records/ReactionPDF.swift#L35

Added line #L35 was not covered by tests
.toolbar {
ToolbarItem(placement: .navigationBarLeading) {
HStack {
Expand Down
16 changes: 9 additions & 7 deletions Intake/ChiefComplaint/LLMInteraction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,20 +158,22 @@
var firstName: String = ""
var dob: String = ""
var gender: String = ""

if let patient = fhirStore.patient {
fullName = getInfo(patient: patient, field: "name").filter { !$0.isNumber }
dob = getInfo(patient: patient, field: "birthDate")
gender = getInfo(patient: patient, field: "gender")

Check warning on line 165 in Intake/ChiefComplaint/LLMInteraction.swift

View check run for this annotation

Codecov / codecov/patch

Intake/ChiefComplaint/LLMInteraction.swift#L165

Added line #L165 was not covered by tests
let age = calculateAge(from: dob)
let nameString = fullName.components(separatedBy: " ")

if let firstNameValue = nameString.first {
firstName = firstNameValue
} else {
print("First Name is empty")
}
data.generalData.name = fullName
data.generalData.birthdate = dob
data.generalData.sex = gender
data.generalData.age = age

firstName = nameString.first ?? "First Name is empty"
print(firstName == "First Name is empty" ? "First Name is empty" : "")

Check warning on line 176 in Intake/ChiefComplaint/LLMInteraction.swift

View check run for this annotation

Codecov / codecov/patch

Intake/ChiefComplaint/LLMInteraction.swift#L169-L176

Added lines #L169 - L176 were not covered by tests

let systemMessage = """
The first name of the patient is \(String(describing: firstName)) and the patient is \(String(describing: age))\
Expand Down
2 changes: 1 addition & 1 deletion Intake/Intake.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class DataStore {
var surgeries: [SurgeryItem] = []
var surgeriesLoaded = false
var chiefComplaint: String = ""
var generalData = PatientData(name: "Akash", birthdate: "01/08/2003", age: "21", sex: "Male")
var generalData = PatientData(name: "", birthdate: "", age: "", sex: "")
}

@Observable
Expand Down
36 changes: 33 additions & 3 deletions Intake/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@
},
"Additional Details" : {

},
"Additional Details: " : {

},
"Additional Symptoms" : {

Expand Down Expand Up @@ -214,6 +217,9 @@
},
"DELETE_REACTION" : {

},
"details" : {

},
"DETAILS" : {

Expand All @@ -229,17 +235,23 @@
},
"Edit Surgery" : {

},
"End" : {

},
"end date" : {

},
"Ex: Heavy bleeding on second day, fatigue..." : {

},
"Ex: Smoked for 10 years, quit 5 years ago..." : {

},
"Export to PDF" : {
"FHIR_RESOURCES_CHAT_CANCEL" : {

},
"FHIR_RESOURCES_CHAT_CANCEL" : {
"fix medication" : {

},
"Get Started" : {
Expand Down Expand Up @@ -497,6 +509,9 @@
},
"Other important questions." : {

},
"Pack Years:" : {

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

Expand Down Expand Up @@ -610,6 +625,9 @@
},
"Sex" : {

},
"Share" : {

},
"Share with provider of your choice." : {

Expand All @@ -625,9 +643,18 @@
},
"Start" : {

},
"start date" : {

},
"Start:" : {

},
"Status" : {

},
"Submit" : {

},
"Submit your Form" : {

Expand Down Expand Up @@ -715,7 +742,10 @@

},
"Yes" : {


},
"YYYY-MM-DD" : {

}
},
"version" : "1.0"
Expand Down
69 changes: 58 additions & 11 deletions Intake/ScrollablePDF.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
var body: some View {
Button(action: {
}) {
Text("Export to PDF")
Text("Share")

Check warning on line 65 in Intake/ScrollablePDF.swift

View check run for this annotation

Codecov / codecov/patch

Intake/ScrollablePDF.swift#L65

Added line #L65 was not covered by tests
.foregroundColor(.white)
.padding()
.frame(maxWidth: .infinity)
Expand All @@ -82,28 +82,75 @@
HStack {
Text(item.surgeryName)
Spacer()
Text(item.date ?? "")
Text(item.date)

Check warning on line 85 in Intake/ScrollablePDF.swift

View check run for this annotation

Codecov / codecov/patch

Intake/ScrollablePDF.swift#L85

Added line #L85 was not covered by tests
.foregroundColor(.secondary)
}
}
}
}
}

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

var body: some View {
Section(header: HeaderTitle(title: "Menstrual Cycle", nextView: NavigationViews.menstrual)) {
List {
HStack {
Text("Start:")
Spacer()
Text("start date")
.foregroundColor(.secondary)
}
HStack {
Text("End")
Spacer()
Text("end date")
.foregroundColor(.secondary)
}
HStack {
Text("Additional Details: ")
Text("details")
.foregroundColor(.secondary)
}
}
}
}

Check warning on line 119 in Intake/ScrollablePDF.swift

View check run for this annotation

Codecov / codecov/patch

Intake/ScrollablePDF.swift#L97-L119

Added lines #L97 - L119 were not covered by tests
}

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

var body: some View {
Section(header: HeaderTitle(title: "Smoking", nextView: NavigationViews.smoking)) {
List {
HStack {
Text("Pack Years:")
Spacer()
Text("start date")
.foregroundColor(.secondary)
}
HStack {
Text("Additional Details: ")
Text("details")
.foregroundColor(.secondary)
}
}
}
}

Check warning on line 142 in Intake/ScrollablePDF.swift

View check run for this annotation

Codecov / codecov/patch

Intake/ScrollablePDF.swift#L126-L142

Added lines #L126 - L142 were not covered by tests
}


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

var body: some View {
Section(header: HeaderTitle(title: "Medications", nextView: NavigationViews.medication)) {
VStack(alignment: .leading) {
ForEach(Array(data.medicationData)) { item in
HStack {
Text(item.type.localizedDescription)
.padding(.leading)
Spacer()
}
}
Text("fix medication")

Check warning on line 153 in Intake/ScrollablePDF.swift

View check run for this annotation

Codecov / codecov/patch

Intake/ScrollablePDF.swift#L153

Added line #L153 was not covered by tests
}
}
}
Expand Down Expand Up @@ -191,11 +238,9 @@
}
}


@Environment(DataStore.self) private var data
@Environment(NavigationPathWrapper.self) private var navigationPath
@Environment(ReachedEndWrapper.self) private var end


var body: some View {
VStack {
Expand All @@ -206,6 +251,8 @@
SurgerySection()
MedicationSection()
Allergy()
MenstrualSection()
SmokingSection()

Check warning on line 255 in Intake/ScrollablePDF.swift

View check run for this annotation

Codecov / codecov/patch

Intake/ScrollablePDF.swift#L254-L255

Added lines #L254 - L255 were not covered by tests
}
.navigationTitle("Patient Form")
.onAppear(perform: {
Expand Down
14 changes: 14 additions & 0 deletions Intake/SocialHistory/SmokingHistory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,21 @@
Text("Pack years: \(packYears, specifier: "%.2f")")
}
}

// The Submit button can remain for explicit submission, if required
Button("Submit") {
calculatePackYears()
}
SubmitButton(nextView: NavigationViews.pdfs)
.foregroundColor(.white)
.padding()
.frame(maxWidth: .infinity)
.background(Color.blue)
.cornerRadius(8)
.padding(.horizontal)
.padding(.bottom)

Check warning on line 116 in Intake/SocialHistory/SmokingHistory.swift

View check run for this annotation

Codecov / codecov/patch

Intake/SocialHistory/SmokingHistory.swift#L104-L116

Added lines #L104 - L116 were not covered by tests
}
.navigationTitle("Social History")

Check warning on line 118 in Intake/SocialHistory/SmokingHistory.swift

View check run for this annotation

Codecov / codecov/patch

Intake/SocialHistory/SmokingHistory.swift#L118

Added line #L118 was not covered by tests
}
}

Expand Down
2 changes: 1 addition & 1 deletion Intake/Surgery/SurgeryView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@
let LLMResponse = try await self.queryLLM(surgeryNames: surgeryNames)

let filteredNames = LLMResponse.components(separatedBy: ", ")
var filteredSurgeries = surgeries.filter { self.containsAnyWords(item: $0.surgeryName, words: filteredNames) }
let filteredSurgeries = surgeries.filter { self.containsAnyWords(item: $0.surgeryName, words: filteredNames) }

Check warning on line 295 in Intake/Surgery/SurgeryView.swift

View check run for this annotation

Codecov / codecov/patch

Intake/Surgery/SurgeryView.swift#L295

Added line #L295 was not covered by tests

return self.cleanSurgeryNames(surgeries: filteredSurgeries, filteredNames: filteredNames)
}
Expand Down
Loading