[Technical Questions] Adding HL7 FHIR json to questionnaire #47
-
In what area do you have a technical challenge?Swift DescriptionI'm working on the CS342-Behavior project and my task is to modify an existing questionnaire. I have successfully modified the existing questionnaire content and downloaded the JSON for the questionnaire using HL7 FHIR. I'm reading through existing code right now and am having trouble figuring out where the JSON is populated into the questionnaire. I see that the current questionnaire is using the JSON in Behavior/Resources/SocialSupportQuestionnaire. I'm going through the ScheduleView code (which is where the questionnaire seems to be made viewable) but I'm not sure where the JSON is used. ReproductionI'm having trouble reading through the code and may have misunderstood some lines. Here is what I'm currently reading through: https://github.com/CS342/2024-Behavior/blob/365126e5eeb929646919dfb696aaa8369f2ea56d/Behavior/Schedule/ScheduleView.swift Expected behaviorRight now, the questionnaire is loading in the questions and contents of the Social Support Questionnaire. Additional contextNo response Code of Conduct
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
Hi @carolinentran, The questionnaire JSON is being imported in BehaviorScheduler.swift located in Behavior/Schedule. If you look at lines 32-42, you'll see where the Task that represents the Social Support Questionnaire is being created: return Task(
title: String(localized: "TASK_SOCIAL_SUPPORT_QUESTIONNAIRE_TITLE"),
description: String(localized: "TASK_SOCIAL_SUPPORT_QUESTIONNAIRE_DESCRIPTION"),
schedule: Schedule(
start: Calendar.current.startOfDay(for: Date()),
repetition: .matching(dateComponents),
end: .numberOfEvents(365)
),
notifications: true,
context: BehaviorTaskContext.questionnaire(Bundle.main.questionnaire(withName: "SocialSupportQuestionnaire"))
) As you can see, you can customize the title, description, and schedule for the particular task. Every Task in SpeziScheduler also has a customized On line 41, we are attaching a context which contains our questionnaire, drawn from a JSON file in the Resources folder called "SocialSupportQuestionnaire.json". context: BehaviorTaskContext.questionnaire(Bundle.main.questionnaire(withName: "SocialSupportQuestionnaire")) In ScheduleView, when the user taps to start a task, we look at the context and decide what should happen depending on what's attached. If it's a questionnaire, we then launch it using the SpeziQuestionnaire module. If you place your questionnaire file (e.g. "Questionnaire.json") in the |
Beta Was this translation helpful? Give feedback.
-
Hi! I am having some trouble with the task as well. I have replaced the json file, modified the task in TBIScheduler accordingly, and the updated task showing my new questionnaire name is displayed in EventContextView. However, this update is not reflected in ScheduleView, as the scheduled task is still the original questionnaire. I've spent hours and can't seem to update ScheduleView. I am now thinking maybe calculateEventContextsByDate needs to be changed in order to propagate the change in TBIScheduler and EvnentContext over. Any suggestions on how to approach it? |
Beta Was this translation helpful? Give feedback.
Hi @carolinentran,
The questionnaire JSON is being imported in BehaviorScheduler.swift located in Behavior/Schedule.
If you look at lines 32-42, you'll see where the Task that represents the Social Support Questionnaire is being created: