Treatments API
The Treatments API allows you to manage the catalog of dental services offered by the clinic. Services can include consultations, procedures, treatments, and any billable items.Services are also referred to as “treatments” in the API. The endpoint is
/api/treatments but manages the services catalog.Endpoints
List All Services
Retrieve all services/treatments in the catalog.List of all services in the catalog
Create Service
Create a new service in the catalog.MANAGE_TREATMENTS
Request Body
Service name
Service description (optional)
Service price (decimal value)
400 Bad Request- Missing required fields (name or price)401 Unauthorized- Not authenticated or not admin500 Internal Server Error- Database error
Update Service
Update an existing service.MANAGE_TREATMENTS
Request Body
Service ID to update
Updated service name
Updated description (optional)
Updated price
Delete Service
Delete a service from the catalog.MANAGE_TREATMENTS
Request Body
Service ID to delete
Database Schema
Services are stored in theservices table:
| Column | Type | Description |
|---|---|---|
| id | INT | Primary key, auto-increment |
| name | VARCHAR(100) | Service name |
| description | TEXT | Service description |
| price | DECIMAL(10,2) | Service price |
| created_at | TIMESTAMP | Creation timestamp |
Stored Procedures
The API uses these stored procedures:sp_list_services()- Lists all servicessp_create_service(name, description, price)- Creates a new servicesp_update_service(id, name, description, price)- Updates a servicesp_delete_service(id)- Deletes a service
Use Cases
Patient Budget Creation
Services are used when creating budgets for patients:Financial Reporting
Services appear in financial reports to show revenue by service type:Related Endpoints
Reports API
Service revenue and performance reports
Patients API
Patient budgets and treatment plans
Error Messages
Common error messages returned by this endpoint:| Message | Cause |
|---|---|
| ”No autorizado” | User not authenticated or not admin |
| ”Faltan datos” | Missing required fields (name, price, or id) |
| “ID faltante” | Missing service ID in DELETE request |
| ”Error al cargar servicios” | Database error on GET |
| ”Error al crear servicio” | Database error on POST |
| ”Error al actualizar servicio” | Database error on PUT |
| ”Error al eliminar servicio” | Database error on DELETE |
Source Code Reference
Implementation:src/routes/api/treatments/+server.js