export function elderlyCareCalculator(form: FormTs) {
form.addRow(row => {
row.addTextPanel('header', {
computedValue: () => 'Elderly Care Calculator',
customStyles: { 'font-size': '1.5rem', 'font-weight': '600', 'color': '#1e293b' }
});
});
form.addSpacer({ height: 20 });
// Care Level Section
const careSection = form.addSubform('care', { title: '🏠 Care Level' });
careSection.addRow(row => {
row.addRadioButton('careLevel', {
label: 'Level of Care Needed',
options: [
{ id: 'companion', name: 'Companion Care (social, light duties)' },
{ id: 'personal', name: 'Personal Care (ADL assistance)' },
{ id: 'skilled', name: 'Skilled Nursing Care' },
{ id: 'dementia', name: 'Memory/Dementia Care' },
{ id: 'hospice', name: 'Hospice/Palliative Support' }
],
defaultValue: 'personal',
orientation: 'vertical'
});
});
careSection.addRow(row => {
row.addRadioButton('careType', {
label: 'Care Arrangement',
options: [
{ id: 'hourly', name: 'Hourly Care' },
{ id: 'daily', name: 'Daily Care (8+ hours)' },
{ id: 'live-in', name: 'Live-In Care (24/7)' },
{ id: 'overnight', name: 'Overnight Care Only' }
],
defaultValue: 'hourly',
orientation: 'horizontal'
});
});
// Client Needs Section
const clientSection = form.addSubform('client', { title: '👤 Client Needs' });
clientSection.addRow(row => {
row.addDropdown('mobility', {
label: 'Mobility Level',
options: [
{ id: 'independent', name: 'Fully Independent' },
{ id: 'some-assistance', name: 'Some Assistance Needed' },
{ id: 'significant', name: 'Significant Assistance' },
{ id: 'wheelchair', name: 'Wheelchair Bound' },
{ id: 'bedridden', name: 'Bedridden' }
],
defaultValue: 'some-assistance',
isRequired: true
}, '1fr');
row.addDropdown('cognitive', {
label: 'Cognitive Status',
options: [
{ id: 'clear', name: 'Clear/Alert' },
{ id: 'mild-decline', name: 'Mild Decline' },
{ id: 'moderate-decline', name: 'Moderate Decline' },
{ id: 'dementia', name: 'Dementia/Alzheimer\'s' },
{ id: 'severe', name: 'Severe Cognitive Issues' }
],
defaultValue: 'clear'
}, '1fr');
});
clientSection.addRow(row => {
row.addCheckbox('fallRisk', {
label: 'Fall Risk',
defaultValue: false
}, '1fr');
row.addCheckbox('wandering', {
label: 'Wandering Risk',
defaultValue: false,
isVisible: () => clientSection.dropdown('cognitive')?.value() !== 'clear'
}, '1fr');
});
clientSection.addRow(row => {
row.addCheckbox('twoPersonLift', {
label: 'Two-Person Lift Required',
defaultValue: false,
isVisible: () => clientSection.dropdown('mobility')?.value() === 'wheelchair' || clientSection.dropdown('mobility')?.value() === 'bedridden'
}, '1fr');
row.addCheckbox('hospitalEquipment', {
label: 'Medical Equipment in Home',
defaultValue: false
}, '1fr');
});
// Schedule Section
const scheduleSection = form.addSubform('schedule', { title: '📅 Schedule' });
scheduleSection.addRow(row => {
row.addDropdown('hoursPerDay', {
label: 'Hours per Day',
options: [
{ id: '4', name: '4 hours' },
{ id: '6', name: '6 hours' },
{ id: '8', name: '8 hours' },
{ id: '10', name: '10 hours' },
{ id: '12', name: '12 hours' },
{ id: '24', name: '24 hours (live-in)' }
],
defaultValue: '8',
isRequired: true,
isVisible: () => careSection.radioButton('careType')?.value() !== 'live-in'
}, '1fr');
row.addDropdown('daysPerWeek', {
label: 'Days per Week',
options: [
{ id: '1', name: '1 day' },
{ id: '2', name: '2 days' },
{ id: '3', name: '3 days' },
{ id: '4', name: '4 days' },
{ id: '5', name: '5 days' },
{ id: '6', name: '6 days' },
{ id: '7', name: '7 days' }
],
defaultValue: '5',
isRequired: true
}, '1fr');
});
scheduleSection.addRow(row => {
row.addCheckbox('weekendCare', {
label: 'Weekend Care Needed',
defaultValue: false
}, '1fr');
row.addCheckbox('holidayCare', {
label: 'Holiday Care Needed',
defaultValue: false
}, '1fr');
});
// Caregiver Section
const caregiverSection = form.addSubform('caregiver', { title: '👩⚕️ Caregiver Requirements' });
caregiverSection.addRow(row => {
row.addRadioButton('caregiverLevel', {
label: 'Caregiver Type',
options: [
{ id: 'companion', name: 'Companion/Aide' },
{ id: 'cna', name: 'Certified Nursing Assistant (CNA)' },
{ id: 'hha', name: 'Home Health Aide (HHA)' },
{ id: 'lpn', name: 'Licensed Practical Nurse (LPN)' },
{ id: 'rn', name: 'Registered Nurse (RN)' }
],
defaultValue: 'cna',
orientation: 'vertical'
});
});
caregiverSection.addRow(row => {
row.addDropdown('experience', {
label: 'Experience Level',
options: [
{ id: 'entry', name: 'Entry Level (0-2 years)' },
{ id: 'experienced', name: 'Experienced (2-5 years)' },
{ id: 'senior', name: 'Senior (5-10 years)' },
{ id: 'specialist', name: 'Specialist (10+ years)' }
],
defaultValue: 'experienced'
}, '1fr');
});
caregiverSection.addRow(row => {
row.addCheckbox('dementiaTraining', {
label: 'Dementia Care Training',
defaultValue: false
}, '1fr');
row.addCheckbox('hospiceExperience', {
label: 'Hospice Experience',
defaultValue: false
}, '1fr');
});
caregiverSection.addRow(row => {
row.addCheckbox('bilingual', {
label: 'Bilingual Caregiver',
defaultValue: false
}, '1fr');
row.addCheckbox('sameCaregiver', {
label: 'Same Caregiver Consistency',
defaultValue: true
}, '1fr');
});
// Services Section
const servicesSection = form.addSubform('services', { title: '📋 Services Needed' });
servicesSection.addRow(row => {
row.addCheckbox('bathing', {
label: 'Bathing/Grooming Assistance',
defaultValue: false
}, '1fr');
row.addCheckbox('dressing', {
label: 'Dressing Assistance',
defaultValue: false
}, '1fr');
});
servicesSection.addRow(row => {
row.addCheckbox('toileting', {
label: 'Toileting/Incontinence Care',
defaultValue: false
}, '1fr');
row.addCheckbox('feeding', {
label: 'Feeding Assistance',
defaultValue: false
}, '1fr');
});
servicesSection.addRow(row => {
row.addCheckbox('medication', {
label: 'Medication Reminders',
defaultValue: false
}, '1fr');
row.addCheckbox('medAdmin', {
label: 'Medication Administration',
defaultValue: false,
isVisible: () => caregiverSection.radioButton('caregiverLevel')?.value() === 'lpn' || caregiverSection.radioButton('caregiverLevel')?.value() === 'rn'
}, '1fr');
});
servicesSection.addRow(row => {
row.addCheckbox('mealPrep', {
label: 'Meal Preparation',
defaultValue: false
}, '1fr');
row.addCheckbox('lightHousekeeping', {
label: 'Light Housekeeping',
defaultValue: false
}, '1fr');
});
servicesSection.addRow(row => {
row.addCheckbox('transportation', {
label: 'Transportation to Appointments',
defaultValue: false
}, '1fr');
row.addCheckbox('companionship', {
label: 'Companionship/Activities',
defaultValue: true
}, '1fr');
});
servicesSection.addRow(row => {
row.addCheckbox('woundCare', {
label: 'Wound Care',
defaultValue: false,
isVisible: () => careSection.radioButton('careLevel')?.value() === 'skilled' || caregiverSection.radioButton('caregiverLevel')?.value() === 'lpn' || caregiverSection.radioButton('caregiverLevel')?.value() === 'rn'
}, '1fr');
row.addCheckbox('physicalTherapy', {
label: 'Physical Therapy Exercises',
defaultValue: false
}, '1fr');
});
form.addSpacer({ height: 20, showLine: true, lineStyle: 'dashed' });
// Pricing Section
const pricingSection = form.addSubform('pricing', { title: '💰 Pricing', isCollapsible: false });
const calculatePrice = () => {
const careLevel = careSection.radioButton('careLevel')?.value() || 'personal';
const careType = careSection.radioButton('careType')?.value() || 'hourly';
const mobility = clientSection.dropdown('mobility')?.value() || 'some-assistance';
const cognitive = clientSection.dropdown('cognitive')?.value() || 'clear';
const hoursPerDay = parseInt(scheduleSection.dropdown('hoursPerDay')?.value() || '8');
const daysPerWeek = parseInt(scheduleSection.dropdown('daysPerWeek')?.value() || '5');
const caregiverLevel = caregiverSection.radioButton('caregiverLevel')?.value() || 'cna';
const experience = caregiverSection.dropdown('experience')?.value() || 'experienced';
// Base hourly rate by caregiver type
const baseRates: Record<string, number> = {
'companion': 18,
'cna': 23,
'hha': 25,
'lpn': 32,
'rn': 45
};
let hourlyRate = baseRates[caregiverLevel] || 23;
// Experience adjustment
const experienceMult: Record<string, number> = {
'entry': 0.9,
'experienced': 1.0,
'senior': 1.15,
'specialist': 1.3
};
hourlyRate *= experienceMult[experience] || 1.0;
// Care level adjustment
const careLevelMult: Record<string, number> = {
'companion': 0.9,
'personal': 1.0,
'skilled': 1.2,
'dementia': 1.25,
'hospice': 1.15
};
hourlyRate *= careLevelMult[careLevel] || 1.0;
// Mobility adjustment
const mobilityMult: Record<string, number> = {
'independent': 0.9,
'some-assistance': 1.0,
'significant': 1.1,
'wheelchair': 1.15,
'bedridden': 1.25
};
hourlyRate *= mobilityMult[mobility] || 1.0;
// Cognitive adjustment
const cognitiveMult: Record<string, number> = {
'clear': 1.0,
'mild-decline': 1.05,
'moderate-decline': 1.1,
'dementia': 1.2,
'severe': 1.3
};
hourlyRate *= cognitiveMult[cognitive] || 1.0;
// Special requirements
if (clientSection.checkbox('fallRisk')?.value()) hourlyRate += 2;
if (clientSection.checkbox('wandering')?.value()) hourlyRate += 3;
if (clientSection.checkbox('twoPersonLift')?.value()) hourlyRate *= 1.5; // Need two caregivers
if (clientSection.checkbox('hospitalEquipment')?.value()) hourlyRate += 2;
// Caregiver qualifications
if (caregiverSection.checkbox('dementiaTraining')?.value()) hourlyRate += 2;
if (caregiverSection.checkbox('hospiceExperience')?.value()) hourlyRate += 2;
if (caregiverSection.checkbox('bilingual')?.value()) hourlyRate += 1;
if (caregiverSection.checkbox('sameCaregiver')?.value()) hourlyRate += 1;
// Schedule adjustments
if (scheduleSection.checkbox('weekendCare')?.value()) hourlyRate *= 1.1;
if (scheduleSection.checkbox('holidayCare')?.value()) hourlyRate *= 1.25;
// Services additions (small per-hour additions for complex tasks)
let servicesAddition = 0;
if (servicesSection.checkbox('bathing')?.value()) servicesAddition += 1;
if (servicesSection.checkbox('dressing')?.value()) servicesAddition += 0.5;
if (servicesSection.checkbox('toileting')?.value()) servicesAddition += 1.5;
if (servicesSection.checkbox('feeding')?.value()) servicesAddition += 1;
if (servicesSection.checkbox('medication')?.value()) servicesAddition += 0.5;
if (servicesSection.checkbox('medAdmin')?.value()) servicesAddition += 2;
if (servicesSection.checkbox('mealPrep')?.value()) servicesAddition += 1;
if (servicesSection.checkbox('lightHousekeeping')?.value()) servicesAddition += 0.5;
if (servicesSection.checkbox('transportation')?.value()) servicesAddition += 2;
if (servicesSection.checkbox('woundCare')?.value()) servicesAddition += 3;
if (servicesSection.checkbox('physicalTherapy')?.value()) servicesAddition += 2;
hourlyRate += servicesAddition;
// Live-in care calculation (different pricing model)
let dailyRate = 0;
let weeklyHours = 0;
if (careType === 'live-in') {
dailyRate = hourlyRate * 10; // Live-in typically priced at 10-12 effective hours
weeklyHours = daysPerWeek * 24; // Full days
} else if (careType === 'overnight') {
dailyRate = hourlyRate * 8; // Overnight flat rate
weeklyHours = daysPerWeek * 8;
} else {
weeklyHours = hoursPerDay * daysPerWeek;
}
const weeklyTotal = careType === 'live-in' || careType === 'overnight'
? dailyRate * daysPerWeek
: hourlyRate * weeklyHours;
const monthlyTotal = weeklyTotal * 4.33;
const yearlyTotal = monthlyTotal * 12;
return {
hourlyRate: Math.round(hourlyRate * 100) / 100,
dailyRate: Math.round(dailyRate),
weeklyHours,
weeklyTotal: Math.round(weeklyTotal),
monthlyTotal: Math.round(monthlyTotal),
yearlyTotal: Math.round(yearlyTotal),
isLiveIn: careType === 'live-in',
isOvernight: careType === 'overnight',
daysPerWeek
};
};
pricingSection.addRow(row => {
row.addPriceDisplay('hourlyRate', {
label: 'Hourly Rate',
computedValue: () => calculatePrice().hourlyRate,
variant: 'default',
isVisible: () => !calculatePrice().isLiveIn && !calculatePrice().isOvernight
}, '1fr');
row.addPriceDisplay('dailyRate', {
label: 'Daily Rate',
computedValue: () => calculatePrice().dailyRate,
variant: 'default',
isVisible: () => calculatePrice().isLiveIn || calculatePrice().isOvernight
}, '1fr');
});
pricingSection.addRow(row => {
row.addPriceDisplay('weekly', {
label: 'Weekly',
computedValue: () => calculatePrice().weeklyTotal,
variant: 'default'
}, '1fr');
row.addPriceDisplay('monthly', {
label: 'Monthly',
computedValue: () => calculatePrice().monthlyTotal,
variant: 'default'
}, '1fr');
});
// Summary Section
const summarySection = form.addSubform('summary', {
title: '🧾 Summary',
isCollapsible: false,
sticky: 'bottom'
});
summarySection.addRow(row => {
row.addPriceDisplay('total', {
label: 'Monthly Total',
computedValue: () => calculatePrice().monthlyTotal,
variant: 'large'
}, '1fr');
row.addTextPanel('rateInfo', {
computedValue: () => {
const price = calculatePrice();
if (price.isLiveIn || price.isOvernight) {
return `$${price.dailyRate}/day`;
}
return `$${price.hourlyRate}/hour`;
},
customStyles: { 'font-size': '1rem', 'color': '#64748b', 'text-align': 'center', 'align-self': 'center' }
}, '1fr');
});
summarySection.addRow(row => {
row.addTextPanel('scheduleInfo', {
computedValue: () => {
const price = calculatePrice();
if (price.isLiveIn) {
return `${price.daysPerWeek} days/week of live-in care`;
}
return `${price.weeklyHours} hours/week`;
},
customStyles: { 'font-size': '0.9rem', 'color': '#475569', 'text-align': 'center' }
});
});
summarySection.addRow(row => {
row.addTextPanel('yearlyInfo', {
computedValue: () => `Annual estimate: $${calculatePrice().yearlyTotal.toLocaleString()}`,
customStyles: { 'font-size': '0.9rem', 'color': '#475569', 'text-align': 'center' }
});
});
summarySection.addRow(row => {
row.addTextPanel('note', {
computedValue: () => 'Rates may vary. Does not include agency fees. Consult with your insurance or Medicaid for coverage options.',
customStyles: { 'font-size': '0.85rem', 'color': '#64748b', 'text-align': 'center' }
});
});
form.configureSubmitButton({
label: 'Get Care Quote'
});
}