Version: 1.0.0Documentation Index
Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt
Use this file to discover all available pages before exploring further.
Last Updated: 2025-12-31
Owner: Platform Foundation (PF)
Purpose
This guide documents the organizational data structure across the Encore Health OS Platform. It defines when to use each entity, how they relate, and best practices for implementation. Related Documents:- Constitution:
constitution.mdSection 5.2.2 - AI Guide:
AI_GUIDE.mdSection “Organizational Data Management” - Unified Analysis:
specs/pf/UNIFIED_ORGANIZATIONAL_DATA_ANALYSIS.md - Implementation Plan:
specs/pf/ORGANIZATIONAL_DATA_IMPLEMENTATION_PLAN.md
Platform Foundation Organizational Entities
pf_organizations
Purpose: Top-level tenants in the multi-tenant system.
Usage:
- Every business table includes
organization_idfor tenant isolation - RLS policies enforce organization boundaries
- Users can belong to multiple organizations
- Always include
organization_idin business tables - Reference in RLS policies for tenant isolation
pf_sites
Purpose: Physical work locations within organizations.
Fields:
id,organization_id,name,slugtax_jurisdiction- For payroll tax calculationaddress_line_1,address_line_2,city,state,zip_code,countrytimezone- For time-based policies
- ✅ Always include
site_idwhen entity is location-specific:- Residences, work orders, assets
- Site-specific policies, forms, training
- Site-based operations (episodes, attendance)
- ❌ Do NOT include
site_idwhen entity is organization-wide:- Strategic goals, vision statements
- Organization-level settings
- Cross-site teams (some cases)
- Use
primary_site_idfor employee work location (NOTwork_locationTEXT) - Enhance sites with tax jurisdiction for payroll
- Use site timezone for time-based policies
pf_departments
Purpose: Unified organizational units for both HR and Finance.
Fields:
id,organization_id,site_idname,code,parent_department_id(hierarchical)department_type- ‘operational’ | ‘cost_center’ | ‘both’- HR fields:
department_head_id,is_clinical - FA fields:
cost_center,cost_allocation_method
- ✅ Always use
pf_departments(NOThr_departmentsorfa_departments) - ✅ For employee organization (HR)
- ✅ For cost allocation (FA)
- ✅ For department-based policies (GR)
- ✅ For department-based access control
- Set
department_typebased on usage:- ‘operational’ - Used for HR/employee organization
- ‘cost_center’ - Used for FA/cost allocation
- ‘both’ - Used for both purposes
- Use hierarchical structure via
parent_department_id - Link to
pf_sitesfor site-specific departments
pf_levels
Purpose: Employee classification for policy assignment and access control.
Fields:
id,organization_idlevel_name- ‘Executive’, ‘Manager’, ‘Individual Contributor’level_code- ‘EXEC’, ‘MGR’, ‘IC’level_rank- 1-10 (1 = highest, 10 = lowest)
- ✅ For level-based policy assignment (spend policies, access)
- ✅ For reporting and analytics (compensation by level)
- ✅ For formula fields (e.g., “all employees with level_rank <= 3”)
- ✅ For access control (executives get different access)
- Assign
level_idto all employees - Use
level_rankfor ordering and comparisons - Create default levels: Executive (1), Manager (5), Individual Contributor (10)
pf_positions
Purpose: Job title library for consistency across modules.
Fields:
id,organization_idtitle,code,descriptionis_clinical- For credential requirements
- ✅ For employee job titles (HR)
- ✅ For training assignments (GR)
- ✅ For form field lookups (FW)
- ✅ For reporting and analytics
- Maintain position library for consistency
- Use
is_clinicalto drive credential requirements - Reference in
hr_employees.position_id
pf_teams
Purpose: Cross-functional groups for projects and collaboration.
Fields:
id,organization_idname,descriptionteam_lead_id- Referenceshr_employees
- ✅ For cross-functional projects (HR, GR, FW, LO)
- ✅ For team-based policies (GR)
- ✅ For form access control (FW)
- ✅ For goal assignment (LO)
- Use for temporary or project-based groups
- Link to
pf_departmentsif team is department-specific - Reference via
hr_team_membersjunction table
Module-Specific Organizational Entities
rh_programs (Recovery Housing)
Purpose: Operational/resident programs for phase management.
Fields:
id,organization_id,site_idname,program_type,duration_baseline_dayscapacity_limit,eligibility_criteria
- ✅ For resident program structure
- ✅ For phase management
- ✅ For program-specific forms and workflows
- Optional:
fa_programs.rh_program_idfor financial tracking
fa_programs (Finance)
Purpose: Financial/cost reporting programs for Medicaid and grants.
Fields:
id,organization_idcode,name,department_idis_revenue_generating
- ✅ For Medicaid cost reporting
- ✅ For grant tracking
- ✅ For revenue/expense allocation
- Optional:
rh_program_idto link to operational programs
fa_funds (Finance)
Purpose: Fund accounting (restricted/unrestricted).
Fields:
id,organization_idfund_code,name,fund_type
- ✅ For fund accounting
- ✅ For grant management
- ✅ For financial reporting
Integration Patterns
Policy Assignment
Level-Based Policies:Access Control
Level-Based Access:Financial Integration
Department Cost Allocation:Migration Guide
From Duplicate Departments
Before:hr_departmentsfor employee organizationfa_departmentsfor cost centers- No integration between them
pf_departmentsunified tabledepartment_typefield distinguishes usage- Single source of truth
- Create
pf_departmentstable - Migrate
hr_departments→pf_departments(type: ‘operational’) - Migrate
fa_departments→pf_departments(type: ‘cost_center’ or ‘both’ if duplicate) - Update foreign keys
- Create backward-compatible views
From Work Location TEXT
Before:hr_employees.work_location TEXT(unstructured)hr_employees.primary_site_id(structured)
hr_employees.primary_site_idonlypf_sitesenhanced with address, tax jurisdiction
- Enhance
pf_siteswith address fields - Create sites from unique
work_locationTEXT values - Update
primary_site_idto reference new sites - Deprecate
work_locationTEXT field
Best Practices
When Creating New Features
-
Always use Platform Foundation entities:
pf_departments(not core-specific)pf_sites(not TEXT fields)pf_levels(for policy assignment)pf_positions(for job titles)pf_teams(for cross-functional groups)
-
Include
site_idwhen location matters:- Residences, work orders, assets
- Site-specific policies, forms, training
- Site-based operations
-
Consider organizational context:
- Policy assignment (level, site, department)
- Access control (level, site, department)
- Financial integration (department, program)
-
Document relationships:
- Optional relationships (e.g.,
fa_programs.rh_program_id) - Hierarchical structures (e.g.,
parent_department_id) - Many-to-many relationships (e.g.,
hr_team_members)
- Optional relationships (e.g.,
Common Patterns
Employee Organizational Context
Department Hierarchy
Site-Based Filtering
References
- Constitution:
constitution.mdSection 5.2.2 - AI Guide:
AI_GUIDE.mdSection “Organizational Data Management” - Unified Analysis:
specs/pf/UNIFIED_ORGANIZATIONAL_DATA_ANALYSIS.md - Implementation Plan:
specs/pf/ORGANIZATIONAL_DATA_IMPLEMENTATION_PLAN.md - HR-01 Spec:
specs/hr/HR-01-employee-directory.md - FA-01 Spec:
specs/fa/FA-01-chart-of-accounts.md - PF-01 Spec:
specs/pf/PF-01-organization-site-management.md
Last Updated: 2025-01-27