> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/marcosfabricio3/simple-manager-mobile/llms.txt
> Use this file to discover all available pages before exploring further.

# Appointment

> Appointment entity represents scheduled appointments in Simple Manager Mobile

## Overview

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

## Interface Definition

```typescript theme={null}
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

<ParamField path="id" type="string" required>
  Unique identifier for the appointment
</ParamField>

<ParamField path="patientId" type="string" required>
  Identifier of the patient associated with this appointment
</ParamField>

<ParamField path="date" type="string" required>
  ISO 8601 timestamp for the scheduled appointment date and time
</ParamField>

<ParamField path="durationMinutes" type="number" required>
  Duration of the appointment in minutes
</ParamField>

<ParamField path="status" type="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
</ParamField>

<ParamField path="createdAt" type="string" required>
  ISO 8601 timestamp indicating when the appointment was created
</ParamField>

<ParamField path="updatedAt" type="string" required>
  ISO 8601 timestamp indicating when the appointment was last updated
</ParamField>

<ParamField path="isDeleted" type="boolean" required>
  Soft deletion flag. When `true`, the appointment is marked as deleted but not removed from the database
</ParamField>

<ParamField path="notes" type="string">
  Optional notes or additional information about the appointment
</ParamField>

## Usage Example

```typescript theme={null}
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

```typescript theme={null}
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

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

### Cancelling an Appointment

```typescript theme={null}
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

<Note>
  Once an appointment is marked as `completed` or `cancelled`, it typically should not transition to other states.
</Note>

## Related Entities

* [Record](/api/entities/record)
* [Service](/api/entities/service)
