70 lines
2.0 KiB
Python
70 lines
2.0 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Test script to verify note field saving functionality
|
|
"""
|
|
|
|
import logging
|
|
import os
|
|
import sys
|
|
|
|
import pandas as pd
|
|
|
|
# Add src directory to path to import modules
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "src"))
|
|
|
|
from data_manager import DataManager
|
|
from medicine_manager import MedicineManager
|
|
from pathology_manager import PathologyManager
|
|
|
|
|
|
def test_note_saving():
|
|
"""Test note saving functionality by checking current data"""
|
|
print("Testing note saving functionality...")
|
|
|
|
# Initialize logger
|
|
logger = logging.getLogger("test")
|
|
logger.setLevel(logging.INFO)
|
|
|
|
# Initialize managers
|
|
medicine_manager = MedicineManager("medicines.json")
|
|
pathology_manager = PathologyManager("pathologies.json")
|
|
data_manager = DataManager(
|
|
"thechart_data.csv", logger, medicine_manager, pathology_manager
|
|
)
|
|
|
|
# Load current data
|
|
df = data_manager.load_data()
|
|
|
|
if df.empty:
|
|
print("No data found in CSV file")
|
|
return
|
|
|
|
print(f"Found {len(df)} entries in the data file")
|
|
|
|
# Check if we have any entries with notes
|
|
entries_with_notes = df[df["note"].notna() & (df["note"] != "")].copy()
|
|
|
|
print(f"Entries with notes: {len(entries_with_notes)}")
|
|
|
|
if len(entries_with_notes) > 0:
|
|
print("\nEntries with notes:")
|
|
for _, row in entries_with_notes.iterrows():
|
|
note_preview = (
|
|
row["note"][:50] + "..." if len(str(row["note"])) > 50 else row["note"]
|
|
)
|
|
print(f" Date: {row['date']}, Note: {note_preview}")
|
|
|
|
# Show the most recent entry
|
|
if len(df) > 0:
|
|
latest_entry = df.iloc[-1]
|
|
print("\nMost recent entry:")
|
|
print(f" Date: {latest_entry['date']}")
|
|
print(f" Note: '{latest_entry['note']}'")
|
|
print(f" Note length: {len(str(latest_entry['note']))}")
|
|
is_empty = pd.isna(latest_entry["note"]) or latest_entry["note"] == ""
|
|
print(f" Note is empty/null: {is_empty}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
test_note_saving()
|