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 = () => (
{Object.entries(currentEntry.effectiveness).map(([timePoint, rating]) => { const isActiveTime = shouldShowEffectivenessRating(timePoint); const targetHours = parseInt(timePoint.replace('hrs', '')); return (
{timePoint}: {isActiveTime && ( Rate Now! )}
{[0, 1, 2, 3, 4].map(value => ( updateEntry(`effectiveness.${timePoint}`, val)} label={value === 0 ? 'None' : value === 4 ? 'Excellent' : ''} color="green" /> ))}
{rating === 0 ? 'None' : rating === 4 ? 'Excellent' : `${rating}/4`}
); })}
); const TimingDashboard = () => { if (!medicationTakenTime) return null; const status = getTimingStatus(); const now = new Date(); const medTime = new Date(medicationTakenTime); const hoursSince = (now - medTime) / (1000 * 60 * 60); const minutesSince = Math.floor((hoursSince % 1) * 60); const hoursFloor = Math.floor(hoursSince); return (

Medication Timer

{status.message}

{hoursFloor}h {minutesSince}m
since medication
{nextReminder && (
Next effectiveness rating: {nextReminder.time} hours {nextReminder.date.toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'})}
)}
); }; return (

Vyvanse Medication Log

Track your ADHD medication journey

{/* Timing Dashboard */} {/* Quick Stats */}
Days Tracked

{new Set(entries.map(e => e.date)).size}

Total Entries

{entries.length}

Avg Focus

{entries.length ? (entries.reduce((sum, e) => sum + e.focus, 0) / entries.length).toFixed(1) : '-'}

Side Effects

{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)) : '-'}

{/* Current Entry Form */}
{/* Basic Info */}
updateEntry('date', e.target.value)} className="w-full p-2 border border-gray-300 rounded-md" />
updateEntry('time', e.target.value)} className="w-full p-2 border border-gray-300 rounded-md" />
{!currentEntry.medicationTaken ? ( ) : (
✓ Medication Taken {medicationTakenTime && (
{new Date(medicationTakenTime).toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'})}
)}
)}
{/* Physical Measurements */}
{expandedSections.physical && (
updateEntry('heartRate', e.target.value)} placeholder="e.g., 72" className="w-full p-2 border border-gray-300 rounded-md" />
updateEntry('bloodPressure', e.target.value)} placeholder="e.g., 120/80" className="w-full p-2 border border-gray-300 rounded-md" />
updateEntry('weight', e.target.value)} placeholder="e.g., 150.5" className="w-full p-2 border border-gray-300 rounded-md" />
)}
{/* ADHD Symptoms */}
{expandedSections.symptoms && (
Focus & Concentration {currentEntry.focus}/10
{[1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(value => ( updateEntry('focus', val)} color="blue" /> ))}

1 = Very poor focus, 10 = Excellent focus

Sustained Attention {currentEntry.attention}/10
{[1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(value => ( updateEntry('attention', val)} color="blue" /> ))}

1 = Can't stay focused, 10 = Great attention span

Hyperactivity Control {currentEntry.hyperactivity}/10
{[1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(value => ( updateEntry('hyperactivity', val)} color="green" /> ))}

1 = Very restless/hyperactive, 10 = Calm and settled

Impulse Control {currentEntry.impulsivity}/10
{[1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map(value => ( updateEntry('impulsivity', val)} color="green" /> ))}

1 = Very impulsive, 10 = Excellent self-control

)}
{/* Side Effects */}
{expandedSections.sideEffects && (
Appetite {currentEntry.appetite}/4
{[0, 1, 2, 3, 4].map(value => ( updateEntry('appetite', val)} color="green" /> ))}

0 = No appetite, 4 = Normal appetite

Sleep Quality {currentEntry.sleepQuality}/4
{[0, 1, 2, 3, 4].map(value => ( updateEntry('sleepQuality', val)} color="blue" /> ))}

0 = Very poor sleep, 4 = Excellent sleep

Mood {currentEntry.mood}/4
{[0, 1, 2, 3, 4].map(value => ( updateEntry('mood', val)} color="purple" /> ))}

0 = Very irritable/sad, 4 = Great mood

Anxiety/Nervousness {currentEntry.anxiety}/4
{[0, 1, 2, 3, 4].map(value => ( updateEntry('anxiety', val)} color="red" /> ))}

0 = None, 4 = Severe anxiety

Headache {currentEntry.headache}/4
{[0, 1, 2, 3, 4].map(value => ( updateEntry('headache', val)} color="red" /> ))}

0 = None, 4 = Severe headache

Nausea/Stomach Issues {currentEntry.nausea}/4
{[0, 1, 2, 3, 4].map(value => ( updateEntry('nausea', val)} color="red" /> ))}

0 = None, 4 = Severe nausea

Dry Mouth {currentEntry.dryMouth}/4
{[0, 1, 2, 3, 4].map(value => ( updateEntry('dryMouth', val)} color="red" /> ))}

0 = None, 4 = Very dry mouth

Jitteriness/Restlessness {currentEntry.jitteriness}/4
{[0, 1, 2, 3, 4].map(value => ( updateEntry('jitteriness', val)} color="red" /> ))}

0 = None, 4 = Very jittery

)}
{/* Effectiveness Timeline */}
{expandedSections.effectiveness && (

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:

)}
{/* Notes */}