Digestive Enzyme Deficiency Checker

Digestive Enzyme Deficiency Checker

User Details
Symptom Checklist

Please check all symptoms you have been experiencing regularly.

${item.status} (${item.likelihood.toFixed(0)}%)

${item.recommendation}

`; } textResultsContainer.innerHTML = textHTML; // Update Chart const chartCtx = document.getElementById('results-chart').getContext('2d'); if (resultsChartInstance) { resultsChartInstance.destroy(); } resultsChartInstance = new Chart(chartCtx, { type: 'bar', data: { labels: ['Lipase', 'Amylase', 'Protease'], datasets: [{ label: 'Likelihood of Deficiency (%)', data: [analysis.lipase.likelihood, analysis.amylase.likelihood, analysis.protease.likelihood], backgroundColor: [ 'rgba(239, 68, 68, 0.6)', // Red for Lipase 'rgba(234, 179, 8, 0.6)', // Yellow for Amylase 'rgba(59, 130, 246, 0.6)' // Blue for Protease ], borderColor: [ 'rgba(239, 68, 68, 1)', 'rgba(234, 179, 8, 1)', 'rgba(59, 130, 246, 1)' ], borderWidth: 1 }] }, options: { responsive: true, indexAxis: 'y', scales: { x: { beginAtZero: true, max: 100, title: { display: true, text: 'Likelihood (%)' } } }, plugins: { legend: { display: false }, title: { display: true, text: 'Potential Deficiency Likelihood' } } } }); resultsSection.style.display = 'block'; resultsSection.scrollIntoView({ behavior: 'smooth' }); } /** * Generates and downloads a PDF report. */ async function generatePdf() { const { jsPDF } = window.jspdf; const doc = new jsPDF({ orientation: 'p', unit: 'mm', format: 'a4' }); const analysis = analyzeDeficiency(); const userName = document.getElementById('user-name').value || 'N/A'; const checkDate = checkDateInput.value ? new Date(checkDateInput.value).toLocaleDateString() : 'N/A'; const pageHeight = doc.internal.pageSize.height; const pageWidth = doc.internal.pageSize.width; const margin = 15; let y = margin; // Header doc.setFont('helvetica', 'bold'); doc.setFontSize(20); doc.text('Digestive Enzyme Deficiency Report', margin, y); y += 15; // User Info doc.setFont('helvetica', 'bold'); doc.setFontSize(11); doc.text('Name:', margin, y); doc.setFont('helvetica', 'normal'); doc.text(userName, margin + 20, y); doc.setFont('helvetica', 'bold'); doc.text('Date:', pageWidth / 2 + 20, y); doc.setFont('helvetica', 'normal'); doc.text(checkDate, pageWidth / 2 + 35, y); y += 10; doc.setDrawColor(226, 232, 240); doc.line(margin, y, pageWidth - margin, y); y += 10; // Analysis Results doc.setFont('helvetica', 'bold'); doc.setFontSize(14); doc.text('Analysis Summary', margin, y); y += 10; for (const enzyme in analysis) { const item = analysis[enzyme]; if (y > pageHeight - 40) { doc.addPage(); y = margin; } doc.setFont('helvetica', 'bold'); doc.setFontSize(12); doc.text(`${enzyme.charAt(0).toUpperCase() + enzyme.slice(1)} Deficiency`, margin, y); doc.setFont('helvetica', 'normal'); doc.setFontSize(11); doc.text(`Likelihood: ${item.likelihood.toFixed(0)}% - `, margin + 50, y); doc.setFont('helvetica', 'bold'); if (item.status.includes('Low')) doc.setTextColor(34, 197, 94); else if (item.status.includes('Possible')) doc.setTextColor(234, 179, 8); else doc.setTextColor(239, 68, 68); doc.text(item.status, margin + 85, y); doc.setTextColor(0, 0, 0); y += 8; doc.setFont('helvetica', 'italic'); doc.setFontSize(10); const recLines = doc.splitTextToSize(`Recommendation: ${item.recommendation}`, pageWidth - (margin * 2)); doc.text(recLines, margin, y); y += recLines.length * 5 + 5; } // Footer doc.setFontSize(8); doc.setTextColor(148, 163, 184); doc.text(`This checklist is an informational tool and not a substitute for a medical diagnosis.`, margin, pageHeight - 15); doc.text(`Always consult with a qualified healthcare professional for any health concerns.`, margin, pageHeight - 10); doc.save(`Digestive_Health_Report_${userName.replace(/ /g, '_')}.pdf`); } // --- EVENT LISTENERS --- if(analyzeBtn) analyzeBtn.addEventListener('click', displayResults); if(downloadPdfBtn) downloadPdfBtn.addEventListener('click', generatePdf); // --- INITIALIZATION --- checkDateInput.valueAsDate = new Date(); initializeSymptoms(); });
Scroll to Top