wiki:UseCase18

Version 3 (modified by 236021, 21 hours ago) ( diff )

--

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.
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;
  1. Admin filters users by role.
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;
  1. Admin enters the new login credentials, and the system creates the user account first, since the doctor profile will need to reference it.
INSERT INTO users (username, password, role, first_name, last_name, is_active)
VALUES (
  'nikola.trajkov2@medora.com',
  '$2b$12$slaz0XboBErLVSsQBaQSQOkl2uOd8/RiEzyovbImHAS95rtMvKDiO',
  'DOCTOR',
  'Nikola',
  'Trajkov',
  TRUE
)
RETURNING user_id;
  1. Admin enters the new doctor's professional details, and the system creates the doctor profile linked to that user account.
INSERT INTO doctors (doctor_id, first_name, last_name, email_address, level_id, specialization_id, department_id, user_id)
VALUES (
  (SELECT COALESCE(MAX(doctor_id), 0) + 1 FROM doctors),
  'Nikola',
  'Trajkov',
  'nikola.trajkov2@medora.com',
  (SELECT level_id FROM doctor_level WHERE level = 'RESIDENT'),
  (SELECT specialization_id FROM doctor_specialization WHERE specialization_name = 'CARDIOLOGY'),
  (SELECT department_id FROM departments WHERE department_name = 'CARDIOLOGY_DEPT'),
  (SELECT MAX(user_id) FROM users)
)
RETURNING doctor_id;
  1. System displays the updated user list confirming the new account.
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;
Note: See TracWiki for help on using the wiki.