Some checks failed
Build and Push Docker Image / build-and-push (push) Has been cancelled
3.4 KiB
3.4 KiB
Medicine Dose Graph Plots Feature
Overview
Added graph plots for medicine dose tracking with toggle buttons to control display, similar to the existing symptom plots. The feature displays actual daily dosages rather than just binary intake indicators.
Changes Made
1. Graph Manager Updates (src/graph_manager.py)
Added Medicine Toggle Variables
- Added toggle variables for all 5 medicines: bupropion, hydroxyzine, gabapentin, propranolol, quetiapine
- Set bupropion and propranolol to show by default (most commonly used medicines)
Enhanced Toggle UI
- Organized toggles into two labeled sections: "Symptoms" and "Medicines"
- Symptoms section: Depression, Anxiety, Sleep, Appetite
- Medicines section: All 5 medicines with individual toggle buttons
Medicine Dose Visualization
- Medicine doses displayed as colored bars positioned at the bottom of the graph
- Each medicine has a distinct color:
- Bupropion: Red (#FF6B6B)
- Hydroxyzine: Teal (#4ECDC4)
- Gabapentin: Blue (#45B7D1)
- Propranolol: Green (#96CEB4)
- Quetiapine: Yellow (#FFEAA7)
Dose Calculation Logic
- Parses dose strings in format:
timestamp:dose|timestamp:dose - Handles various formats including
•symbols and missing timestamps - Calculates total daily dose by summing all individual doses
- Extracts numeric values from dose strings (e.g., "150mg" → 150)
Graph Layout Improvements
- Doses scaled by 1/10 for better visibility (labeled as "mg/10")
- Bars positioned below main chart area with dynamic positioning
- Y-axis label updated to "Rating (0-10) / Dose (mg)"
- Semi-transparent bars (alpha=0.6) to avoid overwhelming the main data
Features
Dose Parsing
- Automatically calculates total daily doses from timestamp:dose entries
- Handles multiple formats:
- Standard:
2025-07-30 08:00:00:150mg|2025-07-30 20:00:00:150mg - With symbols:
• • • • 2025-07-30 07:50:00:300 - Mixed formats and missing data (NaN values)
- Standard:
Toggle Controls
- Users can independently show/hide each medicine dose from the graph
- Organized into logical groups (Symptoms vs Medicines)
- Changes take effect immediately when toggled
Visual Design
- Medicine doses appear as colored bars scaled to fit with symptom data
- Clear legend showing all visible elements with "(mg/10)" notation
- Does not interfere with existing symptom line plots
- Dynamic positioning based on actual dose ranges
Data Integration
- Uses existing dose data columns (
bupropion_doses,propranolol_doses, etc.) - Compatible with current data structure
- No changes needed to data collection or storage
Usage
- Run the app:
.venv/bin/python src/main.pyor use the VS Code task - Use the "Medicines" toggle buttons to show/hide specific medicine doses
- Medicine doses appear as colored bars at the bottom of the graph
- Doses are scaled by 1/10 for visibility (e.g., 150mg shows as 15 on the chart)
- Combine with symptom data to see correlations between dosage and symptoms
Technical Notes
- Dose data is read from existing CSV columns (
*_doses) - Daily totals calculated by parsing and summing individual dose entries
- Bars positioned using dynamic
bottomparameter based on scaled dose values - Y-axis automatically adjusted to accommodate bars
- Maintains backward compatibility with existing functionality
- Robust parsing handles various dose string formats and edge cases