A React TypeScript monorepo application for Bahmni applications, built with Nx, Webpack, and Carbon Design System. This application includes PWA support for offline capabilities.
Bahmni is an open-source healthcare information system designed to serve healthcare providers in resource-limited settings. It combines electronic medical records (EMR), hospital information management, and clinical workflows into a unified platform. Bahmni is built on OpenMRS and focuses on making healthcare delivery more efficient and patient-centric. The platform follows FHIR (Fast Healthcare Interoperability Resources) standards to ensure interoperability with other healthcare systems.
- React - UI library for building user interfaces
- Carbon Design System - IBM's open-source design system
- Webpack - Module bundler for modern JavaScript applications
- React Router - Declarative routing for React applications
- i18n Support - Internationalization for multiple languages
- Display Controls - Reusable clinical data visualization components
- Node.js (v18.x or later recommended)
- Yarn (v1.22.x or later recommended)
# Install dependencies
yarnFor a comprehensive setup guide including development environments, Docker configuration, authentication setup, and troubleshooting, please refer to our Setup Guide.
- Frontend Architecture - A comprehensive overview of the Bahmni Apps Frontend architecture
- Project Structure - A high-level overview of the project structure
- i18n Guide - Internationalization implementation details
- Sortable Data Table Guide - Usage of the sortable data table component
- Global Notification Guide - Using the notification system
# Build the application
yarn build The build artifacts will be stored in the dist/ directory.
# Start the development server
yarn nx serve distroThis will start the development server at http://localhost:3000.
# Run ESLint to check for code quality issues
yarn lint
# Fix ESLint issues automatically
yarn lint:fixFor a more detailed explanation of the project structure and architecture, see Architecture Documentation and Project Structure Documentation.
yarn dev- Start the development serveryarn build- Build the application for productionyarn test- Run testsyarn test:watch- Run tests in watch modeyarn test:coverage- Run tests with coverage reportyarn lint- Run ESLint to check for code quality issuesyarn lint:fix- Fix ESLint issues automaticallyyarn format- Format code with Prettier
- React - UI library
- TypeScript - Type-safe JavaScript
- Carbon Design System - IBM's design system
- Webpack - Module bundler
- React Router - Routing library
- i18next - Internationalization framework
- Jest - Testing framework
- React Testing Library - React testing utilities
- ESLint - Code quality tool
- Prettier - Code formatter
- Workbox - PWA tooling
This branch adds two AI features on top of standard Bahmni:
- Agent Bahmni — a voice/text assistant that registers patients, searches records, opens consultations, and records diagnoses, medications, and observations by speaking or typing.
- Clinical Insights — an AI-powered panel on the consultation page that streams evidence-based recommendations for the patient's active conditions (requires the
bahmni-aibackend service).
- A floating chat panel appears on every page.
- Click the microphone to speak, or type a command directly.
- Speech is transcribed (Web Speech API or local Whisper) and sent to Claude Sonnet via the Anthropic API.
- Claude calls structured tools (register patient, search, add diagnosis, etc.) that interact with the OpenMRS FHIR API.
- A "Clinical Insights" panel appears on the patient consultation page.
- Click Generate to stream AI recommendations for the patient's conditions.
- The panel calls the
bahmni-aiPython service (localhost:8090), which fetches FHIR data, loads clinical guidelines, and runs inference via an LLM.
| Requirement | For what | Where to get it |
|---|---|---|
| Node.js v22+ / Yarn v1.22+ | Frontend | Standard setup above |
Anthropic API key (sk-ant-...) |
Agent Bahmni + Ask Questions | console.anthropic.com |
bahmni-ai Python service |
Clinical Insights panel | Clone the bahmni-ai repo separately |
| Python 3.11+ + ffmpeg | Local Whisper STT (optional) | python.org, ffmpeg.org |
Clinical Insights without
bahmni-ai: The panel renders but "Generate" will silently fail (connection error). This is expected — Clinical Insights is a separate service. Agent Bahmni and the voice tools work without it.
Run the interactive setup script:
./setup.shThe script walks through:
- Anthropic API key — prompts for your
sk-ant-...key and writes it toai-config.json. - Frontend dependencies — runs
yarn installifnode_modulesis missing. - Whisper STT server (optional) — choose a model size, writes
whisper-server/.env, installs Python deps.
At the end it prints the exact commands to start each service. Then continue with the bahmni-ai backend step below.
Step 1 — Add your Anthropic API key
Open ai-config.json in the project root and replace the placeholder:
{
"anthropicApiKey": "sk-ant-..."
}The webpack dev server serves this file at /ai-config. The agent and Clinical Insights panel load the key from there at startup — no hardcoding or environment variables needed.
Important:
ai-config.jsonis listed in.gitignore. Never commit a real key. If you accidentally do, rotate the key immediately at console.anthropic.com.
Step 2 — Start the bahmni-ai backend (for Clinical Insights)
Clone and start the service in a separate terminal:
git clone https://github.com/Bahmni/bahmni-ai.git
cd bahmni-ai
# Follow the README there for Python env setup and configuration
python -m uvicorn app.main:app --host 0.0.0.0 --port 8090The webpack dev server proxies /bahmni-ai → http://localhost:8090 automatically. If bahmni-ai is not running, the Clinical Insights panel shows "Connection error" — this does not affect Agent Bahmni.
Step 3 — Start the Whisper STT server (optional)
Whisper replaces Chrome's cloud-based Web Speech API, which is often blocked on hospital networks.
cd whisper-server
pip install -r requirements.txt
python server.pyStarts on http://localhost:8765. The dev server proxies /whisper-stt to it automatically.
To choose a model size, set WHISPER_MODEL in whisper-server/.env or inline:
WHISPER_MODEL=medium python server.pyAvailable sizes: tiny (~75 MB), small (~465 MB, default), medium (~1.5 GB), large (~3 GB).
Or run via Docker:
docker build -t whisper-server ./whisper-server
docker run -p 8765:8765 whisper-serverStep 4 — Start the frontend
yarn devStarts at http://localhost:3000. The webpack dev server also handles the Anthropic proxy at /anthropic-proxy/v1/messages — no separate process needed for development.
Step 5 — Use the Agent
- Log in to Bahmni and navigate to any screen.
- Click the chat panel in the bottom-right header area to open Agent Bahmni.
- Speak or type, for example:
- "Register John Doe, male, born 1990"
- "Search patient Ramesh Kumar"
- "Add fever diagnosis"
- "Add blood pressure 120 over 80"
- "Submit consultation"
The agent understands English, Hindi, and Hinglish (mixed Hindi-English).
| Component | Repo / Location | Port | Required for |
|---|---|---|---|
| Frontend (webpack dev server) | distro/ |
3000 | Everything |
bahmni-ai Python service |
bahmni-ai repo |
8090 | Clinical Insights |
| Whisper STT server | whisper-server/ |
8765 | Local voice input (optional) |
| Standalone Anthropic proxy | anthropic-proxy/ |
3001 | nginx deployments only |
| Agent source | distro/src/agent/ |
— | — |
When serving via nginx instead of the webpack dev server, the built-in Anthropic proxy is unavailable. Run the standalone Node.js proxy:
cd anthropic-proxy
node server.jsOr via Docker:
docker build -t anthropic-proxy ./anthropic-proxy
docker run -p 3001:3001 anthropic-proxyThen add to your nginx config:
location /anthropic-proxy/ {
proxy_pass http://localhost:3001/;
}
location /bahmni-ai/ {
proxy_pass http://localhost:8090/;
}| Issue | Impact | Workaround / Status |
|---|---|---|
"New Consultation" crash — ClinicalInsights has no error boundary; any render error takes down the whole consultation page |
Page crash on consultation load if ClinicalInsights throws |
Wrap <ClinicalInsights /> in an <ErrorBoundary> in ConsultationPage.tsx:270 |
Agent start_encounter navigates to wrong route — tool navigates to /clinical/<uuid>/consultation but the route is /:patientUuid |
Agent opens a blank page instead of the consultation | Fix targetPath in distro/src/agent/tools/startEncounterTool.ts:43 to /clinical/<uuid> |
Deep imports from @bahmni/clinical-app fail in production builds — addDiagnosisTool and addMedicationTool import from @bahmni/clinical-app/stores/... which is not in the package exports map |
Agent diagnosis/medication tools silently broken in production; yarn typecheck reports errors in distro/ |
Works in yarn dev (webpack alias). Production builds require either adding exports entries to apps/clinical/package.json or moving the shared Zustand stores into a separate importable package |
yarn typecheck reports errors in distro/ |
TypeScript check fails for agent tools | Known — does not affect yarn dev or the clinical/registration apps. Run nx typecheck @bahmni/clinical to check only the clinical app |
ai-config.jsonis gitignored — your API key stays local only.- Never commit a real key. If you accidentally do, rotate it immediately at console.anthropic.com.
- The Anthropic proxy strips all headers before forwarding — your key is never logged or stored server-side.
[Add license information here]