@ -52,4 +52,171 @@ With all the files created, should look like the next image:
The files are in charge of managing all the forms that are generated with ResearchKit, the Managers are in charge of saying what and what parts are added to the form, that is, the questions, and the ViewController is in charge of triggering it and displaying it on the cell phone.
In case of Consent it's similar, but it's divide de Manager in two files, the sections and the content.
### Develop Consent
For develop a consent it's necessary knows the content that you need for your participants, but most of them require the same sections.
In ConsentDocument it is required put the sections that content the consent, and you need to add a code like this:
```
import Foundation
import ResearchKit
public var ConsentDocument: ORKConsentDocument {
let consentDocument = ORKConsentDocument()
consentDocument.title = "Conset for questionaires IPAQ and MMSE" // Title
// Type of sections
let sectionTypes: [ORKConsentSectionType] = [
.overview,
.dataGathering,
.privacy,
.dataUse,
.timeCommitment,
.studySurvey,
.studyTasks,
.withdrawing
]
let text = [
"Section 1: Welcome. This study is about...",
"Section 2: Data Gathering. This study will collect data from your Apple Watch...",
"Section 3: Privacy. We value your privacy...",
"Section 4: Data Use. The data collected will be used for...",
"Section 5: Time Commitment. This study will take you roughly...",
"Section 6: Study Survey. For this study, you will need to fill out a survey...",
"Section 7: Study Tasks. You will be requested to do these tasks...",
"Section 8: Withdrawing. To withdraw from the study..."
]
// Create sections and add them to the consent document
var sections: [ORKConsentSection] = []
for (index, sectionType) in sectionTypes.enumerated() {
let section = ORKConsentSection(type: sectionType)
let localizedText = NSLocalizedString(text[index], comment: "")
let localizedSummary = localizedText.components(separatedBy: ".")[0] + "."
section.summary = localizedSummary
section.content = localizedText
sections.append(section)
}
consentDocument.sections = sections
// add sign to consent
let signature = ORKConsentSignature(forPersonWithTitle: "Participante", dateFormatString: nil, identifier: "ConsentDocumentParticipantSignature")
consentDocument.addSignature(signature)
return consentDocument
}
```
This code define sections such as privacy, data collection and use, time commitment, and withdrawal from the study, assigning explanatory texts to each. Additionally, add a field for the participant to sign, ensuring that the consent is complete and ready to be used in the app.
And now the sequence of how it will be shown is putted in the file ConsentTask like the next code:
```
import UIKit
import ResearchKit
public var ConsentTask: ORKOrderedTask {
var steps = [ORKStep]()
// Visualization of sections
let consentDocument = ConsentDocument
// Section 1: Welcome
let section1 = ORKInstructionStep(identifier: "consentSection1InstructionStep")
This code explain each section, the sequence and the contet shown in the application.
Now is necessary program the trigger, it means the button that show the consent.The button of consent is programmed in ConsentViewController, need to open the consent en the interface, for to drag the button to the controller and give it the action function, adding the code where it tells us that when pressing the button, the consent is displayed.
The following GIF shows how the drag would be done and the code will be placed below.