What are Providers?

- The same person can be a provider in one clinic but not in another
- Each provider has their own schedule and service assignments per clinic
- Provider availability is calculated by intersecting clinic hours with provider hours
Provider Architecture
Multi-Tenant Model
Providers are managed through the
UserClinic relationship with is_provider=True. This allows flexible team configurations across clinics.Per-Clinic Configuration
Each provider has independent schedules, service assignments, and availability settings for each clinic they work in.
Work Hours Intersection
Provider availability is calculated by intersecting clinic hours with provider-specific hours (providers cannot work when clinic is closed).
Service Assignment
Providers are assigned to specific services, enabling specialized scheduling and availability filtering.
Key Concepts
Provider Status (is_provider)
Located in the user_clinics table, this boolean flag determines if a user is a provider:
Provider Work Hours
Providers can have custom work hours that differ from clinic hours:Clinic Hours: 08:00-20:00, Provider Hours: 09:00-17:00
Clinic Hours: 08:00-20:00, Provider Hours: 09:00-17:00
Result: Provider can only see patients from 09:00-17:00 (intersection).The system calculates effective availability by intersecting the two time ranges:
Clinic Hours: 09:00-13:00, 15:00-19:00, Provider Hours: 10:00-18:00
Clinic Hours: 09:00-13:00, 15:00-19:00, Provider Hours: 10:00-18:00
Result: Provider works 10:00-13:00 and 15:00-18:00 (intersection with both clinic periods).The system handles multiple non-contiguous periods:
Clinic Closed Saturday, Provider Hours: 09:00-22:00 Saturday
Clinic Closed Saturday, Provider Hours: 09:00-22:00 Saturday
Result: NO availability on Saturday (clinic hours take precedence).Business Rule: If clinic has no work_hours for a weekday, NO appointments are allowed regardless of provider availability.
Service Assignment
Providers are linked to services they can deliver:1
Create Service
Define a service (e.g., “Haircut”, “Consultation”) with duration and price.
2
Assign Provider
Link the provider to the service via the
Service.provider_id foreign key.3
Availability Filtering
When patients request this service, only slots from the assigned provider are shown.
Provider Lifecycle
Common Use Cases
Part-Time Provider
Scenario: Provider works mornings only (09:00-13:00).Setup: Create provider work_hours for Monday-Friday 09:00-13:00. Clinic can operate full day, but this provider only sees patients in the morning.
Specialist Provider
Scenario: Dentist specializes in orthodontics only.Setup: Assign provider ONLY to “Orthodontic Consultation” service. They won’t appear for “General Dental Cleaning” appointments.
Multi-Clinic Provider
Scenario: Provider works at Clinic A (full-time) and Clinic B (weekends only).Setup:
- Clinic A:
is_provider=true, work_hours Monday-Friday 09:00-18:00 - Clinic B:
is_provider=true, work_hours Saturday-Sunday 10:00-16:00
Provider on Leave
Scenario: Provider on vacation for 2 weeks.Setup: Create a closure (provider-specific) for the vacation period. System automatically excludes this provider’s availability during closure.
Provider Access Patterns
From Code (Services/API)
From AuthenticatedUser
Database Schema
user_clinics Table
work_hours Table (Provider-Specific)
Important Notes
Work Hours Hierarchy
Work Hours Hierarchy
Clinic Hours Define Operational Window:
- Clinic hours define when the clinic is open (e.g., 08:00-20:00)
- Provider hours must intersect with clinic hours
- If clinic is closed (no clinic-level work_hours for weekday), NO appointments allowed regardless of provider availability
- Clinic closed Saturday (no work_hours entry)
- Provider has work_hours Saturday 09:00-17:00
- Result: NO availability on Saturday (clinic closed)
Multiple Non-Contiguous Periods
Multiple Non-Contiguous Periods
Providers (and clinics) can have multiple time periods per day:Valid Configuration:System Behavior: Slots are generated ONLY within valid periods, NOT in gaps.
Overlap Validation
Overlap Validation
The system prevents overlapping work hours:Invalid Configuration:Validation: Two periods overlap if
A_start < B_end AND B_start < A_end.Contiguous Periods OK: 09:00-13:00 and 13:00-17:00 is valid (A_end == B_start).