Baby Immunization & Checkup Reminder

Baby Immunization

& Checkup Reminder

${item.name} ${item.dose ? `(${item.dose})` : ''}

${item.details ? `

${item.details}

` : ''}
`).join('')}
`; timelineContainer.appendChild(timelineItem); } // Add event listeners to new checkboxes document.querySelectorAll('input[type="checkbox"]').forEach(checkbox => { checkbox.addEventListener('change', handleCheckboxChange); }); }; const handleCheckboxChange = (e) => { const age = e.target.dataset.age; const isChecked = e.target.checked; const itemsToUpdate = generatedSchedule.filter(item => item.ageMonths == age); itemsToUpdate.forEach(item => { localStorage.setItem(`item-${item.dueDate.toISOString()}`, isChecked); }); renderTimeline(); // Re-render to update status colors }; const getAgeLabel = (months) => { if (months == 0) return 'At Birth'; if (months < 12) return `${months} Months`; if (months % 12 === 0) return `${months / 12} Year${months / 12 > 1 ? 's' : ''}`; return `${months} Months`; }; const handlePdfDownload = () => { if (generatedSchedule.length === 0) return; const { jsPDF } = window.jspdf; const doc = new jsPDF(); const babyName = babyNameInput.value || "Your Baby"; const dob = new Date(birthDateInput.value).toLocaleDateString('en-US'); doc.setFont('helvetica', 'bold').setFontSize(20); doc.text(`${babyName}'s Immunization Schedule`, 105, 20, { align: 'center' }); doc.setFont('helvetica', 'normal').setFontSize(12); doc.text(`Date of Birth: ${dob}`, 105, 28, { align: 'center' }); const tableData = generatedSchedule.map(item => { const isCompleted = localStorage.getItem(`item-${item.dueDate.toISOString()}`) === 'true'; return [ getAgeLabel(item.ageMonths), item.dueDate.toLocaleDateString('en-US'), item.name, item.dose || 'N/A', isCompleted ? 'Yes' : 'No' ]; }); doc.autoTable({ startY: 40, head: [['Age', 'Due Date', 'Vaccine / Checkup', 'Dose', 'Completed']], body: tableData, theme: 'grid', headStyles: { fillColor: '#0ea5e9' } }); doc.save(`${babyName}_Immunization_Schedule.pdf`); }; // --- EVENT LISTENERS --- generateBtn.addEventListener('click', handleGenerate); downloadPdfBtn.addEventListener('click', handlePdfDownload); });
Scroll to Top