> ## Documentation Index
> Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt
> Use this file to discover all available pages before exploring further.

# CE 63 pipeline stage transition INTEGRATION

# CE-63: Pipeline Stage Transition Workflow — Integration Documentation

**Spec:** `specs/ce/specs/CE-63-pipeline-stage-transition-workflow.md`\
**Status:** 📝 Planned\
**Last Updated:** 2026-05-16

***

## Overview

CE-63 adds **guarded stage transitions** on the lead pipeline: prompt dialogs for scheduled stages, a closure form for terminal failure, and a confirmation step for terminal success. Cross-core effects are limited to **published events** and intra-core CE tables — no direct RH/PM imports from CE React code.

***

## Integration Pattern

**Pattern:** Event-Based Integration (Pattern 2 — constitution §1.3) for conversion; intra-core writes for audit and referral tracking.

***

## Event Contracts (reuse CE-29)

| Event                           | Role in CE-63                                                                                                                                                                                                |
| ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `ce_lead_converted_to_resident` | **Required** on terminal success confirm. Canonical RH handoff signal per [EVENT\_CONTRACTS](./EVENT_CONTRACTS.md#ce_lead_converted_to_resident). Payload remains **IDs only** (no PHI, no free-text notes). |
| `ce_lead_converted`             | **Do not use** for new CE-63 work — deprecated in favor of direction-specific events.                                                                                                                        |

**Publisher:** CE lead mutation / workflow layer (same stack as CE-29).\
**Subscribers:** RH-01 (resident/admission), PM-39 (waitlist), analytics — unchanged from CE-29.

***

## Intra-core integrations

| Target                  | Mechanism                       | Notes                                                                           |
| ----------------------- | ------------------------------- | ------------------------------------------------------------------------------- |
| CE-60 Audit             | Service or shared audit helper  | Message pattern: `Lead closed — {reason_label}`                                 |
| CE-19 Referral outcomes | Insert/update via CE data layer | When `referral_given = true`, persist outbound partner linkage per CE-19 schema |
| PF-15                   | Picklist resolution             | Closure reasons and appointment types                                           |

***

## Security & tenancy

* All writes scoped by `organization_id`.
* RLS on `ce_lead_closures` uses existing `ce_has_org_access` pattern.
* UI mutations: `.eq('organization_id', orgId)` defense-in-depth.

***

## Contract validation checklist

* [ ] `KnownEventName` / workflow catalog includes only reused events (no rename).
* [ ] E2E verifies emitted payload matches CE-29 schema (keys present, no unexpected PHI fields).
* [ ] `npm run audit:integration-contracts` passes after matrix update.

***

## References

* CE-29 Lead Conversion Integration (see CE-17 spec)
* [CE-17 Spec](../../../specs/ce/specs/CE-17-ce-rh-admission-handoff.md)
* [CROSS\_CORE\_INTEGRATIONS.md](./CROSS_CORE_INTEGRATIONS.md) (CE-63 row)
