export function veterinaryCostCalculator(form: FormTs) {
form.addRow(row => {
row.addTextPanel('header', {
computedValue: () => 'Veterinary Cost Estimator',
customStyles: { 'font-size': '1.5rem', 'font-weight': '600', 'color': '#1e293b' }
});
});
form.addSpacer({ height: 20 });
// Pet Information Section
const petSection = form.addSubform('pet', { title: '🐾 Pet Information' });
petSection.addRow(row => {
row.addDropdown('petType', {
label: 'Pet Type',
options: [
{ id: 'dog', name: 'Dog' },
{ id: 'cat', name: 'Cat' },
{ id: 'rabbit', name: 'Rabbit' },
{ id: 'bird', name: 'Bird' },
{ id: 'reptile', name: 'Reptile' },
{ id: 'small-mammal', name: 'Small Mammal (hamster, guinea pig)' },
{ id: 'exotic', name: 'Exotic Pet' }
],
defaultValue: 'dog',
isRequired: true
}, '1fr');
row.addDropdown('petSize', {
label: 'Pet Size',
options: [
{ id: 'small', name: 'Small (under 20 lbs)' },
{ id: 'medium', name: 'Medium (20-50 lbs)' },
{ id: 'large', name: 'Large (50-90 lbs)' },
{ id: 'giant', name: 'Giant (90+ lbs)' }
],
defaultValue: 'medium',
isVisible: () => ['dog', 'cat'].includes(petSection.dropdown('petType')?.value() || '')
}, '1fr');
});
petSection.addRow(row => {
row.addDropdown('petAge', {
label: 'Pet Age',
options: [
{ id: 'puppy-kitten', name: 'Puppy/Kitten (under 1 year)' },
{ id: 'young', name: 'Young Adult (1-3 years)' },
{ id: 'adult', name: 'Adult (3-7 years)' },
{ id: 'senior', name: 'Senior (7-10 years)' },
{ id: 'geriatric', name: 'Geriatric (10+ years)' }
],
defaultValue: 'adult'
}, '1fr');
row.addCheckbox('existingConditions', {
label: 'Has Existing Health Conditions',
defaultValue: false,
tooltip: 'Chronic conditions may require additional testing'
}, '1fr');
});
// Visit Type Section
const visitSection = form.addSubform('visit', { title: '🏥 Visit Type' });
visitSection.addRow(row => {
row.addRadioButton('visitType', {
label: 'Type of Visit',
options: [
{ id: 'wellness', name: 'Wellness Exam' },
{ id: 'sick', name: 'Sick Visit' },
{ id: 'emergency', name: 'Emergency' },
{ id: 'surgery', name: 'Surgery' },
{ id: 'dental', name: 'Dental Care' },
{ id: 'specialist', name: 'Specialist Visit' }
],
defaultValue: 'wellness',
isRequired: true
});
});
// Wellness Services Section
const wellnessSection = form.addSubform('wellness', {
title: '💉 Wellness Services',
isVisible: () => visitSection.radioButton('visitType')?.value() === 'wellness'
});
wellnessSection.addRow(row => {
row.addCheckbox('examFee', {
label: 'Physical Examination',
defaultValue: true
}, '1fr');
row.addCheckbox('vaccinations', {
label: 'Vaccinations',
defaultValue: true
}, '1fr');
});
wellnessSection.addRow(row => {
row.addDropdown('vaccinePackage', {
label: 'Vaccination Package',
options: [
{ id: 'core', name: 'Core Vaccines Only' },
{ id: 'recommended', name: 'Core + Recommended' },
{ id: 'full', name: 'Full Protection Package' }
],
defaultValue: 'recommended',
isVisible: () => wellnessSection.checkbox('vaccinations')?.value() === true
}, '1fr');
row.addCheckbox('heartwormTest', {
label: 'Heartworm Test',
defaultValue: true,
isVisible: () => ['dog', 'cat'].includes(petSection.dropdown('petType')?.value() || '')
}, '1fr');
});
wellnessSection.addRow(row => {
row.addCheckbox('fecalExam', {
label: 'Fecal Examination',
defaultValue: false
}, '1fr');
row.addCheckbox('bloodwork', {
label: 'Wellness Blood Panel',
defaultValue: false
}, '1fr');
});
wellnessSection.addRow(row => {
row.addCheckbox('microchip', {
label: 'Microchip Implant',
defaultValue: false
}, '1fr');
row.addCheckbox('preventatives', {
label: 'Flea/Tick/Heartworm Prevention (3 months)',
defaultValue: false
}, '1fr');
});
// Surgery Section
const surgerySection = form.addSubform('surgery', {
title: '🔪 Surgery Type',
isVisible: () => visitSection.radioButton('visitType')?.value() === 'surgery'
});
surgerySection.addRow(row => {
row.addDropdown('surgeryType', {
label: 'Procedure',
options: [
{ id: 'spay', name: 'Spay (Female)' },
{ id: 'neuter', name: 'Neuter (Male)' },
{ id: 'mass-removal', name: 'Mass/Tumor Removal' },
{ id: 'dental-extraction', name: 'Dental Extraction' },
{ id: 'foreign-body', name: 'Foreign Body Removal' },
{ id: 'acl', name: 'ACL/Cruciate Repair' },
{ id: 'fracture', name: 'Fracture Repair' },
{ id: 'bladder-stones', name: 'Bladder Stone Removal' },
{ id: 'other', name: 'Other Surgery' }
],
defaultValue: 'spay',
isRequired: true
});
});
surgerySection.addRow(row => {
row.addCheckbox('preSurgeryBloodwork', {
label: 'Pre-Surgery Blood Panel',
defaultValue: true,
tooltip: 'Recommended for anesthesia safety'
}, '1fr');
row.addCheckbox('ivFluids', {
label: 'IV Fluids During Surgery',
defaultValue: true
}, '1fr');
});
surgerySection.addRow(row => {
row.addCheckbox('painMeds', {
label: 'Pain Medication (take-home)',
defaultValue: true
}, '1fr');
row.addCheckbox('eCollar', {
label: 'E-Collar/Cone',
defaultValue: true
}, '1fr');
});
// Dental Section
const dentalSection = form.addSubform('dental', {
title: '🦷 Dental Services',
isVisible: () => visitSection.radioButton('visitType')?.value() === 'dental'
});
dentalSection.addRow(row => {
row.addDropdown('dentalLevel', {
label: 'Dental Cleaning Level',
options: [
{ id: 'grade1', name: 'Grade 1 (Mild tartar)' },
{ id: 'grade2', name: 'Grade 2 (Moderate tartar)' },
{ id: 'grade3', name: 'Grade 3 (Heavy tartar, possible extractions)' },
{ id: 'grade4', name: 'Grade 4 (Severe, multiple extractions likely)' }
],
defaultValue: 'grade2',
isRequired: true
});
});
dentalSection.addRow(row => {
row.addCheckbox('dentalXrays', {
label: 'Dental X-Rays',
defaultValue: true,
tooltip: 'Shows problems below gumline'
}, '1fr');
row.addInteger('extractionsEstimate', {
label: 'Estimated Extractions',
min: 0,
max: 20,
defaultValue: 0
}, '1fr');
});
// Emergency Section
const emergencySection = form.addSubform('emergency', {
title: '🚨 Emergency Care',
isVisible: () => visitSection.radioButton('visitType')?.value() === 'emergency'
});
emergencySection.addRow(row => {
row.addDropdown('emergencyType', {
label: 'Emergency Type',
options: [
{ id: 'trauma', name: 'Trauma/Injury' },
{ id: 'toxin', name: 'Toxin Ingestion' },
{ id: 'gi', name: 'GI Emergency (vomiting, bloat)' },
{ id: 'respiratory', name: 'Respiratory Distress' },
{ id: 'seizure', name: 'Seizures' },
{ id: 'urinary', name: 'Urinary Blockage' },
{ id: 'other', name: 'Other Emergency' }
],
defaultValue: 'trauma',
isRequired: true
});
});
emergencySection.addRow(row => {
row.addDropdown('emergencySeverity', {
label: 'Severity Level',
options: [
{ id: 'minor', name: 'Minor (stable, non-critical)' },
{ id: 'moderate', name: 'Moderate (needs treatment)' },
{ id: 'serious', name: 'Serious (hospitalization likely)' },
{ id: 'critical', name: 'Critical (ICU/surgery needed)' }
],
defaultValue: 'moderate'
}, '1fr');
row.addCheckbox('afterHours', {
label: 'After-Hours/Weekend',
defaultValue: false,
tooltip: 'Emergency fees are typically higher'
}, '1fr');
});
// Sick Visit Section
const sickSection = form.addSubform('sick', {
title: '🤒 Sick Visit Services',
isVisible: () => visitSection.radioButton('visitType')?.value() === 'sick'
});
sickSection.addRow(row => {
row.addCheckbox('diagnosticExam', {
label: 'Diagnostic Examination',
defaultValue: true
}, '1fr');
row.addCheckbox('sickBloodwork', {
label: 'Diagnostic Blood Panel',
defaultValue: false
}, '1fr');
});
sickSection.addRow(row => {
row.addCheckbox('xrays', {
label: 'X-Rays',
defaultValue: false
}, '1fr');
row.addCheckbox('ultrasound', {
label: 'Ultrasound',
defaultValue: false
}, '1fr');
});
sickSection.addRow(row => {
row.addCheckbox('medications', {
label: 'Medications',
defaultValue: true
}, '1fr');
row.addCheckbox('fluids', {
label: 'Subcutaneous Fluids',
defaultValue: false
}, '1fr');
});
form.addSpacer({ height: 20, showLine: true, lineStyle: 'dashed' });
// Results Section
const resultsSection = form.addSubform('results', { title: '📊 Cost Estimate', isCollapsible: false });
const calculatePricing = () => {
const petType = petSection.dropdown('petType')?.value() || 'dog';
const petSize = petSection.dropdown('petSize')?.value() || 'medium';
const petAge = petSection.dropdown('petAge')?.value() || 'adult';
const visitType = visitSection.radioButton('visitType')?.value() || 'wellness';
const hasConditions = petSection.checkbox('existingConditions')?.value() || false;
// Size multiplier for dogs
const sizeMultipliers = {
'small': 0.8,
'medium': 1.0,
'large': 1.3,
'giant': 1.6
};
const sizeMultiplier = ['dog'].includes(petType) ? sizeMultipliers[petSize] : 1.0;
let lowEstimate = 0;
let highEstimate = 0;
if (visitType === 'wellness') {
// Exam fee
if (wellnessSection.checkbox('examFee')?.value()) {
lowEstimate += 50;
highEstimate += 100;
}
// Vaccinations
if (wellnessSection.checkbox('vaccinations')?.value()) {
const vaccinePackage = wellnessSection.dropdown('vaccinePackage')?.value() || 'recommended';
const vaccineCosts = {
'core': { low: 40, high: 80 },
'recommended': { low: 80, high: 150 },
'full': { low: 150, high: 250 }
};
lowEstimate += vaccineCosts[vaccinePackage].low;
highEstimate += vaccineCosts[vaccinePackage].high;
}
// Other wellness services
if (wellnessSection.checkbox('heartwormTest')?.value()) {
lowEstimate += 35;
highEstimate += 60;
}
if (wellnessSection.checkbox('fecalExam')?.value()) {
lowEstimate += 25;
highEstimate += 50;
}
if (wellnessSection.checkbox('bloodwork')?.value()) {
lowEstimate += 100;
highEstimate += 200;
}
if (wellnessSection.checkbox('microchip')?.value()) {
lowEstimate += 45;
highEstimate += 75;
}
if (wellnessSection.checkbox('preventatives')?.value()) {
lowEstimate += 50 * sizeMultiplier;
highEstimate += 100 * sizeMultiplier;
}
}
if (visitType === 'surgery') {
const surgeryType = surgerySection.dropdown('surgeryType')?.value() || 'spay';
const surgeryCosts = {
'spay': { low: 200, high: 500 },
'neuter': { low: 150, high: 400 },
'mass-removal': { low: 300, high: 1500 },
'dental-extraction': { low: 400, high: 1200 },
'foreign-body': { low: 1500, high: 4000 },
'acl': { low: 2500, high: 5000 },
'fracture': { low: 1500, high: 4000 },
'bladder-stones': { low: 1000, high: 3000 },
'other': { low: 500, high: 2500 }
};
lowEstimate += surgeryCosts[surgeryType].low * sizeMultiplier;
highEstimate += surgeryCosts[surgeryType].high * sizeMultiplier;
if (surgerySection.checkbox('preSurgeryBloodwork')?.value()) {
lowEstimate += 80;
highEstimate += 150;
}
if (surgerySection.checkbox('ivFluids')?.value()) {
lowEstimate += 40;
highEstimate += 80;
}
if (surgerySection.checkbox('painMeds')?.value()) {
lowEstimate += 30;
highEstimate += 75;
}
if (surgerySection.checkbox('eCollar')?.value()) {
lowEstimate += 15;
highEstimate += 30;
}
}
if (visitType === 'dental') {
const dentalLevel = dentalSection.dropdown('dentalLevel')?.value() || 'grade2';
const dentalCosts = {
'grade1': { low: 250, high: 400 },
'grade2': { low: 400, high: 700 },
'grade3': { low: 600, high: 1200 },
'grade4': { low: 1000, high: 2000 }
};
lowEstimate += dentalCosts[dentalLevel].low;
highEstimate += dentalCosts[dentalLevel].high;
if (dentalSection.checkbox('dentalXrays')?.value()) {
lowEstimate += 150;
highEstimate += 300;
}
const extractions = dentalSection.integer('extractionsEstimate')?.value() || 0;
lowEstimate += extractions * 30;
highEstimate += extractions * 80;
}
if (visitType === 'emergency') {
const severity = emergencySection.dropdown('emergencySeverity')?.value() || 'moderate';
const afterHours = emergencySection.checkbox('afterHours')?.value() || false;
const emergencyCosts = {
'minor': { low: 200, high: 500 },
'moderate': { low: 500, high: 1500 },
'serious': { low: 1500, high: 4000 },
'critical': { low: 3000, high: 10000 }
};
lowEstimate += emergencyCosts[severity].low;
highEstimate += emergencyCosts[severity].high;
// Emergency exam fee
lowEstimate += 100;
highEstimate += 200;
if (afterHours) {
lowEstimate *= 1.3;
highEstimate *= 1.5;
}
}
if (visitType === 'sick') {
if (sickSection.checkbox('diagnosticExam')?.value()) {
lowEstimate += 60;
highEstimate += 100;
}
if (sickSection.checkbox('sickBloodwork')?.value()) {
lowEstimate += 100;
highEstimate += 250;
}
if (sickSection.checkbox('xrays')?.value()) {
lowEstimate += 150;
highEstimate += 350;
}
if (sickSection.checkbox('ultrasound')?.value()) {
lowEstimate += 300;
highEstimate += 600;
}
if (sickSection.checkbox('medications')?.value()) {
lowEstimate += 30;
highEstimate += 100;
}
if (sickSection.checkbox('fluids')?.value()) {
lowEstimate += 40;
highEstimate += 80;
}
}
if (visitType === 'specialist') {
lowEstimate += 200;
highEstimate += 500;
// Specialist typically adds 50-100% to costs
lowEstimate *= 1.5;
highEstimate *= 2.0;
}
// Age adjustment for seniors
if (['senior', 'geriatric'].includes(petAge)) {
lowEstimate *= 1.1;
highEstimate *= 1.2;
}
// Exotic pet premium
if (['bird', 'reptile', 'exotic'].includes(petType)) {
lowEstimate *= 1.3;
highEstimate *= 1.5;
}
return {
lowEstimate: Math.round(lowEstimate),
highEstimate: Math.round(highEstimate),
average: Math.round((lowEstimate + highEstimate) / 2)
};
};
resultsSection.addRow(row => {
row.addTextPanel('rangeLabel', {
computedValue: () => 'Estimated Cost Range',
customStyles: { 'font-size': '1rem', 'font-weight': '500', 'text-align': 'center' }
});
});
resultsSection.addRow(row => {
row.addPriceDisplay('lowEstimate', {
label: 'Low Estimate',
computedValue: () => calculatePricing().lowEstimate,
variant: 'default'
}, '1fr');
row.addPriceDisplay('highEstimate', {
label: 'High Estimate',
computedValue: () => calculatePricing().highEstimate,
variant: 'default'
}, '1fr');
});
// Summary Section
const summarySection = form.addSubform('summary', {
title: '💚 Cost Summary',
isCollapsible: false,
sticky: 'bottom'
});
summarySection.addRow(row => {
row.addTextPanel('averageLabel', {
computedValue: () => {
const pricing = calculatePricing();
return `Expected: $${pricing.lowEstimate} - $${pricing.highEstimate}`;
},
customStyles: { 'font-size': '1.5rem', 'font-weight': '600', 'text-align': 'center', 'color': '#059669' }
});
});
summarySection.addRow(row => {
row.addTextPanel('note', {
computedValue: () => 'Prices vary by location and clinic. Call for exact pricing. Consider pet insurance for unexpected costs.',
customStyles: { 'font-size': '0.8rem', 'color': '#64748b', 'text-align': 'center' }
});
});
form.configureSubmitButton({
label: 'Book Appointment'
});
}