Changes between Initial Version and Version 1 of UseCase0012PrototypeImplementation


Ignore:
Timestamp:
01/21/26 21:28:48 (5 days ago)
Author:
213257
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • UseCase0012PrototypeImplementation

    v1 v1  
     1= Use-case 0012 Implementation - Book Appointment for Viewing
     2
     3'''Initiating actor:''' Client
     4
     5'''Other actors:''' Agent
     6
     7'''Description:'''
     8
     9A 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=== Step 1
     14
     15'''User action:''' Client navigates to booking page for unit 101 in Golden Tower.
     16
     17'''Screenshot:''' [Image]
     18
     19'''System action:''' System displays available agents and timeslots.
     20
     21'''Query: '''
     22{{{
     23SET search_path TO project;
     24
     25SELECT
     26    a.agent_id,
     27    a.name AS agent_name,
     28    a.email,
     29    t.timeslot_id,
     30    t.date,
     31    t.time_start,
     32    t.time_end
     33FROM agent a
     34JOIN timeslot t ON a.agent_id = t.agent_id
     35WHERE t. status = 'Available'
     36AND t.date >= CURRENT_DATE
     37ORDER BY a.name, t.date, t.time_start;
     38}}}
     39
     40=== Step 2
     41
     42'''User action:''' Client selects agent "Bojana" and timeslot "June 1, 2026 at 11:00 AM".
     43
     44'''Screenshot:''' [Image]
     45
     46=== Step 3
     47
     48'''User action: ''' Client enters their information:  Luka Krstikj, lukakr@gmail.com, +389 70 123 456.
     49
     50'''Screenshot:''' [Image]
     51
     52=== Step 4
     53
     54'''User action:''' Client clicks "Confirm Appointment".
     55
     56'''Screenshot:''' [Image]
     57
     58'''System action:''' System verifies timeslot is still available.
     59
     60'''Query:'''
     61{{{
     62SET search_path TO project;
     63
     64SELECT status
     65FROM timeslot
     66WHERE timeslot_id = (
     67    SELECT timeslot_id FROM timeslot
     68    WHERE date = '2026-06-01'
     69    AND time_start = '11:00:00'
     70    AND agent_id = (SELECT agent_id FROM agent WHERE name = 'Bojana')
     71);
     72}}}
     73
     74=== Step 5
     75
     76'''System action:''' System creates client record if needed.
     77
     78'''Query:'''
     79{{{
     80SET search_path TO project;
     81
     82INSERT INTO client (name, email, phone)
     83VALUES ('Luka Krstikj', 'lukakr@gmail.com', '+389 70 123 456')
     84ON CONFLICT (email) DO UPDATE
     85SET name = 'Luka Krstikj', phone = '+389 70 123 456'
     86RETURNING client_id;
     87}}}
     88
     89=== Step 6
     90
     91'''System action:''' System creates the appointment.
     92
     93'''Query:'''
     94{{{
     95SET search_path TO project;
     96
     97INSERT INTO appointment (status, client_id, unit_id, timeslot_id, agent_id)
     98VALUES (
     99    'Scheduled',
     100    (SELECT client_id FROM client WHERE email = 'lukakr@gmail.com'),
     101    (SELECT unit_id FROM unit WHERE unit_number = '101'
     102     AND floor_id = (SELECT floor_id FROM floor
     103                     WHERE building_id = (SELECT building_id FROM building WHERE name = 'Golden Tower')
     104                     AND floor_number = 1)),
     105    (SELECT timeslot_id FROM timeslot
     106     WHERE date = '2026-06-01'
     107     AND time_start = '11:00:00'
     108     AND agent_id = (SELECT agent_id FROM agent WHERE name = 'Bojana')),
     109    (SELECT agent_id FROM agent WHERE name = 'Bojana')
     110)
     111RETURNING appointment_id;
     112}}}
     113
     114=== Step 7
     115
     116'''System action:''' System updates timeslot to booked.
     117
     118'''Query:'''
     119{{{
     120SET search_path TO project;
     121
     122UPDATE timeslot
     123SET status = 'Booked'
     124WHERE timeslot_id = (SELECT timeslot_id FROM timeslot
     125                     WHERE date = '2026-06-01'
     126                     AND time_start = '11:00:00'
     127                     AND agent_id = (SELECT agent_id FROM agent WHERE name = 'Bojana'));
     128}}}
     129
     130=== Step 8
     131
     132'''System action: ''' System displays confirmation with appointment details.
     133
     134'''Query:'''
     135{{{
     136SET search_path TO project;
     137
     138SELECT
     139    ap.appointment_id,
     140    c.name AS client_name,
     141    c.email AS client_email,
     142    c. phone AS client_phone,
     143    u.unit_number,
     144    b.name AS building_name,
     145    f.floor_number,
     146    t.date,
     147    t.time_start,
     148    t.time_end,
     149    a.name AS agent_name,
     150    a.email AS agent_email
     151FROM appointment ap
     152JOIN client c ON ap.client_id = c. client_id
     153JOIN unit u ON ap.unit_id = u. unit_id
     154JOIN floor f ON u.floor_id = f. floor_id
     155JOIN building b ON f.building_id = b. building_id
     156JOIN timeslot t ON ap.timeslot_id = t.timeslot_id
     157JOIN agent a ON ap. agent_id = a.agent_id
     158WHERE ap.appointment_id = (SELECT appointment_id FROM appointment
     159                           WHERE client_id = (SELECT client_id FROM client WHERE email = 'lukakr@gmail.com')
     160                           ORDER BY appointment_id DESC LIMIT 1);
     161}}}
     162
     163'''Screenshot:''' [Image]