A modern web application for interacting with FHIR servers. Built with FastAPI backend and React frontend.
- Patient Management: Search, create, and view patient records
- Clinical Data: Query encounters, orders, medications, and referrals
- Operational Data: Manage practitioners, schedules, and coverage
- Modern UI: Responsive React interface with real-time queries
- Type-Safe: Full type safety with Pydantic and TypeScript support
- Async: Built on async/await patterns for optimal performance
fhir_web/
├── backend/ # FastAPI backend
│ └── app/
│ ├── routers/ # API endpoints
│ ├── models/ # Response models
│ ├── middleware/ # Error handlers
│ ├── config.py # Configuration
│ ├── dependencies.py # DI setup
│ └── main.py # FastAPI app
├── frontend/ # React frontend
│ └── src/
│ ├── api/ # API client
│ ├── components/ # React components
│ ├── App.jsx # Main app
│ └── App.css # Styles
└── pyproject.toml # Python dependencies
- Python 3.11+
- Node.js 18+
- uv (Python package installer)
- Access to a FHIR server (uses public HAPI FHIR server by default)
# Install all dependencies
make install
# Or install with dev dependencies
make dev# Backend
uv venv
uv pip install -e .
# Frontend
cd frontend
npm install- Copy the example environment files:
cp .env.example .env
cp frontend/.env.example frontend/.env- Edit
.envto configure your FHIR server:
FHIR_BASE_URL=https://hapi.fhir.org/baseR4
FHIR_AUTH_TOKEN=your-token-if-required- Edit
frontend/.envif needed:
VITE_API_BASE_URL=http://localhost:8000Terminal 1 - Backend:
make run-backendTerminal 2 - Frontend:
make run-frontendBackend:
cd backend
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000Frontend:
cd frontend
npm run dev- Frontend UI: http://localhost:5173
- Backend API: http://localhost:8000
- API Documentation: http://localhost:8000/docs (Swagger UI)
- Alternative API Docs: http://localhost:8000/redoc (ReDoc)
POST /api/patients/- Create patientGET /api/patients/{patient_id}- Get patient by IDGET /api/patients/mrn/{mrn}- Get patient by MRNGET /api/patients/- Search patientsPUT /api/patients/{patient_id}- Update patient
POST /api/clinical/encounters- Create encounterGET /api/clinical/patients/{patient_id}/encounters- Get patient encountersPOST /api/clinical/orders- Create orderGET /api/clinical/patients/{patient_id}/orders- Get patient ordersPOST /api/clinical/medications- Create medication orderGET /api/clinical/patients/{patient_id}/medications- Get patient medicationsPOST /api/clinical/referrals- Create referralGET /api/clinical/patients/{patient_id}/referrals- Get patient referrals
POST /api/operational/practitioners- Create practitionerGET /api/operational/practitioners/{id}- Get practitionerGET /api/operational/practitioners/npi/{npi}- Search by NPIPOST /api/operational/coverage- Create coverageGET /api/operational/patients/{id}/coverage- Get patient coveragePOST /api/operational/schedules- Create schedulePOST /api/operational/slots- Create appointment slot
make formatmake lintmake typecheckmake test# Build frontend
make build
# Frontend will be built to frontend/dist/To serve in production:
# Backend with production ASGI server
uvicorn app.main:app --host 0.0.0.0 --port 8000 --workers 4
# Serve frontend build with nginx or similarThe backend follows a clean architecture pattern:
- Routers: Handle HTTP requests and responses
- Dependencies: Provide service instances via dependency injection
- Services: Business logic (from FHIR client library)
- Models: Pydantic models for API responses
- Middleware: Error handling and request processing
- Config: Environment-based configuration
The frontend uses modern React patterns:
- React Router: Client-side routing
- React Query: Data fetching and caching
- Axios: HTTP client
- Functional Components: With hooks
- CSS: Modern CSS with custom properties
- Backend: Add new router in
backend/app/routers/ - Frontend: Add API methods in
frontend/src/api/client.js - Frontend: Create components in
frontend/src/components/ - Register: Add router to
main.pyand route toApp.jsx
- Edit
frontend/src/App.cssfor styling - Modify components in
frontend/src/components/ - Update API client in
frontend/src/api/client.js
- Check that the FHIR library is accessible at
../fhir/ - Verify environment variables in
.env - Ensure port 8000 is not in use
- Verify backend is running on port 8000
- Check
VITE_API_BASE_URLinfrontend/.env - Check browser console for CORS errors
- Test connectivity:
curl https://hapi.fhir.org/baseR4/metadata - Verify
FHIR_BASE_URLin.env - Check if authentication token is required
make cleanMIT
Contributions welcome! Please follow the existing code style and run linting before submitting PRs.