Overview
PM-35 adds encounter-level cost accounting to the Practice Management core: cost category configuration, rate management, automatic cost calculation on encounter completion, and margin reporting. It integrates with PM-07 (charge snapshot for margin), PM-25 (VBP cost benchmarking), and FA-35 (cost allocation) via an event contract.Integration Points (from spec)
Data Source Tables (PM-35)
Event Contract: encounter_cost_calculated
Publisher: PM (edge function pm-calculate-encounter-cost, triggered on encounter_completed)
Subscriber: FA-35 (cost allocation / program cost reporting)
Status: 📝 Payload schema documented in EVENT_CONTRACTS.md (encounter_cost_calculated entry). Outstanding: FA-35 consumer confirmation of cost_breakdown field shape (see PENDING_CONTRACTS.md).
Draft payload:
Schema pending: Finalize in EVENT_CONTRACTS.md entry during Phase 2 task generation. FA-35 team must confirm consumption fields before publishing.
Trigger Mechanism
Auto-cost-calculation is driven by an edge function (supabase/functions/pm-calculate-encounter-cost/index.ts) triggered by the encounter_completed event:
- Validates
auto_calculate_encounter_cost = trueinpm_module_settings - Looks up effective cost rates for
service_date,site_id, andprovider_id - Calculates
cost_breakdownandtotal_costper rate_unit rules (spec § Rate Calculation Rules C-8) - Snapshots
charge_amountfrompm_chargesfor the encounter (C-2) - Inserts
pm_encounter_costswithstatus = 'calculated' - Publishes
encounter_cost_calculatedevent for FA
Dependency (Plan A-3): Confirm encounter_completed event is already published by PM-03/PM-07 before Phase 2 implementation begins.
Platform Layer Usage
Open Items
References
- PM-35 Spec:
specs/pm/specs/PM-35-encounter-level-cost-accounting.md - PM-35 Plan:
specs/pm/plans/PM-35-encounter-level-cost-accounting-PLAN.md - PM-25 VBP Integration:
docs/architecture/integrations/PM-25-VBP-APM-INTEGRATION.md - EVENT_CONTRACTS.md:
docs/architecture/integrations/EVENT_CONTRACTS.md(encounter_cost_calculated — pending) - PENDING_CONTRACTS.md:
docs/architecture/integrations/PENDING_CONTRACTS.md