core PK: id 10 required 1 unique

Description

Represents a caregiver or next-of-kin relationship associated with a contact in the peer mentor program. Each contact can have one or more registered caregivers — typically family members, spouses, or emergency contacts who are involved in the contact's support network. This entity enables peer mentors and coordinators to reach relevant parties when needed, particularly for elderly contacts, contacts with disabilities, or those in vulnerable situations.

14
Attributes
4
Indexes
8
Validation Rules
11
CRUD Operations

Data Structure

Name Type Description Constraints
id uuid Primary key — unique identifier for the caregiver record
PKrequiredunique
contact_id uuid Foreign key referencing the contact this caregiver is associated with
required
name string Full name of the caregiver or next-of-kin
required
relationship_type enum Nature of the relationship between the caregiver and the contact
required
phone string Primary phone number for reaching the caregiver — Norwegian format preferred
-
email string Email address of the caregiver
-
address text Physical address of the caregiver — classified as a sensitive field; triggers screen reader warning when VoiceOver or TalkBack is active
-
is_primary boolean Whether this caregiver is designated as the primary contact for the associated contact record. Only one caregiver per contact may be primary.
required
is_emergency_contact boolean Whether this caregiver should be contacted in emergency situations
required
notes text Free-text notes about the caregiver relationship or relevant context for peer mentors
-
organization_id uuid Organization context for multi-tenant isolation — inherited from the associated contact's organization
required
created_by uuid User ID of the peer mentor or coordinator who created this caregiver record
required
created_at datetime Timestamp when the caregiver record was first created
required
updated_at datetime Timestamp of the most recent update to this caregiver record
required

Database Indexes

idx_contact_caregiver_contact_id
btree

Columns: contact_id

idx_contact_caregiver_org_id
btree

Columns: organization_id

idx_contact_caregiver_primary
btree

Columns: contact_id, is_primary

idx_contact_caregiver_contact_org
btree

Columns: contact_id, organization_id

Validation Rules

contact_id_exists error

Validation failed

name_not_empty error

Validation failed

relationship_type_valid error

Validation failed

phone_format warning

Validation failed

email_format error

Validation failed

name_max_length error

Validation failed

notes_max_length error

Validation failed

organization_id_matches_contact error

Validation failed

Business Rules

single_primary_caregiver
on_create

At most one caregiver record per contact may have is_primary = true. When a new caregiver is set as primary, any existing primary caregiver for the same contact must be demoted (is_primary set to false) within the same transaction.

Enforced by: Caregiver Service
single_primary_caregiver_on_update
on_update

When updating is_primary to true, enforce uniqueness of primary caregiver per contact by clearing the flag on the previously primary record.

Enforced by: Caregiver Service
at_least_one_contact_method
on_create

A caregiver record should have at least one contact method — either phone or email — to be useful. This is enforced as a warning rather than a hard error to allow incomplete records during data entry.

role_based_access
always

Only peer mentors assigned to the contact and coordinators within the contact's local association may create, read, update, or delete caregiver records. Org Admins may read all caregiver records for their organization.

tenant_isolation
always

All queries against contact_caregivers must include an organization_id filter matching the authenticated user's organization to prevent cross-tenant data access.

Enforced by: Caregiver Service
cascade_delete_with_contact
on_delete

When a contact record is deleted, all associated caregiver records are automatically deleted via ON DELETE CASCADE to prevent orphaned records.

Enforced by: Caregiver Service
sensitive_address_warning
always

When the address field is rendered on screen with an active screen reader (VoiceOver or TalkBack), the Sensitive Field Widget must intercept the readout and display a warning before proceeding. This is required per the WCAG 2.2 AA accessibility mandate and NHF's explicit requirement.

Storage Configuration

Storage Type
primary_table
Location
main_db
Partitioning
No Partitioning
Retention
Permanent Storage