5d98aa57cb7af5314a80c4dfacc2e90638654684
Poona Hospital Asset Management System
A centralized Hospital Asset Management and Maintenance System for Poona Hospital and Research Centre.
Quick Start
Prerequisites
- Python 3.11+
- Node.js 18+
Backend
cd backend
python -m venv .venv
# Windows PowerShell:
.venv\Scripts\activate
# macOS/Linux:
# source .venv/bin/activate
pip install -r requirements.txt
python -m uvicorn app.main:app --reload --port 8000
- Health check: http://localhost:8000/api/health
- API docs: http://localhost:8000/docs
Frontend
cd frontend
npm install
npm run dev
Run both servers (with Make)
make dev
Run tests
# Backend (activate .venv first: Windows .venv\Scripts\activate | macOS/Linux source .venv/bin/activate)
cd backend
python -m pytest tests/ -v
# Or via Make: make test
# Frontend (build + Vitest)
cd frontend
npm run build
npm test
Seed demo data
# Activate .venv first: Windows .venv\Scripts\activate | macOS/Linux source .venv/bin/activate
cd backend
python -m app.seed.seed
# Or via Make: make seed
Docker Compose (Production-style local container run)
cp .env.example .env
docker compose up --build
- Frontend (Nginx +
/apireverse proxy): http://localhost:5173 - Backend API & Swagger docs: http://localhost:8000/docs
- SQLite DB and uploads persist under
./backend/data(mounted to/app/data).
Documentation & Walkthroughs
- 10-Minute Demo Script
- Acceptance Checklist & UAT Sign-off Matrix
- Role-Based User Guide
- Assumptions, Retention & Governance Policies
Database Backup & Disaster Recovery
The application includes an automated, online backup utility in backend/scripts/backup.py that utilizes SQLite's safe online backup API (sqlite3.Connection.backup) to capture a transactionally consistent snapshot of the database alongside all uploaded attachment files without requiring downtime.
Running a Manual Backup
cd backend
# Windows:
.venv\Scripts\python.exe scripts/backup.py backup
# macOS/Linux:
python scripts/backup.py backup
- Creates a timestamped archive:
backend/data/backups/ams_backup_YYYYMMDD_HHMMSS.zipcontainingams.dband theuploads/folder. - Runs
PRAGMA integrity_checkautomatically before bundling. - Retains the latest 7 backups by default (
--keep Nflag configurable).
Verifying Backup Integrity
cd backend
python scripts/backup.py verify data/backups/ams_backup_20261113_174700.zip
Restoring from a Backup
cd backend
python scripts/backup.py restore data/backups/ams_backup_YYYYMMDD_HHMMSS.zip
- Validates SQLite integrity before restoring.
- Automatically saves a
.safety_pre_restore_<timestamp>.bakof the active database before overwriting. - Unpacks attachments directly into
backend/data/uploads/.
Automated Nightly Backups
To schedule automatic nightly backups at 01:00 AM:
- Linux / Docker (cron):
0 1 * * * cd /path/to/poona-ams/backend && /path/to/poona-ams/backend/.venv/bin/python scripts/backup.py backup >> /var/log/ams_backup.log 2>&1 - Windows (Task Scheduler / PowerShell):
schtasks /create /tn "PoonaAMS_NightlyBackup" /tr "powershell -ExecutionPolicy Bypass -Command 'cd C:\path\to\poona-ams\backend; .\.venv\Scripts\python.exe scripts\backup.py backup'" /sc daily /st 01:00
Demo Accounts
| Password | Role | |
|---|---|---|
| admin@poona.demo | Demo@123 | System Admin |
| bio@poona.demo | Demo@123 | Biomedical |
| dept@poona.demo | Demo@123 | Department User (ICU) |
| mgmt@poona.demo | Demo@123 | Management |
| coord@poona.demo | Demo@123 | Coordinator |
Implemented Application (Phases 0–8 Complete)
- Complete SQLAlchemy 19-table data model across masters, assets, maintenance, complaints, operations, and system modules with performance indexes on foreign keys, status, and date columns
- JWT authentication (
/api/auth/login,/api/auth/me), sliding-window login rate limiter (429 RATE_LIMITED), RBAC permission matrix for 5 roles, and Quick Demo Login - Admin Master Lists CRUD (
/masters: Departments, Locations, Categories, Vendors, Users) and Audit Log Viewer (/audit-logs,system_adminonly with entity/user/action/date filters and JSON diff modal) - Typed System Settings (
/settings) and TopBar "As of Date" Demo Clock (POST /api/settings/demo-date) + Admin"Run alert check now"(POST /api/alerts/run) - Live Global Quick Search in TopBar (
GET /api/search?q=) returning grouped Assets & Complaints withdepartment_userscoping - Asset Register (
/assets&/assets/:id): full CRUD with duplicate asset code check (409), department scoping, coordinator field-level edit restrictions, 8-tab Asset Detail Overview, audit logging, and Bulk Asset Import (GET /api/assets/import-templateExcel template withMaster Referencesheet +POST /api/assets/bulk-importdry-run validation preview & skip-invalid option) - Breakdown & Complaint Register (
/complaints&/complaints/:id): sequential complaint numbering,AssetPickerraise modal with multi-file attachments, response time & ongoing/milestone downtime calculations, assign/attend/restore/close/reopen workflow with asset status sync, event timeline, admin timestamp correction, and role-enforced technical/CE/spares section (FORBIDDEN_TECHNICAL_FIELDS403 + read-only lock banner) - Preventive Maintenance (
/pm): in-house & outsourced PM schedules (/api/pm/schedules), dynamic read-timeupcoming/due/overdue/completed/rescheduledstatus & severity evaluation againsteffective_today(), KPI summary strip, Table View & 7-column Mon–Sun Month Calendar View, Complete (auto-advancing next cycle viaadd_months) and Reschedule workflows, plus Asset Detail PM tab actions - Calibration (
/calibration): single & bulk calibration plan creation (/api/calibration/plans/from-asset/:assetId,/bulk-from-assets), management/admin/coordinator-gated frequency edit & approval (FORBIDDEN_CALIBRATION_APPROVAL403 for biomedical), dynamic read-time status/severity computation, completion with certificate file upload (calibration_recordattachments) and auto-generated next due cycle, plus Asset Detail Calibration tab wiring - Contracts & Warranties (
/contracts): AMC/CMC/OTHER contract CRUD, expiry chips (amc_cmc_lead_days,red_threshold_days), renewal workflow (POST /api/contracts/:id/renewmarking prior contractis_superseded=Trueand linkingrenewed_from_id), renewal history chain (/api/contracts/history/:assetId), warranty tracking with auto-computed editable end date, and inline document attachments (contract/warranty) - Asset Insurance (
/insurance) & Slide-OverInsuranceDrawer: insurance policy register with INR coverage display, expiry alerts, policy attachments (insurance), and"View Insurance"drawer accessible fromAssetDetailPage,AssetPicker, andComplaintDetailPage - Demo Equipment (
/demo-equipment): trial equipment register with dynamicon_demo/overdue_return/returnedstatus relative toeffective_today(), return logging (POST /api/demo-equipment/:id/return), anddemo_equipmentattachments - Department Visits (
/visits): biomedical/admin round logs with management read access (403 fordepartment_userandcoordinator), department-filtered multi-asset checklist, observations, and complaint creation/linking (POST /api/visits/:id/link-complaint) - Alert Engine, Scheduler & Notifications (
/notifications+ TopBar Bell & Calibration Login Pop-up): APScheduler06:00 Asia/Kolkatadaily job using short-livedget_scheduler_db(), deduplicated 7-type alerts (amc_expiry,calibration_due,pm_due,insurance_expiry,warranty_expiry,demo_overdue,critical_complaint) evaluated againsteffective_today()/effective_now_utc(), per-userNotificationReadstate withdepartment_userentity-department filtering, 60s bell polling with live toast alerts, and once-per-loginCalibrationReminderModal - Hospital Operations Dashboard (
/): role-awaredepartment_scopebanner, 7 clickable KPI cards, 4 Recharts visualizations (Complaints by Status, Complaints by Department, 6-monthclip_downtime_to_monthDowntime Trend, PM Planned vs Completed),"Needs Attention"red alerts panel, and"Recent Complaints"table - 8 Operational Reports & Excel Exports (
/reports&/reports/:reportKey): Monthly Maintenance (withclip_downtime_to_monthuptime/downtime hours,"How this is calculated"formula_infopanel, and Recharts BarChart + PieChart), Monthly Department, Daily Department Visit (403 fordepartment_user&coordinator), Breakdown & Complaints, PM Compliance, Calibration Due, AMC/CMC & Warranty, and Demo Equipment reports; tailored filters, styled openpyxl Excel (.xlsx) report exports (/api/reports/{report_key}/export), Excel (.xlsx) table exports across allDataTableviews, and A4@media printstyles (no-print/print-header) - Reusable
AssetPicker(/api/assets/lookup) with warranty/condemned status badges - Secure Document Attachments (
/api/attachments: JPG/PNG/PDF validation with magic-byte check, 10 MB limit, authenticated preview/download, role-based upload/delete) - Idempotent deterministic seed script (
python -m app.seed.seed) populating realistic hospital demo data - Responsive React + TypeScript frontend app shell across
360px+mobile,768px+tablet, and1280px+desktop (wrapping TopBar,lg:drawer Sidebar, responsive modals & tabs, accessible<ConfirmDialog />, DataTable with Excel.xlsxexport, Tailwind CSS + shadcn/ui) - Docker packaging (
docker-compose.yml,backend/Dockerfile,frontend/Dockerfile,frontend/nginx.conf,.env.example) &Makefile
Modules (Phases 0–8 Complete)
Phase 0: Scaffold | Phase 1: Auth & Masters | Phase 2: Assets | Phase 3: Complaints Phase 4: PM & Calibration | Phase 5: Contracts, Warranty, Insurance, Demo, Visits Phase 6: Notifications & Dashboard | Phase 7: Reports | Phase 8: Polish, Search, Audit Log, Packaging & Docs
Languages
TypeScript
50.2%
Python
49.4%
CSS
0.2%
JavaScript
0.1%
