Activity Type
Data Entity
Description
Configuration entity defining the catalogue of recognisable peer-mentor activity categories (home visit, phone call, group meeting, etc.). Each activity record references exactly one activity type. Types control Bufdir report mapping, default duration, expense eligibility, and UI display order. Organizations may extend the global catalogue with custom types; system defaults cannot be deleted.
Data Structure
| Name | Type | Description | Constraints |
|---|---|---|---|
id |
uuid |
Surrogate primary key, generated server-side (UUID v4) | PKrequiredunique |
code |
string |
Machine-readable slug used in API payloads and Bufdir export mappings (e.g. 'home_visit', 'phone_call'). Unique per organization scope (NULL org_id = system-global). | required |
name |
string |
Human-readable display name shown in activity wizard step and quick-log screen (e.g. 'Home Visit', 'Phone Call'). | required |
description |
text |
Optional longer description surfaced in the activity wizard help text. | - |
organization_id |
uuid |
FK to organizations. NULL means this is a system-level default available to all organizations. Non-null means it is an organization-specific custom type. | - |
bufdir_category |
enum |
Maps this activity type to the corresponding Bufdir reporting category for automated Bufdir export. Must be one of the officially recognized Bufdir activity classes. | required |
is_refundable |
boolean |
When true, activities of this type may include travel expense claims. Approximately 60-70% of registrations are non-refundable (simple logging only). Drives UI branching in the activity wizard. | required |
requires_contact |
boolean |
When true, the activity wizard enforces selection of a contact person. Some activity types (e.g. coordinator administrative task) do not require a linked contact. | required |
requires_duration |
boolean |
When true, a duration value is mandatory on the activity record. For administrative/background tasks this may be optional. | required |
default_duration_minutes |
integer |
Pre-filled duration value (in minutes) surfaced as the default in quick-log and wizard date/time step. HLF standardises on 30 min for most types. Must be positive. | - |
is_active |
boolean |
Soft-delete flag. Inactive types are hidden from selection UIs but retained for historical activity records. Activity types with existing activities MUST be deactivated rather than deleted. | required |
is_system_default |
boolean |
True for types seeded by Norse Digital Products. System defaults are visible to all organizations and cannot be deleted or deactivated by org admins. | required |
display_order |
integer |
Controls the sort position in type selector UIs. Lower values appear first. Enables organizations to surface their most common types at the top. | required |
icon_name |
string |
Optional Flutter icon identifier (Material icon name) for visual differentiation in the activity wizard step and quick-log screen. | - |
created_at |
datetime |
Timestamp of record creation (UTC). | required |
updated_at |
datetime |
Timestamp of last modification (UTC). Updated on every write. | required |
Database Indexes
idx_activity_types_code_org
Columns: code, organization_id
idx_activity_types_org_active
Columns: organization_id, is_active
idx_activity_types_bufdir_category
Columns: bufdir_category
idx_activity_types_display_order
Columns: organization_id, is_active, display_order
Validation Rules
name_non_empty
error
Validation failed
code_slug_format
error
Validation failed
default_duration_positive
error
Validation failed
bufdir_category_valid_enum
error
Validation failed
display_order_non_negative
warning
Validation failed
organization_id_must_exist
error
Validation failed
Business Rules
no_hard_delete_with_activities
An activity type that is referenced by one or more activity records MUST NOT be hard-deleted. The type must be deactivated (is_active = false) instead to preserve historical integrity.
system_defaults_immutable_by_org_admin
Activity types where is_system_default = true cannot be modified or deactivated by organization admins or coordinators. Only global admins (Norse staff) may change system defaults.
org_type_scoped_to_organization
An organization-specific activity type (organization_id IS NOT NULL) is only visible and selectable within that organization. It must never appear in type selector UIs for other organizations.
bufdir_mapping_required_for_reporting
Every activity type must have a valid bufdir_category value. Activities registered under this type will be aggregated into Bufdir reports using this category mapping. Types with bufdir_category = 'other' are flagged in Bufdir export for manual review.
refundable_type_enables_expense_flow
When is_refundable = true, the activity wizard and quick-log screen MUST offer the option to attach an expense record. When false, the expense registration flow is entirely suppressed for that activity.
default_duration_surfaced_as_prefill
When default_duration_minutes is set, the value is automatically pre-filled in the duration field of the activity wizard and quick-log screen. Users may override it. This drives the HLF requirement for 30-minute defaults.
code_unique_per_org_scope
The combination of (code, organization_id) must be unique. System types use NULL organization_id; two system types cannot share a code, and an org type cannot duplicate a system-level code within the same org.