Spaces:
Sleeping
Sleeping
#!/usr/bin/env python3 | |
""" | |
Test script to verify that the Clinical Assessment header is present in the formatted summary | |
""" | |
import sys | |
import os | |
sys.path.append(os.path.dirname(os.path.abspath(__file__))) | |
from ai_med_extract.agents.patient_summary_agent import PatientSummarizerAgent | |
def test_clinical_assessment_header(): | |
"""Test that Clinical Assessment header is present in formatted summary""" | |
# Create a mock patient data | |
patient_data = { | |
"result": { | |
"patientname": "John Doe", | |
"patientnumber": "12345", | |
"agey": "65", | |
"gender": "Male", | |
"allergies": ["Penicillin"], | |
"social_history": "Retired, former smoker", | |
"past_medical_history": ["Hypertension", "Diabetes"], | |
"encounters": [ | |
{ | |
"visit_date": "2024-01-15", | |
"chief_complaint": "Chest pain", | |
"symptoms": "Shortness of breath", | |
"diagnosis": ["Acute coronary syndrome"], | |
"dr_notes": "Patient presents with chest pain", | |
"vitals": {"BP": "150/90", "HR": "85"}, | |
"lab_results": {"Troponin": "0.5"}, | |
"medications": ["Aspirin", "Metoprolol"], | |
"treatment": "Medical management" | |
} | |
] | |
} | |
} | |
# Create agent with fallback loader (since we don't have actual models) | |
agent = PatientSummarizerAgent(model_name="test", model_type="test") | |
# Generate summary | |
summary = agent.generate_clinical_summary(patient_data) | |
# Check if Clinical Assessment header is present | |
has_clinical_assessment = "## Clinical Assessment" in summary | |
print("Test Results:") | |
print("=" * 50) | |
print(f"Clinical Assessment header present: {has_clinical_assessment}") | |
if has_clinical_assessment: | |
print("β SUCCESS: Clinical Assessment header is present in the summary") | |
else: | |
print("β FAILURE: Clinical Assessment header is missing from the summary") | |
print("\nSummary excerpt:") | |
print("-" * 30) | |
# Find the AI-Generated Narrative section | |
narrative_start = summary.find("--- AI-GENERATED CLINICAL NARRATIVE ---") | |
if narrative_start != -1: | |
excerpt = summary[narrative_start:narrative_start + 500] | |
print(excerpt + "...") | |
else: | |
print("Could not find AI-Generated Narrative section") | |
return has_clinical_assessment | |
if __name__ == "__main__": | |
success = test_clinical_assessment_header() | |
sys.exit(0 if success else 1) | |