Relative Case Link
Data Entity
Description
Junction entity linking a registered relative to a contact (case), enabling family members and next-of-kin to be associated with the primary case being supported by a peer mentor. Supports Barnekreftforeningen's relatives database where families around a child with cancer are tracked as distinct contacts linked to the same case.
Data Structure
| Name | Type | Description | Constraints |
|---|---|---|---|
id |
uuid |
Primary key | PKrequiredunique |
relative_id |
uuid |
Foreign key referencing the relative record being linked | required |
contact_id |
uuid |
Foreign key referencing the contact (case) this relative is linked to | required |
organization_id |
uuid |
Tenant scoping — the organization this link belongs to | required |
relationship_type |
enum |
Nature of the relationship between the relative and the contact | required |
is_primary_contact |
boolean |
Whether this relative is the primary point of contact for the case | required |
notes |
text |
Free-text notes about this relationship or link context | - |
linked_by_user_id |
uuid |
User (peer mentor or coordinator) who created this link | required |
linked_at |
datetime |
Timestamp when the link was created | required |
updated_at |
datetime |
Timestamp of last modification | required |
is_active |
boolean |
Soft-delete flag; false means the link has been removed without deleting the record | required |
Database Indexes
idx_relative_case_links_relative_id
Columns: relative_id
idx_relative_case_links_contact_id
Columns: contact_id
idx_relative_case_links_organization_id
Columns: organization_id
idx_relative_case_links_relative_contact
Columns: relative_id, contact_id
idx_relative_case_links_contact_active
Columns: contact_id, is_active
Validation Rules
relative_exists_in_org
error
Validation failed
contact_exists_in_org
error
Validation failed
relationship_type_required
error
Validation failed
linked_by_user_in_org
error
Validation failed
Business Rules
unique_relative_contact_pair
A relative can only be linked to the same contact once (enforced by unique index). Re-linking after soft-delete reactivates the existing record rather than inserting a duplicate.
tenant_scoped_link
Both relative_id and contact_id must belong to the same organization_id as the link record. Cross-tenant linking is forbidden.
single_primary_contact_per_case
At most one relative per contact can have is_primary_contact = true. Setting a new primary contact automatically clears the flag on any existing primary relative for that contact.
relatives_database_module_required
Relative case links can only be created when the relatives-database module is enabled for the organization.