Depression Severity Scale (PHQ-9)

Depression Severity Scale (PHQ-9)

A tool to help screen for depression severity.

Over the last 2 weeks, how often have you been bothered by any of the following problems?

Important Disclaimer: This tool is for informational screening purposes only and is based on the PHQ-9 questionnaire. It is not a substitute for a professional diagnosis. If you are concerned about your mental health, please consult a qualified healthcare provider.

${index + 1}. ${q}

`; OPTIONS.forEach(opt => { html += `
`; }); html += `
`; }); form.innerHTML = html; }; // --- 3. HELPER FUNCTIONS --- const showError = (message) => { errorMessageDiv.textContent = message; errorMessageDiv.classList.remove('hidden'); resultsSection.classList.add('hidden'); window.scrollTo(0, errorMessageDiv.offsetTop - 20); }; const clearError = () => errorMessageDiv.classList.add('hidden'); // --- 4. CORE CALCULATION LOGIC --- const calculateScore = () => { clearError(); let totalScore = 0; let allAnswered = true; for (let i = 0; i < QUESTIONS.length; i++) { const selectedOption = form.querySelector(`input[name="q${i}"]:checked`); if (selectedOption) { totalScore += parseInt(selectedOption.value); } else { allAnswered = false; break; } } if (!allAnswered) { showError('Please answer all questions before calculating your score.'); return; } renderResults(totalScore); }; // --- 5. RENDER RESULTS --- const renderResults = (score) => { let severity, colorClass, interpretation; if (score >= 20) { severity = 'Severe'; colorClass = 'severity-severe'; interpretation = 'These symptoms are severe and likely causing significant distress or impairment. It is highly recommended to seek professional help immediately.'; } else if (score >= 15) { severity = 'Moderately Severe'; colorClass = 'severity-moderately-severe'; interpretation = 'Your symptoms suggest moderately severe depression. A thorough evaluation with a healthcare professional is strongly advised.'; } else if (score >= 10) { severity = 'Moderate'; colorClass = 'severity-moderate'; interpretation = 'Your symptoms may indicate moderate depression. Consulting with a healthcare provider to discuss treatment options is a good next step.'; } else if (score >= 5) { severity = 'Mild'; colorClass = 'severity-mild'; interpretation = 'Your score suggests mild depression. Monitoring your symptoms and considering lifestyle changes or talking to a professional could be helpful.'; } else { severity = 'Minimal'; colorClass = 'severity-minimal'; interpretation = 'Your score does not suggest significant depressive symptoms. However, if you are concerned, please consult a professional.'; } // Special check for question 9 (suicidal ideation) const lastQuestionValue = parseInt(form.querySelector('input[name="q8"]:checked').value); let suicideWarning = ''; if (lastQuestionValue > 0) { suicideWarning = `

Important Note

You indicated having thoughts of self-harm. Please seek help immediately. You can contact a crisis hotline or emergency services.

`; } resultsOutput.innerHTML = `

${severity} Depression

${score}

Total Score (out of 27)

${interpretation}

${suicideWarning} `; resultsSection.classList.remove('hidden'); window.scrollTo(0, resultsSection.offsetTop - 20); }; // --- 6. PDF GENERATION --- const handlePdfDownload = () => { const { jsPDF } = window.jspdf; const contentToPrint = document.getElementById('printable-content'); const buttonContainer = document.getElementById('pdf-button-container'); if (!contentToPrint) return; buttonContainer.classList.add('hide-for-pdf'); html2canvas(contentToPrint, { scale: 2, useCORS: true }).then(canvas => { buttonContainer.classList.remove('hide-for-pdf'); const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'portrait', unit: 'pt', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = pdf.internal.pageSize.getHeight(); const canvasWidth = canvas.width; const canvasHeight = canvas.height; const ratio = canvasWidth / pdfWidth; const calculatedHeight = canvasHeight / ratio; pdf.addImage(imgData, 'PNG', 0, 0, pdfWidth, calculatedHeight); pdf.save('Depression_Severity_Report.pdf'); }).catch(err => { buttonContainer.classList.remove('hide-for-pdf'); showError('An error occurred while generating the PDF.'); }); }; // --- 7. EVENT LISTENERS --- calculateBtn.addEventListener('click', calculateScore); downloadPdfBtn.addEventListener('click', handlePdfDownload); // --- INITIALIZE --- initQuestions(); });
Scroll to Top