Skip to content

feat:Implement Questionnaire + Family History Foundation

Overview

This MR implements Phase 2 of the Genix AI backend by introducing the foundational infrastructure for medical history collection, questionnaire management, and family pedigree analysis.

The implementation focuses on:

  • Structured questionnaire workflows
  • Persistent autosave functionality
  • Session lifecycle management
  • Family medical history tracking
  • Progress monitoring and resume capability

Key Changes

1. Database Models & Migrations

Implemented new database entities and relationships:

  • CounsellingSession

    • Tracks session lifecycle, status, progress, and activity timestamps.
  • Questionnaire

    • Stores master questionnaire definitions.

    • Supports dynamic question types such as:

      • TEXT
      • NUMBER
      • BOOLEAN
      • SELECT
      • MULTI_SELECT
  • UserAnswer

    • Persists user responses.
    • Supports both plain text and JSON-based answers.
  • FamilyMember

    • Stores pedigree-related family member information.
  • FamilyCondition

    • Tracks medical conditions associated with family members.

Migration

Added Alembic migration:

implement_phase_2_questionnaire_and_family_history

2. Business Logic (Service Layer)

Autosave System

  • User responses are automatically persisted on submission.
  • Prevents data loss during incomplete sessions.

Progress Tracking

  • Automatically calculates completion percentage based on required questions answered.

Session Resume Support

  • Users can resume incomplete sessions.
  • Restores latest saved progress and answers.

3. API Endpoints

Implemented 24 new endpoints across the following modules:

Sessions

  • /start
  • /{session_id}/resume
  • /{session_id}/complete

Questions

  • Full CRUD support for questionnaire master data
  • Admin-restricted operations

Answers

  • Individual answer submission

  • Bulk autosave endpoint:

    • /bulk

Family History

  • CRUD operations for:

    • Family members
    • Medical conditions

4. RBAC & Validation

Integrated with existing authentication and RBAC from Phase 1.

Security & Validation Features

  • Admin/User access separation

  • Session ownership validation

  • Enum validation for:

    • Question categories
    • Relationship types
    • Question types

Verification

Verified the following:

  • All endpoints visible and functional in Swagger UI (/docs)

  • Alembic migrations applied successfully

  • Database integrity validated

  • Manual testing completed for:

    • Answer submission
    • Autosave flow
    • Progress updates
    • Session resume functionality

Checklist

  • Branch created from develop

  • Semantic commit messages followed

  • Alembic migrations generated and applied

  • Clean architecture maintained

    • Models → Schemas → CRUD → Services → Routes
  • OpenAPI/Swagger documentation updated

  • RBAC validations implemented

  • Autosave and resume flows verified

Edited by Praveena Veeranki

Merge request reports

Loading