Investment Plans workspace
Open raw ↗

# HAD Digital - Developer README

Version: 1.0.0 Date: 5 September 2026 Author: Dr Kais Aldabbagh, Polyclinique St Come - Medical Oncology


Quick Start

Running the Application

Option 1: Run the .exe (Recommended)

  1. Navigate to: C:\AI Projects\Kais Project\MVP\dist\HAD Digital\
  1. Double-click HAD Digital.exe
  1. Open your browser to: http://127.0.0.1:8080
  1. Login with: dmin / dmin123

Option 2: Run from Source

  1. Open a terminal
  1. Navigate to: C:\AI Projects\Kais Project\MVP\
  1. Run: python app.py
  1. Open your browser to: http://127.0.0.1:8080
  1. Login with: dmin / dmin123

Project Structure

C:\AI Projects\Kais Project\MVP\
├── app.py                    # Main HTTP server (19 API endpoints)
├── database.py               # SQLite database manager
├── user_store.py             # Authentication with scrypt hashing
├── ctcae_engine.py           # CTCAE grading engine
├── alert_engine.py           # Tiered alert routing
├── audit_logger.py           # Immutable audit log
├── seed_demo.py              # Demo data seeder
├── config_manager.py         # Configuration manager
├── config.json               # Application configuration
├── adapters/                 # AI adapter system
│   ├── base.py               # Base adapter interface
│   ├── stub.py               # Stub adapter (offline demo)
│   └── glm.py                # GLM adapter (online AI)
├── static/                   # Frontend files
│   ├── index.html            # Main HTML page
│   ├── app.css               # Styles (29 KB)
│   └── app.js                # Application logic (30 KB)
├── data/                     # Data files
│   ├── had.db                # SQLite database (auto-created)
│   └── ctcae_rules.json      # CTCAE grading rules (14 KB)
├── guidance/                 # Patient guidance
│   └── guidance.json         # Guidance content (24 KB)
└── dist/                     # Distribution files
    └── HAD Digital/          # Built .exe bundle
        ├── HAD Digital.exe   # Standalone executable
        ├── static/           # Frontend files
        ├── data/             # Data files
        └── guidance/         # Guidance files

Architecture

Backend (Python)

The backend is a pure Python HTTP server using the built-in http.server module. No external dependencies are required.

Key Components:

  1. app.py - Main HTTP server with 19 API endpoints
  1. database.py - SQLite database manager with WAL mode
  1. user_store.py - Authentication with scrypt password hashing
  1. ctcae_engine.py - CTCAE grading engine with rule-based logic
  1. alert_engine.py - Tiered alert routing (routine/urgent/emergency)
  1. audit_logger.py - Immutable audit trail
  1. config_manager.py - Configuration with environment variable overrides
  1. adapters/ - Pluggable AI adapter system

Design Principles:

Frontend (HTML/CSS/JS)

The frontend is a single-page application (SPA) using vanilla HTML, CSS, and JavaScript. No framework dependencies.

Key Features:

Database (SQLite)

The database uses SQLite with WAL (Write-Ahead Logging) mode for better concurrency and data integrity.

Key Tables:


API Endpoints

Authentication

MethodPathDescription
POST/api/loginLogin with username/password
POST/api/logoutLogout and destroy session
GET/api/whoamiGet current user info

Patients

MethodPathDescription
GET/api/patientsList patients (role-filtered)
GET/api/patients/{id}Get patient details

Toxicity Reports

MethodPathDescription
POST/api/reportsSubmit toxicity report
GET/api/reportsList reports

CTCAE Grades

MethodPathDescription
GET/api/gradesList CTCAE grades
GET/api/symptomsList CTCAE symptom terms

Alerts

MethodPathDescription
GET/api/alertsList alerts
POST/api/alerts/{id}/acknowledgeAcknowledge alert

Timeline

MethodPathDescription
GET/api/timelineGet care timeline

Treatment Plan

MethodPathDescription
GET/api/treatment-planGet treatment plan

Messages

MethodPathDescription
POST/api/messagesSend message
GET/api/messagesList messages

Export

MethodPathDescription
GET/api/export/summaryExport toxicity summary

Guidance

MethodPathDescription
GET/api/guidanceGet patient guidance

Audit

MethodPathDescription
GET/api/audit-logGet audit trail

AI Chat

MethodPathDescription
POST/api/chatAI chat (stub adapter)

Configuration

config.json

{
  "app_name": "HAD Digital MVP",
  "version": "1.0.0",
  "host": "127.0.0.1",
  "port": 8080,
  "debug": false,
  "database": {
    "path": "data/had.db",
    "wal_mode": true
  },
  "session": {
    "cookie_name": "HAD_SESSION",
    "max_age_seconds": 86400
  },
  "ai": {
    "adapter": "stub"
  }
}

Environment Variables

VariableDescriptionDefault
HAD_HOSTServer host127.0.0.1
HAD_PORTServer port8080
HAD_DEBUGDebug modefalse
HAD_DB_PATHDatabase pathdata/had.db
HAD_SESSION_SECRETSession secret(auto-generated)
HAD_AI_ADAPTERAI adapterstub
GLM_API_KEYGLM API key(none)

Demo Users

UsernamePasswordRoleDisplay Name
adminadmin123adminMarie Dupont
dr.martindemo123oncologistDr Martin
inf.moretdemo123had_nurseNurse Moret
nurse.leroydemo123community_nurseNurse Leroy
dr.thomasdemo123gpDr Thomas
pharm.garciademo123pharmacistPharmacist Garcia
patient.duranddemo123patientMarie Durand
caregiver.duranddemo123caregiverPierre Durand

Building the .exe

Prerequisites

Build Command

cd "C:\AI Projects\Kais Project\MVP"
python -m PyInstaller --noconfirm --clean --onedir --name "HAD Digital" --add-data "static;static" --add-data "data;data" --add-data "guidance;guidance" --add-data "adapters;adapters" --hidden-import adapters --hidden-import adapters.stub --hidden-import adapters.glm --hidden-import adapters.base app.py

Output

The built .exe is in: C:\AI Projects\Kais Project\MVP\dist\HAD Digital\


Documentation

DocumentPathDescription
API Contract03_Architecture/API_Contract.mdFull API documentation
Database Schema03_Architecture/Database_Schema.mdDatabase tables and relationships
Escalation Protocol02_Requirements/Escalation_Protocol.mdClinical escalation rules
Role Permissions02_Requirements/Role_Permissions.mdAccess control matrix
CTCAE Terms02_Requirements/CTCAE_Term_Subset.mdPrioritized CTCAE terms
User Stories02_Requirements/User_Stories.md23 user stories with acceptance criteria
MVP PlanMVP_PLAN.mdProject planning document
Execution PlanMVP_EXECUTION_PLAN.mdFull execution plan
SpecificationHAD_Digital_Specifications.docxOriginal specification

Development Notes

What's Built

What's Not Built (Future Phases)


Support

For questions or issues, contact:


License

This project is proprietary. See the specification document for intellectual property details.