# Backoffice Services

This directory contains services used by the backoffice application.

## Services

### `CategoryService`

Manages procedure categories. Categories are the first level of organization after procedure family (aesthetics/surgery).

- **`create(category)`**: Creates a new category.
- **`getAll()`**: Retrieves all active categories.
- **`getAllByFamily(family)`**: Retrieves all active categories for a specific procedure family.
- **`update(id, category)`**: Updates an existing category.
- **`delete(id)`**: Soft deletes a category.
- **`getById(id)`**: Retrieves a category by its ID.

### `ProductService`

Manages products, which are sub-items of a `Technology`.

- **`create(technologyId, brandId, product)`**: Creates a new product under a technology.
- **`getAllByTechnology(technologyId)`**: Retrieves all products for a technology.
- **`getAllByBrand(brandId)`**: Retrieves all products for a brand.
- **`update(technologyId, productId, product)`**: Updates a product.
- **`delete(technologyId, productId)`**: Soft deletes a product.
- **`getById(technologyId, productId)`**: Retrieves a product by its ID.

### `ConstantsService`

Manages administrative constants like treatment benefits and contraindications.

- **`getTreatmentBenefits()`**: Retrieves all treatment benefits.
- **`addTreatmentBenefit(benefit)`**: Adds a new treatment benefit.
- **`updateTreatmentBenefit(benefit)`**: Updates an existing treatment benefit.
- **`deleteTreatmentBenefit(benefitId)`**: Deletes a treatment benefit.
- **`getContraindications()`**: Retrieves all contraindications.
- **`addContraindication(contraindication)`**: Adds a new contraindication.
- **`updateContraindication(contraindication)`**: Updates an existing contraindication.
- **`deleteContraindication(contraindicationId)`**: Deletes a contraindication.

### `AnalyticsService` (Proposed)

Comprehensive financial and analytical intelligence service for the Clinic Admin app. Provides insights about doctors, procedures, appointments, patients, products, and clinic operations.

**Status**: Proposal phase - See [analytics.service.proposal.md](./analytics.service.proposal.md) for detailed design and implementation plan.

**Planned Features**:
- Practitioner performance analytics (appointments, cancellations, time efficiency, revenue)
- Procedure analytics (popularity, profitability, product usage)
- Appointment time analytics (booked vs actual time, efficiency metrics)
- Cancellation & no-show analytics (by clinic, practitioner, patient, procedure)
- Financial analytics (revenue, costs, payment status, trends)
- Product usage analytics (usage patterns, revenue contribution)
- Patient analytics (lifetime value, retention, appointment frequency)
- Clinic analytics (performance metrics, comparisons)
- Comprehensive dashboard data aggregation
