diff --git a/README.md b/README.md index 9b41892..84b2cec 100644 --- a/README.md +++ b/README.md @@ -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") + section1.title = "Welcome" + section1.iconImage = UIImage(systemName: "hand.wave") + section1.detailText = "Section 1: Welcome. This study is about..." + steps += [section1] + + // Section 2: Data Collection + let section2 = ORKInstructionStep(identifier: "consentSection2InstructionStep") + section2.title = "Data Collection" + section2.iconImage = UIImage(systemName: "doc.text") + section2.detailText = "Section 2: Data Collection. This study will collect data..." + steps += [section2] + + // Section 3: Privacy + let section3 = ORKInstructionStep(identifier: "consentSection3InstructionStep") + section3.title = "Privacy" + section3.iconImage = UIImage(systemName: "lock.shield") + section3.detailText = "Section 3: Privacy. We value your privacy..." + steps += [section3] + + // Section 4: Data Use + let section4 = ORKInstructionStep(identifier: "consentSection4InstructionStep") + section4.title = "Data Use" + section4.iconImage = UIImage(systemName: "chart.bar") + section4.detailText = "Section 4: Data Use. The collected data will be used for..." + steps += [section4] + + // Section 5: Time Commitment + let section5 = ORKInstructionStep(identifier: "consentSection5InstructionStep") + section5.title = "Time Commitment" + section5.iconImage = UIImage(systemName: "clock") + section5.detailText = "Section 5: Time Commitment. This study will take approximately..." + steps += [section5] + + // Section 6: Study Survey + let section6 = ORKInstructionStep(identifier: "consentSection6InstructionStep") + section6.title = "Study Survey" + section6.iconImage = UIImage(systemName: "list.bullet.rectangle") + section6.detailText = "Section 6: Study Survey. For this study, you will need to complete a survey..." + steps += [section6] + + // Section 7: Study Tasks + let section7 = ORKInstructionStep(identifier: "consentSection7InstructionStep") + section7.title = "Study Tasks" + section7.iconImage = UIImage(systemName: "pencil.and.outline") + section7.detailText = "Section 7: Study Tasks. You will be required to perform these tasks..." + steps += [section7] + + // Section 8: Withdrawal + let section8 = ORKInstructionStep(identifier: "consentSection8InstructionStep") + section8.title = "Withdrawal" + section8.iconImage = UIImage(systemName: "arrow.backward.circle") + section8.detailText = "Section 8: Withdrawal. To withdraw from the study..." + steps += [section8] + + // Review and Sign + let signature = consentDocument.signatures!.first! + let reviewConsentStep = ORKConsentReviewStep(identifier: "ConsentReviewStep", signature: signature, in: consentDocument) + reviewConsentStep.title = "Review" + reviewConsentStep.text = "Review the consent form." + reviewConsentStep.reasonForConsent = "Consent to join the study" + steps += [reviewConsentStep] + + // Passcode/TouchID Protection + let passcodeStep = ORKPasscodeStep(identifier: "Passcode") + passcodeStep.iconImage = UIImage(systemName: "lock.circle") + passcodeStep.text = "You will now create a passcode to identify yourself in the app and protect the entered information." + steps += [passcodeStep] + + // Completion + let completionStep = ORKCompletionStep(identifier: "CompletionStep") + completionStep.iconImage = UIImage(systemName: "checkmark.seal") + completionStep.title = "Welcome aboard" + completionStep.text = "Thank you for joining this study." + steps += [completionStep] + + return ORKOrderedTask(identifier: "ConsentTask", steps: steps) +} +``` + +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. + diff --git a/SAGE_RK_ML/SAGE_RK_ML.xcodeproj/project.xcworkspace/xcuserdata/JD2207.xcuserdatad/UserInterfaceState.xcuserstate b/SAGE_RK_ML/SAGE_RK_ML.xcodeproj/project.xcworkspace/xcuserdata/JD2207.xcuserdatad/UserInterfaceState.xcuserstate index 4eb6127..88ae0f8 100644 Binary files a/SAGE_RK_ML/SAGE_RK_ML.xcodeproj/project.xcworkspace/xcuserdata/JD2207.xcuserdatad/UserInterfaceState.xcuserstate and b/SAGE_RK_ML/SAGE_RK_ML.xcodeproj/project.xcworkspace/xcuserdata/JD2207.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/SAGE_RK_ML/SAGE_RK_ML/Base.lproj/Main.storyboard b/SAGE_RK_ML/SAGE_RK_ML/Base.lproj/Main.storyboard index 5e8135f..7b6e239 100644 --- a/SAGE_RK_ML/SAGE_RK_ML/Base.lproj/Main.storyboard +++ b/SAGE_RK_ML/SAGE_RK_ML/Base.lproj/Main.storyboard @@ -29,6 +29,9 @@ + + +