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

# Tenant Onboarding & Data Import — Integration

> Status: 📋 Planned (spec reviewed and accepted 2026-03-24) Spec: specs/pf/specs/PF-88-tenant-onboarding-data-import.md Plan: specs/pf/plans/PF-88-tenant-onboar…

**Status:** 📋 Planned (spec reviewed and accepted 2026-03-24)\
**Spec:** `specs/pf/specs/PF-88-tenant-onboarding-data-import.md`\
**Plan:** `specs/pf/plans/PF-88-tenant-onboarding-data-import-PLAN.md`\
**Last updated:** 2026-03-24

***

## Purpose

Document how the **tenant onboarding and batch import framework** (`pf_import_*`, `pf_onboarding_sessions`) integrates with Data Manager (PF-23/24/25), bulk operations (PF-47), terminology validation (PF-70), and **downstream cores** (HR, PM, FA) without core-to-core imports.

***

## Scope

* **In scope:** Import adapters (CSV/XLSX/JSON), field-mapping UI, batch pipeline, deduplication, onboarding wizard orchestration, tenant-scoped storage, RLS, permission keys from the spec.
* **Out of scope:** Live/API sync (PF-63/65/66), outbound export (PF-44), form-submission-only import (FW-02).

***

## Related platform documents

| Document                                                                         | Relationship                                                                   |
| -------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
| [PLATFORM\_INTEGRATION\_LAYERS.md](./PLATFORM_INTEGRATION_LAYERS.md)             | Cores consume `@/platform` import APIs; no CL↔HR direct imports                |
| [CROSS\_CORE\_INTEGRATIONS.md](./CROSS_CORE_INTEGRATIONS.md)                     | Matrix row for PF-88                                                           |
| [PF-23 Data Manager](./data-manager-integration.md)                              | Target schemas and single-entity CSV paths; PF-88 adds multi-entity onboarding |
| [PF-70 Medical Terminology](./medical-terminology-code-libraries-integration.md) | Validation hooks for coded fields on clinical/billing imports                  |
| `.cursor/rules/bulk-import-patterns.md`                                          | Shared CSV / edge vs client / progress patterns                                |

***

## Consumer obligations (HR / PM / FA / others)

1. Use **platform import APIs** and shared UI components; do not duplicate `pf_import_*` RLS or storage paths in domain cores.
2. **Mutations** must include `organization_id` (defense in depth) when writing target entities created from imports.
3. **PHI:** Treat uploaded source files as PHI artifacts; mask previews per spec; no PHI in logs, toasts, or analytics payloads.

***

## Auth and tenant isolation

* All `pf_import_*` and `pf_onboarding_sessions` rows are scoped by `organization_id` with RLS (`pf_has_org_access` pattern as in spec).
* Storage objects must use **tenant-namespaced paths**; signed URLs short-lived.

***

## Checklist (implementation)

* [ ] Migration creates four tables with JSONB `CHECK` constraints and `COMMENT ON COLUMN` for mapping/error arrays as in spec.
* [ ] Permission keys seeded + `constants.ts` entries for `pf.import.*`, `pf.onboarding.manage`.
* [ ] RLS tests for all four tables; UPDATE policies use `WITH CHECK`.
* [ ] User/admin guides linked from UI when `docs/pf/data-import-guide.md` and `docs/pf/onboarding-admin-guide.md` exist.
