core PK: id 10 required 1 unique

Description

Represents a family member or next-of-kin contact associated with a case or contact in the system. Used by Barnekreftforeningen to register parents, siblings, and primary caregivers of children with cancer as separate contact subjects linked to the same case. Supports the Relatives Database area with registration, case linking, and role tagging.

16
Attributes
4
Indexes
6
Validation Rules
17
CRUD Operations

Data Structure

Name Type Description Constraints
id uuid Primary key
PKrequiredunique
organization_id uuid Organization this relative belongs to (tenant isolation)
required
first_name string Relative's first name
required
last_name string Relative's last name
required
phone string Phone number for contact
-
email string Email address for contact
-
relation_type enum The relative's relationship to the primary case subject
required
role_tags json Array of org-specific role tags assigned to this relative (e.g. primary_caregiver, emergency_contact)
-
notes text Free-text notes about the relative
-
is_primary_contact boolean Whether this relative is the primary contact for communications
required
consent_given boolean Whether the relative has given consent for data storage
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 active
-

Database Indexes

idx_relatives_organization_id
btree

Columns: organization_id

idx_relatives_created_by
btree

Columns: created_by_user_id

idx_relatives_org_deleted
btree

Columns: organization_id, deleted_at

idx_relatives_relation_type
btree

Columns: organization_id, relation_type

Validation Rules

name_required error

Validation failed

email_format error

Validation failed

phone_format warning

Validation failed

relation_type_valid error

Validation failed

consent_date_when_consent_given error

Validation failed

role_tags_valid_json error

Validation failed

Business Rules

organization_isolation
always

A relative record is always scoped to a single organization. Cross-organization access is forbidden.

consent_required_before_storage
on_create

A relative's personal data must not be persisted unless consent_given is true. Consent date must be recorded at the same time.

single_primary_contact_per_case
on_update

Only one relative per case link group 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 may never be hard-deleted due to audit and reporting requirements. Deletion sets deleted_at timestamp.

module_toggle_enforcement
always

The relatives-database module must be enabled for the user's organization before any relative CRUD operations are permitted.

Enforced by: RelativeService

Storage Configuration

Storage Type
primary_table
Location
main_db
Partitioning
No Partitioning
Retention
Permanent Storage