core PK: id 10 required 1 unique

Description

A family member or next-of-kin contact registered in relation to a primary case or contact record. Used by Barnekreftforeningen to track parents, siblings, and primary caregivers of children with cancer, and by other organizations for caregiver/next-of-kin tracking linked to peer mentor cases.

17
Attributes
5
Indexes
8
Validation Rules
15
CRUD Operations

Data Structure

Name Type Description Constraints
id uuid Primary key
PKrequiredunique
organization_id uuid Tenant isolation — the organization this relative record belongs to
required
first_name string Relative's first name
required
last_name string Relative's last name
required
phone string Primary phone number for reaching this relative
-
email string Email address for this relative
-
date_of_birth datetime Date of birth, used for age-sensitive context (e.g. minor siblings)
-
relation_type enum Semantic relationship to the primary contact/case (e.g. parent, sibling, spouse, caregiver)
required
role_tag string Free-form role label assigned via Relative Role Tagging, e.g. 'primary caregiver', 'legal guardian'. Supplements relation_type with org-specific semantics.
-
notes text Internal notes about this relative relevant to the case context
-
is_primary_contact boolean Flags this relative as the primary point of contact for the linked case
required
consent_given boolean Whether this relative has given consent for their data to be stored and used in the platform
required
consent_date datetime Timestamp when consent was recorded
-
created_by_user_id uuid User who created this relative record
required
created_at datetime Record creation timestamp
required
updated_at datetime Last update timestamp
required
deleted_at datetime Soft-delete timestamp; null means record is active
-

Database Indexes

idx_relatives_organization_id
btree

Columns: organization_id

idx_relatives_created_by_user_id
btree

Columns: created_by_user_id

idx_relatives_relation_type
btree

Columns: organization_id, relation_type

idx_relatives_deleted_at
btree

Columns: deleted_at

idx_relatives_name_search
btree

Columns: organization_id, last_name, first_name

Validation Rules

name_not_empty error

Validation failed

email_format error

Validation failed

phone_format error

Validation failed

relation_type_valid_enum error

Validation failed

date_of_birth_past error

Validation failed

consent_date_set_with_consent error

Validation failed

role_tag_max_length error

Validation failed

organization_id_immutable error

Validation failed

Business Rules

tenant_isolation
always

Relative records are scoped to an organization. A peer mentor or coordinator may only create, view, or edit relatives belonging to their own organization.

consent_required_before_storage
on_create

A relative's personal data (name, phone, email) must not be persisted without consent_given = true. The registration screen must capture consent before submitting.

single_primary_contact_per_case
on_create

Within the set of relatives linked to a given case (via relative_case_links), at most one relative may have is_primary_contact = true. Setting a new primary contact must clear the flag on any existing primary.

soft_delete_only
on_delete

Relatives are never hard-deleted. Setting deleted_at marks the record inactive and removes it from normal queries, but the record is retained for audit purposes.

role_tag_requires_case_link
on_update

A role tag may only be assigned to a relative that is already linked to at least one case via relative_case_links. Role tagging without a case link is meaningless.

offline_sync_eligibility
on_create

Relative records created offline are queued in the mutation outbox and synced when connectivity is restored. Conflict resolution favors server state for shared fields (name, phone) and merges role tags.

Storage Configuration

Storage Type
primary_table
Location
main_db
Partitioning
No Partitioning
Retention
Permanent Storage