Care-plan coordination platform for hospital staff — Team Gita Yoddhas (SYNAPSE 1.0 · PS-14).
Collect → Connect → Detect → Correct → Remind → Escalate
CareLoop unifies fragmented hospital schedules—clinic encounters, lab orders, procedures, and medications—into a single patient timeline. It detects scheduling collisions and duplicate lab orders in real time, proposes de-conflicted corrective plans, and logs every staff resolution in an append-only audit trail.
Operational coordination support only — not intended for clinical diagnosis or medical decision-making.
- Risk-Ranked Patient Roster: Tracks 14 baseline patients (2 deterministic demo patients + 12 curated Synthea EHR patients, 487 clinical events) sorted by live scheduling risk score.
- Multi-Lane Clinical Timeline: Organizes events across
encounter,lab_order,procedure, andmedicationlanes, flagging overlapping appointments and redundant lab orders. - Deterministic Rule Engine:
- Schedule Conflicts: Flags non-cancelled overlapping events (
a.start_time < b.end_timeandb.start_time < a.end_time) ashighseverity /Definiteconfidence. - Duplicate Lab Orders: Flags matching
test_typeorders within 72 hours without results (Definite/med), or within 7 days / with an existing result (Possible/low). - Risk Score:
min(1.0, (2 * missed + 1.5 * overdue + 3 * conflicts + 1 * duplicates) / 10).
- Schedule Conflicts: Flags non-cancelled overlapping events (
- Corrected Plan Proposals: Generates before-and-after schedule adjustments (automatic next-slot rescheduling and duplicate order cancellation) with one-click staff approval.
- Anomaly Simulation Sandbox: Inject synthetic conflicts or duplicate lab orders via the UI or REST API and inspect sub-second detection latency.
- Append-Only Audit Trail: Captures prior state, new state, actor ID, timestamp, and notes for every accepted adjustment.
- Offline-First Stack: Runs completely locally on FastAPI, SQLite, and React/Vite (with an optional standalone Mock Mode toggle in the dashboard header).
careloop/
├── api/ # FastAPI application, schemas & adapters (port 8000)
│ ├── main.py # REST endpoints (/patients, /alerts, /inject, /reset, /audit, /health)
│ ├── adapters.py # Adapter routing between data/engine packages & fallback
│ ├── fallback.py # Self-contained SQLite fallback layer
│ ├── models.py # Pydantic request/response models (API_CONTRACT.md v1.3)
│ └── timeutil.py # UTC ISO-8601 parsing & formatting helpers
├── data/ # SQLite persistence & Synthea dataset loaders
│ ├── db.py # SQLite connection & schema setup (careloop.db)
│ ├── store.py # Patient, event, alert, and audit CRUD + risk scoring
│ ├── seed.py # Baseline seeder (2 demo patients + 12 Synthea subset patients)
│ ├── synthea_demo.json # Curated 12-patient / 480-event Synthea subset
│ ├── synthea_subset.py # Loader for synthea_demo.json into careloop.db
│ ├── synthea_loader.py # Full Synthea CSV ingestion pipeline (data/raw/*.csv)
│ └── test_names.py # LOINC lab test name normalizer
├── engine/ # Pure rule-based detection & plan correction engine
│ ├── config.py # Time windows (72h, 7d, 14d) & risk weights
│ ├── rules.py # Conflict, duplicate, missing-step, slot-finder & risk rules
│ └── service.py # Service bindings connecting rules to data.store
├── frontend/ # React + TypeScript + Vite + Tailwind CSS UI (port 5173)
│ └── src/
│ ├── api.js # Backend API client & optional standalone mock simulator
│ ├── pages/ # Patients, Timeline, Alerts, CorrectedPlan, InjectTest, AuditLog
│ ├── components/ # Header, Sidebar, OfflineBanner, Footer, skeletons, toasts
│ └── utils/ # Frontend overlap/duplicate helpers & tests
├── tests/ # Pytest test suite, HTTP stress tests & metrics benchmark
├── API_CONTRACT.md # REST API v1.3 specification, rules & seed reference
├── requirements.txt # Python dependencies
└── run.bat # Windows launcher for backend + frontend
- Python 3.10+
- Node.js 18+
pip install -r requirements.txt
uvicorn api.main:app --reload --port 8000On first launch, CareLoop automatically initializes careloop.db and seeds the 14 baseline patients (p-101, p-102, and p-s01–p-s12).
cd frontend
npm install
npm run devOpen http://localhost:5173 in your browser.
(On Windows, after installing Python and Node dependencies, you can run run.bat from the repository root to start both servers.)
See API_CONTRACT.md for full request/response schemas.
| Method | Endpoint | Purpose |
|---|---|---|
GET |
/health |
Service health check |
GET |
/patients |
List patients ranked by risk_score descending |
GET |
/patients/{id}/timeline |
Get chronological clinical events for a patient |
GET |
/alerts |
List alerts (filterable by patient_id and status) |
GET |
/patients/{id}/corrected-plan |
Get proposed schedule & cancellation adjustments |
POST |
/inject |
Inject a synthetic conflict or duplicate event and run detection |
POST |
/alerts/{id}/accept |
Accept adjustment, update timeline, resolve alert & write audit log |
GET |
/audit |
Retrieve append-only audit history (newest first) |
POST |
/reset |
Reset database to clean 14-patient baseline |
| Variable | Default | Description |
|---|---|---|
USE_TEAM_CODE |
1 |
Set to 0 to route through standalone api/fallback.py |
CARELOOP_SYNTHEA |
1 |
Set to 0 to seed only the 2 deterministic demo patients (p-101, p-102) |
CARELOOP_ENGINE |
(unset) | Set to fallback (with USE_TEAM_CODE=0) to use fallback detection rules |
CARELOOP_DB |
careloop.db |
SQLite database path used by api/fallback.py |
VITE_API_URL |
http://localhost:8000 |
Override backend API base URL in the frontend |
python -m pytest -vtests/test_stress.py automatically connects to a running server on http://127.0.0.1:8000 or spawns a temporary uvicorn instance during the test run.
To run the live accuracy & latency benchmark (with the backend running):
python tests/metrics.pycd frontend
npm run lint
npm test
npm run buildTeam Gita Yoddhas — SYNAPSE 1.0 (PS-14)
- Rohit Kumar Singh (
data/) — Data loading, SQLite schema, CRUD store, demo seed & Synthea ingestion - Samir Kumar Shaw (
engine/) — Conflict, duplicate & missing-step detection rules, slot finder & risk scoring - Sanchayan Saha (
api/,frontend/) — FastAPI backend & React staff coordination dashboard - Monomoy Dikhshit (
tests/) — Integration tests, stress harness & accuracy metrics