> ## 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.

# Integration Contract — Allergy & Adverse Reaction Tracking

> Spec: ../../../specs/cl/specs/CL-45-allergy-adverse-reaction-tracking.md Status: 📝 Draft (event schemas land with Phase 3) Last Updated: 2026-05-08

**Spec:** [`../../../specs/cl/specs/CL-45-allergy-adverse-reaction-tracking.md`](../../../specs/cl/specs/CL-45-allergy-adverse-reaction-tracking.md)
**Status:** 📝 Draft (event schemas land with Phase 3)
**Last Updated:** 2026-05-08

## Publishers

| Event                         | Channel     | Trigger                                              | Subscribers                                         |
| ----------------------------- | ----------- | ---------------------------------------------------- | --------------------------------------------------- |
| `cl_allergy_recorded`         | `cl_events` | INSERT on `cl_patient_allergies` (active, non-NKA)   | CL-08 (CDS), CL-15 (quality), PF-10 (notifications) |
| `cl_allergy_status_changed`   | `cl_events` | UPDATE of `clinical_status` or `verification_status` | CL-08, CL-15                                        |
| `cl_allergy_alert_overridden` | `cl_events` | INSERT on `cl_allergy_alert_overrides`               | CL-08, GR audit                                     |
| `cl_nka_confirmed`            | `cl_events` | INSERT/UPDATE setting `nka_flag`                     | CL-08, PF-10                                        |

### Payload (UUID-only, no PHI)

```jsonc theme={null}
// cl_allergy_recorded
{
  "event": "cl_allergy_recorded",
  "publisher": "CL",
  "subscriber": ["CL-08", "CL-15", "PF-10"],
  "payload": {
    "allergy_id": "uuid",
    "chart_id": "uuid",
    "organization_id": "uuid",
    "criticality": "low | high | unable-to-assess",
    "is_sud_mat_class": false
  },
  "metadata": { "organization_id": "uuid", "user_id": "uuid", "timestamp": "iso8601", "correlation_id": "uuid" }
}
```

No allergen names, reaction text, or patient identifiers in payload — consumers fetch via RLS-gated reads.

## API Contracts (synchronous)

### `getActiveAllergies(chartId): AllergyForAlert[]`

* Exposed via `@/platform/clinical`.
* Consumers: CL-05 medication ordering, CL-06 e-prescribing.
* Returns active allergies filtered by RLS + `cl_has_sud_consent` for SUD-MAT class.
* Shape: `{ id, allergen_code, allergen_class_code, allergen_display, reaction_severity, criticality }[]`.

## Idempotency & Retry

* All events idempotent on `(event, payload.allergy_id, metadata.timestamp)`.
* Subscribers MUST tolerate at-least-once delivery.

## Security

* No PHI in event payloads (constitution §4).
* SUD-MAT-class payloads still emit but with `is_sud_mat_class=true`; consumers re-resolve via consent-gated read before disclosure.
* Redisclosure log entry written by CL-16 / CL-20 when exporting SUD-MAT class allergies.

## Open Items

* Confirm channel name (`cl_events` vs spec-specific) with EVENT\_CONTRACTS.md owner before Phase 3.
* Confirm GR audit subscription mechanism (event vs trigger) for `cl_allergy_alert_overridden`.
