Skip to main content
Version: 1.0.0 Last Updated: 2026-02-17 Constitution Reference: Section 1.2 (Core Independence), Section 1.3 (Integration Patterns) Source: CL-PM-SPEC-REVIEW Findings 2.1, 5.1

Overview

This contract defines how clinical documentation (CL core) triggers charge capture (PM core) without direct cross-core dependencies. Both CL and PM depend only on Platform Foundation (PF). Integration uses Pattern 2: Event-Based from the constitution.

Encounter Entity

Problem

No spec in CL or PM defines a formal encounter entity. The encounter is the central concept linking appointments, clinical notes, charges, and claims but currently exists only as scattered references:
  • pm_charges.encounter_id UUID (nullable, no FK)
  • CL-04 progress notes function as encounter records
  • PM-03 appointments transition to encounters implicitly

Solution: pm_encounters Table

The encounter entity lives in PM (owned by PM-03) because encounter lifecycle tracks the business/operational flow. CL adds clinical content to encounters via events.

Encounter Lifecycle


Event Contract: clinical_note_finalized

Event: clinical_note_finalized Channel: cl_pm_events Publisher: CL (Clinical & EHR) — CL-04 Progress Notes Subscribers: PM (Practice Management) — PM-07 Charge Capture Status: 📝 Planned

Trigger

When a progress note transitions to signed or cosigned status in cl_progress_notes.

Payload Schema

Implementation

Consumer: PM-07 Charge Capture

Edge Function: supabase/functions/cl-note-charge-capture/index.ts Consumer responsibilities:
  1. Receive clinical_note_finalized event
  2. Check idempotency_key — skip if charge already exists for this note
  3. Look up fee schedule for provider’s payer/plan
  4. Calculate AHCCCS timed units from duration_minutes
  5. Apply auto-modifiers (HQ for group, GT/95 for telehealth, etc.)
  6. Create pm_charges record with status pending
  7. Update pm_encounters.charge_captured_at and status
  8. Log to pf_audit_logs

Error Handling


Event Contract: charge_status_changed

Event: charge_status_changed Channel: pm_events Publisher: PM — PM-07 Charge Capture Subscribers: CL (for status visibility on chart) Status: 📝 Planned

Payload Schema


Cross-Reference