Skip to main content

Overview

The Appointment entity manages scheduled appointments between patients and service providers. It includes status tracking, duration management, and soft deletion capabilities.

Interface Definition

export type AppointmentStatus = "pending" | "cancelled" | "completed";

export interface Appointment {
    id: string;
    patientId: string;
    date: string;
    durationMinutes: number;
    status: AppointmentStatus;
    createdAt: string;
    updatedAt: string;
    isDeleted: boolean;
    notes?: string;
}

Properties

id
string
required
Unique identifier for the appointment
patientId
string
required
Identifier of the patient associated with this appointment
date
string
required
ISO 8601 timestamp for the scheduled appointment date and time
durationMinutes
number
required
Duration of the appointment in minutes
status
AppointmentStatus
required
Current status of the appointment. Must be one of:
  • pending: Appointment is scheduled and awaiting completion
  • cancelled: Appointment has been cancelled
  • completed: Appointment has been completed
createdAt
string
required
ISO 8601 timestamp indicating when the appointment was created
updatedAt
string
required
ISO 8601 timestamp indicating when the appointment was last updated
isDeleted
boolean
required
Soft deletion flag. When true, the appointment is marked as deleted but not removed from the database
notes
string
Optional notes or additional information about the appointment

Usage Example

import { Appointment, AppointmentStatus } from '@/domain/entities/Appointment';

const appointment: Appointment = {
  id: 'appt_123456',
  patientId: 'patient_789',
  date: '2024-03-15T14:00:00Z',
  durationMinutes: 60,
  status: 'pending',
  createdAt: '2024-03-12T10:30:00Z',
  updatedAt: '2024-03-12T10:30:00Z',
  isDeleted: false,
  notes: 'Initial consultation for new patient'
};

Common Operations

Creating a New Appointment

const newAppointment: Omit<Appointment, 'id' | 'createdAt' | 'updatedAt'> = {
  patientId: 'patient_456',
  date: '2024-03-20T09:00:00Z',
  durationMinutes: 30,
  status: 'pending',
  isDeleted: false,
  notes: 'Follow-up appointment'
};

Updating Appointment Status

const completedAppointment: Appointment = {
  ...existingAppointment,
  status: 'completed',
  updatedAt: new Date().toISOString()
};

Cancelling an Appointment

const cancelledAppointment: Appointment = {
  ...existingAppointment,
  status: 'cancelled',
  updatedAt: new Date().toISOString(),
  notes: existingAppointment.notes + ' - Cancelled by patient'
};

Status Workflow

The typical appointment status flow:
  1. pending: Initial state when appointment is created
  2. completed or cancelled: Final states
Once an appointment is marked as completed or cancelled, it typically should not transition to other states.

Build docs developers (and LLMs) love