export function caregiverFeedbackSurvey(form: FormTs) {
// Caregiver Experience Survey - Compassionate wellbeing check-in for family caregivers
// Demonstrates: EmojiRating, Slider, MatrixQuestion, CheckboxList, conditional support resources
// ============================================
// STATE
// ============================================
const stressLevel = form.state<number>(5);
const needsSupport = form.state<boolean>(false);
// ============================================
// HEADER
// ============================================
form.addRow(row => {
row.addTextPanel('header', {
label: 'Caregiver Check-In',
computedValue: () => "Taking care of yourself matters too. Let us know how you're doing.",
customStyles: {
background: 'linear-gradient(135deg, #a8edea 0%, #fed6e3 100%)',
color: '#1e293b',
padding: '28px',
borderRadius: '12px',
textAlign: 'center'
}
});
});
// ============================================
// SECTION 1: Care Situation
// ============================================
const situationSection = form.addSubform('situation', {
title: 'Your Care Situation'
});
situationSection.addRow(row => {
row.addDropdown('relationship', {
label: 'What is your relationship to the person you care for?',
options: [
{ id: 'spouse', name: 'Spouse/Partner' },
{ id: 'parent', name: 'Parent' },
{ id: 'child', name: 'Child' },
{ id: 'sibling', name: 'Sibling' },
{ id: 'grandparent', name: 'Grandparent' },
{ id: 'friend', name: 'Friend' },
{ id: 'other', name: 'Other family/relationship' }
],
placeholder: 'Select relationship...'
}, '1fr');
row.addDropdown('duration', {
label: 'How long have you been caregiving?',
options: [
{ id: 'new', name: 'Less than 1 month' },
{ id: 'months', name: '1-6 months' },
{ id: 'year', name: '6-12 months' },
{ id: 'years', name: '1-3 years' },
{ id: 'long', name: 'More than 3 years' }
],
placeholder: 'Select duration...'
}, '1fr');
});
situationSection.addRow(row => {
row.addCheckboxList('careTypes', {
label: 'What types of care do you provide? (Select all that apply)',
options: [
{ id: 'daily', name: 'Daily living activities (bathing, dressing, meals)' },
{ id: 'medical', name: 'Medical tasks (medications, treatments)' },
{ id: 'transport', name: 'Transportation to appointments' },
{ id: 'emotional', name: 'Emotional support and companionship' },
{ id: 'financial', name: 'Managing finances and bills' },
{ id: 'coordination', name: 'Coordinating care with providers' }
],
orientation: 'vertical'
});
});
// ============================================
// SECTION 2: Current Wellbeing
// ============================================
const wellbeingSection = form.addSubform('wellbeing', {
title: 'How Are You Feeling?'
});
wellbeingSection.addRow(row => {
row.addEmojiRating('mood', {
label: 'How would you describe your overall mood lately?',
preset: 'mood',
size: 'lg',
showLabels: true,
alignment: 'center'
});
});
wellbeingSection.addRow(row => {
row.addSlider('stressLevel', {
label: 'Rate your current stress level',
min: 1,
max: 10,
step: 1,
defaultValue: 5,
showValue: true,
unit: '/ 10',
onValueChange: (val) => {
stressLevel.set(val ?? 5);
needsSupport.set((val ?? 5) >= 7);
}
});
});
wellbeingSection.addRow(row => {
row.addTextPanel('stressLabel', {
computedValue: () => {
const level = stressLevel();
if (level <= 3) return '💚 Manageable - Keep it up!';
if (level <= 6) return '💛 Moderate - Some support might help';
if (level <= 8) return '🧡 High - Please reach out for help';
return '❤️ Very High - You deserve support right now';
},
customStyles: () => {
const level = stressLevel();
const baseStyles = { textAlign: 'center', padding: '8px', borderRadius: '8px', fontWeight: 'bold' };
if (level <= 3) return { ...baseStyles, backgroundColor: '#d1fae5', color: '#065f46' };
if (level <= 6) return { ...baseStyles, backgroundColor: '#fef3c7', color: '#92400e' };
return { ...baseStyles, backgroundColor: '#fee2e2', color: '#991b1b' };
}
});
});
wellbeingSection.addRow(row => {
row.addSlider('energyLevel', {
label: 'Rate your energy level this past week',
min: 1,
max: 10,
step: 1,
defaultValue: 5,
showValue: true,
unit: '/ 10'
});
});
// ============================================
// SECTION 3: Sleep & Self-Care
// ============================================
const selfCareSection = form.addSubform('selfCare', {
title: 'Taking Care of Yourself'
});
selfCareSection.addRow(row => {
row.addRadioButton('sleepQuality', {
label: 'How has your sleep been?',
options: [
{ id: 'great', name: 'Great - Getting enough rest' },
{ id: 'ok', name: 'OK - Some disruptions' },
{ id: 'poor', name: 'Poor - Often interrupted or insufficient' },
{ id: 'very_poor', name: 'Very poor - Barely sleeping' }
],
orientation: 'vertical'
});
});
selfCareSection.addRow(row => {
row.addCheckboxList('selfCareActivities', {
label: 'In the past week, have you been able to:',
options: [
{ id: 'meals', name: 'Eat regular, nutritious meals' },
{ id: 'exercise', name: 'Get some physical activity' },
{ id: 'social', name: 'Connect with friends or family' },
{ id: 'hobbies', name: 'Do something enjoyable for yourself' },
{ id: 'breaks', name: 'Take short breaks from caregiving' },
{ id: 'appointments', name: 'Attend your own health appointments' }
],
orientation: 'vertical'
});
});
// ============================================
// SECTION 4: Support Needs Assessment
// ============================================
const supportSection = form.addSubform('supportNeeds', {
title: 'Support You Need'
});
supportSection.addRow(row => {
row.addMatrixQuestion('supportMatrix', {
label: 'Rate how much you need the following types of support:',
rows: [
{ id: 'respite', label: 'Respite care (time off from caregiving)' },
{ id: 'info', label: 'Information about care needs' },
{ id: 'training', label: 'Training on care tasks' },
{ id: 'emotional', label: 'Emotional support/counseling' },
{ id: 'financial', label: 'Financial assistance' },
{ id: 'community', label: 'Community resources/services' }
],
columns: [
{ id: 'none', label: 'Not needed' },
{ id: 'low', label: 'Slightly' },
{ id: 'moderate', label: 'Moderately' },
{ id: 'high', label: 'Greatly' }
],
striped: true,
fullWidth: true
});
});
// ============================================
// SECTION 5: Healthcare Provider Support
// ============================================
const providerSection = form.addSubform('provider', {
title: 'Support from Healthcare Team'
});
providerSection.addRow(row => {
row.addStarRating('providerCommunication', {
label: "Rate the healthcare team's communication with you as a caregiver",
maxStars: 5,
size: 'lg',
alignment: 'center'
});
});
providerSection.addRow(row => {
row.addCheckboxList('providerNeeds', {
label: 'What would help you work better with the healthcare team?',
options: [
{ id: 'included', name: 'Being included in care discussions' },
{ id: 'explained', name: 'Having things explained clearly' },
{ id: 'written', name: 'Written care instructions' },
{ id: 'contact', name: 'Easy way to contact the care team' },
{ id: 'training', name: 'Training on home care tasks' },
{ id: 'acknowledgment', name: 'Recognition of my role as caregiver' }
],
orientation: 'vertical'
});
});
// ============================================
// SECTION 6: Crisis Support Resources (Conditional)
// ============================================
const crisisSection = form.addSubform('crisis', {
title: 'Support Resources for You',
isVisible: () => needsSupport(),
customStyles: {
backgroundColor: '#fef3c7',
padding: '20px',
borderRadius: '12px',
border: '2px solid #f59e0b'
}
});
crisisSection.addRow(row => {
row.addTextPanel('crisisMessage', {
label: "We're Here for You",
computedValue: () => "Your wellbeing matters. High stress is common among caregivers, and help is available.\n\nConsider reaching out to:\n• Your care coordinator or social worker\n• A caregiver support group\n• A mental health professional\n• The Caregiver Action Network: 1-855-227-3640",
customStyles: {
whiteSpace: 'pre-line',
fontSize: '14px',
lineHeight: '1.6'
}
});
});
crisisSection.addRow(row => {
row.addCheckbox('wantsFollowup', {
label: "I'd like someone to reach out to me about support options"
});
});
crisisSection.addRow(row => {
row.addTextbox('preferredContact', {
label: 'Best way to reach you:',
placeholder: 'Phone or email...',
isVisible: () => crisisSection.checkbox('wantsFollowup')?.value() === true
});
});
// ============================================
// SECTION 7: Open Feedback
// ============================================
const feedbackSection = form.addSubform('feedback', {
title: 'Additional Thoughts'
});
feedbackSection.addRow(row => {
row.addTextarea('challenges', {
label: 'What is your biggest challenge as a caregiver right now?',
placeholder: 'Share whatever is on your mind...',
rows: 3,
autoExpand: true
});
});
feedbackSection.addRow(row => {
row.addTextarea('whatHelps', {
label: 'What helps you cope with caregiving responsibilities?',
placeholder: 'What strategies, people, or resources support you?',
rows: 2,
autoExpand: true
});
});
// ============================================
// SUMMARY SECTION
// ============================================
const summarySection = form.addSubform('summary', {
title: 'Your Check-In Summary'
});
summarySection.addRow(row => {
row.addTextPanel('summaryContent', {
computedValue: () => {
const stress = stressLevel();
const energy = wellbeingSection.slider('energyLevel')?.value() ?? 5;
const mood = wellbeingSection.emojiRating('mood')?.value();
const sleep = selfCareSection.radioButton('sleepQuality')?.value();
const providerRating = providerSection.starRating('providerCommunication')?.value();
const moodLabels: Record<string, string> = {
'sad': 'Struggling',
'down': 'Discouraged',
'neutral': 'Managing',
'happy': 'Positive',
'excited': 'Thriving'
};
let summary = `Caregiver Wellbeing Summary\n${'═'.repeat(30)}\n\n`;
if (mood) {
summary += `Mood: ${moodLabels[mood] || mood}\n`;
}
summary += `Stress Level: ${stress}/10\n`;
summary += `Energy Level: ${energy}/10\n`;
if (sleep) {
const sleepLabels: Record<string, string> = {
'great': 'Good',
'ok': 'Fair',
'poor': 'Poor',
'very_poor': 'Very Poor'
};
summary += `Sleep: ${sleepLabels[sleep]}\n`;
}
if (providerRating) {
summary += `\nProvider Support: ${'★'.repeat(providerRating)}${'☆'.repeat(5 - providerRating)}\n`;
}
// Wellbeing indicator
const wellbeingScore = (10 - stress + energy) / 2;
summary += '\n';
if (wellbeingScore >= 7) {
summary += '💚 Overall Status: Doing well';
} else if (wellbeingScore >= 4) {
summary += '💛 Overall Status: Some support may help';
} else {
summary += '❤️ Overall Status: Please seek support';
}
return summary;
},
customStyles: () => {
const stress = stressLevel();
const energy = wellbeingSection.slider('energyLevel')?.value() ?? 5;
const wellbeingScore = (10 - stress + energy) / 2;
const baseStyles = {
padding: '16px',
borderRadius: '8px',
whiteSpace: 'pre-wrap',
fontFamily: 'monospace',
fontSize: '13px'
};
if (wellbeingScore >= 7) {
return { ...baseStyles, backgroundColor: '#d1fae5', borderLeft: '4px solid #10b981' };
} else if (wellbeingScore >= 4) {
return { ...baseStyles, backgroundColor: '#fef3c7', borderLeft: '4px solid #f59e0b' };
}
return { ...baseStyles, backgroundColor: '#fee2e2', borderLeft: '4px solid #ef4444' };
}
});
});
// ============================================
// FORM CONFIGURATION
// ============================================
form.configureSubmitButton({
label: 'Submit Check-In'
});
form.configureCompletionScreen({
type: 'text',
title: 'Thank You for Sharing',
message: "Your wellbeing matters as much as the person you care for. Remember: you can't pour from an empty cup. We appreciate your dedication and hope you'll reach out for support when you need it."
});
}