configuration PK: id 12 required 1 unique

Description

Configuration entity defining the catalogue of valid activity types available for activity registration. Supports platform-wide defaults and per-organization custom types, with Bufdir reporting codes and UI configuration for the activity wizard and quick-log flows.

17
Attributes
5
Indexes
6
Validation Rules
15
CRUD Operations

Data Structure

Name Type Description Constraints
id uuid Primary key, generated on creation
PKrequiredunique
organization_id uuid FK to organizations. NULL means platform-wide default visible to all tenants; non-null means org-scoped custom type visible only to that organization
-
name string Human-readable display name for this activity type (e.g. 'Home Visit', 'Phone Call', 'Group Meeting'). Subject to organization label overrides via terminology system
required
code string Machine-readable slug used in API payloads, Bufdir mappings, and offline sync. Unique per (organization_id, code) pair. Platform defaults use a shared code namespace (e.g. 'home_visit', 'phone_call')
required
description text Optional longer description shown in the activity wizard help text or admin configuration UI
-
category enum Broad semantic category used for Bufdir reporting grouping and UI iconography. Determines which Bufdir reporting bucket this type maps into
required
bufdir_category_code string The official Bufdir reporting category code this activity type maps to. Required for any type that should appear in Bufdir exports. NULL means this type is excluded from Bufdir counts (e.g. internal admin types)
-
requires_contact boolean If true, activities of this type must reference a contact record. Quick-log and wizard enforce this. Home visits and phone calls typically require a contact; group activities may not
required
requires_duration boolean If true, the activity wizard forces the user to specify a duration before submitting. Types like 'group meeting' may require duration for Bufdir hour-counting
required
allows_attachments boolean Whether document attachments are permitted for activities of this type. Linked to the document-attachments feature toggle; if the module is disabled the value is ignored
required
default_duration_minutes integer Pre-filled duration in minutes shown in the activity wizard. HLF context: 30 minutes is the typical default. Users can override it. NULL means no pre-fill
-
display_order integer Sort position within the org's activity type picker. Lower values appear first. Platform defaults start at 100, 200, … to leave room for org-scoped types to be inserted at lower values
required
icon_name string Flutter Material icon name or custom design-token icon key used to render this type's icon in the quick-log screen and wizard type picker
-
is_platform_default boolean True for built-in types shipped by Norse Digital Products. Platform defaults cannot be deleted and their code cannot be changed. Org admins can deactivate them for their tenant but not remove them
required
is_active boolean Soft-enable flag. Inactive types are hidden from all registration UIs but remain referenced by historical activities. Org admins can deactivate platform defaults for their tenant by creating an org-scoped override
required
created_at datetime Record creation timestamp (UTC)
required
updated_at datetime Last modification timestamp (UTC), updated on every write
required

Database Indexes

idx_activity_types_org_active
btree

Columns: organization_id, is_active

idx_activity_types_code_org
btree unique

Columns: code, organization_id

idx_activity_types_org_display_order
btree

Columns: organization_id, display_order

idx_activity_types_bufdir_code
btree

Columns: bufdir_category_code

idx_activity_types_platform_defaults
btree

Columns: is_platform_default, is_active

Validation Rules

code_format error

Validation failed

name_non_empty error

Validation failed

default_duration_positive error

Validation failed

display_order_non_negative error

Validation failed

bufdir_code_format warning

Validation failed

category_enum_valid error

Validation failed

Business Rules

platform_defaults_immutable
on_update

Activity types where is_platform_default=true cannot be deleted and their code field cannot be modified. Org admins may deactivate them for their tenant (is_active=false) but cannot alter the record itself

org_scoped_visibility
always

When resolving the type picker list for a given user session, the API returns platform defaults (organization_id IS NULL AND is_active=true) merged with that user's org-scoped active types, sorted by display_order ascending

inactive_types_blocked_for_new_activities
on_create

Activities cannot be created or updated to reference an inactive activity type (is_active=false). Historical activities already linked to a now-inactive type retain their reference and are displayed with a deprecation indicator

bufdir_code_required_for_export
always

Activity types with bufdir_category_code=NULL are excluded from Bufdir export counts. The Bufdir report builder warns the org admin if a significant share of activities reference types with no Bufdir code

offline_sync_cache
always

The full active type catalogue for the user's organization is cached in the local Drift database on first sync and refreshed whenever the org's configuration changes. Activity registration must work fully offline using the cached catalogue

contact_requirement_enforced_in_wizard
on_create

When requires_contact=true, the activity wizard prevents the user from submitting without selecting a contact. Quick-log screen shows the contact picker automatically. Bulk registration skips this check when the coordinator explicitly registers on behalf of a group

no_duplicate_org_code
on_create

Within a single organization_id scope (including NULL for platform defaults), the code field must be unique. Enforced by the unique index idx_activity_types_code_org and validated before insert

Storage Configuration

Storage Type
lookup_table
Location
main_db
Partitioning
No Partitioning
Retention
Permanent Storage