File size: 2,200 Bytes
9c5ada7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
// Shared functions across all pages
document.addEventListener('DOMContentLoaded', function() {
    // Initialize modals
    const authModal = document.querySelector('auth-modal');
    
    // Role selection handling
    const roleCards = document.querySelectorAll('.role-card');
    if (roleCards.length > 0) {
        roleCards.forEach(card => {
            card.addEventListener('click', function(e) {
                e.preventDefault();
                authModal.setAttribute('role', this.getAttribute('href').replace('.html', '').replace('/', ''));
                authModal.setAttribute('open', 'true');
            });
        });
    }
    
    // Initialize tooltips
    const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
    tooltipTriggerList.map(function (tooltipTriggerEl) {
        return new bootstrap.Tooltip(tooltipTriggerEl);
    });
});

// Data storage simulation
const mockDatabase = {
    users: [
        { id: 1, name: "Admin User", role: "admin", email: "admin@clinicflow.com" },
        { id: 2, name: "Receptionist", role: "receptionist", email: "reception@clinicflow.com" },
        { id: 3, name: "Dr. Smith", role: "doctor", email: "doctor@clinicflow.com" },
        { id: 4, name: "Pathologist", role: "pathologist", email: "path@clinicflow.com" },
        { id: 5, name: "John Patient", role: "patient", email: "patient@example.com" }
    ],
    patients: [
        { id: 1, name: "John Doe", age: 35, gender: "male", contact: "1234567890" },
        { id: 2, name: "Jane Smith", age: 28, gender: "female", contact: "9876543210" }
    ],
    consultations: [
        { id: 1, patientId: 1, doctorId: 3, notes: "Patient complains of headache", date: "2023-05-15" }
    ],
    tests: [
        { id: 1, patientId: 1, consultationId: 1, type: "Blood Test", status: "pending", result: "" }
    ]
};

// Utility functions
function getCurrentUser() {
    return JSON.parse(localStorage.getItem('currentUser')) || null;
}

function setCurrentUser(user) {
    localStorage.setItem('currentUser', JSON.stringify(user));
}

function logout() {
    localStorage.removeItem('currentUser');
    window.location.href = 'index.html';
}