Activities
Data Entity
Description
Core entity representing logged peer mentor interactions (home visits, phone calls, meetings, group activities) that feed personal statistics, coordinator team reports, and Bufdir reporting. Activities are the primary unit of value capture in the Meander platform — every other operational artifact (expenses, attachments, home-visit reports, flags, duplicate detection) hangs off an activity.
Data Structure
| Name | Type | Description | Constraints |
|---|---|---|---|
id |
uuid |
Primary key — server-assigned UUID. Offline-created activities use a client-generated temporary ID mapped to server ID on sync. | PKrequiredunique |
organization_id |
uuid |
Tenant scope. Every activity belongs to exactly one organization; tenant isolation is enforced at query time. | required |
peer_mentor_id |
uuid |
The peer mentor who performed the activity. For proxy registrations this is the mentor the activity is logged on behalf of, not the coordinator who entered it. | required |
contact_id |
uuid |
The contact the activity was with. Optional for group/event-style activities where no single contact applies. | - |
event_id |
uuid |
Link to an event when the activity was performed as part of one (e.g. workshops, group activities). | - |
activity_type |
enum |
Category of interaction. Drives Bufdir categorization and statistics aggregation. | required |
occurred_at |
datetime |
When the activity took place (ISO 8601, UTC). Defaults to current date per HLF requirement for low-friction quick logging. | required |
duration_minutes |
integer |
Duration of the activity in minutes. Defaults to 30 (HLF standard) but is overrideable. | required |
summary |
text |
Free-text summary of the activity. May be dictated via speech-to-text. Encrypted at application level when containing sensitive personal data. | - |
location |
string |
Optional location description (e.g. home address, café, video). Sensitive — handled by sensitive-field-readout-warning on screen readers. | - |
registered_by_user_id |
uuid |
User who entered the record. Differs from peer_mentor_id when a coordinator proxy-registers on behalf of a mentor. | required |
registration_source |
enum |
How the activity was entered. Drives audit trails and downstream reporting. | required |
proxy_registration_id |
uuid |
Set when registration_source = proxy. Links to the proxy_registrations record describing the coordinator action. | - |
bulk_registration_id |
uuid |
Set when registration_source = bulk. Links to the bulk_registrations batch. | - |
status |
enum |
Lifecycle state of the activity record. Driven by admin review/approval workflow. | required |
approved_by_user_id |
uuid |
Org admin who approved the activity (if status = approved). | - |
approved_at |
datetime |
Timestamp of approval. | - |
is_flagged |
boolean |
Quick-lookup flag indicating an open flag exists in the flags table. Maintained by flag-service. | required |
duplicate_of_activity_id |
uuid |
If duplicate detection has confirmed this is a duplicate of another activity, this points to the canonical record. | - |
bufdir_reportable |
boolean |
Whether the activity counts toward Bufdir aggregation. False for test-org activities and certain internal categories. | required |
client_temp_id |
string |
Offline client-generated identifier used to deduplicate sync uploads from offline-created activities before the server assigned id was returned. | unique |
synced_at |
datetime |
When the offline-created record was successfully synced to the server. Null until then. | - |
metadata |
json |
Extensible bag for organization-specific fields (e.g. Blindeforbundet home-visit categories at the activity row level, NHF chapter linkage). Schema-less to avoid per-tenant code paths. | - |
created_at |
datetime |
Record creation timestamp (server time). | required |
updated_at |
datetime |
Last modification timestamp (server time). | required |
deleted_at |
datetime |
Soft-delete timestamp. Activities are never hard-deleted while referenced by expenses or Bufdir reports. | - |
Database Indexes
idx_activities_organization
Columns: organization_id
idx_activities_peer_mentor_occurred
Columns: peer_mentor_id, occurred_at
idx_activities_contact
Columns: contact_id
idx_activities_org_status_occurred
Columns: organization_id, status, occurred_at
idx_activities_event
Columns: event_id
idx_activities_proxy
Columns: proxy_registration_id
idx_activities_bulk
Columns: bulk_registration_id
idx_activities_client_temp_id
Columns: client_temp_id
idx_activities_bufdir_reportable
Columns: organization_id, bufdir_reportable, occurred_at
Validation Rules
occurred_at_not_in_future
error
Validation failed
duration_within_bounds
error
Validation failed
summary_max_length
error
Validation failed
activity_type_in_enum
error
Validation failed
peer_mentor_belongs_to_organization
error
Validation failed
contact_belongs_to_organization
error
Validation failed
proxy_id_consistency
error
Validation failed
approval_fields_consistency
error
Validation failed
duplicate_self_reference_forbidden
error
Validation failed
encrypted_pii_format
error
Validation failed
Business Rules
default_occurred_at_today
When created via quick-log, occurred_at defaults to today's date and duration_minutes defaults to 30 per HLF low-friction requirement; both are overrideable.
proxy_requires_coordinator
registration_source = proxy is only allowed when registered_by_user_id holds the Coordinator role for the organization owning the target peer_mentor.
bulk_creates_one_per_mentor
A bulk registration produces exactly one activity row per target peer mentor, all sharing the same bulk_registration_id.
approval_assigns_approver
Transition to status = approved requires approved_by_user_id and approved_at to be set atomically.
duplicate_review_required_for_high_confidence
When duplicate detection finds a high-confidence match, the activity is auto-flagged for review and cannot be Bufdir-counted until resolved.
test_org_excluded_from_bufdir
Activities owned by the Norse Test Organization always have bufdir_reportable = false regardless of input.
module_toggle_gate
Activity creation requires the activity-registration module to be enabled for the tenant; speech-to-text, attachments, and home-visit-report features additionally require their respective config flags.
soft_delete_only_when_unreferenced
An activity may not be hard-deleted while referenced by expenses, attachments, or a finalized Bufdir export; soft-delete (deleted_at) is used instead.
audit_trail_on_mutation
Every create/update/delete on an activity emits an audit_logs entry capturing actor, before/after, and source surface.
offline_sync_idempotency
Sync must deduplicate by client_temp_id so retried uploads from the offline outbox never create duplicate server rows.