= UseCase18PrototypeImplementation - System Administrator Manages Users = == Initiating Actor - `System Administrator` == == Description == A system administrator creates new user accounts. The admin can register doctors, patients, and other users by entering their data directly into a form. == Scenario == 1.System Admin navigates to the user management section and clicks "Add New Doctor". [[Image(uc018-1.png, width=100%)]])]] 2. System Admin fills in the doctor's information and submits the form. [[Image(uc-018-2.png, width=100%)]])]] {{{ #!sql INSERT INTO doctors (first_name, last_name, email_address, level_id, specialization_id, department_id) VALUES ( 'Maja', 'Ivanova', 'maja.ivanova@hospital.com', 2, 2, 2 ) RETURNING doctor_id; }}} 3. System creates the linked user account using the newly created doctor's ID. {{{ #!sql INSERT INTO users (username, password, role, first_name, last_name, is_active, doctor_id) VALUES ( 'maja.ivanova@medora.com', 'password123', 'DOCTOR', 'Maja', 'Ivanova', TRUE, (SELECT doctor_id FROM doctors WHERE email_address = 'maja.ivanova@hospital.com') ) RETURNING user_id; }}} 4. System displays the updated doctor list confirming the new account. [[Image(uc018-3.png, width=100%)]])]] {{{ #!sql SELECT u.user_id, u.username, u.role, d.first_name, d.last_name, u.is_active, ds.specialization_name, dep.department_name, dl.level FROM doctors d JOIN users u ON d.doctor_id = u.doctor_id LEFT JOIN doctor_specialization ds ON d.specialization_id = ds.specialization_id LEFT JOIN departments dep ON d.department_id = dep.department_id LEFT JOIN doctor_level dl ON d.level_id = dl.level_id ORDER BY u.username; }}}