Cold vs. Flu Symptom Checker

Cold vs. Flu Symptom Checker

Select the severity of your symptoms to get a possible indication.

${result.description}

Your Symptom Summary

    `; userSelections.forEach(selection => { if (selection.value !== 'None') { html += `
  • ${selection.label}: ${selection.value}
  • `; } }); html += `

Disclaimer: This tool provides a possible indication for informational purposes only. It is not a medical diagnosis. Consult a healthcare professional for accurate diagnosis and treatment.

`; resultsSection.innerHTML = html; resultsSection.classList.remove('hidden'); document.getElementById('pdf-download-btn').addEventListener('click', () => downloadPdf(result, userSelections)); }; /** * Generates and downloads the PDF report. * @param {object} result - The result object. * @param {Array} userSelections - The user's selected symptoms. */ const downloadPdf = async (result, userSelections) => { let pdfHTML = `

Cold vs. Flu Symptom Report

Likely Diagnosis:

${result.title}

${result.description}

Symptom Summary

`; userSelections.forEach((selection, index) => { if (selection.value !== 'None') { const bgColor = index % 2 === 0 ? '#ffffff' : '#f8fafc'; pdfHTML += ` `; } }); pdfHTML += `
${selection.label} ${selection.value}

Disclaimer: This report is for informational purposes only and is not a substitute for professional medical advice, diagnosis, or treatment. Always seek the advice of your physician or other qualified health provider with any questions you may have regarding a medical condition.

`; pdfContentContainer.innerHTML = pdfHTML; pdfContentContainer.classList.remove('hidden'); pdfContentContainer.style.position = 'absolute'; pdfContentContainer.style.left = '-9999px'; try { const { jsPDF } = window.jspdf; const canvas = await html2canvas(pdfContentContainer, { scale: 2, useCORS: true }); const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'portrait', unit: 'mm', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = (canvas.height * pdfWidth) / canvas.width; pdf.addImage(imgData, 'PNG', 0, 0, pdfWidth, pdfHeight); pdf.save('Cold-vs-Flu-Symptom-Report.pdf'); } catch (error) { console.error("Failed to generate PDF:", error); } finally { pdfContentContainer.classList.add('hidden'); pdfContentContainer.style.position = ''; pdfContentContainer.style.left = ''; } }; // --- EVENT LISTENERS --- checkSymptomsBtn.addEventListener('click', analyzeSymptoms); // --- RUN ON LOAD --- populateSymptoms(); });
Scroll to Top