File size: 11,544 Bytes
c024705
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
#!/usr/bin/env python3
"""
Add sample data to the database for testing
"""

import sqlite3
import time
import hashlib
import uuid

# Database file path
DB_FILE = "aimhsa.db"

def hash_password(password):
    """Hash a password using SHA-256"""
    return hashlib.sha256(password.encode()).hexdigest()

def add_sample_data():
    """Add sample data to the database"""
    
    print("="*60)
    print("ADDING SAMPLE DATA")
    print("="*60)
    
    conn = sqlite3.connect(DB_FILE)
    
    try:
        current_time = time.time()
        
        # Add sample user
        print("Adding sample user...")
        conn.execute("""
            INSERT OR REPLACE INTO users (
                username, password_hash, created_ts, email, fullname, 
                telephone, province, district, created_at
            ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
        """, (
            'Mugisha',
            hash_password('password123'),
            current_time,
            'mugisha@example.com',
            'Mugisha DUKUZUMUREMYI',
            '0785354935',
            'Eastern',
            'Kirehe',
            current_time
        ))
        print("βœ… Sample user 'Mugisha' added")
        
        # Add sample professional
        print("Adding sample professional...")
        conn.execute("""
            INSERT OR REPLACE INTO professionals (
                username, password_hash, first_name, last_name, email, phone,
                license_number, specialization, expertise_areas, languages,
                qualifications, availability_schedule, location_latitude,
                location_longitude, location_address, district, max_patients_per_day,
                consultation_fee, experience_years, bio, profile_picture,
                is_active, created_ts, updated_ts
            ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
        """, (
            'jean.ntwari',
            hash_password('password123'),
            'Jean',
            'Ntwari',
            'jean.ntwari@example.com',
            '+250788123456',
            'LIC123456',
            'Clinical Psychologist',
            '["Depression", "Anxiety", "Trauma", "Stress Management"]',
            '["English", "Kinyarwanda", "French"]',
            '["PhD in Clinical Psychology", "Licensed Clinical Psychologist"]',
            '{"monday": "09:00-17:00", "tuesday": "09:00-17:00", "wednesday": "09:00-17:00", "thursday": "09:00-17:00", "friday": "09:00-17:00"}',
            -1.9441,
            30.0619,
            'Kigali, Rwanda',
            'Kigali',
            10,
            50000.0,
            8,
            'Experienced clinical psychologist specializing in trauma therapy and cognitive behavioral therapy.',
            None,
            1,
            current_time,
            current_time
        ))
        print("βœ… Sample professional 'Jean Ntwari' added")
        
        # Get professional ID
        professional = conn.execute("SELECT id FROM professionals WHERE username = 'jean.ntwari'").fetchone()
        professional_id = professional[0]
        
        # Add sample conversation
        conv_id = str(uuid.uuid4())
        print("Adding sample conversation...")
        conn.execute("""
            INSERT OR REPLACE INTO conversations (
                conv_id, owner_key, preview, ts
            ) VALUES (?, ?, ?, ?)
        """, (
            conv_id,
            'Mugisha',
            'User is feeling overwhelmed and struggling with low mood. Needs support and resources.',
            current_time
        ))
        print("βœ… Sample conversation added")
        
        # Add sample messages
        print("Adding sample messages...")
        messages = [
            (conv_id, 'user', 'I am feeling overwhelmed and tired. I need help.', current_time - 3600),
            (conv_id, 'assistant', 'I understand you\'re feeling overwhelmed and tired. That sounds really difficult. Can you tell me more about what\'s been going on?', current_time - 3500),
            (conv_id, 'user', 'I have been struggling with low mood and lack of motivation. Everything feels too much.', current_time - 3400),
            (conv_id, 'assistant', 'I hear that you\'re experiencing low mood and feeling like everything is too much. These feelings are valid and it\'s important that you\'re reaching out for support. Would you like me to help you connect with a mental health professional?', current_time - 3300),
            (conv_id, 'user', 'Yes, I think I need professional help. I am in Rwanda and not sure where to find good mental health support.', current_time - 3200),
            (conv_id, 'assistant', 'I can help you connect with a qualified mental health professional in Rwanda. Based on your needs, I\'ll create a booking for you with a professional who specializes in mood disorders and stress management.', current_time - 3100)
        ]
        
        for msg in messages:
            conn.execute("""
                INSERT OR REPLACE INTO messages (
                    conv_id, role, content, ts
                ) VALUES (?, ?, ?, ?)
            """, msg)
        
        print("βœ… Sample messages added")
        
        # Add sample automated booking
        booking_id = 'd63a7794-a89c-452c-80a6-24691e3cb848'
        print("Adding sample automated booking...")
        conn.execute("""
            INSERT OR REPLACE INTO automated_bookings (
                booking_id, conv_id, user_account, user_ip, professional_id,
                risk_level, risk_score, detected_indicators, conversation_summary,
                booking_status, scheduled_datetime, session_type, location_preference,
                notes, created_ts, updated_ts
            ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
        """, (
            booking_id,
            conv_id,
            'Mugisha',
            '127.0.0.1',
            professional_id,
            'medium',
            0.5,
            '["user_requested_booking"]',
            '**Professional Summary:**\n\n**Client:** Female, Rwandan national\n\n**Presenting Concerns:** Feeling overwhelmed, tired, and struggling with low mood.\n\n**Emotional State:** The client is expressing emotional distress, feeling not good, and acknowledging the need for support. She appears to be experiencing significant stress and is open to exploring resources for mental health support in Rwanda.\n\n**Risk Factors:** None explicitly mentioned, but the context suggests a history of challenges faced by Rwanda, which may contribute to the client\'s current emotional state.\n\n**Key Issues:**\n\n* Feeling overwhelmed and tired\n* Low mood and lack of motivation\n* Difficulty in accessing mental health resources in Rwanda\n* Interest in exploring relaxation techniques, journaling, or grounding exercises as coping mechanisms\n\nThis conversation highlights the importance of acknowledging and addressing the client\'s emotional pain, while also providing her with information and support to access necessary resources. Further guidance on managing stress and improving mental well-being is warranted.\n\n**Recommendations:**\n\n* Schedule a follow-up appointment to assess the client\'s progress and provide ongoing support.\n* Explore additional coping mechanisms, such as cognitive-behavioral therapy (CBT) or mindfulness-based interventions.\n* Connect the client with local resources, such as mental health hotlines or counseling services, for continued support.\n\n**Next Steps:**\n\n* Coordinate follow-up appointments to ensure the client\'s ongoing progress and well-being.\n* Monitor the client\'s emotional state and adjust treatment plans as needed.',
            'confirmed',
            current_time + 86400,  # Tomorrow
            'urgent',
            'Kigali',
            'Client needs immediate support for mood and stress management.',
            current_time,
            current_time + 200  # Updated 200 seconds later
        ))
        print("βœ… Sample automated booking added")
        
        # Add sample conversation messages
        print("Adding conversation messages...")
        conv_messages = [
            (conv_id, 'user', 'I am feeling overwhelmed and tired. I need help.', current_time - 3600),
            (conv_id, 'assistant', 'I understand you\'re feeling overwhelmed and tired. That sounds really difficult. Can you tell me more about what\'s been going on?', current_time - 3500),
            (conv_id, 'user', 'I have been struggling with low mood and lack of motivation. Everything feels too much.', current_time - 3400),
            (conv_id, 'assistant', 'I hear that you\'re experiencing low mood and feeling like everything is too much. These feelings are valid and it\'s important that you\'re reaching out for support. Would you like me to help you connect with a mental health professional?', current_time - 3300),
            (conv_id, 'user', 'Yes, I think I need professional help. I am in Rwanda and not sure where to find good mental health support.', current_time - 3200),
            (conv_id, 'assistant', 'I can help you connect with a qualified mental health professional in Rwanda. Based on your needs, I\'ll create a booking for you with a professional who specializes in mood disorders and stress management.', current_time - 3100)
        ]
        
        for msg in conv_messages:
            conn.execute("""
                INSERT OR REPLACE INTO conversation_messages (
                    conv_id, sender, content, timestamp
                ) VALUES (?, ?, ?, ?)
            """, msg)
        
        print("βœ… Conversation messages added")
        
        # Add sample professional notification
        print("Adding sample professional notification...")
        conn.execute("""
            INSERT OR REPLACE INTO professional_notifications (
                professional_id, booking_id, notification_type, title, message,
                is_read, priority, created_ts
            ) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
        """, (
            professional_id,
            booking_id,
            'new_booking',
            'URGENT: MEDIUM Risk Case - Mugisha DUKUZUMUREMYI',
            'Automated booking created for medium risk case. Risk indicators: user_requested_booking\n\nUser Contact Information:\nName: Mugisha DUKUZUMUREMYI\nPhone: 0785354935\nEmail: mugisha@example.com\nLocation: Kirehe, Eastern',
            0,
            'high',
            current_time
        ))
        print("βœ… Sample professional notification added")
        
        # Commit all changes
        conn.commit()
        
        print("\n" + "="*60)
        print("SAMPLE DATA ADDITION COMPLETE!")
        print("="*60)
        
        # Verify data was added
        user_count = conn.execute("SELECT COUNT(*) FROM users").fetchone()[0]
        professional_count = conn.execute("SELECT COUNT(*) FROM professionals").fetchone()[0]
        booking_count = conn.execute("SELECT COUNT(*) FROM automated_bookings").fetchone()[0]
        message_count = conn.execute("SELECT COUNT(*) FROM messages").fetchone()[0]
        
        print(f"\nData Summary:")
        print(f"   Users: {user_count}")
        print(f"   Professionals: {professional_count}")
        print(f"   Bookings: {booking_count}")
        print(f"   Messages: {message_count}")
        
        conn.close()
        
    except Exception as e:
        print(f"❌ Error adding sample data: {e}")
        conn.close()
        raise

if __name__ == "__main__":
    add_sample_data()