export function informedConsentForm(form: FormTs) {
// Research Informed Consent Form
// Demonstrates: TextPanel, CheckboxList with required items, Textbox, Datepicker, multi-page, conditional visibility, dynamic styling
// ============================================
// HEADER
// ============================================
form.addRow(row => {
row.addTextPanel('header', {
label: 'Research Study Informed Consent',
computedValue: () => 'Please read this form carefully before deciding to participate.',
customStyles: {
background: 'linear-gradient(135deg, #4338ca 0%, #6366f1 100%)',
color: 'white',
padding: '24px',
borderRadius: '12px',
textAlign: 'center'
}
});
});
// ============================================
// MULTI-PAGE WIZARD
// ============================================
const pages = form.addPages('consentProcess');
// ============================================
// PAGE 1: Study Information
// ============================================
const page1 = pages.addPage('studyInfo');
page1.addRow(row => {
row.addTextPanel('page1Title', {
label: 'Step 1 of 5: Study Overview',
customStyles: {
fontSize: '18px',
fontWeight: 'bold',
color: '#4338ca',
marginBottom: '16px'
}
});
});
const studyOverview = page1.addSubform('studyOverview', {
title: 'About This Study',
customStyles: { backgroundColor: '#f0f9ff', padding: '16px', borderRadius: '8px' }
});
studyOverview.addRow(row => {
row.addTextPanel('studyTitle', {
label: 'Study Title',
computedValue: () => '[Your Study Title Here]',
customStyles: { fontWeight: 'bold', fontSize: '16px' }
});
});
studyOverview.addRow(row => {
row.addTextPanel('studyPurpose', {
label: 'Purpose of the Study',
computedValue: () => 'This study aims to [describe the purpose of your research]. We are investigating [brief description of what you are studying]. Your participation will help us understand [expected outcomes or contributions].\n\nThis research is being conducted by [Principal Investigator Name] at [Institution Name].',
customStyles: { whiteSpace: 'pre-wrap', lineHeight: '1.6' }
});
});
studyOverview.addRow(row => {
row.addTextPanel('eligibility', {
label: 'Who Can Participate',
computedValue: () => 'To participate in this study, you must:\n• Be 18 years of age or older\n• [Add other eligibility criteria]\n• [Add additional criteria as needed]',
customStyles: { whiteSpace: 'pre-wrap', lineHeight: '1.6' }
});
});
page1.addRow(row => {
row.addCheckbox('understandOverview', {
label: 'I have read and understand the study overview',
isRequired: true
});
});
// ============================================
// PAGE 2: Procedures & Time Commitment
// ============================================
const page2 = pages.addPage('procedures');
page2.addRow(row => {
row.addTextPanel('page2Title', {
label: 'Step 2 of 5: What Will Happen',
customStyles: {
fontSize: '18px',
fontWeight: 'bold',
color: '#4338ca',
marginBottom: '16px'
}
});
});
const proceduresSection = page2.addSubform('proceduresSection', {
title: 'Study Procedures',
customStyles: { backgroundColor: '#f0f9ff', padding: '16px', borderRadius: '8px' }
});
proceduresSection.addRow(row => {
row.addTextPanel('procedures', {
label: 'What You Will Be Asked To Do',
computedValue: () => 'If you agree to participate, you will be asked to:\n\n1. [First procedure, e.g., Complete a brief questionnaire about your experiences]\n2. [Second procedure, e.g., Participate in a 30-minute interview]\n3. [Third procedure, e.g., Review materials and provide feedback]\n\nYour participation is expected to take approximately [duration, e.g., 45-60 minutes] in total.',
customStyles: { whiteSpace: 'pre-wrap', lineHeight: '1.6' }
});
});
proceduresSection.addRow(row => {
row.addTextPanel('dataCollection', {
label: 'Data Collection',
computedValue: () => 'During this study, we will collect:\n• [Type of data, e.g., Survey responses]\n• [Type of data, e.g., Audio recordings of interviews]\n• [Type of data, e.g., Written feedback]\n\nAll data will be stored securely and handled according to our confidentiality policies described later.',
customStyles: { whiteSpace: 'pre-wrap', lineHeight: '1.6' }
});
});
page2.addRow(row => {
row.addCheckbox('understandProcedures', {
label: 'I understand what will be asked of me during this study',
isRequired: true
});
});
// ============================================
// PAGE 3: Risks & Benefits
// ============================================
const page3 = pages.addPage('risksBenefits');
page3.addRow(row => {
row.addTextPanel('page3Title', {
label: 'Step 3 of 5: Risks & Benefits',
customStyles: {
fontSize: '18px',
fontWeight: 'bold',
color: '#4338ca',
marginBottom: '16px'
}
});
});
const risksSection = page3.addSubform('risksSection', {
title: 'Potential Risks',
customStyles: { backgroundColor: '#fef3c7', padding: '16px', borderRadius: '8px' }
});
risksSection.addRow(row => {
row.addTextPanel('risks', {
label: 'Known Risks',
computedValue: () => 'The risks of participating in this study are minimal. They may include:\n\n• [Risk 1, e.g., Temporary discomfort when discussing certain topics]\n• [Risk 2, e.g., Time taken away from other activities]\n• [Risk 3, e.g., Possible breach of confidentiality, though we take extensive precautions]\n\nTo minimize risks, we will [describe safeguards, e.g., allow you to skip any questions you prefer not to answer].',
customStyles: { whiteSpace: 'pre-wrap', lineHeight: '1.6' }
});
});
const benefitsSection = page3.addSubform('benefitsSection', {
title: 'Potential Benefits',
customStyles: { backgroundColor: '#d1fae5', padding: '16px', borderRadius: '8px' }
});
benefitsSection.addRow(row => {
row.addTextPanel('benefits', {
label: 'Benefits',
computedValue: () => 'Direct benefits to you may include:\n• [Benefit 1, e.g., Opportunity to reflect on your experiences]\n• [Benefit 2, e.g., Contribution to scientific knowledge]\n\nBroader benefits to society include:\n• [Societal benefit, e.g., Improved understanding of this topic]\n• [Societal benefit, e.g., Information that may help future programs]',
customStyles: { whiteSpace: 'pre-wrap', lineHeight: '1.6' }
});
});
const compensationSection = page3.addSubform('compensationSection', {
title: 'Compensation'
});
compensationSection.addRow(row => {
row.addTextPanel('compensation', {
label: '',
computedValue: () => '[Describe compensation, e.g., You will receive a $25 gift card for completing the full study. If you withdraw early, you will receive prorated compensation based on your participation.]',
customStyles: { lineHeight: '1.6' }
});
});
page3.addRow(row => {
row.addCheckbox('understandRisksBenefits', {
label: 'I understand the potential risks and benefits of participation',
isRequired: true
});
});
// ============================================
// PAGE 4: Confidentiality & Rights
// ============================================
const page4 = pages.addPage('confidentiality');
page4.addRow(row => {
row.addTextPanel('page4Title', {
label: 'Step 4 of 5: Your Privacy & Rights',
customStyles: {
fontSize: '18px',
fontWeight: 'bold',
color: '#4338ca',
marginBottom: '16px'
}
});
});
const confidentialitySection = page4.addSubform('confidentialitySection', {
title: 'Confidentiality',
customStyles: { backgroundColor: '#f0f9ff', padding: '16px', borderRadius: '8px' }
});
confidentialitySection.addRow(row => {
row.addTextPanel('confidentiality', {
label: 'How We Protect Your Information',
computedValue: () => 'Your privacy is important to us. We will protect your information by:\n\n• Assigning you a participant ID number instead of using your name\n• Storing all data on secure, password-protected servers\n• Limiting access to data to authorized research team members only\n• Removing identifying information from any published results\n• Destroying raw data [timeframe, e.g., 5 years after study completion]\n\nNote: Absolute confidentiality cannot be guaranteed due to the limited protections of Internet communication.',
customStyles: { whiteSpace: 'pre-wrap', lineHeight: '1.6' }
});
});
const rightsSection = page4.addSubform('rightsSection', {
title: 'Your Rights as a Participant',
customStyles: { backgroundColor: '#ecfdf5', padding: '16px', borderRadius: '8px' }
});
rightsSection.addRow(row => {
row.addTextPanel('rights', {
label: 'Voluntary Participation',
computedValue: () => 'Your participation is completely voluntary. You have the right to:\n\n• Decline to participate without penalty\n• Withdraw at any time without penalty\n• Skip any questions you do not wish to answer\n• Request that your data be deleted (before data anonymization)\n• Ask questions at any time\n\nWithdrawal will not affect your relationship with [Institution Name] or any services you receive.',
customStyles: { whiteSpace: 'pre-wrap', lineHeight: '1.6' }
});
});
page4.addRow(row => {
row.addCheckbox('understandConfidentiality', {
label: 'I understand how my information will be protected',
isRequired: true
});
});
page4.addRow(row => {
row.addCheckbox('understandRights', {
label: 'I understand my rights as a research participant',
isRequired: true
});
});
// ============================================
// PAGE 5: Consent & Signature
// ============================================
const page5 = pages.addPage('signature');
page5.addRow(row => {
row.addTextPanel('page5Title', {
label: 'Step 5 of 5: Your Consent',
customStyles: {
fontSize: '18px',
fontWeight: 'bold',
color: '#4338ca',
marginBottom: '16px'
}
});
});
const contactSection = page5.addSubform('contactSection', {
title: 'Contact Information',
customStyles: { backgroundColor: '#f0f9ff', padding: '16px', borderRadius: '8px' }
});
contactSection.addRow(row => {
row.addTextPanel('contacts', {
label: 'Questions or Concerns?',
computedValue: () => 'For questions about the study, contact:\n• Principal Investigator: [Name], [Email], [Phone]\n\nFor questions about your rights as a participant, contact:\n• IRB Office: [Institution IRB Name], [Email], [Phone]',
customStyles: { whiteSpace: 'pre-wrap', lineHeight: '1.6' }
});
});
// Final acknowledgments
const finalConsent = page5.addSubform('finalConsent', {
title: 'Statement of Consent',
customStyles: () => {
const allChecked = finalConsent.checkbox('confirmRead')?.value() &&
finalConsent.checkbox('confirmUnderstand')?.value() &&
finalConsent.checkbox('confirmVoluntary')?.value() &&
finalConsent.checkbox('confirmAgree')?.value();
if (allChecked) {
return { backgroundColor: '#d1fae5', padding: '16px', borderRadius: '8px', border: '2px solid #10b981' };
}
return { backgroundColor: '#fafafa', padding: '16px', borderRadius: '8px', border: '1px solid #e5e7eb' };
}
});
finalConsent.addRow(row => {
row.addTextPanel('consentStatement', {
computedValue: () => 'By checking the boxes below and signing, I acknowledge that:',
customStyles: { fontWeight: 'bold', marginBottom: '12px' }
});
});
finalConsent.addRow(row => {
row.addCheckbox('confirmRead', {
label: 'I have read this entire consent form',
isRequired: true
});
});
finalConsent.addRow(row => {
row.addCheckbox('confirmUnderstand', {
label: 'I understand the study procedures, risks, and benefits',
isRequired: true
});
});
finalConsent.addRow(row => {
row.addCheckbox('confirmVoluntary', {
label: 'I understand my participation is voluntary and I can withdraw at any time',
isRequired: true
});
});
finalConsent.addRow(row => {
row.addCheckbox('confirmAgree', {
label: 'I voluntarily agree to participate in this research study',
isRequired: true
});
});
// Signature section
const signatureSection = page5.addSubform('signatureSection', {
title: 'Digital Signature',
isVisible: () => {
return finalConsent.checkbox('confirmRead')?.value() === true &&
finalConsent.checkbox('confirmUnderstand')?.value() === true &&
finalConsent.checkbox('confirmVoluntary')?.value() === true &&
finalConsent.checkbox('confirmAgree')?.value() === true;
},
customStyles: { backgroundColor: '#f0fdf4', padding: '16px', borderRadius: '8px' }
});
signatureSection.addRow(row => {
row.addTextbox('fullName', {
label: 'Full Legal Name (as signature)',
placeholder: 'Type your full name',
isRequired: true
}, '1fr');
row.addDatepicker('signatureDate', {
label: 'Date',
isRequired: true
}, '200px');
});
signatureSection.addRow(row => {
row.addEmail('participantEmail', {
label: 'Your Email (for copy of consent)',
placeholder: 'your@email.com',
isRequired: true
});
});
// Optional: Age verification
signatureSection.addRow(row => {
row.addCheckbox('confirmAge', {
label: 'I confirm that I am 18 years of age or older',
isRequired: true
});
});
// ============================================
// SUMMARY SECTION
// ============================================
const summarySection = page5.addSubform('summarySection', {
title: 'Consent Summary',
isVisible: () => {
const name = signatureSection.textbox('fullName')?.value();
const date = signatureSection.datepicker('signatureDate')?.value();
const age = signatureSection.checkbox('confirmAge')?.value();
return !!(name && name.trim() !== '' && date && age === true);
}
});
summarySection.addRow(row => {
row.addTextPanel('summaryContent', {
computedValue: () => {
const name = signatureSection.textbox('fullName')?.value();
const date = signatureSection.datepicker('signatureDate')?.value();
const email = signatureSection.email('participantEmail')?.value();
let summary = `Research Consent Record\n`;
summary += `${'═'.repeat(30)}\n\n`;
summary += `Participant: ${name}\n`;
summary += `Date: ${date}\n`;
summary += `Email: ${email}\n\n`;
summary += `Acknowledgments:\n`;
summary += `✓ Read consent form\n`;
summary += `✓ Understands procedures, risks, benefits\n`;
summary += `✓ Understands voluntary participation\n`;
summary += `✓ Agrees to participate\n`;
summary += `✓ Confirms 18+ years of age\n\n`;
summary += `Status: CONSENT OBTAINED`;
return summary;
},
customStyles: {
padding: '16px',
borderRadius: '8px',
backgroundColor: '#d1fae5',
borderLeft: '4px solid #10b981',
whiteSpace: 'pre-wrap',
fontFamily: 'monospace',
fontSize: '14px'
}
});
});
// ============================================
// FORM CONFIGURATION
// ============================================
form.configureSubmitButton({
label: 'Submit Consent',
isVisible: () => {
const name = signatureSection.textbox('fullName')?.value();
const date = signatureSection.datepicker('signatureDate')?.value();
const email = signatureSection.email('participantEmail')?.value();
const age = signatureSection.checkbox('confirmAge')?.value();
return !!(name && name.trim() !== '' && date && email && email.trim() !== '' && age === true);
}
});
form.configureCompletionScreen({
type: 'text',
title: 'Consent Recorded',
message: 'Thank you for agreeing to participate in this research study. A copy of this consent form has been sent to your email address for your records. The research team will contact you with next steps.\n\nIf you have any questions, please contact the Principal Investigator using the information provided in the consent form.'
});
}