import React, { useState } from ‘react’; import { Card, CardContent, CardHeader, CardTitle } from ‘@/components/ui/card’; import { Button } from ‘@/components/ui/button’; import { AlertCircle, Mail, FileText, Check } from ‘lucide-react’; import { Alert, AlertDescription } from ‘@/components/ui/alert’; // Previous PHQ9 and GAD7 configurations remain the same const questionnaires = { phq9: {/* … previous PHQ-9 config … */}, gad7: {/* … previous GAD-7 config … */}, vanderbilt: { title: ‘Vanderbilt ADHD Diagnostic Rating Scale’, intro: ‘Please rate each behavior described below.’, sections: [ { title: ‘Inattention’, questions: [ “Fails to give attention to details or makes careless mistakes in schoolwork”, “Has difficulty sustaining attention to tasks or activities”, “Does not seem to listen when spoken to directly”, “Does not follow through on instructions and fails to finish schoolwork”, “Has difficulty organizing tasks and activities”, “Avoids, dislikes, or is reluctant to engage in tasks that require sustained mental effort”, “Loses things necessary for tasks or activities”, “Is easily distracted by extraneous stimuli”, “Is forgetful in daily activities” ], type: ‘symptoms’ }, { title: ‘Hyperactivity/Impulsivity’, questions: [ “Fidgets with hands or feet or squirms in seat”, “Leaves seat in classroom or in other situations when remaining seated is expected”, “Runs about or climbs excessively in situations when remaining seated is expected”, “Has difficulty playing or engaging in leisure activities quietly”, “Is ‘on the go’ or often acts as if ‘driven by a motor'”, “Talks excessively”, “Blurts out answers before questions have been completed”, “Has difficulty waiting in line”, “Interrupts or intrudes on others” ], type: ‘symptoms’ }, { title: ‘Oppositional Defiant Disorder’, questions: [ “Loses temper”, “Actively defies or refuses to comply with adults’ requests or rules”, “Is angry or resentful”, “Is spiteful and vindictive”, “Argues with adults”, “Deliberately annoys people”, “Blames others for his or her mistakes or misbehavior”, “Is touchy or easily annoyed by others” ], type: ‘symptoms’ }, { title: ‘Conduct Disorder’, questions: [ “Bullies, threatens, or intimidates others”, “Initiates physical fights”, “Lies to obtain goods for favors or to avoid obligations (i.e., ‘cons’ others)”, “Is physically cruel to people”, “Has stolen items of nontrivial value”, “Deliberately destroys others’ property”, “Is physically cruel to animals”, “Has deliberately set fires to cause damage”, “Has broken into someone else’s home, business, or car”, “Has stayed out at night without permission”, “Has run away from home overnight”, “Has forced someone into sexual activity”, “Is truant from school (skips school)”, “Uses a weapon that can cause serious harm” ], type: ‘symptoms’ }, { title: ‘Performance’, questions: [ “Reading”, “Mathematics”, “Written expression”, “Relationship with peers”, “Following directions”, “Disrupting class”, “Assignment completion”, “Organizational skills” ], type: ‘performance’ } ], symptomOptions: [ { value: 0, label: ‘Never’ }, { value: 1, label: ‘Occasionally’ }, { value: 2, label: ‘Often’ }, { value: 3, label: ‘Very Often’ } ], performanceOptions: [ { value: 1, label: ‘Excellent’ }, { value: 2, label: ‘Above Average’ }, { value: 3, label: ‘Average’ }, { value: 4, label: ‘Somewhat of a Problem’ }, { value: 5, label: ‘Problematic’ } ], calculateScores: (answers) => { let currentIndex = 0; const scores = { inattention: { symptoms: answers.slice(currentIndex, currentIndex + 9).filter(v => v >= 2).length, score: answers.slice(currentIndex, currentIndex + 9).reduce((sum, v) => sum + (v || 0), 0) }, hyperactivity: { symptoms: answers.slice(currentIndex + 9, currentIndex + 18).filter(v => v >= 2).length, score: answers.slice(currentIndex + 9, currentIndex + 18).reduce((sum, v) => sum + (v || 0), 0) }, odd: { symptoms: answers.slice(currentIndex + 18, currentIndex + 26).filter(v => v >= 2).length, score: answers.slice(currentIndex + 18, currentIndex + 26).reduce((sum, v) => sum + (v || 0), 0) }, conduct: { symptoms: answers.slice(currentIndex + 26, currentIndex + 40).filter(v => v >= 2).length, score: answers.slice(currentIndex + 26, currentIndex + 40).reduce((sum, v) => sum + (v || 0), 0) }, performance: answers.slice(currentIndex + 40) }; return scores; } } }; const VanderbiltQuestion = ({ question, index, sectionType, value, onChange }) => { const options = sectionType === ‘symptoms’ ? questionnaires.vanderbilt.symptomOptions : questionnaires.vanderbilt.performanceOptions; return (

{index + 1}. {question}

{options.map((option) => ( ))}
); }; const VanderbiltResults = ({ scores }) => (
Inattention

Total Score: {scores.inattention.score}

Significant Symptoms: {scores.inattention.symptoms}/9

= 6 ? ‘text-red-600 font-bold’ : ”}> {scores.inattention.symptoms >= 6 ? ‘Clinically Significant’ : ‘Not Clinically Significant’}

Hyperactivity/Impulsivity

Total Score: {scores.hyperactivity.score}

Significant Symptoms: {scores.hyperactivity.symptoms}/9

= 6 ? ‘text-red-600 font-bold’ : ”}> {scores.hyperactivity.symptoms >= 6 ? ‘Clinically Significant’ : ‘Not Clinically Significant’}

Oppositional Defiant Disorder

Total Score: {scores.odd.score}

Significant Symptoms: {scores.odd.symptoms}/8

= 4 ? ‘text-red-600 font-bold’ : ”}> {scores.odd.symptoms >= 4 ? ‘Clinically Significant’ : ‘Not Clinically Significant’}

Conduct Disorder

Total Score: {scores.conduct.score}

Significant Symptoms: {scores.conduct.symptoms}/14

= 3 ? ‘text-red-600 font-bold’ : ”}> {scores.conduct.symptoms >= 3 ? ‘Clinically Significant’ : ‘Not Clinically Significant’}

Performance Evaluation
{questionnaires.vanderbilt.sections[4].questions.map((question, index) => (
= 4 ? ‘bg-red-50’ : ‘bg-gray-50’ }`}>

{question}

= 4 ? ‘text-red-600’ : ”}> {questionnaires.vanderbilt.performanceOptions.find( opt => opt.value === scores.performance[index] )?.label || ‘Not Rated’}

))}
); const PsychGrade = () => { const [selectedTest, setSelectedTest] = useState(null); const [step, setStep] = useState(‘select’); const [answers, setAnswers] = useState({}); // Rest of the component implementation remains the same, but when rendering // Vanderbilt questions, use the VanderbiltQuestion component and when showing // results, use the VanderbiltResults component return (
{/* Previous JSX remains the same until the questions section */} {step === ‘questions’ && selectedTest?.id === ‘vanderbilt’ && (
{questionnaires.vanderbilt.sections.map((section, sectionIndex) => ( {section.title} {section.questions.map((question, questionIndex) => { const globalIndex = sectionIndex * section.questions.length + questionIndex; return ( { setAnswers(prev => ({ …prev, [globalIndex]: value })); }} /> ); })} ))}
)} {step === ‘results’ && selectedTest?.id === ‘vanderbilt’ && ( )} {/* Rest of the JSX remains the same */}
); }; export default PsychGrade;