CaregiverRepository
Component Detail
Description
Data access layer that handles persistence and retrieval of caregiver and next-of-kin records from the underlying database. It maps raw database rows to typed Caregiver domain objects and executes all CRUD queries scoped to a contact identifier. It also supports offline-capable local storage writes that sync when connectivity is restored.
caregiver-repository
Sources & reasoning
Line 121 establishes Barnekreftforeningen's need to track caregivers and next-of-kin linked to the same contact case, directly motivating this feature within the Contacts area. Line 467 canonically places Caregiver & Next-of-Kin in the Contacts area taxonomy. The blueprint marks it MVP, consistent with Barnekreftforeningen's Phase 1 MUST requirement for family-linked contact tracking noted in the priority matrix (line 161).
-
docs/source/likeperson.md · line 121Barnekreftforeningen jobber primært med familier rundt barn med kreft, ikke kun med de berørte selv. Appen må støtte registrering av pårørende (foreldre, søsken, nærmeste omsorgsperson)
-
docs/source/likeperson.md · line 467| contacts | Contacts | Contact List & Search, Contact Detail & Edit, Caregiver & Next-of-Kin |
Responsibilities
- Query all caregiver rows for a given contact ID and return typed domain objects
- Insert new caregiver records with generated IDs and timestamps
- Update mutable fields on existing caregiver records by primary key
- Delete caregiver records by primary key with cascading cleanup if required
- Buffer writes to a local store for offline operation and flush on reconnection
Interfaces
findByContactId(contactId: string): Promise<Caregiver[]>
create(contactId: string, data: CaregiverFormData): Promise<Caregiver>
update(caregiverId: string, data: Partial<CaregiverFormData>): Promise<Caregiver>
delete(caregiverId: string): Promise<void>
syncPendingWrites(): Promise<void>