generated from StanfordSpezi/SpeziTemplateApplication
-
-
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.
Integrate M-CHAT R/F questionnaire into an updated Schedule view (#35)
# Integrate M-CHAT R/F questionnaire into an updated Schedule view ## ♻️ Current situation & Problem The current `ScheduleView` implementation is directly taken from the `SpeziTemplateApplication`. In our application, we won't need to schedule repeated Tasks or questionnaires, but instead have a fixed set of questionnaires to be completed for each patient. ## 💡 Proposed solution This PR adds initial support for the M-CHAT R/F questionnaire and restructures the ScheduleView to show a fixed set of tasks depending on the completion status of a given patient. ## ⚙️ Release Notes * A new ScheduleView shows all Task to be completed for a selected patient. * Added initial support for the M-CHAT R/F questionnaire. ## ➕ Additional Information ### Related PRs -- ### Testing New UI Tests were added to cover the added UI components. ### Reviewer Nudging -- ### Code of Conduct & Contributing Guidelines By submitting creating this pull request, you agree to follow our [Code of Conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md): - [x] I agree to follow the [Code of Conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md) and [Contributing Guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md).
- Loading branch information
Showing
41 changed files
with
814 additions
and
674 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
41 changes: 41 additions & 0 deletions
41
NAMS/Patients/Model/PatientListModel+QuestionnaireResponse.swift
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,41 @@ | ||
// | ||
// This source file is part of the Neurodevelopment Assessment and Monitoring System (NAMS) project | ||
// | ||
// SPDX-FileCopyrightText: 2023 Stanford University | ||
// | ||
// SPDX-License-Identifier: MIT | ||
// | ||
|
||
import SpeziFHIR | ||
import SpeziFirestore | ||
|
||
|
||
// SpeziFHIR defines the Observation Model which collides with Apples Observation framework naming | ||
|
||
extension PatientListModel { | ||
func add(response: QuestionnaireResponse) async throws { | ||
guard let questionnaireId = response.questionnaire?.value?.url.absoluteString else { | ||
Self.logger.error("Failed to retrieve questionnaire id for response!") | ||
throw QuestionnaireError.unexpectedFormat | ||
} | ||
|
||
guard let activePatient, | ||
let patientId = activePatient.id else { | ||
Self.logger.error("Couldn't save questionnaire response \(questionnaireId). No patient found!") | ||
throw QuestionnaireError.missingPatient | ||
} | ||
|
||
guard let questionnaire = PatientQuestionnaire.all.first(where: { $0.questionnaire.url?.value?.url.absoluteString == questionnaireId }) else { | ||
Self.logger.error("Failed to match questionnaire response with id \(questionnaireId) to any of our local questionnaires.") | ||
throw QuestionnaireError.failedQuestionnaireMatch | ||
} | ||
|
||
do { | ||
try await completedQuestionnairesCollection(patientId: patientId) | ||
.addDocument(from: CompletedQuestionnaire(internalQuestionnaireId: questionnaire.id, questionnaireResponse: response)) | ||
} catch { | ||
Self.logger.error("Failed to save questionnaire response for questionnaire \(questionnaireId)!") | ||
throw FirestoreError(error) | ||
} | ||
} | ||
} |
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
Oops, something went wrong.