Contact
Data Entity
Description
A person receiving support from a peer mentor. The label 'Contact' is the platform default but can be overridden per organization via the Organization Labels system (e.g. 'Familie', 'Bruker'). Contacts are scoped to the peer mentor who registered them and are the primary subject of activity logging, caregiver registration, and case linking.
Data Structure
| Name | Type | Description | Constraints |
|---|---|---|---|
id |
uuid |
Primary key | PKrequiredunique |
organization_id |
uuid |
Foreign key to organizations. Enforces tenant isolation — a contact belongs to exactly one organization. | required |
owner_user_id |
uuid |
The peer mentor or coordinator who registered and owns this contact. Determines visibility in the contact list. | required |
first_name |
string |
Contact's first name. | required |
last_name |
string |
Contact's last name. | required |
phone |
string |
Primary phone number. Norwegian format preferred but not enforced. | - |
email |
string |
Email address for the contact. | - |
address_line1 |
string |
Street address line 1. | - |
address_line2 |
string |
Street address line 2 / apartment. | - |
postal_code |
string |
Postal code. | - |
city |
string |
City. | - |
date_of_birth |
datetime |
Date of birth. Used for age-sensitive workflows and Bufdir reporting age buckets. | - |
gender |
enum |
Gender used for Bufdir statistical reporting. | - |
notes |
text |
Free-text notes about the contact visible only to the owner and their coordinator. | - |
is_active |
boolean |
Soft-delete flag. Inactive contacts are hidden from list views but retained for historical activity records. | required |
sensitive_readout_warning |
boolean |
When true, the UI displays a screen-reader warning before reading out this contact's detail screen. Required for WCAG 2.2 AA sensitive-field compliance (NHF requirement). | required |
source |
enum |
How the contact was registered — directly by the peer mentor or via an encrypted assignment dispatch. | required |
local_id |
string |
Client-generated offline UUID used by the Drift mutation outbox before server sync. Mapped to id after successful sync. | - |
last_activity_at |
datetime |
Denormalized timestamp of the most recent activity logged against this contact. Used to sort contact lists by recency without a subquery. | - |
created_at |
datetime |
Record creation timestamp (server UTC). | required |
updated_at |
datetime |
Last modification timestamp (server UTC). | required |
deleted_at |
datetime |
Soft-delete timestamp. Null means the record is active. | - |
Database Indexes
idx_contacts_owner_user_id
Columns: owner_user_id
idx_contacts_organization_id
Columns: organization_id
idx_contacts_owner_org_active
Columns: owner_user_id, organization_id, is_active
idx_contacts_last_activity_at
Columns: owner_user_id, last_activity_at
idx_contacts_deleted_at
Columns: deleted_at
idx_contacts_name_search
Columns: organization_id, first_name, last_name
Validation Rules
first_name_required
error
Validation failed
last_name_required
error
Validation failed
email_format
error
Validation failed
phone_format
error
Validation failed
date_of_birth_not_future
error
Validation failed
at_least_one_contact_method
warning
Validation failed
owner_belongs_to_same_org
error
Validation failed
update_requires_ownership_or_coordinator_role
error
Validation failed
Business Rules
owner_scoped_visibility
A peer mentor can only see contacts they own (owner_user_id = current user). Coordinators can see all contacts within their organization scope. Org Admins have full organization visibility via admin portal only.
organization_tenant_isolation
All contact queries must be scoped to organization_id derived from the authenticated user's session. Cross-organization contact access is forbidden.
soft_delete_only
Contacts are never hard-deleted. Setting deleted_at + is_active=false preserves historical activity records required for Bufdir reporting.
last_activity_denormalization
last_activity_at is updated whenever a new activity is saved for this contact, to enable efficient recency sorting on the contact list without aggregation queries.
offline_id_mapping
Contacts created offline are assigned a local_id by the mobile client. On sync, the server assigns a permanent UUID (id) and the local_id is retained for the outbox mapping table. All local references to local_id must be updated after sync completes.
sensitive_readout_default_false
sensitive_readout_warning defaults to false. Users or coordinators may enable it per contact. Once enabled, the screen reader warning is shown on every detail page view for this contact.
bufdir_reporting_inclusion
Contacts marked as is_active=false are excluded from live Bufdir report generation unless the reporting period overlaps with their active window (based on activities logged during the period).