Overview
Service assignment links providers to the services they can deliver. This enables:- Specialized scheduling: Only show availability for providers who offer the requested service
- Provider filtering: Patients can select specific providers when booking
- Service-based availability: System calculates availability based on provider’s schedule AND service assignment
Per-Service Assignment: Each service can have ONE assigned provider. If multiple providers offer the same service (e.g., “General Consultation”), create separate service entries for each provider.
Prerequisites
1
Services Created
Services must exist before assignment. See Create Service.
2
Provider Configured
Provider must have
is_provider = true and work hours configured.3
Required Permissions
You must have
CLINIC_ADMIN role to assign services.Service Assignment Architecture
Database Schema
Method 1: Assign During Service Creation
When creating a new service, you can immediately assign it to a provider.1
Navigate to Services
Go to Services from the main menu.
2
Click Create Service
Click the Create Service button.
3
Fill Service Details
- Name: Service name (e.g., “Haircut”, “Dental Cleaning”)
- Duration: Service duration in minutes (e.g., 30, 60)
- Price: Service price (optional)
4
Select Provider
In the Provider dropdown, select the provider who will deliver this service.
5
Save Service
Click Create to save the service with provider assignment.
API Request
Response
Method 2: Assign to Existing Service
To assign a provider to an existing service:1
Navigate to Services
Go to Services from the main menu.
2
Find the Service
Locate the service in the list (use search if needed).
3
Click Edit
Click the edit icon on the service card.
4
Select Provider
In the Provider dropdown, select the provider to assign.
5
Save Changes
Click Save to update the service.
API Request
Method 3: Bulk Assign from Provider View
Assign multiple services to a provider from the provider’s detail view.1
Navigate to Providers
Go to Providers from the main menu.
2
Open Provider Details
Click on the provider card to open their details modal.
3
Go to Services Tab
Click the Services tab.
4
Click Assign Services
Click Assign Services button.
5
Select Services
Check the services to assign to this provider (multi-select).
6
Save Assignments
Click Save to update all selected services.

Bulk Assignment: This method updates the
provider_id field for all selected services in a single transaction.Unassigning Services
To remove a provider from a service:1
Open Service Edit Dialog
Navigate to the service and click Edit.
2
Clear Provider Selection
In the Provider dropdown, select “None” or “Any Provider”.
3
Save Changes
Click Save to remove the assignment.
API Request
How Service Assignment Affects Availability
Scenario 1: Service with Assigned Provider
Configuration:- Service: “Dental Cleaning” (30 min, assigned to Dr. García)
- Dr. García work hours: Monday 09:00-17:00
- Clinic hours: Monday 08:00-20:00
- System fetches Dr. García’s work hours (09:00-17:00)
- Intersects with clinic hours (08:00-20:00)
- Effective availability: 09:00-17:00
- Generates slots: 09:00, 09:30, 10:00, …, 16:30
Scenario 2: Service Without Assigned Provider
Configuration:- Service: “General Consultation” (30 min, NO assigned provider)
- Multiple providers available
- System fetches ALL providers with work hours
- Generates availability across all providers
- Patient can book with any available provider
Scenario 3: Multiple Services, Same Provider
Configuration:- Service A: “Haircut” (30 min, assigned to Dr. García)
- Service B: “Hair Coloring” (60 min, assigned to Dr. García)
- Dr. García work hours: Monday 09:00-17:00
- For Haircut: Slots at 09:00, 09:30, 10:00, …, 16:30 (30-min duration)
- For Hair Coloring: Slots at 09:00, 10:00, 11:00, …, 16:00 (60-min duration, needs continuous 60-min window)
Service Assignment Best Practices
Specialized Providers
Specialized Providers
Use Case: Dental clinic with general dentists and orthodontists.Pattern:
- Service: “Dental Cleaning” → Assigned to general dentists (create separate services per dentist)
- Service: “Orthodontic Consultation” → Assigned to orthodontist specialist
- Service: “Emergency Visit” → NO assignment (any provider can handle)
Part-Time Providers
Part-Time Providers
Use Case: Provider works mornings only (09:00-13:00).Pattern:
- Assign specialized services to this provider
- System automatically limits availability to morning slots
- No need to manually filter by time of day
Multi-Provider Services
Multi-Provider Services
Use Case: Multiple providers offer the same service (e.g., “Haircut”).Pattern:
- Create separate services: “Haircut - Dr. García”, “Haircut - Dr. López”
- Assign each to the respective provider
- Patients can choose their preferred provider
Provider on Leave
Provider on Leave
Use Case: Provider is on vacation for 2 weeks.Pattern:
- Do NOT unassign services
- Create a provider-specific closure for the vacation period
- System automatically excludes this provider’s availability during closure
- Services remain assigned, availability resumes after closure ends
Viewing Service Assignments
From Services List
Each service card shows the assigned provider (if any):From Provider View
The provider’s Services tab lists all services assigned to them:API: List Services by Provider
Common Errors
403 Forbidden - Cannot Manage Clinic
403 Forbidden - Cannot Manage Clinic
Cause: You don’t have
CLINIC_ADMIN role in the selected clinic.Solution: Contact your system administrator to grant you CLINIC_ADMIN permissions.404 Not Found - Provider Not Found
404 Not Found - Provider Not Found
Cause: The
provider_id doesn’t exist or the user is not a provider in this clinic.Solution:- Verify the provider ID is correct
- Check
user_clinicstable:is_provider = truefor this clinic? - Ensure you’re using the
user_id, not theuser_clinic_id
400 Bad Request - Service Already Assigned
400 Bad Request - Service Already Assigned
Cause: Attempting to assign a service that’s already assigned to another provider.Solution:
- If you want to reassign: Use PATCH to update the existing service’s
provider_id - If you want multiple providers: Create separate service entries (e.g., “Haircut - Dr. A”, “Haircut - Dr. B”)
Provider Has Services But No Availability
Provider Has Services But No Availability
Cause: Provider has services assigned but no work hours configured.Solution: Navigate to Configure Schedule to add work hours for the provider.
Database Query Examples
Get All Services for a Provider
Get All Providers for a Service (Alternative Architecture)
Note: Current schema supports ONE provider per service. For many-to-many relationship, you would need a junction table:Impact on Appointment Booking
Patient-Facing Booking Flow
- Patient selects service: “Haircut - Dr. García”
- System fetches provider:
provider_id = user-789-xyz-012 - Availability calculated: Only Dr. García’s schedule is considered
- Patient selects time slot: From Dr. García’s available slots
- Appointment created: Linked to service AND provider
WhatsApp Agent Booking Flow
- Patient says: “Quiero una cita para corte de pelo”
- Agent uses ServiceMapper: Fuzzy match “corte de pelo” → “Haircut - Dr. García”
- Agent calls get_availability: Filtered by
provider_idfrom service - Agent shows slots: Only Dr. García’s available times
- Patient confirms: Appointment created with service + provider
Audit Logging
Service assignments are tracked inaudit_logs: