| | 1 | == Use-case 0012 - Book Appointment for Viewing |
| | 2 | |
| | 3 | '''Initiating actor:''' Client |
| | 4 | |
| | 5 | '''Other actors:''' Agent |
| | 6 | |
| | 7 | '''Description:''' |
| | 8 | |
| | 9 | A client books an appointment to physically view an apartment unit. This reserves a timeslot with an agent and marks the slot as booked. |
| | 10 | |
| | 11 | '''Scenario:''' |
| | 12 | |
| | 13 | 1. Client navigates to booking page for unit 101 in Golden Tower. |
| | 14 | |
| | 15 | 2. System displays available agents and timeslots: |
| | 16 | {{{ |
| | 17 | SELECT |
| | 18 | a.agent_id, |
| | 19 | a.name AS agent_name, |
| | 20 | a.email, |
| | 21 | t.timeslot_id, |
| | 22 | t.date, |
| | 23 | t.time_start, |
| | 24 | t.time_end |
| | 25 | FROM agent a |
| | 26 | JOIN timeslot t ON a.agent_id = t.agent_id |
| | 27 | WHERE t.status = 'Available' |
| | 28 | AND t.date >= CURRENT_DATE |
| | 29 | ORDER BY a.name, t.date, t.time_start; |
| | 30 | }}} |
| | 31 | |
| | 32 | 3. Client selects agent "Teodora" and timeslot "Jan 9, 2025 at 10:00 AM". |
| | 33 | |
| | 34 | 4. System displays booking confirmation form with unit, date/time, and agent details. |
| | 35 | |
| | 36 | 5. Client enters their information (name, email and phone number): Marko Petrovski, marko.p@gmail.com, +389 70 123 456. |
| | 37 | |
| | 38 | 6. System creates a client record if there are no previous records with the same email: |
| | 39 | {{{ |
| | 40 | INSERT INTO client (name, email, phone) |
| | 41 | VALUES ('Marko Petrovski', 'marko.p@gmail.com', '+389 70 123 456') |
| | 42 | ON CONFLICT (email) DO NOTHING; |
| | 43 | }}} |
| | 44 | |
| | 45 | 7. Client clicks "Confirm Appointment". |
| | 46 | |
| | 47 | 8. System verifies that the timeslot is available: |
| | 48 | {{{ |
| | 49 | SELECT status |
| | 50 | FROM timeslot |
| | 51 | WHERE timeslot_id = ( |
| | 52 | SELECT timeslot_id FROM timeslot |
| | 53 | WHERE date = '2025-01-10' |
| | 54 | AND time_start = '10:00:00' |
| | 55 | AND agent_id = (SELECT agent_id FROM agent WHERE name = 'Teodora') |
| | 56 | ); |
| | 57 | }}} |
| | 58 | |
| | 59 | 9. System creates the appointment: |
| | 60 | {{{ |
| | 61 | INSERT INTO appointment (status, client_id, unit_id, timeslot_id, agent_id) |
| | 62 | VALUES ( |
| | 63 | 'Scheduled', |
| | 64 | (SELECT client_id FROM client WHERE email = 'marko.p@gmail.com'), |
| | 65 | ( |
| | 66 | SELECT unit_id FROM unit WHERE unit_number = '101' |
| | 67 | AND floor_id = ( |
| | 68 | SELECT floor_id FROM floor |
| | 69 | WHERE building_id = (SELECT building_id FROM building WHERE name = 'Golden Tower') |
| | 70 | AND floor_number = 1) |
| | 71 | ), |
| | 72 | ( |
| | 73 | SELECT timeslot_id FROM timeslot |
| | 74 | WHERE date = '2025-01-10' |
| | 75 | AND time_start = '10:00:00' |
| | 76 | AND agent_id = (SELECT agent_id FROM agent WHERE name = 'Teodora') |
| | 77 | ), |
| | 78 | (SELECT agent_id FROM agent WHERE name = 'Teodora') |
| | 79 | ); |
| | 80 | }}} |
| | 81 | |
| | 82 | 10. System updates timeslot to booked: |
| | 83 | {{{ |
| | 84 | UPDATE timeslot |
| | 85 | SET status = 'Booked' |
| | 86 | WHERE timeslot_id = (SELECT timeslot_id FROM timeslot |
| | 87 | WHERE date = '2025-01-10' |
| | 88 | AND time_start = '10:00:00' |
| | 89 | AND agent_id = (SELECT agent_id FROM agent WHERE name = 'Teodora')); |
| | 90 | }}} |
| | 91 | |
| | 92 | 11. System displays confirmation with appointment details. |