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

Debugging symptoms tab #30

Merged
merged 9 commits into from
Mar 13, 2023
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
//

import Foundation
import HealthKitOnFHIR
import ModelsR4


extension Foundation.Bundle {
func ecgTracing(withName name: String) -> Observation {
guard let resourceURL = self.url(forResource: name, withExtension: "json") else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public struct HomeScreen: View {
func firstName(fullName: String) -> String {
var names = fullName.components(separatedBy: " ")
let first = names.removeFirst()
return first
return first + "!"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import FirebaseCore
import FirebaseFirestore
import FirestoreDataStorage
import Foundation
import HealthKitOnFHIR
import HealthKitUI

/// A data storage provider that collects all uploads and displays them in a user interface using the ``MockUploadList``.
Expand All @@ -39,6 +40,10 @@ public actor MockDataStorageProvider: DataStorageProvider, ObservableObjectProvi
let json = String(decoding: data, as: UTF8.self)
print(json)

// let tracing = try JSONDecoder().decode(HKElectrocardiogramMapping.self, from: data)
// print(tracing)
// Bundle.module.ecgTracing(withName: json)
// let symptoms = tracing.symptomsStatus.codings.description
let symptoms = getSymptoms(tracing: json)

_Concurrency.Task { @MainActor in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import FirebaseCore
import FirebaseFirestore
import FirestoreDataStorage
import Foundation
import HealthKitOnFHIR


struct MockUpload: Identifiable, Hashable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,41 @@ struct MockUploadHeader: View {
var body: some View {
let date = "\(format(mockUpload.date))"
let time = date.range(of: "at")!.lowerBound
let symptomNum = seperateSymptoms(allSymptoms: mockUpload.symptoms ?? "").count
//let symptomNum = seperateSymptoms(allSymptoms: mockUpload.symptoms ?? "").count

VStack(alignment: .leading, spacing: 4) {
ZStack{
RoundedRectangle(cornerRadius: 10)
.foregroundColor(Color(.systemBackground))
.frame(width: 360)
.shadow(radius: 5)
.opacity(0.9)
.border(backgroundGradient, width: 2)
.cornerRadius(10)
.shadow(radius: 10)
VStack(alignment: .leading, spacing: 4) {
Text(date[..<time])
.font(.title3)
.bold()
.padding([.bottom], 3)
.padding([.leading], 8)
Text(date[date.index(time, offsetBy: 2)...])
.font(.subheadline)
.padding(.bottom, 10)
.padding(.leading, 8)
Divider()
symptomView
.padding(.bottom, 10)
.padding(.leading, 8)
.cornerRadius(4)
Divider()
statusView.onAppear(perform: checkStatus)
.padding(8)
.cornerRadius(4)
.font(.title3)
.bold()
.padding([.top, .bottom], 3)
.padding([.leading], 10)
Text(date[date.index(time, offsetBy: 2)...])
.font(.subheadline)
.padding(.bottom, 10)
.padding(.leading, 10)
Divider()
symptomView
.padding(.bottom, 10)
.padding(.leading, 10)
.cornerRadius(4)
Divider()
statusView.onAppear(perform: checkStatus)
.padding(8)
.padding(.leading, 10)
.cornerRadius(4)
}
}
.frame(width: 350, height: 110 + CGFloat(30*symptomNum))
// .border(backgroundGradient, width: 5)


//.frame(width: 350, height: 110 + CGFloat(30*symptomNum))
}

@ViewBuilder var statusView: some View {
Expand All @@ -77,13 +87,15 @@ struct MockUploadHeader: View {

@ViewBuilder var symptomView: some View {
let symptoms = seperateSymptoms(allSymptoms: mockUpload.symptoms ?? "")
if (symptoms.count == 0) {
Text("No symptoms reported")
if (symptoms.count <= 0) {
Text("No Symptoms Reported")
.bold()
.padding([.top, .bottom], 3)
.padding([.leading], 2)
} else {
Text("Symptoms Reported:")
.bold()
.padding(.top, 2)
.padding([.bottom], 3)
.padding([.top, .bottom], 3)
.padding([.leading], 2)
ForEach(symptoms) { symptom in
Text(symptom)
Expand Down Expand Up @@ -121,7 +133,8 @@ struct MockUploadHeader: View {
}

private func seperateSymptoms(allSymptoms: String) -> [String] {
let symptoms = allSymptoms.components(separatedBy: "; ")
var symptoms = allSymptoms.components(separatedBy: "; ")
symptoms.removeLast()
return symptoms
}
}