- 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.
56 lines
1.5 KiB
Python
56 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Test script to demonstrate the dose tracking functionality.
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
from datetime import datetime
|
|
|
|
sys.path.append(os.path.join(os.path.dirname(__file__), "src"))
|
|
|
|
from data_manager import DataManager
|
|
from init import logger
|
|
|
|
|
|
def test_dose_tracking():
|
|
"""Test the dose tracking functionality."""
|
|
|
|
# Initialize data manager
|
|
data_manager = DataManager("thechart_data.csv", logger)
|
|
|
|
# Test adding a dose
|
|
today = datetime.now().strftime("%m/%d/%Y")
|
|
print(f"Testing dose tracking for date: {today}")
|
|
|
|
# Add some test doses
|
|
test_doses = [
|
|
("bupropion", "150mg"),
|
|
("propranolol", "10mg"),
|
|
("bupropion", "150mg"), # Second dose of same medicine
|
|
]
|
|
|
|
for medicine, dose in test_doses:
|
|
success = data_manager.add_medicine_dose(today, medicine, dose)
|
|
if success:
|
|
print(f"✓ Added {medicine} dose: {dose}")
|
|
else:
|
|
print(f"✗ Failed to add {medicine} dose: {dose}")
|
|
|
|
# Retrieve and display doses
|
|
print(f"\nDoses recorded for {today}:")
|
|
medicines = ["bupropion", "hydroxyzine", "gabapentin", "propranolol"]
|
|
|
|
for medicine in medicines:
|
|
doses = data_manager.get_today_medicine_doses(today, medicine)
|
|
if doses:
|
|
print(f"{medicine.title()}:")
|
|
for timestamp, dose in doses:
|
|
print(f" - {timestamp}: {dose}")
|
|
else:
|
|
print(f"{medicine.title()}: No doses recorded")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
test_dose_tracking()
|