Inspiration
Medicine shortages and medicine waste can happen at the same time. One hospital may be close to running out of an essential medicine while another has more stock than it expects to use. We wanted to explore how a shared view of inventory could help hospital teams spot those risks earlier and make better-informed decisions.
That idea became MedSupply AI: a prototype for monitoring medicine supply, exploring changes in demand, and identifying possible transfers between hospitals.
What it does
MedSupply AI brings hospital inventory and demand information together in one dashboard. Using synthetic data, it:
- Highlights medicines with less than 14 days of estimated supply.
- Flags batches approaching their expiry date.
- Suggests transfers from facilities with surplus stock while preserving a 30-day reserve at the sending hospital.
- Lets users simulate a demand surge and compare estimated stock coverage before and after the change.
- Retrieves relevant sample guidance, such as transfer handling and cold-chain precautions.
- Provides a workspace for exploring hospitals, medicines, suppliers, and inventory positions.
Each transfer suggestion includes information for a human reviewer. The prototype does not place orders or execute transfers.
How we built it
We built the application with Python and Flask. The dashboard reads hospital, medicine, inventory, demand, supplier, and document records from a database. It runs locally with SQLite sample data and includes a connection path for IBM Db2.
For the demand estimate, we calculate average daily consumption over the previous 28 calendar days. We divide available stock by that average to estimate days of supply. The transfer logic then looks for facilities with the same medicine and enough stock to retain a 30-day reserve.
We also integrated LangChain to retrieve relevant excerpts from sample procurement and handling documents. The current prototype uses a local in-memory vector store and simple token-based embeddings.
Challenges we faced
A major challenge was making recommendations useful without presenting them as automatic decisions. We added a review screen that shows the proposed quantity, stock levels, and daily use at both facilities. The reviewer still needs to verify batch details, expiry, transport conditions, and local policy.
Another challenge was explaining uncertainty in the forecast. A 28-day average is easy to understand, but it cannot capture every change in demand. We added a scenario simulator so users can explore how increased demand would affect coverage without changing the underlying records.
We also had to account for limited or missing demand history. The dashboard identifies positions without usable demand data rather than producing a shortage estimate for them.
What we learned
Building MedSupply AI showed us that a useful recommendation needs more than a number: users need to see the data, assumptions, and constraints behind it. We also learned how inventory records, demand calculations, document retrieval, and a human review interface can work together in one application.
What’s next
Our next step is to connect and validate the application against a live IBM Db2 instance and explore Db2-native vector search. We also want to improve forecasting, incorporate supplier lead times and batch-level transfer constraints, and add persistent review history and access controls.
MedSupply AI is currently a prototype using synthetic data. Its suggestions require qualified human review and are not intended for clinical or operational use.
Built With
- 7:05-pm-python
- artificial-intelligence
- css
- data
- demand-forecasting
- flask
- healthcare
- html
- ibm-db2
- inventory-management
- javascript
- langchain
- sqlite