import React, { useState, useEffect } from 'react'; import { Calendar, Plus, Download, ChevronDown, ChevronUp, Heart, Moon, Utensils, Brain, AlertTriangle } from 'lucide-react'; const VyvanseMedicationLog = () => { const [entries, setEntries] = useState([]); const [medicationTakenTime, setMedicationTakenTime] = useState(null); const [nextReminder, setNextReminder] = useState(null); const [currentEntry, setCurrentEntry] = useState({ date: new Date().toISOString().split('T')[0], time: new Date().toTimeString().slice(0, 5), medicationTaken: false, dosage: '10', // Physical measurements heartRate: '', bloodPressure: '', weight: '', // ADHD symptoms (1-10 scale, 10 being excellent) focus: 5, attention: 5, hyperactivity: 5, // 1 = very hyperactive, 10 = calm impulsivity: 5, // 1 = very impulsive, 10 = good control // Side effects (0-4 scale) appetite: 2, // 0 = no appetite, 4 = normal appetite sleepQuality: 2, // 0 = very poor, 4 = excellent mood: 2, // 0 = very irritable/sad, 4 = great mood anxiety: 0, // 0 = none, 4 = severe headache: 0, nausea: 0, dryMouth: 0, jitteriness: 0, // Effectiveness timeline effectiveness: { '2hrs': 0, // 0 = no effect, 4 = very effective '4hrs': 0, '6hrs': 0, '8hrs': 0, '10hrs': 0, '12hrs': 0 }, notes: '' }); const [expandedSections, setExpandedSections] = useState({ physical: true, symptoms: true, sideEffects: true, effectiveness: true }); // Timing and reminder logic useEffect(() => { let interval; if (medicationTakenTime) { interval = setInterval(() => { const now = new Date(); const medTime = new Date(medicationTakenTime); const hoursSince = (now - medTime) / (1000 * 60 * 60); // Determine next reminder const reminderTimes = [2, 4, 6, 8, 10, 12]; const nextReminderTime = reminderTimes.find(time => time > hoursSince); if (nextReminderTime) { const nextReminderDate = new Date(medTime.getTime() + nextReminderTime * 60 * 60 * 1000); setNextReminder({ time: nextReminderTime, date: nextReminderDate, hoursSince: hoursSince }); } else { setNextReminder(null); } }, 30000); // Update every 30 seconds } return () => clearInterval(interval); }, [medicationTakenTime]); const startMedicationTimer = () => { const now = new Date(); setMedicationTakenTime(now.toISOString()); updateEntry('medicationTaken', true); updateEntry('time', now.toTimeString().slice(0, 5)); }; const getTimingStatus = () => { if (!medicationTakenTime) return null; const now = new Date(); const medTime = new Date(medicationTakenTime); const hoursSince = (now - medTime) / (1000 * 60 * 60); if (hoursSince < 2) return { phase: 'waiting', message: 'Medication onset period', color: 'blue' }; if (hoursSince < 4) return { phase: 'peak', message: 'Peak effectiveness period', color: 'green' }; if (hoursSince < 8) return { phase: 'active', message: 'Active medication period', color: 'green' }; if (hoursSince < 12) return { phase: 'waning', message: 'Medication wearing off', color: 'yellow' }; return { phase: 'ended', message: 'Medication effects ended', color: 'red' }; }; const shouldShowEffectivenessRating = (timePoint) => { if (!medicationTakenTime) return false; const now = new Date(); const medTime = new Date(medicationTakenTime); const hoursSince = (now - medTime) / (1000 * 60 * 60); const targetHours = parseInt(timePoint.replace('hrs', '')); return hoursSince >= targetHours - 0.25 && hoursSince <= targetHours + 1; }; const toggleSection = (section) => { setExpandedSections(prev => ({ ...prev, [section]: !prev[section] })); }; const updateEntry = (field, value) => { if (field.includes('.')) { const [parent, child] = field.split('.'); setCurrentEntry(prev => ({ ...prev, [parent]: { ...prev[parent], [child]: value } })); } else { setCurrentEntry(prev => ({ ...prev, [field]: value })); } }; const saveEntry = () => { const newEntry = { ...currentEntry, id: Date.now(), medicationTakenTime: medicationTakenTime }; setEntries(prev => [newEntry, ...prev]); // Reset for next entry setMedicationTakenTime(null); setNextReminder(null); const nextDate = new Date(); nextDate.setDate(nextDate.getDate() + 1); setCurrentEntry({ ...currentEntry, date: nextDate.toISOString().split('T')[0], time: '07:00', // Default morning time medicationTaken: false, heartRate: '', bloodPressure: '', weight: '', effectiveness: { '2hrs': 0, '4hrs': 0, '6hrs': 0, '8hrs': 0, '10hrs': 0, '12hrs': 0 }, notes: '' }); }; const exportData = () => { const data = entries.map(entry => ({ ...entry, effectiveness: Object.entries(entry.effectiveness) .map(([time, rating]) => `${time}: ${rating}`) .join(', ') })); const blob = new Blob([JSON.stringify(data, null, 2)], { type: 'application/json' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = `vyvanse-log-${new Date().toISOString().split('T')[0]}.json`; a.click(); }; const ScaleButton = ({ value, currentValue, onChange, label, color = "blue" }) => ( ); const EffectivenessTracker = () => (
{status.message}
Track your ADHD medication journey
{new Set(entries.map(e => e.date)).size}
{entries.length}
{entries.length ? (entries.reduce((sum, e) => sum + e.focus, 0) / entries.length).toFixed(1) : '-'}
{entries.length ? Math.round(entries.slice(0, 7).reduce((sum, e) => sum + (e.headache + e.nausea + e.anxiety + e.jitteriness), 0) / Math.min(7, entries.length)) : '-'}
1 = Very poor focus, 10 = Excellent focus
1 = Can't stay focused, 10 = Great attention span
1 = Very restless/hyperactive, 10 = Calm and settled
1 = Very impulsive, 10 = Excellent self-control
0 = No appetite, 4 = Normal appetite
0 = Very poor sleep, 4 = Excellent sleep
0 = Very irritable/sad, 4 = Great mood
0 = None, 4 = Severe anxiety
0 = None, 4 = Severe headache
0 = None, 4 = Severe nausea
0 = None, 4 = Very dry mouth
0 = None, 4 = Very jittery
Vyvanse typically starts working within 1.5-2 hours and can last up to 13-14 hours. Rate how well the medication is working at different times:
Expected Benefits: Improved focus, attention span, reduced hyperactivity and impulsivity
Timeline: Effects typically begin within 1.5-2 hours and last 13-14 hours
Common Side Effects: Decreased appetite, trouble sleeping, dry mouth, mood changes
Important: Your doctor will monitor your blood pressure and heart rate regularly
Always contact your healthcare provider with concerns or significant side effects.