Без опису

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. //
  2. // ConsentTask.swift
  3. // EncuestaMarle
  4. //
  5. // Created by Tatiana Castro on 5/20/19.
  6. // Copyright © 2019 Marle. All rights reserved.
  7. //
  8. import ResearchKit
  9. let date = Date()
  10. print date
  11. public var ConsentTask: ORKOrderedTask {
  12. let consentDocument = ORKConsentDocument()
  13. consentDocument.title = "MARLE Consent"
  14. consentDocument.signaturePageTitle = "Signature"
  15. consentDocument.signaturePageContent = NSLocalizedString("I agree to participate in this research study.", comment: "")
  16. /*
  17. Add the participant signature, which will be filled in during the
  18. consent review process. This signature initially does not have a
  19. signature image or a participant name; these are collected during
  20. the consent review step.
  21. */
  22. let participantSignatureTitle = "Participant"
  23. let participantSignature = ORKConsentSignature(forPersonWithTitle: participantSignatureTitle, dateFormatString: nil, identifier: "participant_signature")
  24. consentDocument.addSignature(participantSignature)
  25. /*
  26. Add the investigator signature. This is pre-populated with the
  27. investigator's signature image and name, and the date of their
  28. signature. If you need to specify the date as now, you could generate
  29. a date string with code here.
  30. This signature is only used for the generated PDF.
  31. */
  32. let signatureImage = UIImage(named: "signature")!
  33. let investigatorSignatureTitle = NSLocalizedString("Investigator", comment: "")
  34. let investigatorSignatureGivenName = NSLocalizedString("Jonny", comment: "")
  35. let investigatorSignatureFamilyName = NSLocalizedString("Appleseed", comment: "")
  36. let investigatorSignatureDateString = "3/10/15"
  37. let investigatorSignature = ORKConsentSignature(forPersonWithTitle: investigatorSignatureTitle, dateFormatString: nil, identifier: String(describing:Identifier.consentDocumentInvestigatorSignature), givenName: investigatorSignatureGivenName, familyName: investigatorSignatureFamilyName, signatureImage: signatureImage, dateString: investigatorSignatureDateString)
  38. consentDocument.addSignature(investigatorSignature)
  39. /*
  40. This is the HTML content for the "Learn More" page for each consent
  41. section. In a real consent, this would be your content, and you would
  42. have different content for each section.
  43. If your content is just text, you can use the `content` property
  44. instead of the `htmlContent` property of `ORKConsentSection`.
  45. */
  46. let htmlContentString = "<ul><li>Lorem</li><li>ipsum</li><li>dolor</li></ul><p>\(loremIpsumLongText)</p><p>\(loremIpsumMediumText)</p>"
  47. /*
  48. These are all the consent section types that have pre-defined animations
  49. and images. We use them in this specific order, so we see the available
  50. animated transitions.
  51. */
  52. let consentSectionTypes: [ORKConsentSectionType] = [
  53. .overview,
  54. .dataGathering,
  55. .privacy,
  56. .dataUse,
  57. .timeCommitment,
  58. .studySurvey,
  59. .studyTasks,
  60. .withdrawing
  61. ]
  62. /*
  63. For each consent section type in `consentSectionTypes`, create an
  64. `ORKConsentSection` that represents it.
  65. In a real app, you would set specific content for each section.
  66. */
  67. var consentSections: [ORKConsentSection] = consentSectionTypes.map { contentSectionType in
  68. let consentSection = ORKConsentSection(type: contentSectionType)
  69. consentSection.summary = loremIpsumShortText
  70. if contentSectionType == .overview {
  71. consentSection.htmlContent = htmlContentString
  72. }
  73. else {
  74. consentSection.content = loremIpsumLongText
  75. }
  76. return consentSection
  77. }
  78. /*
  79. This is an example of a section that is only in the review document
  80. or only in the generated PDF, and is not displayed in `ORKVisualConsentStep`.
  81. */
  82. let consentSection = ORKConsentSection(type: .onlyInDocument)
  83. consentSection.summary = NSLocalizedString(".OnlyInDocument Scene Summary", comment: "")
  84. consentSection.title = NSLocalizedString(".OnlyInDocument Scene", comment: "")
  85. consentSection.content = loremIpsumLongText
  86. consentSections += [consentSection]
  87. // Set the sections on the document after they've been created.
  88. consentDocument.sections = consentSections
  89. return ORKOrderedTask(identifier: "ConsentTask", steps: steps)
  90. }