= UseCase18 - System Administrator Manages Users = == Initiating Actor - `System Administrator` == == Description == A system administrator creates new user accounts and manages existing ones. The admin can register patients, doctors, lab technicians, and other admins, and can view and filter all users in the system. == Scenario == 1. Admin navigates to the user management section and views all users in the system. {{{ #!sql SELECT u.user_id, u.username, u.role, u.first_name, u.last_name, u.is_active FROM users u ORDER BY u.role, u.username; }}} 2. Admin filters users by role. {{{ #!sql SELECT u.user_id, u.username, u.role, u.first_name, u.last_name, u.is_active FROM users u WHERE u.role = 'DOCTOR' ORDER BY u.username; }}} 3. Admin enters the new doctor's professional details, and the system creates the doctor profile first. {{{ #!sql INSERT INTO doctors (specialization_id, department_id, first_name, last_name, email_address, level_id) VALUES ( (SELECT specialization_id FROM doctor_specialization WHERE specialization_name = 'Cardiology'), (SELECT department_id FROM departments WHERE department_name = 'Cardiology'), 'Nikola', 'Trajkov', 'nikola.trajkov@cardio.com', (SELECT level_id FROM doctor_level WHERE level = 'RESIDENT') ) RETURNING doctor_id; }}} 4. Admin enters the new login credentials, and the system creates the user account linked to that doctor profile. {{{ #!sql INSERT INTO users (username, password, role, first_name, last_name, is_active, doctor_id) VALUES ( 'nikola.trajkov', 'password123', 'DOCTOR', 'Nikola', 'Trajkov', TRUE, (SELECT MAX(doctor_id) FROM doctors) ) RETURNING user_id; }}} 5. System displays the updated user list confirming the new account. {{{ #!sql SELECT u.user_id, u.username, u.role, u.first_name, u.last_name, u.is_active FROM users u ORDER BY u.role, u.username; }}}