RelativeRoleService
Component Detail
Description
Backend service responsible for reading, writing, and validating the semantic role field on case link records. It resolves available role options from the Organization Labels system for the requesting organization and enforces that only valid configured role values are persisted. It exposes the necessary endpoints consumed by the widget and any automated role assignment logic.
relative-role-service
Sources & reasoning
Line 121 enumerates distinct relative types - foreldre (parents), søsken (siblings), nærmeste omsorgsperson (primary caregiver) - implying role differentiation is a first-class requirement, not just a free-text note. Phase 1/MVP is confirmed by the priority matrix (line 161). Role tagging gives structured, queryable meaning to the type enumeration and is marked [MVP] in the blueprint alongside the other relatives-database features.
-
docs/source/likeperson.md · line 121Appen må støtte registrering av pårørende (foreldre, søsken, nærmeste omsorgsperson) som egne kontaktsubjekter knyttet til samme sak.
-
docs/source/likeperson.md · line 161Pårørende database | ✓ | - | - | - | ✓ | MUST (Barnekreft) | 1
Responsibilities
- Persist the assigned role value to the case link record in the database
- Retrieve valid role labels for the organization from the Organization Labels system
- Validate that a submitted role value exists in the organization's configured label set
- Return the current role for a given case link record on read requests
- Support bulk retrieval of roles for a list of case link IDs for list views
Interfaces
assignRole(caseLinkId: string, role: string, orgId: string): Promise<CaseLink>
getRole(caseLinkId: string): Promise<string | null>
getAvailableRoles(orgId: string): Promise<RoleLabel[]>
bulkGetRoles(caseLinkIds: string[]): Promise<Record<string, string | null>>