# Free Consultation Infrastructure

This module manages the infrastructure required for free consultation procedures in the MetaEstetics system.

## Overview

The free consultation feature allows practitioners to offer complimentary initial consultations to patients. This requires specific infrastructure components to be present in the database.

## Infrastructure Components

The system creates the following components when `freeConsultationInfrastructure()` is called:

### 1. Category: "consultation"
- **ID**: `consultation`
- **Name**: Consultation
- **Description**: Professional consultation services for treatment planning and assessment
- **Family**: AESTHETICS

### 2. Subcategory: "free-consultation"
- **ID**: `free-consultation`
- **Name**: Free Consultation
- **Description**: Complimentary initial consultation to discuss treatment options and assess patient needs
- **Parent Category**: consultation

### 3. Technology: "free-consultation-tech"
- **ID**: `free-consultation-tech`
- **Name**: Free Consultation Technology
- **Description**: Technology framework for providing free initial consultations to patients
- **Requirements**: No pre/post requirements
- **Certification**: Minimum level AESTHETICIAN

### 4. Product: "free-consultation-product"
- **ID**: `free-consultation-product`
- **Name**: Free Consultation Service
- **Description**: No physical product required for consultation services
- **Brand**: Consultation Services
- **Type**: Virtual service

## Usage

### Ensuring Infrastructure Exists

```typescript
import { freeConsultationInfrastructure } from './free-consultation-utils.admin';

// Ensure infrastructure exists before creating consultation procedures
const infrastructureExists = await freeConsultationInfrastructure();
```

### Creating Free Consultation Procedures

The infrastructure is automatically checked and created when practitioners enable free consultations through the `PractitionerService.EnableFreeConsultation()` method.

## Error Handling

If you encounter the error:
```
Product with ID free-consultation-product not found for technology free-consultation-tech
```

This indicates that the infrastructure was not properly created. The system will automatically attempt to create the missing infrastructure when the error occurs.

## Database Structure

```
categories/
  consultation/
    subcategories/
      free-consultation/

technologies/
  free-consultation-tech/
    products/
      free-consultation-product/
```

## Notes

- The infrastructure is created atomically using Firestore batch operations
- All components are created with `isActive: true`
- The system checks for existing infrastructure before attempting to create new components
- No physical products are required for consultation procedures
