Skip to main content
Version: 1.0 Last Updated: 2026-05-11 Status: ✅ Complete Spec: PM-35 Encounter-Level Cost Accounting Constitution Reference: Section 1.2 (Core Independence), Section 1.3 (Integration Patterns)

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:
  1. Validates auto_calculate_encounter_cost = true in pm_module_settings
  2. Looks up effective cost rates for service_date, site_id, and provider_id
  3. Calculates cost_breakdown and total_cost per rate_unit rules (spec § Rate Calculation Rules C-8)
  4. Snapshots charge_amount from pm_charges for the encounter (C-2)
  5. Inserts pm_encounter_costs with status = 'calculated'
  6. Publishes encounter_cost_calculated event 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