Implement dose tracking functionality and enhance CSV migration

- Added a new migration script to introduce dose tracking columns in the CSV.
- Updated DataManager to handle new dose tracking columns and methods for adding doses.
- Enhanced MedTrackerApp to support dose entry and display for each medicine.
- Modified UIManager to create a scrollable input frame with dose tracking elements.
- Implemented tests for delete functionality, dose tracking, edit functionality, and scrollable input.
- Updated existing tests to ensure compatibility with the new CSV format and dose tracking features.
This commit is contained in:
William Valentin
2025-07-28 20:52:29 -07:00
parent d5423e98c0
commit e35a8af5c1
14 changed files with 1790 additions and 500 deletions

110
DOSE_TRACKING_GUIDE.md Normal file
View File

@@ -0,0 +1,110 @@
# Medicine Dose Tracking Feature - Usage Guide
## Overview
The medicine dose tracking feature allows you to record specific timestamps and doses when you take medications throughout the day. This provides detailed tracking beyond the simple daily checkboxes.
## How to Use
### 1. Recording Medicine Doses
1. **Open the application** - Run `make run` or `uv run python src/main.py`
2. **Find the medicine section** - Look for the "Treatment" section in the input form
3. **For each medicine, you'll see:**
- Checkbox (existing daily tracking)
- Dose entry field (new)
- "Take [Medicine]" button (new)
- Dose display area showing today's doses (new)
### 2. Taking a Dose
1. **Enter the dose amount** in the dose entry field (e.g., "150mg", "10mg", "25mg")
2. **Click the "Take [Medicine]" button** - This will:
- Record the current timestamp
- Save the dose amount
- Update the display area
- Mark the medicine checkbox as taken
### 3. Multiple Doses Per Day
- You can take multiple doses of the same medicine
- Each dose gets its own timestamp
- All doses for the day are displayed in the dose area
- The display shows: `YYYY-MM-DD HH:MM:SS: dose`
### 4. Viewing Dose History
- **Today's doses** are shown in the dose display areas
- **Historical doses** are stored in the CSV with columns:
- `bupropion_doses`, `hydroxyzine_doses`, `gabapentin_doses`, `propranolol_doses`
- Each dose entry format: `timestamp:dose` separated by `|` for multiple doses
- **Edit entries** by double-clicking on table rows - dose information is preserved and displayed
### 5. Editing Entries
When you double-click on an entry in the data table:
- **Dose information is preserved** - existing doses are maintained during edits
- **Read-only dose display** - view all doses taken for that day
- **Symptom and medicine checkboxes** can be modified
- **Notes can be updated** while keeping dose history intact
## CSV Format
The new CSV structure includes dose tracking columns:
```csv
date,depression,anxiety,sleep,appetite,bupropion,bupropion_doses,hydroxyzine,hydroxyzine_doses,gabapentin,gabapentin_doses,propranolol,propranolol_doses,note
07/28/2025,4,5,3,3,1,"2025-07-28 14:30:00:150mg|2025-07-28 18:30:00:150mg",0,"",0,"",1,"2025-07-28 12:30:00:10mg","Multiple doses today"
```
## Features
-**Timestamp recording** - Exact time when medicine is taken
-**Dose amount tracking** - Record specific doses (150mg, 10mg, etc.)
-**Multiple doses per day** - Take the same medicine multiple times
-**Real-time display** - See today's doses immediately
-**Data persistence** - All doses saved to CSV
-**Backward compatibility** - Existing data migrated automatically
-**Scrollable interface** - Vertical scrollbar for expanded UI
## User Interface
The medicine tracking interface now includes:
- **Scrollable input area** - Use mouse wheel or scrollbar to navigate
- **Responsive design** - Interface adapts to window size
- **Expanded medicine section** - Each medicine has dose tracking controls
## Migration
Your existing data has been automatically migrated to the new format. A backup was created as `thechart_data.csv.backup_YYYYMMDD_HHMMSS`.
## Testing
Run the dose tracking test:
```bash
make test-dose-tracking
```
Test the scrollable interface:
```bash
make test-scrollable-input
```
Test the edit functionality:
```bash
make test-edit-functionality
```
## Troubleshooting
1. **Application won't start**: Check that migration completed successfully
2. **Doses not saving**: Ensure you enter a dose amount before clicking "Take"
3. **Data issues**: Restore from backup if needed
4. **UI layout issues**: The new interface may require resizing the window
## Technical Details
- **Timestamp format**: `YYYY-MM-DD HH:MM:SS`
- **Dose separator**: `|` (pipe) for multiple doses
- **Dose format**: `timestamp:dose`
- **Storage**: Additional columns in existing CSV file