Overview
The Medical Appointment Management API uses a clear separation between entities (domain models) and DTOs (Data Transfer Objects) to maintain clean boundaries between the API layer and the business logic layer.Entities vs DTOs
Entities
Purpose: Represent the core business domain- Located in
Models/Entities/ - Include all properties, including auto-generated IDs
- Used internally by the service layer
- Represent the “truth” of the domain model
DTOs (Data Transfer Objects)
Purpose: Define the API contract- Located in
Models/Dtos/ - Used for client-server communication
- Separate creation DTOs (input) from response DTOs (output)
- Allow controlled exposure of data to clients
This separation allows you to change internal models without breaking the API contract, and control what clients can send vs. receive.
Core Entities
Paciente (Patient)
Represents a patient in the medical system.Models/Entities/Paciente.cs
| Property | Type | Required | Description |
|---|---|---|---|
Id | int | Yes (auto) | Unique identifier |
Nombre | string | Yes | Patient’s first name |
Apellido | string | Yes | Patient’s last name |
Dni | string | Yes | National ID/identification number |
Email | string | Yes | Contact email address |
Telefono | string? | No | Contact phone number (optional) |
FechaNacimiento | DateOnly | Yes | Date of birth |
The
required keyword is a C# 11+ feature that ensures these properties must be initialized when creating an instance.Medico (Doctor)
Represents a medical doctor with a specialty assignment.Models/Entities/Medico.cs
| Property | Type | Required | Description |
|---|---|---|---|
Id | int | Yes (auto) | Unique identifier |
Nombre | string | Yes | Doctor’s first name |
Apellido | string | Yes | Doctor’s last name |
NumeroLicencia | string | Yes | Medical license number |
Telefono | string? | No | Contact phone number (optional) |
EspecialidadId | int | Yes | Foreign key to Especialidad |
- Each doctor belongs to one specialty (
EspecialidadIdforeign key) - One-to-many: One specialty can have many doctors
Especialidad (Specialty)
Represents a medical specialty.Models/Entities/Especialidad.cs
| Property | Type | Required | Description |
|---|---|---|---|
Id | int | Yes (auto) | Unique identifier |
Nombre | string | Yes | Specialty name (e.g., “Cardiología”) |
- Cardiología (Cardiology)
- Pediatría (Pediatrics)
- Medicina General (General Medicine)
- Dermatología (Dermatology)
- Neurología (Neurology)
- Traumatología (Traumatology)
Cita (Appointment)
Represents a scheduled medical appointment.Models/Entities/Cita.cs
| Property | Type | Required | Description |
|---|---|---|---|
Id | int | Yes (auto) | Unique identifier |
PacienteId | int | Yes | Foreign key to patient |
MedicoId | int | Yes | Foreign key to doctor |
Costo | decimal | Yes | Appointment cost |
Motivo | string | Yes | Reason for the appointment |
FechaInicio | DateTime | Yes | Appointment start time |
FechaFin | DateTime | Yes | Appointment end time |
Observaciones | string? | No | Additional notes (optional) |
Estado | CitaEstado | Yes | Current appointment status |
- Each appointment belongs to one patient (
PacienteIdforeign key) - Each appointment belongs to one doctor (
MedicoIdforeign key)
Enumerations
CitaEstado (Appointment Status)
Defines the lifecycle states of an appointment.Models/Enums/CitaEstado.cs
| Value | Name | Description | Use Case |
|---|---|---|---|
| 0 | Pendiente | Newly created appointment | Initial state when created |
| 1 | Confirmada | Patient/doctor confirmed | After confirmation call/email |
| 2 | Cancelada | Appointment cancelled | Patient no-show or cancellation |
| 3 | Completada | Appointment completed | After the visit is finished |
Data Transfer Objects (DTOs)
CreatePacienteDto
Used when creating a new patient.Models/Dtos/CreatePacienteDto.cs
Notice there’s no
Id field - IDs are auto-generated by the service layer.PacienteResumenDto
Lightweight patient representation for nested inclusion in other DTOs.Models/Dtos/PacienteResumenDto.cs
CreateMedicoDto
Used when creating a new doctor.Models/Dtos/CreateMedicoDto.cs
MedicoResumenDto
Lightweight doctor representation for nested inclusion.Models/Dtos/MedicoResumenDto.cs
CreateEspecialidadDto
Used when creating a new specialty.Models/Dtos/CreateEspecialidadDto.cs
CreateCitaDto
Used when scheduling a new appointment.Models/Dtos/CreateCitaDto.cs
CitaDto
Enriched appointment representation with nested patient and doctor information.Models/Dtos/CitaDto.cs
CitaDto includes full patient and doctor details instead of just IDs, making it more convenient for clients to display appointment information without additional API calls.Entity Relationships
- One
Especialidadhas manyMedico - One
Medicohas manyCita - One
Pacientehas manyCita - Each
Citabelongs to oneMedicoand onePaciente
Validation Considerations
While the entity models use C#‘srequired keyword for compile-time safety, production APIs should add:
Data Annotations
Business Rules
Implement in the service layer:- Email uniqueness validation
- DNI format and uniqueness validation
- Date range validation (appointment end > start)
- Doctor availability checking
- Past date validation for appointments
Next Steps
Services
Learn how services work with these models
API Reference
See these models in action in the API
DTOs Documentation
Complete DTO reference with examples
Development Guide
Learn how to extend the data models