Purpose: Define the event contracts for asynchronous communication between CL and PM cores, focusing on clinical documentation → charge capture, referral acceptance → care coordination, and financial program cost → outcomes reporting.
Event Contracts
Event 1: clinical_note_finalized
Summary: When a clinical progress note is signed/finalized in CL-04, PM-07 creates a charge capture suggestion.
Payload Schema:
- Validate
encounter_idexists inpm_encounters - Check for duplicate
event_idin processed events (idempotency) - Create charge suggestion in
pm_charge_suggestionswith billing codes, modifiers, duration, and provider - High-risk billing codes (compliance guard): Before auto-posting to
pm_charges, evaluate CPT/HCPCS inevent.payload.billing_codesagainst a curated high-risk list. Default list (same list MUST be used everywhere this guard is implemented; extend only via org config):90839,90840,90785,H0038,H2035,H0004,T1017,96127. Org customization:pm_module_settings.auto_post_high_risk_codes_list(text[] or JSON array of codes) replaces the default when set; empty array = use default. Definition — “high-risk”: codes that (a) require strong clinical documentation / medical necessity evidence, (b) draw payer or regulatory audit scrutiny, or (c) commonly require prior authorization — orgs SHOULD align overrides with their compliance policy.- Add boolean
auto_post_high_risk_codestopm_module_settings(defaultfalse). - Auto-post to
pm_chargesonly when:orgSettings.auto_post_enabled === trueAND (no high-risk code in payload ORorgSettings.auto_post_high_risk_codes === true). - Otherwise create or update
pm_charge_suggestionsfor manual review (PF-10 notify billing as today).
- Add boolean
- If auto-post rules pass, create
pm_chargesdirectly - Send PF-10 notification to billing staff if manual review required
Event 2: referral_accepted
Summary: When PM accepts an inbound referral, CL-12 creates a care coordination transition record.
Payload Schema:
- Check if
cl_patient_chartsexists for patient; if not, flag for chart creation - Create
cl_care_transitionsrecord with referral context - Assign care coordinator via CL-12 assignment rules
- Send PF-10 notification to accepting provider and care coordinator
Event 3: clinical_program_cost_allocated
Summary: When FA allocates program costs, CL-10 outcomes can correlate clinical outcomes with financial investment.
Payload Schema:
- Store cost data in CL-10 outcomes context for cost-effectiveness reporting
- Update CL-15 program quality dashboard with cost-per-outcome metrics
- No direct database writes to FA tables (read-only consumption)
Event 4: cl_crisis_episode_resolved
Summary: When a crisis episode is dispositioned with an assigned billing code (CL-13), PM-07 creates a crisis-specific charge suggestion and links it to the episode for audit.
Payload Schema:
- Idempotency: same pattern as
progress_note_signedusingmetadata.event_idinfw_domain_events - Create crisis-specific
pm_charge_suggestionwithbilling_code,service_date,rendering_provider_id - For S9484 / H2011 and similar time-based codes, derive units from
duration_minutesper org/payer rules inpm_module_settings(or PM-07 configuration) - Link suggestion to
cl_crisis_episodesviaentity_idon suggestion metadata / extension table (implementation-specific) for audit - Apply the same high-risk auto-post guard as Event 1 when codes overlap the high-risk list
event_id as the dedupe key; duplicates must not create a second suggestion.
Idempotency
All event handlers implement the following idempotency pattern:Dead-Letter Queue
Failed events follow the DLQ pattern from ADR-004:- On failure: write to
fw_domain_eventswithstatus = 'failed', error message, retry count - Cron edge function retries failed events (exponential backoff: 1s, 2s, 4s; max 3 retries)
- After final failure: PF-10 notification to system admin
- No retry on 4xx errors (except 429 rate limit)
E2E Test Plan
Related Documents
- EVENT_CONTRACTS.md — Canonical event schema and channel registry
- ADR-004: CL-FW Event Patterns — Channel routing decision
- ADR-002: CL-PM Cross-Core Foreign Keys — FK exception for
pm_encounters - CL-PM-ENCOUNTER-TO-BILLING.md — Existing encounter-to-billing contract
- CL-PM-EPISODE-OF-CARE-INTEGRATION.md — Episode of care lifecycle
- CL-FA-VBP-QUALITY-DATA-PIPELINE.md — CL-FA quality data flow
- constitution.md §1.3 — No direct core-to-core imports; use Platform Integration Layer