Almost complete

main
parent eff6c63434
commit a598bddf59

@ -36,6 +36,8 @@ Doing that, ResearchKit is ready to use.
The first part for develop a application is the visual part, you need to create a visual interface because the participants need a intuitive screen. This repository is not about the interface part, only about the ResearchKit part, therefore, we will skip the visual part, we can only say that it is necessary to place 3 buttons, one for consent, another for IPAQ and another for MMSE.
In this case needs 3 ViewControllers, each one for activity, it is the most easy form to doing and the code it's more easy too.
The visual interface needs to be easy, intuitive, but the design is part of you.
The main screen should be like the next image:
@ -260,6 +262,692 @@ If you push the button, the consent will be open.
![](images/consentopen.gif)
Its time for IPAQ and MMSE, These questionnaires, as mentioned in the article, will be digitized so that they can be answered on Apple mobile devices. The first thing to do is to know the different questions that the questionnaire contains in order to digitize it in the many functions that ResearchKit has incorporated. In this case, ORKValuePickerAnswerFormat, ORKTextAnswerFormat, ORKTextChoiceAnswerFormat, and ORKScaleAnswerFormat are used.
Its time for IPAQ and MMSE, These questionnaires, as mentioned in the article, will be digitized so that they can be answered on Apple mobile devices. The first thing to do is to know the different questions that the questionnaire contains in order to digitize it in the many functions that ResearchKit has incorporated. In this case, ORKValuePickerAnswerFormat, ORKTextAnswerFormat, ORKNumericAnswerFormat, ORKTextChoiceAnswerFormat, and ORKScaleAnswerFormat are used.
For doing a digital questions it is necessary to check the type of physical question, for example:
IPAQ have 7 Questions and 5 espaces for only read (sentences), so the first part is the title, the title says: "INTERNATIONAL PHYSICAL ACTIVITY QUESTIONNAIRE (IPAQ)", its only a sentence so in xcode need the function ORKInstructionStep as see:
```
// Define the introduction step
let ipaqInfo = ORKInstructionStep(identifier: "IPAQInfo")
ipaqInfo.title = "IPAQ Test"
ipaqInfo.iconImage = UIImage(systemName: "figure.run")
ipaqInfo.detailText = "International Physical Activity Questionnaire\n\nWe will ask you 7 questions related to your physical activity. Please answer as honestly as possible."
```
This function have one identifier, a title, one iconImage and a detailText, so the sentence looks like.
![](images/sentence.png)
you can omit one part, but with all the features it's more complete, and for all the sentences it's the same, for both questionnaires.
Now, for questions, let's see the question one of IPAQ, it said: "1. During the last 7 days, on how many days did you do vigorous physical activities like heavy lifting, digging, aerobics, or fast bicycling?", so the firt step is decide in one window all the questions or one for window, in this case it is one for window, so the main function it is ORKQuestionStep, and now, what type of answer exist various types, like picker, text, text choices, scale, among others, it depends our question, for this case, is picker, so the function should be like:
````
let vigorousDaysChoices = [
ORKTextChoice(text: "None", value: "None" as NSString),
ORKTextChoice(text: "1 day", value: "1 day" as NSString),
ORKTextChoice(text: "2 days", value: "2 days" as NSString),
ORKTextChoice(text: "3 days", value: "3 days" as NSString),
ORKTextChoice(text: "4 days", value: "4 days" as NSString),
ORKTextChoice(text: "5 days", value: "5 days" as NSString),
ORKTextChoice(text: "6 days", value: "6 days" as NSString),
ORKTextChoice(text: "7 days", value: "7 days" as NSString)
]
let vigorousDaysStep = ORKQuestionStep(
identifier: "VigorousDays",
title: "Question 1",
question: "In the last 7 days, how many days did you perform vigorous physical activities such as heavy lifting, digging, aerobics, or fast cycling?",
answer: ORKValuePickerAnswerFormat(textChoices: vigorousDaysChoices)
)
````
the first part is the choices as the participant need to see, second part is the identifier, title, the question and the type of answer, and this type of question its the semae only change the choices.
![](images/questionpicker.png)
Other type of questions is Numeric, Text, scale, but each one have its structure, but follow kind of the same for to declarate.
The next image show different types of questions in MMSE, numeric, scale, image, etc.
![](images/types.png)
For doing a IPAQ, as metioned before we need 7 questions and 5 sentences, so the code, is like:
```
import Foundation
import ResearchKit
class IPAQManager {
static let shared = IPAQManager()
func createIPAQ() -> ORKTask {
// Define the introduction step
let ipaqInfo = ORKInstructionStep(identifier: "IPAQInfo")
ipaqInfo.title = "IPAQ Test"
ipaqInfo.iconImage = UIImage(systemName: "figure.run")
ipaqInfo.detailText = "International Physical Activity Questionnaire\n\nWe will ask you 7 questions related to your physical activity. Please answer as honestly as possible."
// Section 1: Vigorous Activities
let sec1 = ORKInstructionStep(identifier: "Sec1")
sec1.title = "Section 1"
sec1.detailText = "Think about all the VIGOROUS activities you did in the last 7 days. Vigorous physical activities are those that require intense physical effort and make you breathe much harder than usual. Consider only those activities that lasted at least 10 consecutive minutes."
let vigorousDaysChoices = [
ORKTextChoice(text: "None", value: "None" as NSString),
ORKTextChoice(text: "1 day", value: "1 day" as NSString),
ORKTextChoice(text: "2 days", value: "2 days" as NSString),
ORKTextChoice(text: "3 days", value: "3 days" as NSString),
ORKTextChoice(text: "4 days", value: "4 days" as NSString),
ORKTextChoice(text: "5 days", value: "5 days" as NSString),
ORKTextChoice(text: "6 days", value: "6 days" as NSString),
ORKTextChoice(text: "7 days", value: "7 days" as NSString)
]
let vigorousDaysStep = ORKQuestionStep(
identifier: "VigorousDays",
title: "Question 1",
question: "In the last 7 days, how many days did you perform vigorous physical activities such as heavy lifting, digging, aerobics, or fast cycling?",
answer: ORKValuePickerAnswerFormat(textChoices: vigorousDaysChoices)
)
vigorousDaysStep.isOptional = false
let vigorousMinutesStep = ORKQuestionStep(
identifier: "VigorousMinutes",
title: "Question 2",
question: "On those days, how much time (in minutes) did you usually spend performing vigorous physical activities?",
answer: ORKNumericAnswerFormat(style: .integer, unit: "minutes", minimum: 0, maximum: 1440)
)
vigorousMinutesStep.isOptional = false
// Section 2: Moderate Activities
let sec2 = ORKInstructionStep(identifier: "Sec2")
sec2.title = "Section 2"
sec2.detailText = "Think about all the MODERATE activities you did in the last 7 days. Moderate activities require moderate physical effort and make you breathe somewhat harder than usual. Consider only those activities that lasted at least 10 consecutive minutes."
let moderateDaysChoices = [
ORKTextChoice(text: "None", value: "None" as NSString),
ORKTextChoice(text: "1 day", value: "1 day" as NSString),
ORKTextChoice(text: "2 days", value: "2 days" as NSString),
ORKTextChoice(text: "3 days", value: "3 days" as NSString),
ORKTextChoice(text: "4 days", value: "4 days" as NSString),
ORKTextChoice(text: "5 days", value: "5 days" as NSString),
ORKTextChoice(text: "6 days", value: "6 days" as NSString),
ORKTextChoice(text: "7 days", value: "7 days" as NSString)
]
let moderateDaysStep = ORKQuestionStep(
identifier: "ModerateDays",
title: "Question 3",
question: "In the last 7 days, how many days did you perform moderate physical activities such as carrying light loads, cycling at a regular pace, or playing doubles tennis? Do not include walking.",
answer: ORKValuePickerAnswerFormat(textChoices: moderateDaysChoices)
)
moderateDaysStep.isOptional = false
let moderateMinutesStep = ORKQuestionStep(
identifier: "ModerateMinutes",
title: "Question 4",
question: "On those days, how much time (in minutes) did you usually spend performing moderate physical activities?",
answer: ORKNumericAnswerFormat(style: .integer, unit: "minutes", minimum: 0, maximum: 1440)
)
moderateMinutesStep.isOptional = false
// Section 3: Walking
let sec3 = ORKInstructionStep(identifier: "Sec3")
sec3.title = "Section 3"
sec3.detailText = "Think about the time you spent WALKING in the last 7 days. This includes walking at work or home, walking to travel from place to place, or any other walking you might do solely for recreation, sport, exercise, or leisure."
let walkingDaysChoices = [
ORKTextChoice(text: "None", value: "None" as NSString),
ORKTextChoice(text: "1 day", value: "1 day" as NSString),
ORKTextChoice(text: "2 days", value: "2 days" as NSString),
ORKTextChoice(text: "3 days", value: "3 days" as NSString),
ORKTextChoice(text: "4 days", value: "4 days" as NSString),
ORKTextChoice(text: "5 days", value: "5 days" as NSString),
ORKTextChoice(text: "6 days", value: "6 days" as NSString),
ORKTextChoice(text: "7 days", value: "7 days" as NSString)
]
let walkingDaysStep = ORKQuestionStep(
identifier: "WalkingDays",
title: "Question 5",
question: "In the last 7 days, how many days did you walk for at least 10 consecutive minutes?",
answer: ORKValuePickerAnswerFormat(textChoices: walkingDaysChoices)
)
walkingDaysStep.isOptional = false
let walkingMinutesStep = ORKQuestionStep(
identifier: "WalkingMinutes",
title: "Question 6",
question: "On those days, how much time (in minutes) did you usually spend walking?",
answer: ORKNumericAnswerFormat(style: .integer, unit: "minutes", minimum: 0, maximum: 1440)
)
walkingMinutesStep.isOptional = false
// Section 4: Sitting
let sec4 = ORKInstructionStep(identifier: "Sec4")
sec4.title = "Section 4"
sec4.detailText = "The last question is about the time you spent SITTING during the weekdays of the last 7 days. This includes time spent at work, at home, while studying, and during leisure time. It includes time spent sitting at a desk, visiting friends, reading, traveling by car, bus, train, or watching television."
let sittingStep = ORKQuestionStep(
identifier: "SittingTime",
title: "Question 7",
question: "On a typical weekday, how much time (in minutes) did you spend sitting?",
answer: ORKNumericAnswerFormat(style: .integer, unit: "minutes", minimum: 0, maximum: 1440)
)
sittingStep.isOptional = false
// Completion Step
let completionStep = ORKCompletionStep(identifier: "IPAQCompletion")
completionStep.title = "Thank you!"
completionStep.iconImage = UIImage(systemName: "checkmark.seal")
completionStep.text = "You have completed the IPAQ Test. Thank you for your participation!"
// Retorna la tarea combinando los pasos
return ORKOrderedTask(identifier: "SurveyTask", steps: [ipaqInfo,
sec1, vigorousDaysStep, vigorousMinutesStep,
sec2, moderateDaysStep, moderateMinutesStep,
sec3, walkingDaysStep, walkingMinutesStep,
sec4, sittingStep,
completionStep])
}
}
```
The return its the form to show the questions, the order.
And for MMSE, its too large, because count with 33 questions and 8 sentences, and with different styles, so the code is like this:
```
import Foundation
import ResearchKit
import ResearchKitUI
class MMSEManager {
static let shared = MMSEManager()
func createMMSE() -> ORKTask {
// Define questionnaire steps
let mmseInfo = ORKInstructionStep(identifier: "MMSEInfo")
mmseInfo.title = "MMSE Test"
mmseInfo.iconImage = UIImage(systemName: "brain.head.profile")
mmseInfo.detailText = "Mini-Mental State Examination\n\nWe will ask you some questions related to your cognition. Please answer as honestly as possible."
// Section 1
let sec1 = ORKInstructionStep(identifier: "Sec1")
sec1.title = "Orientation in Time and Space"
sec1.detailText = "Without checking anything on your phone or any other device, please answer the following questions."
// Question 1
let MMSE1choices = [
ORKTextChoice(text: "Monday", value: "Monday" as NSString),
ORKTextChoice(text: "Tuesday", value: "Tuesday" as NSString),
ORKTextChoice(text: "Wednesday", value: "Wednesday" as NSString),
ORKTextChoice(text: "Thursday", value: "Thursday" as NSString),
ORKTextChoice(text: "Friday", value: "Friday" as NSString),
ORKTextChoice(text: "Saturday", value: "Saturday" as NSString),
ORKTextChoice(text: "Sunday", value: "Sunday" as NSString),
ORKTextChoice(text: "I dont know", value: "I dont know" as NSString)
]
let MMSE1QuestionStep = ORKQuestionStep(
identifier: "01DayOfWeek",
title: "Question 1",
question: "What day of the week is today?",
answer: ORKValuePickerAnswerFormat(textChoices: MMSE1choices)
)
MMSE1QuestionStep.isOptional = false
// Question 2
let MMSE2choices = (2000...2030).map { year in
ORKTextChoice(text: "\(year)", value: "\(year)" as NSString)
}
let MMSE2QuestionStep = ORKQuestionStep(
identifier: "02Year",
title: "Question 2",
question: "What year is it?",
answer: ORKValuePickerAnswerFormat(textChoices: MMSE2choices)
)
MMSE2QuestionStep.isOptional = false
// Question 3
let MMSE3choices = [
ORKTextChoice(text: "January", value: "January" as NSString),
ORKTextChoice(text: "February", value: "February" as NSString),
ORKTextChoice(text: "March", value: "March" as NSString),
ORKTextChoice(text: "April", value: "April" as NSString),
ORKTextChoice(text: "May", value: "May" as NSString),
ORKTextChoice(text: "June", value: "June" as NSString),
ORKTextChoice(text: "July", value: "July" as NSString),
ORKTextChoice(text: "August", value: "August" as NSString),
ORKTextChoice(text: "September", value: "September" as NSString),
ORKTextChoice(text: "October", value: "October" as NSString),
ORKTextChoice(text: "November", value: "November" as NSString),
ORKTextChoice(text: "December", value: "December" as NSString)
]
let MMSE3QuestionStep = ORKQuestionStep(
identifier: "03Month",
title: "Question 3",
question: "What month is it?",
answer: ORKValuePickerAnswerFormat(textChoices: MMSE3choices)
)
MMSE3QuestionStep.isOptional = false
// Question 4
let MMSE4choices = (1...31).map { day in
ORKTextChoice(text: "\(day)", value: "\(day)" as NSString)
}
let MMSE4QuestionStep = ORKQuestionStep(
identifier: "04DayOfMonth",
title: "Question 4",
question: "What is todays date?",
answer: ORKValuePickerAnswerFormat(textChoices: MMSE4choices)
)
MMSE4QuestionStep.isOptional = false
// Question 5
let MMSE5AnswerFormat = ORKTextAnswerFormat(maximumLength: 50)
MMSE5AnswerFormat.multipleLines = false
let MMSE5QuestionStep = ORKQuestionStep(
identifier: "05Time",
title: "Question 5",
question: "What time is it approximately? (e.g., 3:00 PM, 14:00, 4:30 PM, 19:45)",
answer: MMSE5AnswerFormat
)
MMSE5QuestionStep.isOptional = false
// Question 6
let MMSE6choices = [
ORKTextChoice(text: "Spring", value: "Spring" as NSString),
ORKTextChoice(text: "Summer", value: "Summer" as NSString),
ORKTextChoice(text: "Autumn", value: "Autumn" as NSString),
ORKTextChoice(text: "Winter", value: "Winter" as NSString)
]
let MMSE6QuestionStep = ORKQuestionStep(
identifier: "06Season",
title: "Question 6",
question: "What season are we in?",
answer: ORKValuePickerAnswerFormat(textChoices: MMSE6choices)
)
MMSE6QuestionStep.isOptional = false
// Question 7
let MMSE7AnswerFormat = ORKTextAnswerFormat(maximumLength: 50)
MMSE7AnswerFormat.multipleLines = true
let MMSE7QuestionStep = ORKQuestionStep(
identifier: "07Location",
title: "Question 7",
question: "Where are you right now? (e.g., Home, Work, Park, School)",
answer: MMSE7AnswerFormat
)
MMSE7QuestionStep.isOptional = false
// Question 8
let MMSE8AnswerFormat = ORKTextAnswerFormat(maximumLength: 50)
MMSE8AnswerFormat.multipleLines = true
let MMSE8QuestionStep = ORKQuestionStep(
identifier: "08City",
title: "Question 8",
question: "What city are you in?",
answer: MMSE8AnswerFormat
)
MMSE8QuestionStep.isOptional = false
// Question 9
let MMSE9AnswerFormat = ORKTextAnswerFormat(maximumLength: 50)
MMSE9AnswerFormat.multipleLines = true
let MMSE9QuestionStep = ORKQuestionStep(
identifier: "09State",
title: "Question 9",
question: "What state are you in?",
answer: MMSE9AnswerFormat
)
MMSE9QuestionStep.isOptional = false
// Question 10
let MMSE10QuestionStepTitle = "Question 10"
let MMSE10AnswerFormat = ORKTextAnswerFormat(maximumLength: 50)
MMSE10AnswerFormat.multipleLines = true
let MMSE10QuestionStep = ORKQuestionStep(identifier: "10Country", title: MMSE10QuestionStepTitle, question: "Which country are you in?", answer: MMSE10AnswerFormat)
MMSE10QuestionStep.isOptional = false
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Section 2
let sec2 = ORKInstructionStep(identifier: "Sec2")
sec2.title = "Fixation"
sec2.detailText = "Without reviewing anything on your phone or any other device, answer the following questions"
// Question 11
let words1 = ORKInstructionStep(identifier: "words1")
words1.title = "Reading"
words1.detailText = "Read the following 3 words and click the (Next) button \n\nHORSE\n\nWEIGHT\n\nAPPLE"
// Word 1
let MMSE11QuestionStepTitle1 = "Question 11"
let MMSE11QuestionStepAnswer1 = ORKTextAnswerFormat(maximumLength: 30)
MMSE11QuestionStepAnswer1.multipleLines = false
let MMSE11QuestionStep1 = ORKQuestionStep(identifier: "11word1", title: MMSE11QuestionStepTitle1, question: "What was the first word?", answer: MMSE11QuestionStepAnswer1)
MMSE11QuestionStep1.isOptional = false
// Word 2
let MMSE11QuestionStepTitle2 = "Question 11"
let MMSE11QuestionStepAnswer2 = ORKTextAnswerFormat(maximumLength: 30)
MMSE11QuestionStepAnswer2.multipleLines = false
let MMSE11QuestionStep2 = ORKQuestionStep(identifier: "11word2", title: MMSE11QuestionStepTitle2, question: "What was the second word?", answer: MMSE11QuestionStepAnswer2)
MMSE11QuestionStep2.isOptional = false
// Word 3
let MMSE11QuestionStepTitle3 = "Question 11"
let MMSE11QuestionStepAnswer3 = ORKTextAnswerFormat(maximumLength: 30)
MMSE11QuestionStepAnswer3.multipleLines = false
let MMSE11QuestionStep3 = ORKQuestionStep(identifier: "11word3", title: MMSE11QuestionStepTitle3, question: "What was the third word?", answer: MMSE11QuestionStepAnswer3)
MMSE11QuestionStep3.isOptional = false
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Section 3
let sec3 = ORKInstructionStep(identifier: "Sec3")
sec3.title = "Concentration and Calculation"
sec3.detailText = "Without using a calculator, answer the following questions"
// Question 12
let subtract1 = ORKInstructionStep(identifier: "subtract1")
subtract1.title = "Question 12"
subtract1.detailText = "You have 100 pesos, and you will subtract 7 repeatedly"
// Subtraction 1
let MMSE12QuestionStepTitle1 = "Question 12"
let MMSE12QuestionStepAnswer1 = ORKTextAnswerFormat(maximumLength: 30)
MMSE12QuestionStepAnswer1.multipleLines = false
let MMSE12QuestionStep1 = ORKQuestionStep(identifier: "12subtract1", title: MMSE12QuestionStepTitle1, question: "100-7?", answer: MMSE12QuestionStepAnswer1)
MMSE12QuestionStep1.isOptional = false
// Subtraction 2
let MMSE12QuestionStepTitle2 = "Question 12"
let MMSE12QuestionStepAnswer2 = ORKTextAnswerFormat(maximumLength: 30)
MMSE12QuestionStepAnswer2.multipleLines = false
let MMSE12QuestionStep2 = ORKQuestionStep(identifier: "12subtract2", title: MMSE12QuestionStepTitle2, question: "Your previous result - 7?", answer: MMSE12QuestionStepAnswer2)
MMSE12QuestionStep2.isOptional = false
// Subtraction 3
let MMSE12QuestionStepTitle3 = "Question 12"
let MMSE12QuestionStepAnswer3 = ORKTextAnswerFormat(maximumLength: 30)
MMSE12QuestionStepAnswer3.multipleLines = false
let MMSE12QuestionStep3 = ORKQuestionStep(identifier: "12subtract3", title: MMSE12QuestionStepTitle3, question: "Your previous result - 7?", answer: MMSE12QuestionStepAnswer3)
MMSE12QuestionStep3.isOptional = false
// Subtraction 4
let MMSE12QuestionStepTitle4 = "Question 12"
let MMSE12QuestionStepAnswer4 = ORKTextAnswerFormat(maximumLength: 30)
MMSE12QuestionStepAnswer4.multipleLines = false
let MMSE12QuestionStep4 = ORKQuestionStep(identifier: "12subtract4", title: MMSE12QuestionStepTitle4, question: "Your previous result - 7?", answer: MMSE12QuestionStepAnswer4)
MMSE12QuestionStep4.isOptional = false
// Subtraction 5
let MMSE12QuestionStepTitle5 = "Question 12"
let MMSE12QuestionStepAnswer5 = ORKTextAnswerFormat(maximumLength: 30)
MMSE12QuestionStepAnswer5.multipleLines = false
let MMSE12QuestionStep5 = ORKQuestionStep(identifier: "12subtract5", title: MMSE12QuestionStepTitle5, question: "Your previous result - 7?", answer: MMSE12QuestionStepAnswer5)
MMSE12QuestionStep5.isOptional = false
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Section 4
let sec4 = ORKInstructionStep(identifier: "Sec4")
sec4.title = "Memory"
sec4.detailText = "Remember the 3 words we mentioned earlier, write them below"
// Question 13
// Word 1
let MMSE13QuestionStepTitle1 = "Question 13"
let MMSE13QuestionStepAnswer1 = ORKTextAnswerFormat(maximumLength: 30)
MMSE13QuestionStepAnswer1.multipleLines = false
let MMSE13QuestionStep1 = ORKQuestionStep(identifier: "13word1", title: MMSE13QuestionStepTitle1, question: "What was the first word?", answer: MMSE13QuestionStepAnswer1)
MMSE13QuestionStep1.isOptional = false
// Word 2
let MMSE13QuestionStepTitle2 = "Question 13"
let MMSE13QuestionStepAnswer2 = ORKTextAnswerFormat(maximumLength: 30)
MMSE13QuestionStepAnswer2.multipleLines = false
let MMSE13QuestionStep2 = ORKQuestionStep(identifier: "13word2", title: MMSE13QuestionStepTitle2, question: "What was the second word?", answer: MMSE13QuestionStepAnswer2)
MMSE13QuestionStep2.isOptional = false
// Word 3
let MMSE13QuestionStepTitle3 = "Question 13"
let MMSE13QuestionStepAnswer3 = ORKTextAnswerFormat(maximumLength: 30)
MMSE13QuestionStepAnswer3.multipleLines = false
let MMSE13QuestionStep3 = ORKQuestionStep(identifier: "13word3", title: MMSE13QuestionStepTitle3, question: "What was the third word?", answer: MMSE13QuestionStepAnswer3)
MMSE13QuestionStep3.isOptional = false
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Section 5
let sec5 = ORKInstructionStep(identifier: "Sec5")
sec5.title = "Language and Construction"
sec5.detailText = "Images will be shown, try to tell me what they are"
// Question 14
// Image 1
let MMSE14QuestionStepTitle1 = "Question 14"
// Text answer format
let MMSE14QuestionStepAnswer1 = ORKTextAnswerFormat(maximumLength: 30)
MMSE14QuestionStepAnswer1.multipleLines = false
// Create the question step with image for MMSE14
let MMSE14QuestionStep1 = ORKQuestionStep(
identifier: "14imageQuestion1",
title: MMSE14QuestionStepTitle1,
question: "What do you see in this image?",
answer: MMSE14QuestionStepAnswer1
)
MMSE14QuestionStep1.isOptional = false
// Add image to the step
MMSE14QuestionStep1.image = UIImage(named: "lapiz")
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Image 2
let MMSE14QuestionStepTitle2 = "Question 14"
// Text answer format
let MMSE14QuestionStepAnswer2 = ORKTextAnswerFormat(maximumLength: 30)
MMSE14QuestionStepAnswer2.multipleLines = false
// Create the question step with image for MMSE14
let MMSE14QuestionStep2 = ORKQuestionStep(
identifier: "14imageQuestion2",
title: MMSE14QuestionStepTitle2,
question: "What do you see in this image?",
answer: MMSE14QuestionStepAnswer2
)
MMSE14QuestionStep2.isOptional = false
// Add image to the step
MMSE14QuestionStep2.image = UIImage(named: "reloj")
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Question 15
let MMSE15QuestionStepTitle1 = "Question 15"
let MMSE15QuestionStepAnswer1 = ORKTextAnswerFormat(maximumLength: 30)
MMSE15QuestionStepAnswer1.multipleLines = false
let MMSE15QuestionStep1 = ORKQuestionStep(identifier: "15copy", title: MMSE15QuestionStepTitle1, question: "Repeat the phrase: No ifs, ands, or buts", answer: MMSE15QuestionStepAnswer1)
MMSE15QuestionStep1.isOptional = false
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
// Question 16
let ind16 = ORKInstructionStep(identifier: "ind16")
ind16.title = "Question 16"
ind16.detailText = "I will give you some instructions. Please follow them in the order I tell you: \n\n 1. Select the number 8 \n\n 2. Select all the words that start with P \n\n 3. Write the word 'hair'"
// Instruction 1
let MMSE16QuestionStepTitle1 = "Question 16"
let MMSE16QuestionStepAnswer1 = ORKScaleAnswerFormat(maximumValue: 12, minimumValue: 0, defaultValue: 4, step: 1)
let MMSE16QuestionStep1 = ORKQuestionStep(identifier: "16Instruction1", title: MMSE16QuestionStepTitle1, question: " ", answer: MMSE16QuestionStepAnswer1)
MMSE16QuestionStep1.isOptional = false
// Instruction 2
let MMSE16QuestionStepTitle2 = "Question 16"
let MMSE16QuestionChoices2 = [
ORKTextChoice(text: "Read", value: "Read" as NSString),
ORKTextChoice(text: "Dad", value: "Dad" as NSString),
ORKTextChoice(text: "Play", value: "Play" as NSString),
ORKTextChoice(text: "Bee", value: "Bee" as NSString),
ORKTextChoice(text: "Fight", value: "Fight" as NSString),
ORKTextChoice(text: "Drink", value: "Drink" as NSString),
ORKTextChoice(text: "Paper", value: "Paper" as NSString),
ORKTextChoice(text: "Popcorn", value: "Popcorn" as NSString),
ORKTextChoice(text: "Write", value: "Write" as NSString),
ORKTextChoice(text: "Dance", value: "Dance" as NSString),
ORKTextChoice(text: "Travel", value: "Travel" as NSString),
ORKTextChoice(text: "Comb", value: "Comb" as NSString)
]
let MMSE16QuestionStepAnswer2 = ORKTextChoiceAnswerFormat(style: .multipleChoice, textChoices: MMSE16QuestionChoices2)
MMSE13QuestionStepAnswer2.multipleLines = false
let MMSE16QuestionStep2 = ORKQuestionStep(identifier: "16Indicacion2", title: MMSE16QuestionStepTitle2, question: " ", answer: MMSE16QuestionStepAnswer2)
MMSE13QuestionStep2.isOptional = false
// Instruction 3
let MMSE16QuestionStepTitle3 = "Question 16"
let MMSE16QuestionStepAnswer3 = ORKTextAnswerFormat(maximumLength: 30)
MMSE16QuestionStepAnswer3.multipleLines = false
let MMSE16QuestionStep3 = ORKQuestionStep(identifier: "16Instruction3", title: MMSE16QuestionStepTitle3, question: " ", answer: MMSE16QuestionStepAnswer3)
MMSE16QuestionStep3.isOptional = false
// Question 17
let MMSE17QuestionStepTitle = "Question 17"
// Text answer format
let MMSE17QuestionStepAnswer = ORKTextAnswerFormat(maximumLength: 30)
MMSE17QuestionStepAnswer.multipleLines = false
// Create the image question step for MMSE17
let MMSE17QuestionStep = ORKQuestionStep(
identifier: "17ImageConstruction",
title: MMSE17QuestionStepTitle,
question: "Please do what the image says",
answer: MMSE17QuestionStepAnswer
)
MMSE17QuestionStep.isOptional = false
// Add the image to the step
MMSE17QuestionStep.image = UIImage(named: "name1")
// Question 18
let MMSE18QuestionStep = ORKQuestionStep(identifier: "18Sentence")
MMSE18QuestionStep.title = "Question 18"
MMSE18QuestionStep.question = "Write a sentence as if you were writing a letter."
MMSE18QuestionStep.answerFormat = ORKTextAnswerFormat(maximumLength: 200)
MMSE18QuestionStep.isOptional = false
// Question 19
let MMSE19QuestionStepTitle1 = "Question 19"
// Create the image-only question step
let MMSE19QuestionStep1 = ORKInstructionStep(identifier: "19Drawing1")
MMSE19QuestionStep1.title = MMSE19QuestionStepTitle1
MMSE19QuestionStep1.detailText = "Memorize the image below and click (Next)"
// Add the image to the step
MMSE19QuestionStep1.image = UIImage(named: "dibujo")
let MMSE19QuestionStep2 = ORKSignatureStep(identifier: "19Drawing")
MMSE19QuestionStep2.title = "Draw"
MMSE19QuestionStep2.text = "Draw the image above"
// END
let completionStep = ORKCompletionStep(identifier: "MMSECompletion")
completionStep.title = "Thank you!"
completionStep.iconImage = UIImage(systemName: "checkmark.seal")
completionStep.text = "You have completed the MMSE test. Thank you for your participation!"
// Retorna la tarea combinando los pasos
return ORKOrderedTask(identifier: "MMSESurveyTask", steps: [mmseInfo, sec1, MMSE1QuestionStep, MMSE2QuestionStep, MMSE3QuestionStep, MMSE4QuestionStep, MMSE5QuestionStep, MMSE6QuestionStep, MMSE7QuestionStep, MMSE8QuestionStep, MMSE9QuestionStep, MMSE10QuestionStep, sec2, words1, MMSE11QuestionStep1, MMSE11QuestionStep2, MMSE11QuestionStep3, sec3, subtract1, MMSE12QuestionStep1, MMSE12QuestionStep2, MMSE12QuestionStep3, MMSE12QuestionStep4, MMSE12QuestionStep5, sec4, MMSE13QuestionStep1, MMSE13QuestionStep2, MMSE13QuestionStep3, sec5, MMSE14QuestionStep1, MMSE14QuestionStep2, MMSE15QuestionStep1, ind16, MMSE16QuestionStep1, MMSE16QuestionStep2, MMSE16QuestionStep3, MMSE17QuestionStep, MMSE18QuestionStep,MMSE19QuestionStep1, MMSE19QuestionStep2, completionStep])
}
}
```
And the same form like consent, questionnaires needs to asign a button for trigger a window of formulaire. So the button need to drag to the ViewController, and put the next code:
IPAQ:
```
import UIKit
import ResearchKitUI
import ResearchKit
class IPAQViewController: UIViewController, ORKTaskViewControllerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@IBAction func ipaqButton(_ sender: UIButton) {
let task = IPAQManager.shared.createIPAQ()
let taskViewController = ORKTaskViewController(task: task, taskRun: nil)
taskViewController.modalPresentationStyle = .fullScreen
taskViewController.delegate = self
present(taskViewController, animated: true, completion: nil)
}
func taskViewController(_ taskViewController: ORKTaskViewController, didFinishWith reason: ORKTaskFinishReason, error: (any Error)?) {
taskViewController.dismiss(animated: true, completion: nil)
}
}
```
MMSE:
```
import UIKit
import ResearchKitUI
import ResearchKit
class MMSEViewController: UIViewController, ORKTaskViewControllerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@IBAction func mmseButton(_ sender: UIButton) {
let task = MMSEManager.shared.createMMSE()
let taskViewController = ORKTaskViewController(task: task, taskRun: nil)
taskViewController.modalPresentationStyle = .fullScreen
taskViewController.delegate = self
present(taskViewController, animated: true, completion: nil)
}
func taskViewController(_ taskViewController: ORKTaskViewController, didFinishWith reason: ORKTaskFinishReason, error: (any Error)?) {
taskViewController.dismiss(animated: true, completion: nil)
}
}
```
Now let's see how it show in the next GIF's
![](images/ipaqopen.gif)
![](images/mmseopen.gif)

BIN
SAGE_RK_ML/.DS_Store vendored

Binary file not shown.

@ -7,32 +7,32 @@
objects = {
/* Begin PBXBuildFile section */
8E0E958F2D4A8CE900B17C02 /* ResearchKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8E0E95872D4A8AA900B17C02 /* ResearchKit.framework */; };
8E0E95902D4A8CE900B17C02 /* ResearchKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 8E0E95872D4A8AA900B17C02 /* ResearchKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
8E0E95912D4A8CE900B17C02 /* ResearchKitActiveTask.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8E0E958D2D4A8AA900B17C02 /* ResearchKitActiveTask.framework */; };
8E0E95922D4A8CE900B17C02 /* ResearchKitActiveTask.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 8E0E958D2D4A8AA900B17C02 /* ResearchKitActiveTask.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
8E0E95932D4A8CE900B17C02 /* ResearchKitUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8E0E958B2D4A8AA900B17C02 /* ResearchKitUI.framework */; };
8E0E95942D4A8CE900B17C02 /* ResearchKitUI.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 8E0E958B2D4A8AA900B17C02 /* ResearchKitUI.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
F5EDE54E2D4EC4FE00A3D82C /* ResearchKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F5EDE5472D4EC4F600A3D82C /* ResearchKit.framework */; };
F5EDE54F2D4EC4FE00A3D82C /* ResearchKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = F5EDE5472D4EC4F600A3D82C /* ResearchKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
F5EDE5502D4EC4FE00A3D82C /* ResearchKitActiveTask.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F5EDE54D2D4EC4F600A3D82C /* ResearchKitActiveTask.framework */; };
F5EDE5512D4EC4FE00A3D82C /* ResearchKitActiveTask.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = F5EDE54D2D4EC4F600A3D82C /* ResearchKitActiveTask.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
F5EDE5522D4EC4FE00A3D82C /* ResearchKitUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F5EDE54B2D4EC4F600A3D82C /* ResearchKitUI.framework */; };
F5EDE5532D4EC4FE00A3D82C /* ResearchKitUI.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = F5EDE54B2D4EC4F600A3D82C /* ResearchKitUI.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
8E0E95862D4A8AA900B17C02 /* PBXContainerItemProxy */ = {
F5EDE5462D4EC4F600A3D82C /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 8E0E957C2D4A8AA800B17C02 /* ResearchKit.xcodeproj */;
containerPortal = F5EDE53D2D4EC4F500A3D82C /* ResearchKit.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = B183A5951A8535D100C76870;
remoteInfo = ResearchKit;
};
8E0E958A2D4A8AA900B17C02 /* PBXContainerItemProxy */ = {
F5EDE54A2D4EC4F600A3D82C /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 8E0E957C2D4A8AA800B17C02 /* ResearchKit.xcodeproj */;
containerPortal = F5EDE53D2D4EC4F500A3D82C /* ResearchKit.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = CA1C7A5A288B0C68004DAB3A;
remoteInfo = ResearchKitUI;
remoteInfo = "ResearchKitUI (iOS)";
};
8E0E958C2D4A8AA900B17C02 /* PBXContainerItemProxy */ = {
F5EDE54C2D4EC4F600A3D82C /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 8E0E957C2D4A8AA800B17C02 /* ResearchKit.xcodeproj */;
containerPortal = F5EDE53D2D4EC4F500A3D82C /* ResearchKit.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = CAD08967289DD747007B2A98;
remoteInfo = ResearchKitActiveTask;
@ -46,9 +46,9 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
8E0E95942D4A8CE900B17C02 /* ResearchKitUI.framework in Embed Frameworks */,
8E0E95902D4A8CE900B17C02 /* ResearchKit.framework in Embed Frameworks */,
8E0E95922D4A8CE900B17C02 /* ResearchKitActiveTask.framework in Embed Frameworks */,
F5EDE5532D4EC4FE00A3D82C /* ResearchKitUI.framework in Embed Frameworks */,
F5EDE54F2D4EC4FE00A3D82C /* ResearchKit.framework in Embed Frameworks */,
F5EDE5512D4EC4FE00A3D82C /* ResearchKitActiveTask.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
@ -57,7 +57,7 @@
/* Begin PBXFileReference section */
8E0E95642D4A87B400B17C02 /* SAGE_RK_ML.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SAGE_RK_ML.app; sourceTree = BUILT_PRODUCTS_DIR; };
8E0E957C2D4A8AA800B17C02 /* ResearchKit.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = ResearchKit.xcodeproj; path = "/Users/JD2207/Downloads/ResearchKit-main/ResearchKit.xcodeproj"; sourceTree = "<absolute>"; };
F5EDE53D2D4EC4F500A3D82C /* ResearchKit.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = ResearchKit.xcodeproj; path = "/Users/juandavidlopezregalado/Downloads/ResearchKit-main/ResearchKit.xcodeproj"; sourceTree = "<absolute>"; };
/* End PBXFileReference section */
/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */
@ -86,9 +86,9 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
8E0E95932D4A8CE900B17C02 /* ResearchKitUI.framework in Frameworks */,
8E0E958F2D4A8CE900B17C02 /* ResearchKit.framework in Frameworks */,
8E0E95912D4A8CE900B17C02 /* ResearchKitActiveTask.framework in Frameworks */,
F5EDE5522D4EC4FE00A3D82C /* ResearchKitUI.framework in Frameworks */,
F5EDE54E2D4EC4FE00A3D82C /* ResearchKit.framework in Frameworks */,
F5EDE5502D4EC4FE00A3D82C /* ResearchKitActiveTask.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -98,7 +98,7 @@
8E0E955B2D4A87B400B17C02 = {
isa = PBXGroup;
children = (
8E0E957C2D4A8AA800B17C02 /* ResearchKit.xcodeproj */,
F5EDE53D2D4EC4F500A3D82C /* ResearchKit.xcodeproj */,
8E0E95662D4A87B400B17C02 /* SAGE_RK_ML */,
8E0E958E2D4A8CE900B17C02 /* Frameworks */,
8E0E95652D4A87B400B17C02 /* Products */,
@ -113,21 +113,21 @@
name = Products;
sourceTree = "<group>";
};
8E0E957F2D4A8AA900B17C02 /* Products */ = {
8E0E958E2D4A8CE900B17C02 /* Frameworks */ = {
isa = PBXGroup;
children = (
8E0E95872D4A8AA900B17C02 /* ResearchKit.framework */,
8E0E958B2D4A8AA900B17C02 /* ResearchKitUI.framework */,
8E0E958D2D4A8AA900B17C02 /* ResearchKitActiveTask.framework */,
);
name = Products;
name = Frameworks;
sourceTree = "<group>";
};
8E0E958E2D4A8CE900B17C02 /* Frameworks */ = {
F5EDE5402D4EC4F500A3D82C /* Products */ = {
isa = PBXGroup;
children = (
F5EDE5472D4EC4F600A3D82C /* ResearchKit.framework */,
F5EDE54B2D4EC4F600A3D82C /* ResearchKitUI.framework */,
F5EDE54D2D4EC4F600A3D82C /* ResearchKitActiveTask.framework */,
);
name = Frameworks;
name = Products;
sourceTree = "<group>";
};
/* End PBXGroup section */
@ -185,8 +185,8 @@
projectDirPath = "";
projectReferences = (
{
ProductGroup = 8E0E957F2D4A8AA900B17C02 /* Products */;
ProjectRef = 8E0E957C2D4A8AA800B17C02 /* ResearchKit.xcodeproj */;
ProductGroup = F5EDE5402D4EC4F500A3D82C /* Products */;
ProjectRef = F5EDE53D2D4EC4F500A3D82C /* ResearchKit.xcodeproj */;
},
);
projectRoot = "";
@ -197,25 +197,25 @@
/* End PBXProject section */
/* Begin PBXReferenceProxy section */
8E0E95872D4A8AA900B17C02 /* ResearchKit.framework */ = {
F5EDE5472D4EC4F600A3D82C /* ResearchKit.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = ResearchKit.framework;
remoteRef = 8E0E95862D4A8AA900B17C02 /* PBXContainerItemProxy */;
remoteRef = F5EDE5462D4EC4F600A3D82C /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
8E0E958B2D4A8AA900B17C02 /* ResearchKitUI.framework */ = {
F5EDE54B2D4EC4F600A3D82C /* ResearchKitUI.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = ResearchKitUI.framework;
remoteRef = 8E0E958A2D4A8AA900B17C02 /* PBXContainerItemProxy */;
remoteRef = F5EDE54A2D4EC4F600A3D82C /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
8E0E958D2D4A8AA900B17C02 /* ResearchKitActiveTask.framework */ = {
F5EDE54D2D4EC4F600A3D82C /* ResearchKitActiveTask.framework */ = {
isa = PBXReferenceProxy;
fileType = wrapper.framework;
path = ResearchKitActiveTask.framework;
remoteRef = 8E0E958C2D4A8AA900B17C02 /* PBXContainerItemProxy */;
remoteRef = F5EDE54C2D4EC4F600A3D82C /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>SAGE_RK_ML.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>2</integer>
</dict>
</dict>
</dict>
</plist>

@ -19,7 +19,7 @@ class MMSEViewController: UIViewController, ORKTaskViewControllerDelegate {
@IBAction func mmseButton(_ sender: UIButton) {
let task = MMSEManager.shared.createMMSE() // Cambia el cuestionario a MMSE
let task = MMSEManager.shared.createMMSE()
let taskViewController = ORKTaskViewController(task: task, taskRun: nil)
taskViewController.modalPresentationStyle = .fullScreen
taskViewController.delegate = self

Binary file not shown.

After

Width:  |  Height:  |  Size: 322 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 308 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Loading…
Cancel
Save