How akkisensei/triagerag works
TriageRAG is a synthetic-data emergency-triage research prototype: deterministic code makes safety decisions, while a constrained generator drafts protocol-based actions that are machine-verified. The main workflow evaluates patient state, retrieves population-aware protocol evidence, drafts and verifies a plan, then produces a verdict and audit record. The graph also preserves protocol ingestion and the API/web surfaces. Some UI-to-API and route-to-workflow wiring is not shown in the sampled evidence, so those connections are omitted.
Main entry points: orchestrator.py Triage workflow · rule_engine.py Rule evaluation · service.py Patient-aware retrieval · draft.py Plan drafting
Components 19
Inputs and contracts
- Patient contracts
src/triagerag/contracts/schemas.py - Input normalization
src/triagerag/normalize/validators.py - Triage workflow
src/triagerag/orchestrator.py
Deterministic safety
- Clinical registry
src/triagerag/engine/registry.py - Rule evaluation
src/triagerag/engine/rule_engine.py - Dose calculation
src/triagerag/engine/dose_engine.py - Physiology scoring
src/triagerag/engine/scores.py - Safety verdict
src/triagerag/engine/verdict.py
Protocol evidence
- Protocol ingestion
src/triagerag/rag/ingest.py - Decision chunking
src/triagerag/rag/chunking.py - Retrieval index
src/triagerag/rag/index.py - Patient-aware retrieval
src/triagerag/rag/service.py
Plan and audit
- Plan drafting
src/triagerag/llm/draft.py - Deterministic mock
src/triagerag/llm/fake.py - Plan verification
src/triagerag/verify/plan_verifier.py - Audit chain
src/triagerag/audit/chain.py
User surfaces
- Web interface
web/src/App.tsx - HTTP API
src/triagerag/api/app.py
Other components
- Triage user
Connections 22
- Triage user → Web interface: submits case
- Web interface → HTTP API: sends requests
- HTTP API → Triage workflow: runs triage
- Triage workflow → Input normalization: validates input
src/triagerag/orchestrator.py - Triage workflow → Rule evaluation: evaluates rules
src/triagerag/orchestrator.py - Triage workflow → Physiology scoring: computes scores
src/triagerag/orchestrator.py - Triage workflow → Safety verdict: resolves verdict
src/triagerag/orchestrator.py - Rule evaluation → Clinical registry: reads rules
src/triagerag/engine/rule_engine.py - Rule evaluation → Dose calculation: checks doses
src/triagerag/engine/rule_engine.py - Triage workflow → Patient-aware retrieval: retrieves evidence
src/triagerag/orchestrator.py - Patient-aware retrieval → Retrieval index: searches index
src/triagerag/rag/service.py - Protocol ingestion → Decision chunking: parses protocols
src/triagerag/rag/ingest.py - Triage workflow → Plan drafting: requests draft
src/triagerag/orchestrator.py - Plan drafting → Deterministic mock: generates draft
- Triage workflow → Plan verification: verifies plan
src/triagerag/orchestrator.py - Triage workflow → Audit chain: records assessment
src/triagerag/orchestrator.py - Patient contracts → Triage workflow: defines payloads
src/triagerag/orchestrator.py - Triage workflow → Rule evaluation: Pass 1 safety
src/triagerag/orchestrator.py - Rule evaluation → Patient-aware retrieval: conditions retrieval
- Patient-aware retrieval → Plan drafting: supplies evidence
- Plan drafting → Plan verification: submits plan
- Plan verification → Audit chain: verified result