A backend service for ingesting patient medication data from multiple sources, detecting conflicts, and managing their resolution.
API Documentation (Swagger UI): 👉 https://medication-reconciliation-service-1.onrender.com/docs
# Clone the repository
git clone <your-repo-link>
cd medication-reconciliation-service
# Create virtual environment
python -m venv venv
venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txt
# Set environment variable
set MONGO_URL=your_mongodb_atlas_url
# Run the server
uvicorn app.main:app --reloadThe service follows a layered architecture:
- Routes → API endpoints (FastAPI)
- Services → Business logic (ingestion, conflict detection)
- Repositories → Database interaction (MongoDB)
- Models/Schemas → Data validation (Pydantic)
- Client sends medication data
- Service compares with latest snapshot
- Conflicts are detected
- New snapshot stored with versioning
- Conflicts stored separately for tracking
- Conflict detection is based on simple field comparison (e.g., dose mismatch)
- Versioning is linear (no branching/merging of histories)
- No authentication added to keep scope focused
- MongoDB chosen for flexibility with nested medication data
- No user authentication / authorization
- Conflict resolution is manual only
- No pagination for reports
- No advanced conflict rules (e.g., drug interactions)
- Add auth (JWT)
- Improve conflict detection rules
- Add audit logs
- Deploy with Docker for portability
You can populate sample data using:
python scripts/seed.pyRun tests with:
pytestCovers core ingestion and conflict detection logic.
AI tools were used to:
- Speed up boilerplate setup (FastAPI structure, initial scaffolding)
- Assist in refining architecture and edge-case handling
- Designed overall architecture and data flow
- Implemented conflict detection and versioning logic
- Structured repositories and services cleanly
- FastAPI
- MongoDB (Atlas)
- Motor (async MongoDB driver)
- Pydantic
- Pytest
- Hosted on Render
- Uses MongoDB Atlas for cloud database
- Environment-based configuration for production readiness
- Medication ingestion with versioning
- Conflict detection across sources
- Conflict storage and resolution
- Reporting of unresolved conflicts
- Fully async backend
Arun S Nair