core PK: id 12 required 2 unique

Description

Structured post-visit form capturing health status, course interest, assistive device situation, and follow-up actions after a peer mentor home visit. Acts as a formal handoff document to the coordinator.

21
Attributes
6
Indexes
5
Validation Rules
16
CRUD Operations

Data Structure

Name Type Description Constraints
id uuid Primary key
PKrequiredunique
activity_id uuid Foreign key to the parent activity (home visit). One-to-one relationship.
requiredunique
peer_mentor_id uuid User ID of the peer mentor who conducted the visit. Denormalized for query efficiency.
required
contact_id uuid Contact who was visited.
required
organization_id uuid Organization context for tenant isolation.
required
visit_date datetime Date and time the home visit took place.
required
health_status text Free-text field describing the contact's current health status as observed during the visit.
-
health_status_rating enum Structured rating of the contact's health status.
-
course_interest text Free-text notes on courses or training the contact has expressed interest in.
-
course_interest_flag boolean Quick checkbox indicating the contact expressed interest in any course or training.
required
assistive_device_situation text Notes on the contact's current assistive device needs, status, or requests.
-
assistive_device_action_needed boolean Flag indicating coordinator action is needed regarding assistive devices.
required
next_steps text Free-text describing the agreed follow-up actions — acts as a task order to the coordinator.
-
coordinator_action_required boolean Set to true when the report contains items requiring coordinator follow-up action.
required
additional_notes text Unstructured supplementary notes from the peer mentor.
-
status enum Lifecycle status of the report.
required
submitted_at datetime Timestamp when the peer mentor submitted the report.
-
reviewed_at datetime Timestamp when the coordinator marked the report as reviewed.
-
reviewed_by uuid User ID of the coordinator who reviewed the report.
-
created_at datetime Record creation timestamp.
required
updated_at datetime Last modification timestamp.
required

Database Indexes

idx_home_visit_reports_activity_id
btree unique

Columns: activity_id

idx_home_visit_reports_peer_mentor_id
btree

Columns: peer_mentor_id

idx_home_visit_reports_organization_id
btree

Columns: organization_id

idx_home_visit_reports_status
btree

Columns: status

idx_home_visit_reports_coordinator_action
btree

Columns: organization_id, coordinator_action_required, status

idx_home_visit_reports_visit_date
btree

Columns: visit_date

Validation Rules

activity_id_required error

Validation failed

visit_date_not_future error

Validation failed

status_transition_valid error

Validation failed

text_field_length error

Validation failed

peer_mentor_owns_activity error

Validation failed

Business Rules

one_report_per_activity
on_create

Each activity of type home visit may have at most one home visit report. The activity_id column has a unique constraint.

submitted_at_set_on_submit
on_update

When status transitions to 'submitted', submitted_at must be set to current timestamp.

Enforced by: HomeVisitReportService
reviewed_by_required_on_review
on_update

When status transitions to 'reviewed', reviewed_at and reviewed_by must be populated.

no_edit_after_submission
on_update

Peer mentors cannot edit a report once status is 'submitted' or 'reviewed'. Only coordinators may update status to 'reviewed'.

Enforced by: HomeVisitReportService
coordinator_action_flag_auto_set
on_create

coordinator_action_required is automatically set to true when next_steps is non-empty or assistive_device_action_needed is true.

Enforced by: HomeVisitReportService
tenant_isolation
always

Reports are always scoped to the organization_id of the creating user. Cross-organization reads are forbidden.

offline_sync_eligible
on_create

Draft reports created offline are queued in the mutation outbox and synced when connectivity is restored. Conflict resolution favors the most recent client version.

Storage Configuration

Storage Type
primary_table
Location
main_db
Partitioning
No Partitioning
Retention
Permanent Storage