Notes
Data Entity
Description
Free-text records created by peer mentors and coordinators linked to specific contacts, capturing qualitative observations, follow-up items, and contextual information that structured activity logs cannot represent. Notes provide continuity of care across sessions and support offline creation with autosave drafts.
Data Structure
| Name | Type | Description | Constraints |
|---|---|---|---|
id |
uuid |
Unique identifier for the note | PKrequiredunique |
contact_id |
uuid |
Reference to the contact this note is about | required |
user_id |
uuid |
Reference to the peer mentor or coordinator who authored the note | required |
organization_id |
uuid |
Organization scope for multi-tenant isolation | required |
text |
text |
Free-text content of the note, supports plain text input including speech-to-text dictation output | required |
note_date |
datetime |
Date and time the note pertains to (may differ from created_at if backdated) | required |
is_draft |
boolean |
Whether the note is an autosaved draft or a finalized submission | required |
is_deleted |
boolean |
Soft-delete flag to support undo and audit trail | required |
created_at |
datetime |
Timestamp when the note was first created | required |
updated_at |
datetime |
Timestamp when the note was last modified | required |
synced_at |
datetime |
Timestamp of last successful sync to backend, null if created offline and not yet synced | - |
Database Indexes
idx_notes_contact_id
Columns: contact_id
idx_notes_user_id
Columns: user_id
idx_notes_organization_id
Columns: organization_id
idx_notes_contact_date
Columns: contact_id, note_date
idx_notes_org_user
Columns: organization_id, user_id
idx_notes_created_at
Columns: created_at
idx_notes_text_search
Columns: text
Validation Rules
text_not_empty
error
Validation failed
text_max_length
error
Validation failed
contact_id_exists
error
Validation failed
user_id_exists
error
Validation failed
note_date_valid_format
error
Validation failed
organization_id_matches_user
error
Validation failed
immutable_author
error
Validation failed
Business Rules
note_requires_contact
Every note must be linked to exactly one contact. Notes cannot exist without a contact association.
note_author_must_have_contact_access
The authoring user must have role-based access to the linked contact (peer mentor sees own contacts, coordinator sees team contacts within local association).
tenant_isolation
Notes are scoped to the author's organization. All queries must filter by organization_id to prevent cross-tenant data leakage.
autosave_draft_on_interval
The note editor autosaves draft content at regular intervals to prevent data loss. Drafts are cleared after successful final submission.
soft_delete_with_confirmation
Notes are soft-deleted (is_deleted=true) rather than physically removed. User must confirm deletion via a prompt before the flag is set.
offline_create_and_sync
Notes created offline are persisted locally in SQLite and queued for sync. On connectivity restore, background sync pushes pending notes to the backend.
note_date_not_future
The note_date cannot be set to a future date. Notes document observations that have already occurred.
coordinator_can_view_team_notes
Coordinators can read notes written by peer mentors within their local association scope. Peer mentors can only read their own notes.