wiki:UseCase07

Version 1 (modified by 231035, 2 weeks ago) ( diff )

--

UseCase07 - Create an Appointment

Initiating actor: Owner

Description

An owner schedules an appointment for one of their pets at a vet clinic they choose. The owner selects one of their animals, selects a clinic and submits the appointment request. The system then confirms the appointment has been created.

Scenario

  1. Owner opens a specific vet clinic.
    SELECT
      clinic_id,
      name,
      city,
      address,
      email,
      phone,
      open_time,
      close_time,
      not_working_isodow
    FROM vet_clinics
    WHERE clinic_id = $1;
    
  2. Owner clicks "Create an appointment".
    SELECT
      a.animal_id,
      a.name,
      a.species,
      a.breed
    FROM animals a
    WHERE a.owner_id = $1
    ORDER BY a.name;
    
  3. Owner fills in the form.
    BEGIN;
    
    SELECT 1
    FROM appointments ap
    WHERE ap.clinic_id = $1
      AND ap.date_time = $2
      AND ap.status = 'CONFIRMED'
    FOR UPDATE;
    
    INSERT INTO appointments (
      clinic_id,
      animal_id,
      responsible_owner_id,
      status,
      date_time,
      notes
    )
    VALUES (
      $1,
      $3,
      $4,
      'CONFIRMED',
      $2,
      $5
    )
    RETURNING appointment_id;
    
    COMMIT;
    
Note: See TracWiki for help on using the wiki.