File size: 6,413 Bytes
2929135
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
import streamlit as st
from time import sleep
import pytest
from datetime import datetime

class HealthcareAssistantTester:
    def __init__(self):
        self.test_results = []
        
    def run_test_suite(self):
        """Run all test scenarios"""
        print("\n=== Starting Healthcare Assistant Test Suite ===\n")
        
        # Run all test categories
        self.test_patient_flow()
        self.test_resource_management()
        self.test_staff_scheduling()
        self.test_quality_metrics()
        self.test_emergency_scenarios()
        self.test_department_specific()
        
        # Print test summary
        self.print_test_summary()

    def test_patient_flow(self):
        """Test Patient Flow Related Queries"""
        print("\n1. Testing Patient Flow Queries:")
        queries = [
            "Show me waiting times across all departments",
            "What is the current bed occupancy in the ER?",
            "How many patients are currently waiting for admission?",
            "What's the average wait time in the ICU?",
            "Show patient flow trends for the last 8 hours",
            "Which department has the longest waiting time right now?"
        ]
        self._run_test_batch("Patient Flow", queries)

    def test_resource_management(self):
        """Test Resource Management Queries"""
        print("\n2. Testing Resource Management Queries:")
        queries = [
            "Check medical supplies inventory status",
            "What is the current ventilator availability?",
            "Are there any critical supply shortages?",
            "Show resource utilization across departments",
            "Which supplies need immediate reordering?",
            "What's the equipment maintenance status?"
        ]
        self._run_test_batch("Resource Management", queries)

    def test_staff_scheduling(self):
        """Test Staff Scheduling Queries"""
        print("\n3. Testing Staff Scheduling Queries:")
        queries = [
            "Show current staff distribution",
            "How many nurses are available in ICU?",
            "What is the current shift coverage?",
            "Show staff overtime hours this week",
            "Is there adequate staff coverage for next shift?",
            "Which departments need additional staff right now?"
        ]
        self._run_test_batch("Staff Scheduling", queries)

    def test_quality_metrics(self):
        """Test Quality Metrics Queries"""
        print("\n4. Testing Quality Metrics Queries:")
        queries = [
            "What's our current patient satisfaction score?",
            "Show me compliance rates for the last 24 hours",
            "Are there any quality metrics below target?",
            "What's the current incident report status?",
            "Show quality trends across departments",
            "Which department has the highest patient satisfaction?"
        ]
        self._run_test_batch("Quality Metrics", queries)

    def test_emergency_scenarios(self):
        """Test Emergency Scenario Queries"""
        print("\n5. Testing Emergency Scenarios:")
        queries = [
            "Activate emergency protocol for mass casualty incident",
            "Need immediate bed availability status for emergency",
            "Require rapid staff mobilization plan",
            "Emergency resource allocation needed",
            "Critical capacity alert in ER",
            "Emergency department overflow protocol status"
        ]
        self._run_test_batch("Emergency Scenarios", queries)

    def test_department_specific(self):
        """Test Department-Specific Queries"""
        print("\n6. Testing Department-Specific Queries:")
        queries = [
            "Show complete metrics for ER department",
            "What's the ICU capacity and staff status?",
            "General ward patient distribution",
            "Surgery department resource utilization",
            "Pediatrics department waiting times",
            "Cardiology unit staff coverage"
        ]
        self._run_test_batch("Department-Specific", queries)

    def _run_test_batch(self, category: str, queries: list):
        """Run a batch of test queries"""
        for query in queries:
            try:
                print(f"\nTesting: {query}")
                print("-" * 50)
                
                # Simulate processing time
                print("Processing query...")
                sleep(1)
                
                # Record test execution
                self.test_results.append({
                    'category': category,
                    'query': query,
                    'timestamp': datetime.now(),
                    'status': 'Success'
                })
                
                print("βœ“ Test completed successfully")
                
            except Exception as e:
                print(f"βœ— Test failed: {str(e)}")
                self.test_results.append({
                    'category': category,
                    'query': query,
                    'timestamp': datetime.now(),
                    'status': 'Failed',
                    'error': str(e)
                })

    def print_test_summary(self):
        """Print summary of all test results"""
        print("\n=== Test Execution Summary ===")
        print(f"Total Tests Run: {len(self.test_results)}")
        
        # Calculate statistics
        successful_tests = len([t for t in self.test_results if t['status'] == 'Success'])
        failed_tests = len([t for t in self.test_results if t['status'] == 'Failed'])
        
        print(f"Successful Tests: {successful_tests}")
        print(f"Failed Tests: {failed_tests}")
        
        # Print results by category
        print("\nResults by Category:")
        categories = set([t['category'] for t in self.test_results])
        for category in categories:
            category_tests = [t for t in self.test_results if t['category'] == category]
            category_success = len([t for t in category_tests if t['status'] == 'Success'])
            print(f"{category}: {category_success}/{len(category_tests)} passed")

        print("\n=== Test Suite Completed ===")

def main():
    """Main test execution function"""
    # Initialize and run tests
    tester = HealthcareAssistantTester()
    tester.run_test_suite()

if __name__ == "__main__":
    main()