# Multi-Location Workflows (Program + Cohort)

This system now supports a two-layer training model:

- `training_programs` = logical course owned by a TP in a project.
- `trainings` = delivery cohorts/runs under a program (location + duration + dates).

## Workflow: Setup

1. Create training provider (existing flow).
2. Create training program via `POST /api/projects/:projectId/training-programs`.
3. Create one or more cohorts via `POST /api/projects/:projectId/trainings` using `trainingProgramId`.

If `trainingProgramId` is omitted on cohort creation, the API creates/uses a fallback program to preserve backward compatibility.

## Workflow: Enrollment

- Trainee rows can still carry `trainingId`.
- New table `trainee_enrollments` is auto-synced on:
  - single trainee create
  - bulk trainee import
  - trainee edit (enrollment is re-linked to the updated cohort)

This creates a clean cohort roster for future cohort-first APIs.

## Workflow: Attendance

- Existing attendance endpoints remain training-scoped (training = cohort):
  - manual day submit
  - CSV import
- Duplicate locks continue to operate by cohort/date.
- Attendance submissions are now also logged in `submission_events`.

## Workflow: Outcomes

- Outcome batch APIs now support optional `trainingId` (cohort filter).
- If provided, imported outcome rows are constrained to trainees in that cohort.
- `outcome_report_batches.training_id` and `trainee_outcomes.training_id` are persisted for audit/disaggregation.

## Workflow: Verification

- Verification run creation now supports optional `trainingId`.
- Denominator/numerator trainee ID resolution is filtered by cohort when provided.
- Outcome-report prerequisite checks are cohort-aware when a cohort is selected.

## KPI Aggregation Strategy

- Cohort-level values are primary units (training rows).
- Program-level = aggregate cohorts under a single `trainingProgramId`.
- Provider/project rollups aggregate from cohort/program layers with explicit denominator weighting.
