| 45 | | INSERT INTO users (username, password, role, first_name, last_name, is_active) |
| | 45 | INSERT INTO doctors (specialization_id, department_id, first_name, last_name, email_address, level_id) |
| | 46 | VALUES ( |
| | 47 | (SELECT specialization_id FROM doctor_specialization WHERE specialization_name = 'Cardiology'), |
| | 48 | (SELECT department_id FROM departments WHERE department_name = 'Cardiology'), |
| | 49 | 'Nikola', |
| | 50 | 'Trajkov', |
| | 51 | 'nikola.trajkov@cardio.com', |
| | 52 | (SELECT level_id FROM doctor_level WHERE level = 'RESIDENT') |
| | 53 | ) |
| | 54 | RETURNING doctor_id; |
| | 55 | }}} |
| | 56 | |
| | 57 | 4. Admin enters the new login credentials, and the system creates the user account linked to that doctor profile. |
| | 58 | |
| | 59 | {{{ |
| | 60 | #!sql |
| | 61 | INSERT INTO users (username, password, role, first_name, last_name, is_active, doctor_id) |
| 55 | | }}} |
| 56 | | |
| 57 | | 4. System creates the role-specific profile linked to the new user. |
| 58 | | |
| 59 | | {{{ |
| 60 | | #!sql |
| 61 | | INSERT INTO doctors (user_id, specialization_id, department_id, first_name, last_name, email_address, level_id) |
| 62 | | VALUES ( |
| 63 | | (SELECT user_id FROM users WHERE username = 'nikola.trajkov'), |
| 64 | | (SELECT specialization_id FROM doctor_specialization WHERE specialization_name = 'Cardiology'), |
| 65 | | (SELECT department_id FROM departments WHERE department_name = 'Cardiology'), |
| 66 | | 'Nikola', |
| 67 | | 'Trajkov', |
| 68 | | 'nikola.trajkov@cardio.com', |
| 69 | | (SELECT level_id FROM doctor_level WHERE level = 'RESIDENT') |
| 70 | | ); |