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

Karan Questionnaire bug fixes and code refinement #36

Merged
merged 9 commits into from
Mar 1, 2024
4 changes: 2 additions & 2 deletions PICS/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Schedule"
"value" : "Questionnaire"
}
}
}
Expand All @@ -803,7 +803,7 @@
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Schedule"
"value" : "Questionnaires"
}
}
}
Expand Down
30 changes: 4 additions & 26 deletions PICS/Schedule/EventContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,17 @@

import SpeziScheduler

// struct EventContext: Comparable, Identifiable {
// let event: Event
// let task: Task<PICSTaskContext>
//
//
// var id: Event.ID {
// event.id
// }
//
//
// static func < (lhs: EventContext, rhs: EventContext) -> Bool {
// lhs.event.scheduledAt < rhs.event.scheduledAt
// }
// }

struct EventContext: Comparable, Identifiable, Hashable {
struct EventContext: Comparable, Identifiable {
let event: Event
let task: Task<PICSTaskContext>


var id: Event.ID {
event.id
}


static func < (lhs: EventContext, rhs: EventContext) -> Bool {
lhs.event.scheduledAt < rhs.event.scheduledAt
}

static func == (lhs: EventContext, rhs: EventContext) -> Bool {
lhs.event == rhs.event && lhs.task == rhs.task
}

func hash(into hasher: inout Hasher) {
hasher.combine(event)
hasher.combine(task)
}
}
}
34 changes: 4 additions & 30 deletions PICS/Schedule/PICSScheduler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ extension PICSScheduler {
schedule: Schedule(
start: Calendar.current.startOfDay(for: Date()),
repetition: .matching(dateComponents),
end: .numberOfEvents(365)
end: .numberOfEvents(26)
),
notifications: true,
context: PICSTaskContext.questionnaire(Bundle.main.questionnaire(withName: "PHQ-4"))
Expand All @@ -61,7 +61,7 @@ extension PICSScheduler {
schedule: Schedule(
start: Calendar.current.startOfDay(for: Date()),
repetition: .matching(dateComponents),
end: .numberOfEvents(365)
end: .numberOfEvents(26)
),
notifications: true,
context: PICSTaskContext.questionnaire(Bundle.main.questionnaire(withName: "EQ5D5L"))
Expand All @@ -77,7 +77,7 @@ extension PICSScheduler {
minute: Calendar.current.component(.minute, from: .now)
)
} else {
// For the normal app usage, we schedule the task for every day at 9:00 AM
// For the normal app usage, we schedule the task for every day at 10:00 AM
dateComponents = DateComponents(hour: 10, minute: 0)
}

Expand All @@ -87,38 +87,12 @@ extension PICSScheduler {
schedule: Schedule(
start: Calendar.current.startOfDay(for: Date()),
repetition: .matching(dateComponents),
end: .numberOfEvents(365)
end: .numberOfEvents(26)
),
notifications: true,
context: PICSTaskContext.questionnaire(Bundle.main.questionnaire(withName: "Self-MNA"))
)
}

// static var MiniNutritionlTask: SpeziScheduler.Task<PICSTaskContext> {
// let dateComponents: DateComponents
// if FeatureFlags.testSchedule {
// // Adds a task at the current time for UI testing if the `--testSchedule` feature flag is set
// dateComponents = DateComponents(
// hour: Calendar.current.component(.hour, from: .now),
// minute: Calendar.current.component(.minute, from: .now)
// )
// } else {
// // For the normal app usage, we schedule the task for every day at 9:00 AM
// dateComponents = DateComponents(hour: 10, minute: 0)
// }
//
// return Task(
// title: String(localized: "MiniNutritional_TITLE"),
// description: String(localized: "MiniNutritional_DESCRIPTION"),
// schedule: Schedule(
// start: Calendar.current.startOfDay(for: Date()),
// repetition: .matching(dateComponents),
// end: .numberOfEvents(365)
// ),
// notifications: true,
// context: PICSTaskContext.questionnaire(Bundle.main.questionnaire(withName: "PHQ-4"))
// )
// }

/// Creates a default instance of the ``PICSScheduler`` by scheduling the tasks listed below.
convenience init() {
Expand Down
Loading