Spaces:
Runtime error
Runtime error
File size: 2,343 Bytes
ed0b977 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# SwiftQuery Backend Documentation
## Overview
SwiftQuery is a Flask-based web application designed to assist doctors with patient management, clinical note enhancement, and AI-powered insights. It uses MongoDB as its primary database and integrates various AI services (Google Gemini, Groq, CyborgDB).
## Architecture
- **Framework**: Flask (Python)
- **Database**: MongoDB (accessed via `Flask-PyMongo`)
- **Authentication**: Session-based with `bcrypt` for password hashing.
- **AI Integration**: Modular agents in `ai_agents/` for RAG and text processing.
## Key Directories
- `utils/blueprints/`: Contains the route logic for different user roles (Admin, Doctor, Patient, Assistant, Chat).
- `utils/db/`: Database configuration (`db.py`) and schema definitions.
- `ai_agents/`: Logic for RAG pipelines and clinical summaries.
- `static/` & `templates/`: Frontend assets and HTML files.
## Setup & Configuration
1. **Environment Variables**: Managed via `.env` (requires `MONGO_URI`, `GOOGLE_AI_API_KEY`, `GROQ_API_KEY`, `CYBORGDB_API_KEY`, `SECRET_KEY`).
2. **Dependencies**: Listed in `requirements.txt`. Install via `pip install -r requirements.txt`.
3. **Run**: Execute `python main.py` to start the server.
## Blueprints
### 1. Auth (`auth.py`)
- Handles user login for all roles (Doctor, Admin, Patient, Assistant).
- Manages session creation and destruction (`/logout`).
### 2. Admin (`admin.py`)
- **Manage Users**: Add/Delete Doctors, Assistants, and Patients.
- **Patient ID**: Generates structured IDs like `SQ-2024-001`.
### 3. Doctor (`doctor.py`)
- **Dashboard**: View assigned patients.
- **Session Management**: Start/End sessions to activate AI context.
- **Recording**: Upload audio for transcription.
### 4. Patient (`patient.py`)
- **Read-Only Access**: View medical history, consultations, reports, and bills.
- **Reports**: Download test reports.
### 5. Assistant (`assistant.py`)
- **Data Entry**: Add medical records (History, Consultations, Tests, Treatments) for patients.
- **Account Creation**: Helper interface for creating new accounts.
## Database Schema
Collections include:
- `patient`: Core profile.
- `doctor`, `admin`, `administrativeassistant`: User roles.
- `medicalhistory`, `consultation`, `testreport`, `treatment`: Clinical records.
- `chatsession`, `chatmessage`: AI interaction logs.
|