Providers
Provider and contract management with location associations
Overview
The Providers feature manages external service providers, their contracts, location associations, and integration credentials. It supports provider types, activation tracking, API integration, and comprehensive notes for provider relationships.
Key Features
Provider Management
- Provider Profiles: Complete provider information including contact details and address
- Provider Types: Categorize providers (Agency, Vendor, Partner, etc.)
- API Integration: Store API credentials (username, password, API keys, tokens)
- Active Status: Track active/inactive providers
- API Support Flag: Indicate if provider supports API integration
Location Associations
- LocationProvider Junction: Link providers to specific locations
- Activation Tracking: Record who activated provider at each location and when
- Deactivation Tracking: Record who deactivated provider and when
- Multiple Locations: One provider can serve multiple locations
- Multiple Providers: One location can have multiple providers
Contract Management
- ProviderContract: Track contracts between tenant and providers
- Contract Details: Terms, dates, and agreement information
- Provider Relationship: Link contracts to specific providers
Notes and Documentation
- ProviderNote: Store notes about providers
- User Attribution: Track who created each note
- Timestamps: Automatic note timestamping
Database Models
Provider Model
model Provider {
id String @id @default(cuid())
createdAt DateTime @default(now())
tenantId String
tenant Tenant @relation(fields: [tenantId], references: [id])
createdByUserId String?
createdByUser User? @relation("createdByUser", fields: [createdByUserId], references: [id])
lastModifiedByUserId String?
lastModifiedByUser User? @relation("modifiedByUser", fields: [lastModifiedByUserId], references: [id])
name String
accountNumber String
email String
phone String
contactName String
addressLine1 String
addressLine2 String
city String
state String
postalCode String
country String
username String
password String
apiKey String
token String
type String @default("Agency")
notes String
allowsApi Boolean @default(false)
active Boolean @default(true)
LocationProvider LocationProvider[]
ProviderContract ProviderContract[]
ProviderNote ProviderNote[]
}LocationProvider Model
Association between providers and locations:
model LocationProvider {
id String @id @default(cuid())
createdAt DateTime @default(now())
tenantId String
tenant Tenant @relation(fields: [tenantId], references: [id])
locationId String
location Location @relation(fields: [locationId], references: [id])
providerId String
provider Provider @relation(fields: [providerId], references: [id])
activatedOn DateTime @default(now())
activatedById String?
activatedBy User? @relation("providerActivatedBy", fields: [activatedById], references: [id])
deactivatedOn DateTime?
deactivatedById String?
deactivatedBy User? @relation("providerDeactivatedBy", fields: [deactivatedById], references: [id])
}ProviderContract Model
model ProviderContract {
id String @id @default(cuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
tenantId String
tenant Tenant @relation(fields: [tenantId], references: [id])
providerId String
provider Provider @relation(fields: [providerId], references: [id])
title String
details String @db.NVarChar(max)
startDate DateTime
endDate DateTime?
value Decimal?
status String @default("active")
}ProviderType Model
model ProviderType {
id String @id @default(cuid())
createdAt DateTime @default(now())
name String
order Int @default(0)
}ProviderNote Model
model ProviderNote {
id String @id @default(cuid())
createdAt DateTime @default(now())
providerId String
provider Provider @relation(fields: [providerId], references: [id])
content String @db.NVarChar(max)
createdByUserId String?
createdByUser User? @relation(fields: [createdByUserId], references: [id])
}Provider Types
Common provider types (configurable):
- Agency: Third-party agencies providing services
- Vendor: Product or service vendors
- Partner: Strategic business partners
- Consultant: Professional consultants
- Contractor: Independent contractors
Provider types can be managed via ProviderType model with custom ordering.
Location-Provider Associations
Activation Flow
- Create LocationProvider record
- Set
activatedOnto current date - Record
activatedByIdfor audit trail - Provider becomes active at that location
Deactivation Flow
- Update LocationProvider record
- Set
deactivatedOnto current date - Record
deactivatedByIdfor audit trail - Provider no longer active at that location
Tracking Benefits
- Audit Trail: Complete history of provider activations/deactivations
- User Attribution: Know who made each change
- Temporal Queries: Query active providers as of any date
- Reporting: Provider utilization reports by location and time period
API Integration
Credentials Storage
Providers can store API integration credentials:
{
username: string; // API username
password: string; // API password
apiKey: string; // API key
token: string; // Auth token
allowsApi: boolean; // Flag if API is supported
}Security Considerations
- Encryption: Credentials should be encrypted at rest
- Access Control: Limit who can view/edit credentials
- Rotation: Implement credential rotation policies
- Audit Logging: Log all credential access
Contract Management
Contract Lifecycle
- Create Contract: Define terms, dates, and value
- Active Status: Track contract status (active, expired, terminated)
- End Date: Optional end date for term-limited contracts
- Value Tracking: Store contract value in decimal format
- Details: Rich text field for contract specifics
Contract Queries
Common queries:
- Active contracts for a provider
- Contracts expiring soon
- Total contract value by provider
- Contracts by status
Notes and Documentation
Provider Notes
Store contextual information about providers:
- Communication logs
- Service quality notes
- Issue tracking
- Performance observations
- Contact preferences
Note Features
- User Attribution: Track note creators
- Timestamps: Automatic creation timestamps
- Rich Content: Support for detailed text content
- Provider Association: Notes linked to specific providers
Best Practices
- Complete Profiles: Fill all provider contact information
- Credential Security: Treat API credentials as sensitive data
- Active Status: Keep provider active status current
- Location Associations: Document provider-location relationships
- Contract Tracking: Maintain accurate contract records
- Note Taking: Document important provider interactions
- Type Classification: Use consistent provider types
- Audit Trail: Review activation/deactivation history regularly
Common Operations
Create Provider
- Enter provider details (name, contact, address)
- Set provider type
- Add account number and contact name
- Configure API credentials if applicable
- Set active status
- Save provider profile
Associate Provider with Location
- Select provider and location
- Create LocationProvider record
- Set activation date (defaults to now)
- Record activating user
- Provider now active at location
Deactivate Provider at Location
- Find LocationProvider record
- Set deactivation date
- Record deactivating user
- Provider no longer active at that location
Create Provider Contract
- Select provider
- Enter contract title and details
- Set start date and optional end date
- Enter contract value
- Set status (active by default)
- Save contract
Add Provider Note
- Navigate to provider profile
- Create new note
- Enter note content
- Save (user and timestamp auto-recorded)
Integration Points
- Locations: Provider-location associations via LocationProvider
- Contracts: Contract management via ProviderContract
- Users: Track creators, modifiers, activators, deactivators
- Tenants: Multi-tenant isolation for provider data
- Notes: Detailed provider documentation
- Types: Categorize providers by type
Reporting and Analytics
Potential reports:
- Active providers by location
- Provider activation history
- Contract value by provider
- Contract expiration schedule
- Provider utilization metrics
- API-enabled vs manual providers
- Provider notes and issue trends

