From d8a2dcace0db86070c2dc638c52965492edcc534 Mon Sep 17 00:00:00 2001 From: karansoin <64022954+karansoin@users.noreply.github.com> Date: Wed, 13 Mar 2024 21:02:48 -0700 Subject: [PATCH] Testing for Scheduler and Questionnaires (#59) # Final Tests and Code Refinement - Scheduler & Questionnaires ## :recycle: Current situation & Problem - Current code coverage for Questionnaires/Spezi Scheduler before this PR was at approx 55% - Code was not fully commented and refined - Unnecessary commented out code was still in certain code files ## :gear: Release Notes - Added UI and Unit tests covering majority of Questionnaire/Scheduler files - Cleaned up unnecessary commented out code and refined comments explaining code and logic ## :books: Documentation - Code and testing logic and documentation in the comments for the tests - Used the updated XCTSpezi package - Added tests to improve code coverage to over 75% ## :white_check_mark: Testing - Code Coverage is now 86%+ after this PR - Testing covers more than 75% of Scheduler and Questionnaires lines - Covers both UI and Unit Testing ## :pencil: Code of Conduct & Contributing Guidelines By submitting creating this pull request, you agree to follow our [Code of Conduct](https://github.com/CS342/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/CS342/.github/blob/main/CONTRIBUTING.md): - [x] I agree to follow the [Code of Conduct](https://github.com/CS342/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/CS342/.github/blob/main/CONTRIBUTING.md). --- PICS.xcodeproj/project.pbxproj | 14 +- .../xcshareddata/swiftpm/Package.resolved | 329 ++++++++++++++++++ PICS/Resources/EQ5D5L.json | 2 +- PICS/Resources/Localizable.xcstrings | 2 +- PICS/Schedule/PICSScheduler.swift | 8 +- PICSTests/PICSTests.swift | 1 + PICSUITests/SchedulerTests.swift | 79 +++++ 7 files changed, 423 insertions(+), 12 deletions(-) create mode 100644 PICS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved create mode 100644 PICSUITests/SchedulerTests.swift diff --git a/PICS.xcodeproj/project.pbxproj b/PICS.xcodeproj/project.pbxproj index 4f4097f..eb4a882 100644 --- a/PICS.xcodeproj/project.pbxproj +++ b/PICS.xcodeproj/project.pbxproj @@ -78,12 +78,13 @@ 653A255528338800005D4D48 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 653A255428338800005D4D48 /* Assets.xcassets */; }; 653A256228338800005D4D48 /* PICSTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 653A256128338800005D4D48 /* PICSTests.swift */; }; 741110F22B5767DF00DFC79E /* PROM-Questionnaire.json in Resources */ = {isa = PBXBuildFile; fileRef = 741110F12B5767DE00DFC79E /* PROM-Questionnaire.json */; }; - 748117172B74BC3E00801A9A /* EQ5D5L.json in Resources */ = {isa = PBXBuildFile; fileRef = 748117152B74BC3E00801A9A /* EQ5D5L.json */; }; 748117182B74BC3E00801A9A /* EQ5D5L.json.license in Resources */ = {isa = PBXBuildFile; fileRef = 748117162B74BC3E00801A9A /* EQ5D5L.json.license */; }; 7481171A2B74BC5B00801A9A /* Self-MNA.json in Resources */ = {isa = PBXBuildFile; fileRef = 748117192B74BC5B00801A9A /* Self-MNA.json */; }; 74AE05882B918DAF00AB5287 /* StroopTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74AE05872B918DAF00AB5287 /* StroopTest.swift */; }; 74AE05932B98620300AB5287 /* AssessmentsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74AE05922B98620300AB5287 /* AssessmentsTests.swift */; }; 74AE05A92B9BB47F00AB5287 /* XCTSpezi in Frameworks */ = {isa = PBXBuildFile; productRef = 74AE05A82B9BB47F00AB5287 /* XCTSpezi */; }; + 74AE05AD2BA1241D00AB5287 /* SchedulerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74AE05AC2BA1241D00AB5287 /* SchedulerTests.swift */; }; + 74AE05B22BA2A44F00AB5287 /* EQ5D5L.json in Resources */ = {isa = PBXBuildFile; fileRef = 74AE05B12BA2A44F00AB5287 /* EQ5D5L.json */; }; 74C593952B720781002D0274 /* (null) in Resources */ = {isa = PBXBuildFile; }; 74C593972B720B5E002D0274 /* (null) in Resources */ = {isa = PBXBuildFile; }; 74C5939A2B720F1B002D0274 /* (null) in Resources */ = {isa = PBXBuildFile; }; @@ -136,7 +137,6 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ - 22201EE52B9259B800E38F47 /* EQ5D5L.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = EQ5D5L.json; sourceTree = ""; }; 22201EE62B9259B800E38F47 /* PHQ-4.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "PHQ-4.json"; sourceTree = ""; }; 22201EE72B9259B800E38F47 /* Self-MNA.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "Self-MNA.json"; sourceTree = ""; }; 22306A292B7C4E8E000A8EC1 /* OnboardingQuestionnaire.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OnboardingQuestionnaire.swift; sourceTree = ""; }; @@ -194,12 +194,13 @@ 653A256728338800005D4D48 /* PICSUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PICSUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 653A258928339462005D4D48 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 741110F12B5767DE00DFC79E /* PROM-Questionnaire.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "PROM-Questionnaire.json"; sourceTree = ""; }; - 748117152B74BC3E00801A9A /* EQ5D5L.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = EQ5D5L.json; sourceTree = ""; }; 748117162B74BC3E00801A9A /* EQ5D5L.json.license */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = EQ5D5L.json.license; sourceTree = ""; }; 748117192B74BC5B00801A9A /* Self-MNA.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "Self-MNA.json"; sourceTree = ""; }; 7481171B2B74BC6D00801A9A /* PHQ-4.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "PHQ-4.json"; sourceTree = ""; }; 74AE05872B918DAF00AB5287 /* StroopTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StroopTest.swift; sourceTree = ""; }; 74AE05922B98620300AB5287 /* AssessmentsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AssessmentsTests.swift; sourceTree = ""; }; + 74AE05AC2BA1241D00AB5287 /* SchedulerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SchedulerTests.swift; sourceTree = ""; }; + 74AE05B12BA2A44F00AB5287 /* EQ5D5L.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = EQ5D5L.json; sourceTree = ""; }; 860750592BA1278200CABE92 /* ApptInfoTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApptInfoTests.swift; sourceTree = ""; }; 862AB7F52B9AA6460048D158 /* ContactsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContactsTests.swift; sourceTree = ""; }; 86400D182B7C4B6D009FEC10 /* ApptInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApptInfo.swift; sourceTree = ""; }; @@ -336,11 +337,10 @@ 2FE5DC2D29EDD792004B9AB4 /* Resources */ = { isa = PBXGroup; children = ( + 74AE05B12BA2A44F00AB5287 /* EQ5D5L.json */, 7481171B2B74BC6D00801A9A /* PHQ-4.json */, 748117192B74BC5B00801A9A /* Self-MNA.json */, - 748117152B74BC3E00801A9A /* EQ5D5L.json */, 748117162B74BC3E00801A9A /* EQ5D5L.json.license */, - 22201EE52B9259B800E38F47 /* EQ5D5L.json */, 22201EE62B9259B800E38F47 /* PHQ-4.json */, 22201EE72B9259B800E38F47 /* Self-MNA.json */, 22365B772B902C9100C4528E /* Onboarding-Questionnaire.json */, @@ -464,6 +464,7 @@ 2F4E237D2989A2FE0013F3D9 /* LaunchTests.swift */, A403A52D2B705A8C003CFA5C /* HealthVisualizationTests.swift */, 74AE05922B98620300AB5287 /* AssessmentsTests.swift */, + 74AE05AC2BA1241D00AB5287 /* SchedulerTests.swift */, 862AB7F52B9AA6460048D158 /* ContactsTests.swift */, 86EF04BD2B9B1661005596D8 /* AppointmentsTests.swift */, A40419F92B9F95EC0038D791 /* OnboardingTests.swift */, @@ -686,8 +687,8 @@ 2FC3439229EE634B002D773C /* ConsentDocument.md in Resources */, 653A255528338800005D4D48 /* Assets.xcassets in Resources */, 74C5939A2B720F1B002D0274 /* (null) in Resources */, - 748117172B74BC3E00801A9A /* EQ5D5L.json in Resources */, 2FC3439029EE6346002D773C /* SocialSupportQuestionnaire.json in Resources */, + 74AE05B22BA2A44F00AB5287 /* EQ5D5L.json in Resources */, 748117182B74BC3E00801A9A /* EQ5D5L.json.license in Resources */, 74C593952B720781002D0274 /* (null) in Resources */, 2FA0BFED2ACC977500E0EF83 /* Localizable.xcstrings in Resources */, @@ -819,6 +820,7 @@ files = ( 862AB7F62B9AA6460048D158 /* ContactsTests.swift in Sources */, A403A52E2B705A8C003CFA5C /* HealthVisualizationTests.swift in Sources */, + 74AE05AD2BA1241D00AB5287 /* SchedulerTests.swift in Sources */, A40419FA2B9F95EC0038D791 /* OnboardingTests.swift in Sources */, 74AE05932B98620300AB5287 /* AssessmentsTests.swift in Sources */, 2F4E237E2989A2FE0013F3D9 /* LaunchTests.swift in Sources */, diff --git a/PICS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/PICS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 0000000..05d7cd7 --- /dev/null +++ b/PICS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,329 @@ +{ + "pins" : [ + { + "identity" : "abseil-cpp-binary", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/abseil-cpp-binary.git", + "state" : { + "revision" : "df308b8b46607675f2b9ec8e569109008f9155ce", + "version" : "1.2022062300.1" + } + }, + { + "identity" : "app-check", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/app-check.git", + "state" : { + "revision" : "3e464dad87dad2d29bb29a97836789bf0f8f67d2", + "version" : "10.18.1" + } + }, + { + "identity" : "fhirmodels", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/FHIRModels", + "state" : { + "revision" : "861afd5816a98d38f86220eab2f812d76cad84a0", + "version" : "0.5.0" + } + }, + { + "identity" : "firebase-ios-sdk", + "kind" : "remoteSourceControl", + "location" : "https://github.com/firebase/firebase-ios-sdk.git", + "state" : { + "revision" : "be49849dcba96f2b5ee550d4eceb2c0fa27dade4", + "version" : "10.22.1" + } + }, + { + "identity" : "googleappmeasurement", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/GoogleAppMeasurement.git", + "state" : { + "revision" : "482cfa4e5880f0a29f66ecfd60c5a62af28bd1f0", + "version" : "10.22.1" + } + }, + { + "identity" : "googledatatransport", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/GoogleDataTransport.git", + "state" : { + "revision" : "a637d318ae7ae246b02d7305121275bc75ed5565", + "version" : "9.4.0" + } + }, + { + "identity" : "googleutilities", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/GoogleUtilities.git", + "state" : { + "revision" : "26c898aed8bed13b8a63057ee26500abbbcb8d55", + "version" : "7.13.1" + } + }, + { + "identity" : "grpc-binary", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/grpc-binary.git", + "state" : { + "revision" : "ea4cb5cc0c39c732b85386263116d2e2fdbbdc61", + "version" : "1.49.2" + } + }, + { + "identity" : "gtm-session-fetcher", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/gtm-session-fetcher.git", + "state" : { + "revision" : "76135c9f4e1ac85459d5fec61b6f76ac47ab3a4c", + "version" : "3.3.1" + } + }, + { + "identity" : "healthkitonfhir", + "kind" : "remoteSourceControl", + "location" : "https://github.com/StanfordBDHG/HealthKitOnFHIR.git", + "state" : { + "revision" : "00d64d38a8f0d826ee9e27b6f3ce32314a29fd3e", + "version" : "0.2.6" + } + }, + { + "identity" : "imagesource", + "kind" : "remoteSourceControl", + "location" : "https://github.com/StanfordBDHG/ImageSource", + "state" : { + "branch" : "main", + "revision" : "9f942f21a485f4d552cfcefffae2e4077c0e9635" + } + }, + { + "identity" : "interop-ios-for-google-sdks", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/interop-ios-for-google-sdks.git", + "state" : { + "revision" : "2d12673670417654f08f5f90fdd62926dc3a2648", + "version" : "100.0.0" + } + }, + { + "identity" : "leveldb", + "kind" : "remoteSourceControl", + "location" : "https://github.com/firebase/leveldb.git", + "state" : { + "revision" : "43aaef65e0c665daadf848761d560e446d350d3d", + "version" : "1.22.4" + } + }, + { + "identity" : "nanopb", + "kind" : "remoteSourceControl", + "location" : "https://github.com/firebase/nanopb.git", + "state" : { + "revision" : "b7e1104502eca3a213b46303391ca4d3bc8ddec1", + "version" : "2.30910.0" + } + }, + { + "identity" : "promises", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/promises.git", + "state" : { + "revision" : "540318ecedd63d883069ae7f1ed811a2df00b6ac", + "version" : "2.4.0" + } + }, + { + "identity" : "researchkit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/StanfordBDHG/ResearchKit", + "state" : { + "revision" : "64512d0a0a5cc3e9d5b3fc5217c54f11d0dc044c", + "version" : "2.2.28" + } + }, + { + "identity" : "researchkitonfhir", + "kind" : "remoteSourceControl", + "location" : "https://github.com/StanfordBDHG/ResearchKitOnFHIR", + "state" : { + "revision" : "7c2efdcb17796fc9ee686900304dbbe9dd4aaf85", + "version" : "1.1.2" + } + }, + { + "identity" : "spezi", + "kind" : "remoteSourceControl", + "location" : "https://github.com/StanfordSpezi/Spezi", + "state" : { + "revision" : "c43e4fa3d3938a847de2b677091a34ddaea5bc76", + "version" : "1.2.3" + } + }, + { + "identity" : "speziaccount", + "kind" : "remoteSourceControl", + "location" : "https://github.com/StanfordSpezi/SpeziAccount.git", + "state" : { + "revision" : "a7d289ef3be54de62b25dc92e8f7ff1a0f093906", + "version" : "1.2.1" + } + }, + { + "identity" : "spezicontact", + "kind" : "remoteSourceControl", + "location" : "https://github.com/StanfordSpezi/SpeziContact.git", + "state" : { + "revision" : "494b776f8c98d771e4a609a1fb706097dba4c030", + "version" : "1.0.0" + } + }, + { + "identity" : "spezifirebase", + "kind" : "remoteSourceControl", + "location" : "https://github.com/StanfordSpezi/SpeziFirebase.git", + "state" : { + "revision" : "e05e665b7da39aa399ecd7fba393aab49b8f3034", + "version" : "1.0.1" + } + }, + { + "identity" : "spezifoundation", + "kind" : "remoteSourceControl", + "location" : "https://github.com/StanfordSpezi/SpeziFoundation", + "state" : { + "revision" : "01af5b91a54f30ddd121258e81aff2ddc2a99ff9", + "version" : "1.0.4" + } + }, + { + "identity" : "spezihealthkit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/StanfordSpezi/SpeziHealthKit.git", + "state" : { + "revision" : "35628084d3977aa897015b0b0c21cfe4d556f1aa", + "version" : "0.5.2" + } + }, + { + "identity" : "spezimockwebservice", + "kind" : "remoteSourceControl", + "location" : "https://github.com/StanfordSpezi/SpeziMockWebService.git", + "state" : { + "revision" : "b18067d3499e630bbd995ef05a296ef8fdd42528", + "version" : "1.0.0" + } + }, + { + "identity" : "spezionboarding", + "kind" : "remoteSourceControl", + "location" : "https://github.com/StanfordSpezi/SpeziOnboarding", + "state" : { + "revision" : "4971a82e94996ce0c3d8ecf64fdeec874a1f20d6", + "version" : "1.1.1" + } + }, + { + "identity" : "speziquestionnaire", + "kind" : "remoteSourceControl", + "location" : "https://github.com/StanfordSpezi/SpeziQuestionnaire.git", + "state" : { + "revision" : "f9d9b6d99bb1e00bda2974b440dca8367733d591", + "version" : "1.1.0" + } + }, + { + "identity" : "spezischeduler", + "kind" : "remoteSourceControl", + "location" : "https://github.com/StanfordSpezi/SpeziScheduler.git", + "state" : { + "revision" : "eed3980f20b01a788720c869010e3fe2fbfcd1fd", + "version" : "0.8.2" + } + }, + { + "identity" : "spezistorage", + "kind" : "remoteSourceControl", + "location" : "https://github.com/StanfordSpezi/SpeziStorage.git", + "state" : { + "revision" : "b958df9b31f24800388a7bfc28f457ce7b82556c", + "version" : "1.0.2" + } + }, + { + "identity" : "speziviews", + "kind" : "remoteSourceControl", + "location" : "https://github.com/StanfordSpezi/SpeziViews.git", + "state" : { + "revision" : "4d2a724d97c8f19ac7de7aa2c046b1cb3ef7b279", + "version" : "1.3.1" + } + }, + { + "identity" : "swift-argument-parser", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-argument-parser", + "state" : { + "revision" : "c8ed701b513cf5177118a175d85fbbbcd707ab41", + "version" : "1.3.0" + } + }, + { + "identity" : "swift-collections", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-collections.git", + "state" : { + "revision" : "94cf62b3ba8d4bed62680a282d4c25f9c63c2efb", + "version" : "1.1.0" + } + }, + { + "identity" : "swift-package-list", + "kind" : "remoteSourceControl", + "location" : "https://github.com/FelixHerrmann/swift-package-list", + "state" : { + "revision" : "412180a72b9a1f8262213c16459e3533b0385ea5", + "version" : "3.1.0" + } + }, + { + "identity" : "swift-protobuf", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-protobuf.git", + "state" : { + "revision" : "65e8f29b2d63c4e38e736b25c27b83e012159be8", + "version" : "1.25.2" + } + }, + { + "identity" : "xctestextensions", + "kind" : "remoteSourceControl", + "location" : "https://github.com/StanfordBDHG/XCTestExtensions.git", + "state" : { + "revision" : "1fe9b8e76aeb7a132af37bfa0892160c9b662dcc", + "version" : "0.4.10" + } + }, + { + "identity" : "xcthealthkit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/StanfordBDHG/XCTHealthKit.git", + "state" : { + "revision" : "6e9344a2d632b801d94fe3bbd1d891817e032103", + "version" : "0.3.5" + } + }, + { + "identity" : "xctruntimeassertions", + "kind" : "remoteSourceControl", + "location" : "https://github.com/StanfordBDHG/XCTRuntimeAssertions", + "state" : { + "revision" : "51da3403f128b120705571ce61e0fe190f8889e6", + "version" : "1.0.1" + } + } + ], + "version" : 2 +} diff --git a/PICS/Resources/EQ5D5L.json b/PICS/Resources/EQ5D5L.json index 08315fd..94d1c87 100644 --- a/PICS/Resources/EQ5D5L.json +++ b/PICS/Resources/EQ5D5L.json @@ -1 +1 @@ -{"title":"EQ-5D-5L: Patient Physical Health Questionnaire","resourceType":"Questionnaire","language":"en-US","status":"draft","publisher":"Stanford Biodesign Digital Health","meta":{"profile":["http://spezi.health/fhir/StructureDefinition/sdf-Questionnaire"],"tag":[{"system":"urn:ietf:bcp:47","code":"en-US","display":"English"}]},"useContext":[{"code":{"system":"http://hl7.org/fhir/ValueSet/usage-context-type","code":"focus","display":"Clinical Focus"},"valueCodeableConcept":{"coding":[{"system":"urn:oid:2.16.578.1.12.4.1.1.8655","display":"EQ-5D-5L: Patient Physical Health Questionnaire"}]}}],"contact":[{"name":"http://spezi.health"}],"subjectType":["Patient"],"url":"http://spezi.health/fhir/questionnaire/e861f1a8-58a7-45db-8a99-53a73f49fea7","item":[{"linkId":"b1cacb3a-e868-451d-db6d-1c27f19b7521","type":"display","text":"Please answer the following questions about your physical health...","required":false},{"linkId":"4efbd9bb-810b-49c4-8e3d-7c283d218a4c","type":"choice","text":"What is your MOBILITY like?","required":true,"answerOption":[{"valueCoding":{"id":"29c6fc8d-68a4-4a2b-8a56-763a737ad2be","code":"0","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I have no problems in walking about"}},{"valueCoding":{"id":"77cc50b1-88c2-4969-fe2d-58366e689d82","code":"1","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I have slight problems in walking about"}},{"valueCoding":{"id":"e4e7f2e6-dad3-4df6-8e45-1efb4409db15","code":"2","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I have moderate problems in walking about"}},{"valueCoding":{"id":"254c50c7-6af1-4a00-b0a6-0634d2c4ac02","code":"3","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I have severe problems in walking about"}},{"valueCoding":{"id":"6b0b9dd3-3a4c-4720-d617-8410987e9ea6","code":"4","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I am unable to walk about"}}]},{"linkId":"722b5b42-e104-4fbd-804a-d5ec75d7976a","type":"choice","text":"What is your SELF-CARE like?","required":true,"answerOption":[{"valueCoding":{"id":"29c6fc8d-68a4-4a2b-8a56-763a737ad2be","code":"0","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I have no problems washing or dressing myself"}},{"valueCoding":{"id":"77cc50b1-88c2-4969-fe2d-58366e689d82","code":"1","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I have slight problems washing or dressing myself"}},{"valueCoding":{"id":"e4e7f2e6-dad3-4df6-8e45-1efb4409db15","code":"2","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I have moderate problems washing or dressing myself"}},{"valueCoding":{"id":"254c50c7-6af1-4a00-b0a6-0634d2c4ac02","code":"3","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I have severe problems washing or dressing myself"}},{"valueCoding":{"id":"6b0b9dd3-3a4c-4720-d617-8410987e9ea6","code":"4","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I am unable to wash or dress myself"}}]},{"linkId":"7e8056af-75e3-4812-d2f5-c816cad6ef85","type":"choice","text":"What are your USUAL ACTIVITIES like? (e.g. work, study, housework, family or leisure activities)","required":true,"answerOption":[{"valueCoding":{"id":"29c6fc8d-68a4-4a2b-8a56-763a737ad2be","code":"0","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I have no problems doing my usual activities"}},{"valueCoding":{"id":"77cc50b1-88c2-4969-fe2d-58366e689d82","code":"1","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I have slight problems doing my usual activities"}},{"valueCoding":{"id":"e4e7f2e6-dad3-4df6-8e45-1efb4409db15","code":"2","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I have moderate problems doing my usual activities"}},{"valueCoding":{"id":"254c50c7-6af1-4a00-b0a6-0634d2c4ac02","code":"3","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I have severe problems doing my usual activities"}},{"valueCoding":{"id":"6b0b9dd3-3a4c-4720-d617-8410987e9ea6","code":"4","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I am unable to do my usual activities"}}]},{"linkId":"de5eeb85-0d9b-497e-8a42-89b7ee101e7a","type":"choice","text":"What is your PAIN / DISCOMFORT like?","required":true,"answerOption":[{"valueCoding":{"id":"29c6fc8d-68a4-4a2b-8a56-763a737ad2be","code":"0","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I have no pain or discomfort"}},{"valueCoding":{"id":"77cc50b1-88c2-4969-fe2d-58366e689d82","code":"1","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I have slight pain or discomfort"}},{"valueCoding":{"id":"e4e7f2e6-dad3-4df6-8e45-1efb4409db15","code":"2","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I have moderate pain or discomfort"}},{"valueCoding":{"id":"254c50c7-6af1-4a00-b0a6-0634d2c4ac02","code":"3","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I have severe pain or discomfort"}},{"valueCoding":{"id":"6b0b9dd3-3a4c-4720-d617-8410987e9ea6","code":"4","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I have extreme pain or discomfort"}}]},{"linkId":"4f0a905f-9a86-4ea2-a957-0f79b2f4ea06","type":"choice","text":"What is your ANXIETY / DEPRESSION like?","required":true,"answerOption":[{"valueCoding":{"id":"29c6fc8d-68a4-4a2b-8a56-763a737ad2be","code":"0","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I am not anxious or depressed"}},{"valueCoding":{"id":"77cc50b1-88c2-4969-fe2d-58366e689d82","code":"1","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I am slightly anxious or depressed"}},{"valueCoding":{"id":"e4e7f2e6-dad3-4df6-8e45-1efb4409db15","code":"2","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I am moderately anxious or depressed"}},{"valueCoding":{"id":"254c50c7-6af1-4a00-b0a6-0634d2c4ac02","code":"3","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I am severely anxious or depressed"}},{"valueCoding":{"id":"6b0b9dd3-3a4c-4720-d617-8410987e9ea6","code":"4","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I am severely anxious or depressed"}}]},{"linkId":"5c4788ea-c68b-47fd-8ecc-fb08f3f677a8","type":"integer","extension":[{"url":"http://hl7.org/fhir/StructureDefinition/minValue","valueInteger":0},{"url":"http://hl7.org/fhir/StructureDefinition/maxValue","valueInteger":100},{"url":"http://ehelse.no/fhir/StructureDefinition/validationtext","valueString":"Please enter a range between 0 and 100!"}],"required":true,"text":"We would like to know how good or bad your health is TODAY.\n• The scale is numbered from 0 to 100.\n• 100 means the best health you can imagine.\n• 0 means the worst health you can imagine.\n• Please write the number you marked on the scale in the space below."}]} +{"resourceType":"Questionnaire","language":"en-US","title":"EQ-5D-5L: Patient Physical Health Questionnaire","status":"draft","publisher":"Stanford Biodesign Digital Health","meta":{"profile":["http://spezi.health/fhir/StructureDefinition/sdf-Questionnaire"],"tag":[{"system":"urn:ietf:bcp:47","code":"en-US","display":"English"}]},"useContext":[{"code":{"system":"http://hl7.org/fhir/ValueSet/usage-context-type","code":"focus","display":"Clinical Focus"},"valueCodeableConcept":{"coding":[{"system":"urn:oid:2.16.578.1.12.4.1.1.8655","display":"EQ-5D-5L: Patient Physical Health Questionnaire"}]}}],"contact":[{"name":"http://spezi.health"}],"subjectType":["Patient"],"url":"http://spezi.health/fhir/questionnaire/e861f1a8-58a7-45db-8a99-53a73f49fea7","item":[{"linkId":"b1cacb3a-e868-451d-db6d-1c27f19b7521","type":"display","text":"Please answer the following questions about your physical health...","required":false},{"linkId":"4efbd9bb-810b-49c4-8e3d-7c283d218a4c","type":"choice","text":"What is your MOBILITY like?","required":true,"answerOption":[{"valueCoding":{"id":"29c6fc8d-68a4-4a2b-8a56-763a737ad2be","code":"0","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I have no problems in walking about"}},{"valueCoding":{"id":"77cc50b1-88c2-4969-fe2d-58366e689d82","code":"1","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I have slight problems in walking about"}},{"valueCoding":{"id":"e4e7f2e6-dad3-4df6-8e45-1efb4409db15","code":"2","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I have moderate problems in walking about"}},{"valueCoding":{"id":"254c50c7-6af1-4a00-b0a6-0634d2c4ac02","code":"3","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I have severe problems in walking about"}},{"valueCoding":{"id":"6b0b9dd3-3a4c-4720-d617-8410987e9ea6","code":"4","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I am unable to walk about"}}]},{"linkId":"722b5b42-e104-4fbd-804a-d5ec75d7976a","type":"choice","text":"What is your SELF-CARE like?","required":true,"answerOption":[{"valueCoding":{"id":"29c6fc8d-68a4-4a2b-8a56-763a737ad2be","code":"0","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I have no problems washing or dressing myself"}},{"valueCoding":{"id":"77cc50b1-88c2-4969-fe2d-58366e689d82","code":"1","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I have slight problems washing or dressing myself"}},{"valueCoding":{"id":"e4e7f2e6-dad3-4df6-8e45-1efb4409db15","code":"2","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I have moderate problems washing or dressing myself"}},{"valueCoding":{"id":"254c50c7-6af1-4a00-b0a6-0634d2c4ac02","code":"3","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I have severe problems washing or dressing myself"}},{"valueCoding":{"id":"6b0b9dd3-3a4c-4720-d617-8410987e9ea6","code":"4","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I am unable to wash or dress myself"}}]},{"linkId":"7e8056af-75e3-4812-d2f5-c816cad6ef85","type":"choice","text":"What are your USUAL ACTIVITIES like? (e.g. work, study, housework, family or leisure activities)","required":true,"answerOption":[{"valueCoding":{"id":"29c6fc8d-68a4-4a2b-8a56-763a737ad2be","code":"0","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I have no problems doing my usual activities"}},{"valueCoding":{"id":"77cc50b1-88c2-4969-fe2d-58366e689d82","code":"1","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I have slight problems doing my usual activities"}},{"valueCoding":{"id":"e4e7f2e6-dad3-4df6-8e45-1efb4409db15","code":"2","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I have moderate problems doing my usual activities"}},{"valueCoding":{"id":"254c50c7-6af1-4a00-b0a6-0634d2c4ac02","code":"3","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I have severe problems doing my usual activities"}},{"valueCoding":{"id":"6b0b9dd3-3a4c-4720-d617-8410987e9ea6","code":"4","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I am unable to do my usual activities"}}]},{"linkId":"de5eeb85-0d9b-497e-8a42-89b7ee101e7a","type":"choice","text":"What is your PAIN / DISCOMFORT like?","required":true,"answerOption":[{"valueCoding":{"id":"29c6fc8d-68a4-4a2b-8a56-763a737ad2be","code":"0","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I have no pain or discomfort"}},{"valueCoding":{"id":"77cc50b1-88c2-4969-fe2d-58366e689d82","code":"1","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I have slight pain or discomfort"}},{"valueCoding":{"id":"e4e7f2e6-dad3-4df6-8e45-1efb4409db15","code":"2","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I have moderate pain or discomfort"}},{"valueCoding":{"id":"254c50c7-6af1-4a00-b0a6-0634d2c4ac02","code":"3","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I have severe pain or discomfort"}},{"valueCoding":{"id":"6b0b9dd3-3a4c-4720-d617-8410987e9ea6","code":"4","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I have extreme pain or discomfort"}}]},{"linkId":"4f0a905f-9a86-4ea2-a957-0f79b2f4ea06","type":"choice","text":"What is your ANXIETY / DEPRESSION like?","required":true,"answerOption":[{"valueCoding":{"id":"29c6fc8d-68a4-4a2b-8a56-763a737ad2be","code":"0","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I am not anxious or depressed"}},{"valueCoding":{"id":"77cc50b1-88c2-4969-fe2d-58366e689d82","code":"1","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I am slightly anxious or depressed"}},{"valueCoding":{"id":"e4e7f2e6-dad3-4df6-8e45-1efb4409db15","code":"2","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I am moderately anxious or depressed"}},{"valueCoding":{"id":"254c50c7-6af1-4a00-b0a6-0634d2c4ac02","code":"3","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I am severely anxious or depressed"}},{"valueCoding":{"id":"6b0b9dd3-3a4c-4720-d617-8410987e9ea6","code":"4","system":"urn:uuid:d993d03b-b418-4561-98e9-714ea69073ff","display":"I am severely anxious or depressed"}}]},{"linkId":"5c4788ea-c68b-47fd-8ecc-fb08f3f677a8","type":"integer","extension":[{"url":"http://hl7.org/fhir/StructureDefinition/maxValue","valueInteger":100},{"url":"http://ehelse.no/fhir/StructureDefinition/validationtext","valueString":"Please enter a range between 0 and 100!"},{"url":"http://hl7.org/fhir/StructureDefinition/questionnaire-itemControl","valueCodeableConcept":{"coding":[{"system":"http://hl7.org/fhir/questionnaire-item-control","code":"slider","display":"Slider"}]}},{"url":"http://hl7.org/fhir/StructureDefinition/minValue","valueInteger":0},{"url":"http://hl7.org/fhir/StructureDefinition/questionnaire-sliderStepValue","valueInteger":20}],"required":true,"text":"We would like to know how good or bad your health is TODAY.\n• The scale is numbered from 0 to 100.\n• 100 means the best health you can imagine.\n• 0 means the worst health you can imagine.\n• Please mark the number that represents your health on the scale below."}]} diff --git a/PICS/Resources/Localizable.xcstrings b/PICS/Resources/Localizable.xcstrings index f86b53d..0f11e8b 100644 --- a/PICS/Resources/Localizable.xcstrings +++ b/PICS/Resources/Localizable.xcstrings @@ -1125,7 +1125,7 @@ "en" : { "stringUnit" : { "state" : "translated", - "value" : "Questionnaire" + "value" : "Questionnaires" } } } diff --git a/PICS/Schedule/PICSScheduler.swift b/PICS/Schedule/PICSScheduler.swift index 09a46b1..7c950c0 100644 --- a/PICS/Schedule/PICSScheduler.swift +++ b/PICS/Schedule/PICSScheduler.swift @@ -51,8 +51,8 @@ extension PICSScheduler { minute: Calendar.current.component(.minute, from: .now) ) } else { - // For the normal app usage, we schedule the task for every 2 weeks at 9:00 AM - dateComponents = DateComponents(hour: 9, minute: 0) + // For the normal app usage, we schedule the task for every 2 weeks at 8:05 AM + dateComponents = DateComponents(hour: 8, minute: 5) } return Task( @@ -77,8 +77,8 @@ extension PICSScheduler { minute: Calendar.current.component(.minute, from: .now) ) } else { - // For the normal app usage we schedule the task for every 2 weeks at 10:00 AM - dateComponents = DateComponents(hour: 10, minute: 0) + // For the normal app usage we schedule the task for every 2 weeks at 8:10 AM + dateComponents = DateComponents(hour: 8, minute: 10) } return Task( diff --git a/PICSTests/PICSTests.swift b/PICSTests/PICSTests.swift index 89cdd37..23bdbd1 100644 --- a/PICSTests/PICSTests.swift +++ b/PICSTests/PICSTests.swift @@ -27,6 +27,7 @@ class PICSTests: XCTestCase { scheduler.tasks.forEach { task in print("Task title: \(task.title)") } + // Testing the existence of each questionnaire's initialization XCTAssertTrue(scheduler.tasks.contains(where: { $0.title == "PHQ-4: Patient Psychological Health Questionnaire" })) XCTAssertTrue(scheduler.tasks.contains(where: { $0.title == "EQ-5D-5L: Patient Physical Health Questionnaire" })) XCTAssertTrue(scheduler.tasks.contains(where: { $0.title == "Self-MNA: Mini Nutritional Assessment" })) diff --git a/PICSUITests/SchedulerTests.swift b/PICSUITests/SchedulerTests.swift new file mode 100644 index 0000000..075a230 --- /dev/null +++ b/PICSUITests/SchedulerTests.swift @@ -0,0 +1,79 @@ +// +// This source file is part of the PICS to test the assessments task tab. +// +// SPDX-FileCopyrightText: 2024 Stanford University +// +// SPDX-License-Identifier: MIT +// + +import XCTest + +class ScheduleViewTests: XCTestCase { + override func setUpWithError() throws { + try super.setUpWithError() + continueAfterFailure = false + + let app = XCUIApplication() + + app.launchArguments = ["--skipOnboarding", "--mockTestData", "--disableFirebase", "--testSchedule"] + app.launch() + } + + // Navigate to ScheduleView + func navigateToScheduleView() -> XCUIElement { + let app = XCUIApplication() + // Assuming there is a button or tab to navigate to the ScheduleView + XCTAssertTrue(app.buttons["Questionnaires"].waitForExistence(timeout: 2), "The Questionnaire tab/button should exist.") + app.buttons["Questionnaires"].tap() + + return app + } + + func testScheduleListLoading() { + let app = navigateToScheduleView() + // Check for the existence of schedule list items + let listItem = app.cells.firstMatch + let listExists = listItem.waitForExistence(timeout: 5) + XCTAssertTrue(listExists, "Schedule list items should load and be visible.") + } + + func testEventContextInteraction() { + let app = navigateToScheduleView() + // Assuming events are listed and identifiable by a unique identifier + let eventContextButton = app.buttons["Questionnaires"].firstMatch + XCTAssertTrue(eventContextButton.waitForExistence(timeout: 2), "Event context button should exist.") + + eventContextButton.tap() + } + + func testAccountButtonVisibility() { + let app = navigateToScheduleView() + // Assuming the conditions have been set for AccountButton to be visible + let accountButton = app.buttons["Questionnaires"] + let exists = accountButton.waitForExistence(timeout: 2) + + XCTAssertTrue(exists, "Account button should be visible under specific conditions.") + } + + func testQuestionnaireViewPresentation() { + let app = navigateToScheduleView() + // Simulating tapping an event that leads to a questionnaire + let eventButton = app.buttons["Start Questionnaire"] + XCTAssertTrue(eventButton.waitForExistence(timeout: 2), "Event button leading to questionnaire should exist.") + eventButton.tap() + } + + func testModalViewPresentation() { + let app = navigateToScheduleView() + // Simulate tapping an event that leads to a modal view + let eventButton = app.buttons["Start Questionnaire"] + XCTAssertTrue(eventButton.waitForExistence(timeout: 2), "Event button leading to modal should exist.") + eventButton.tap() + + // Verify that the ModalView is presented + let titleText = app.staticTexts["Onboarding Survey"] + XCTAssertTrue(titleText.waitForExistence(timeout: 2), "ModalView should be presented upon tapping the event.") + let modalViewText = app.staticTexts["Get Started"] // Identifiable element within ModalView + XCTAssertTrue(modalViewText.waitForExistence(timeout: 2), "ModalView should be presented upon tapping the event.") + } +}