generated from StanfordBDHG/SwiftPackageTemplate
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Timed Walk Test & Improve Rendering Possibilities for the Questio…
…nnaireView (#16) # Add Timed Walk Test & Improve Rendering Possibilities for the `QuestionnaireView` ## ⚙️ Release Notes - Adds the `TimedWalkTestView` - Adds the cancellation configuration to the `QuestionnaireView` ## 📚 Documentation - Adds documentation for all code changes. ## ✅ Testing - Adds automated tests for the timed walk test. ## 📝 Code of Conduct & Contributing Guidelines By submitting creating this pull request, you agree to follow our [Code of Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md): - [x] I agree to follow the [Code of Conduct](https://github.com/StanfordSpezi/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/StanfordSpezi/.github/blob/main/CONTRIBUTING.md). --------- Co-authored-by: Paul Schmiedmayer <[email protected]>
- Loading branch information
1 parent
f25580e
commit f9d9b6d
Showing
41 changed files
with
1,227 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ builder: | |
- platform: ios | ||
documentation_targets: | ||
- SpeziQuestionnaire | ||
- SpeziTimedWalkTest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
Sources/SpeziQuestionnaire/Resources/Localizable.xcstrings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"sourceLanguage" : "en", | ||
"strings" : { | ||
"QUESTIONNAIRE_LOADING_ERROR_MESSAGE" : { | ||
"comment" : "This is a string that is balh", | ||
"localizations" : { | ||
"en" : { | ||
"stringUnit" : { | ||
"state" : "translated", | ||
"value" : "Questionnaire could not be loaded." | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"version" : "1.0" | ||
} |
5 changes: 5 additions & 0 deletions
5
Sources/SpeziQuestionnaire/Resources/Localizable.xcstrings.license
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
This source file is part of the Stanford Spezi open-source project | ||
|
||
SPDX-FileCopyrightText: 2023 Stanford University and the project authors (see CONTRIBUTORS.md) | ||
|
||
SPDX-License-Identifier: MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// | ||
// This source file is part of the Stanford Spezi open-source project | ||
// | ||
// SPDX-FileCopyrightText: 2023 Stanford University and the project authors (see CONTRIBUTORS.md) | ||
// Based on https://github.com/StanfordBDHG/HealthKitOnFHIR/blob/main/Sources/HealthKitOnFHIR/Observation%20Extensions/Observation%2BCollections.swift | ||
// | ||
// SPDX-License-Identifier: MIT | ||
// | ||
|
||
import Foundation | ||
import HealthKit | ||
import ModelsR4 | ||
|
||
|
||
extension Observation { | ||
private func appendElement<T>(_ element: T, to collection: ReferenceWritableKeyPath<Observation, [T]?>) { | ||
// swiftlint:disable:previous discouraged_optional_collection | ||
// Unfortunately we need to use an optional collection here as the ModelsR4 modules uses optional collections in the Observation type. | ||
|
||
guard self[keyPath: collection] != nil else { | ||
self[keyPath: collection] = [element] | ||
return | ||
} | ||
|
||
self[keyPath: collection]?.append(element) | ||
} | ||
|
||
private func appendElements<T>(_ elements: [T], to collection: ReferenceWritableKeyPath<Observation, [T]?>) { | ||
// swiftlint:disable:previous discouraged_optional_collection | ||
// Unfortunately we need to use an optional collection here as the ModelsR4 modules uses optional collections in the Observation type. | ||
|
||
if self[keyPath: collection] == nil { | ||
self[keyPath: collection] = [] | ||
self[keyPath: collection]?.reserveCapacity(elements.count) | ||
} else { | ||
self[keyPath: collection]?.reserveCapacity((self[keyPath: collection]?.count ?? 0) + elements.count) | ||
} | ||
|
||
for element in elements { | ||
appendElement(element, to: collection) | ||
} | ||
} | ||
|
||
|
||
func appendIdentifier(_ identifier: Identifier) { | ||
appendElement(identifier, to: \.identifier) | ||
} | ||
|
||
func appendIdentifiers(_ identifiers: [Identifier]) { | ||
appendElements(identifiers, to: \.identifier) | ||
} | ||
|
||
func appendCategory(_ category: CodeableConcept) { | ||
appendElement(category, to: \.category) | ||
} | ||
|
||
func appendCategories(_ categories: [CodeableConcept]) { | ||
appendElements(categories, to: \.category) | ||
} | ||
|
||
func appendCoding(_ coding: Coding) { | ||
appendElement(coding, to: \.code.coding) | ||
} | ||
|
||
func appendCodings(_ codings: [Coding]) { | ||
appendElements(codings, to: \.code.coding) | ||
} | ||
|
||
func appendComponent(_ component: ObservationComponent) { | ||
appendElement(component, to: \.component) | ||
} | ||
|
||
func appendComponents(_ components: [ObservationComponent]) { | ||
appendElements(components, to: \.component) | ||
} | ||
|
||
func setEffective(startDate: Date, endDate: Date) { | ||
if startDate == endDate { | ||
effective = .dateTime(FHIRPrimitive(try? DateTime(date: startDate))) | ||
} else { | ||
effective = .period( | ||
Period( | ||
end: FHIRPrimitive(try? DateTime(date: endDate)), | ||
start: FHIRPrimitive(try? DateTime(date: startDate)) | ||
) | ||
) | ||
} | ||
} | ||
|
||
func setIssued(on date: Date) { | ||
issued = FHIRPrimitive(try? Instant(date: date)) | ||
} | ||
|
||
func setValue(_ quantity: Quantity) { | ||
value = .quantity(quantity) | ||
} | ||
|
||
func setValue(_ string: String) { | ||
value = .string(string.asFHIRStringPrimitive()) | ||
} | ||
} |
99 changes: 99 additions & 0 deletions
99
Sources/SpeziTimedWalkTest/Resources/Localizable.xcstrings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
{ | ||
"sourceLanguage" : "en", | ||
"strings" : { | ||
"%lld" : { | ||
|
||
}, | ||
"%lld m" : { | ||
|
||
}, | ||
"Cancel" : { | ||
|
||
}, | ||
"Cancel Timed Walk Test?" : { | ||
|
||
}, | ||
"Cancel Walk Test" : { | ||
|
||
}, | ||
"Distance:" : { | ||
|
||
}, | ||
"Done" : { | ||
|
||
}, | ||
"Invalid Data Error" : { | ||
|
||
}, | ||
"Make yourself ready for the %@ minute walk test" : { | ||
|
||
}, | ||
"Next" : { | ||
|
||
}, | ||
"Pedometer access is not authorized" : { | ||
|
||
}, | ||
"Pedometer data is invalid" : { | ||
|
||
}, | ||
"Please go to the Settings App to authorize pedometer access for this application." : { | ||
|
||
}, | ||
"Restart" : { | ||
|
||
}, | ||
"Return" : { | ||
|
||
}, | ||
"Start" : { | ||
|
||
}, | ||
"Steps:" : { | ||
|
||
}, | ||
"The %@ minute walk test will start in %@" : { | ||
"localizations" : { | ||
"en" : { | ||
"stringUnit" : { | ||
"state" : "new", | ||
"value" : "The %1$@ minute walk test will start in %2$@" | ||
} | ||
} | ||
} | ||
}, | ||
"Timed Walk Test" : { | ||
|
||
}, | ||
"Unauthorized Error" : { | ||
|
||
}, | ||
"Unknown" : { | ||
|
||
}, | ||
"Unknown Error" : { | ||
|
||
}, | ||
"WALK_TEST_DEFAULT_COMPLETION_MESSAGE" : { | ||
"localizations" : { | ||
"en" : { | ||
"stringUnit" : { | ||
"state" : "translated", | ||
"value" : "Great job completing the timed walk test. Please review your results and press \"Done\" to save your results." | ||
} | ||
} | ||
} | ||
}, | ||
"WALK_TEST_DEFAULT_TASK_DESCRIPTION %@" : { | ||
"localizations" : { | ||
"en" : { | ||
"stringUnit" : { | ||
"state" : "translated", | ||
"value" : "Welcome to the timed minute walk test!\n\nPlease be sure that you have an enough space and time to walk for %@." | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"version" : "1.0" | ||
} |
5 changes: 5 additions & 0 deletions
5
Sources/SpeziTimedWalkTest/Resources/Localizable.xcstrings.license
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
This source file is part of the Stanford Spezi open-source project | ||
|
||
SPDX-FileCopyrightText: 2023 Stanford University and the project authors (see CONTRIBUTORS.md) | ||
|
||
SPDX-License-Identifier: MIT |
Binary file added
BIN
+238 KB
Sources/SpeziTimedWalkTest/SpeziTimedWalkTest.docc/Resources/GetReady.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions
5
Sources/SpeziTimedWalkTest/SpeziTimedWalkTest.docc/Resources/GetReady.png.license
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
This source file is part of the Stanford Spezi open-source project | ||
|
||
SPDX-FileCopyrightText: 2023 Stanford University and the project authors (see CONTRIBUTORS.md) | ||
|
||
SPDX-License-Identifier: MIT |
Binary file added
BIN
+259 KB
Sources/SpeziTimedWalkTest/SpeziTimedWalkTest.docc/Resources/GetReady~dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions
5
Sources/SpeziTimedWalkTest/SpeziTimedWalkTest.docc/Resources/GetReady~dark.png.license
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
This source file is part of the Stanford Spezi open-source project | ||
|
||
SPDX-FileCopyrightText: 2023 Stanford University and the project authors (see CONTRIBUTORS.md) | ||
|
||
SPDX-License-Identifier: MIT |
Binary file added
BIN
+265 KB
Sources/SpeziTimedWalkTest/SpeziTimedWalkTest.docc/Resources/Result.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions
5
Sources/SpeziTimedWalkTest/SpeziTimedWalkTest.docc/Resources/Result.png.license
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
This source file is part of the Stanford Spezi open-source project | ||
|
||
SPDX-FileCopyrightText: 2023 Stanford University and the project authors (see CONTRIBUTORS.md) | ||
|
||
SPDX-License-Identifier: MIT |
Binary file added
BIN
+291 KB
Sources/SpeziTimedWalkTest/SpeziTimedWalkTest.docc/Resources/Result~dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions
5
Sources/SpeziTimedWalkTest/SpeziTimedWalkTest.docc/Resources/Result~dark.png.license
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
This source file is part of the Stanford Spezi open-source project | ||
|
||
SPDX-FileCopyrightText: 2023 Stanford University and the project authors (see CONTRIBUTORS.md) | ||
|
||
SPDX-License-Identifier: MIT |
Binary file added
BIN
+213 KB
Sources/SpeziTimedWalkTest/SpeziTimedWalkTest.docc/Resources/TimedWalkTest.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions
5
Sources/SpeziTimedWalkTest/SpeziTimedWalkTest.docc/Resources/TimedWalkTest.png.license
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
This source file is part of the Stanford Spezi open-source project | ||
|
||
SPDX-FileCopyrightText: 2023 Stanford University and the project authors (see CONTRIBUTORS.md) | ||
|
||
SPDX-License-Identifier: MIT |
Binary file added
BIN
+225 KB
...ces/SpeziTimedWalkTest/SpeziTimedWalkTest.docc/Resources/TimedWalkTest~dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions
5
Sources/SpeziTimedWalkTest/SpeziTimedWalkTest.docc/Resources/TimedWalkTest~dark.png.license
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
This source file is part of the Stanford Spezi open-source project | ||
|
||
SPDX-FileCopyrightText: 2023 Stanford University and the project authors (see CONTRIBUTORS.md) | ||
|
||
SPDX-License-Identifier: MIT |
Oops, something went wrong.