File size: 4,721 Bytes
e4ff146
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import pytest

class TestExamples:
    """Test example medical notes and functionality"""
    
    def test_example_notes_exist(self):
        """Test that example notes are properly defined"""
        examples = {
            'chest_pain': """Patient: John Smith, 45-year-old male
Chief Complaint: Chest pain for 2 hours
History: Patient reports sudden onset of sharp chest pain while at work. 
Pain is 7/10 intensity, located substernal, radiating to left arm.""",
            
            'diabetes': """Patient: Maria Garcia, 52-year-old female
Chief Complaint: Increased thirst and frequent urination for 3 weeks
History: Patient reports polyuria, polydipsia, and unintentional weight loss.""",
            
            'pediatric': """Patient: Emma Thompson, 8-year-old female
Chief Complaint: Fever and sore throat for 2 days
History: Mother reports fever up to 102°F, sore throat, difficulty swallowing."""
        }
        
        assert 'chest_pain' in examples
        assert 'diabetes' in examples
        assert 'pediatric' in examples
        
        for key, example in examples.items():
            assert len(example.strip()) > 50  # Ensure examples have substance
            assert "Patient:" in example
            assert "Chief Complaint:" in example

    def test_example_loading(self):
        """Test example loading functionality"""
        def mock_load_example(example_key):
            examples = {
                'chest_pain': "Chest pain example loaded",
                'diabetes': "Diabetes example loaded",
                'pediatric': "Pediatric example loaded"
            }
            return examples.get(example_key, "Example not found")
        
        assert mock_load_example('chest_pain') == "Chest pain example loaded"
        assert mock_load_example('diabetes') == "Diabetes example loaded"
        assert mock_load_example('pediatric') == "Pediatric example loaded"
        assert mock_load_example('invalid_key') == "Example not found"

    def test_example_content_quality(self):
        """Test that examples contain required medical information"""
        examples = {
            'chest_pain': """Patient: John Smith, 45-year-old male
Chief Complaint: Chest pain for 2 hours
History: Sharp chest pain, 7/10 intensity
Physical Exam: VS: BP 150/90, HR 110
Assessment: Acute chest pain
Plan: EKG, cardiac enzymes""",
            
            'diabetes': """Patient: Maria Garcia, 52-year-old female  
Chief Complaint: Increased thirst and urination
History: Polyuria, polydipsia, weight loss
Physical Exam: VS: BP 140/85, BMI 28
Assessment: New onset diabetes
Plan: HbA1c, glucose, metformin""",
            
            'pediatric': """Patient: Emma Thompson, 8-year-old female
Chief Complaint: Fever and sore throat
History: Fever 102°F, sore throat, decreased appetite
Physical Exam: Throat erythematous, lymphadenopathy
Assessment: Streptococcal pharyngitis
Plan: Rapid strep test, amoxicillin"""
        }
        
        for key, example in examples.items():
            # Check for essential medical note components
            assert "Patient:" in example
            assert "Chief Complaint:" in example
            assert "History:" in example or "Physical Exam:" in example
            assert "Assessment:" in example
            assert "Plan:" in example
            
            # Check for age and gender
            assert any(age in example for age in ['year-old', 'yo', 'years old'])
            assert any(gender in example for gender in ['male', 'female'])

    def test_example_button_handlers(self):
        """Test example button click handlers"""
        def mock_example_click_handler(example_text):
            def handler():
                return f"Loaded: {example_text[:20]}..."
            return handler
        
        # Test each example handler
        examples = {
            'chest_pain': "Chest pain example text",
            'diabetes': "Diabetes example text", 
            'pediatric': "Pediatric example text"
        }
        
        for key, text in examples.items():
            handler = mock_example_click_handler(text)
            result = handler()
            assert "Loaded:" in result
            assert text[:20] in result

    def test_clear_functionality(self):
        """Test clear button functionality"""
        def mock_clear_handler():
            return {
                'notes_input': '',
                'file_upload': None,
                'output_area': 'Ready to generate SOAP notes!'
            }
        
        result = mock_clear_handler()
        assert result['notes_input'] == ''
        assert result['file_upload'] is None
        assert 'Ready to generate' in result['output_area']