Design Medication Data Import from Multiple Providers
Import medication records from pharmacies, hospitals, and prescribers into one current, explainable medication list per resident, without duplicates or silent overwrites.
Problem statement
Build the backend that brings each resident's medication records in from several outside sources and keeps one trusted list per resident on a care platform.
For this exercise, assume the platform is used by nursing facilities, and it keeps one current medication list for each resident. Medication information comes from outside providers: the pharmacies that fill the facility's prescriptions, hospitals that send discharge records, and prescribers' health record systems.
Each facility connects to a few providers. Some providers offer an API that the platform calls to fetch changes (pull). Others send each change through a webhook, or drop a nightly file with each resident's full list (push).
Providers use their own patient IDs, and some send standard drug codes while others send only a drug name and strength as text.
For this exercise, also assume these rules. The same medication can arrive from several providers, and many times from one provider; the resident's list must show it once. A provider can update or stop a medication, and the list must follow that provider's newest information even when messages arrive out of order.
When two providers disagree about the same medication, for example on the dose, or one stops it while another still lists it, the platform must not pick one silently: the item is flagged for a nurse to resolve, and both versions stay visible. A nurse's decision stands until a newer change from a provider arrives.
A record that cannot be matched to a resident with confidence goes to a review queue instead of a guess. Every item on the list shows which providers reported it and when. This is health information, so only staff of the resident's facility can see it, and access is audited.
Prescribing, recording doses given to residents, drug-interaction checks, billing, and building the providers' own systems are out of scope.
What to build
- An administrator can connect a facility to a provider by pull API, webhook, or nightly file, and the platform imports every medication record that the provider sends or returns.
- Each imported record is matched to one resident, or sent to a review queue when the match is uncertain, and one medication appears once on the resident's list no matter how many providers or resends report it.
- Updates and stops from a provider change the list in the order that provider made them, and disagreements between providers are flagged for a nurse to resolve with both versions shown.
- Staff can see each provider connection's health, including its last successful import, delay, errors, and unmatched records, and are alerted when a connection stops sending or keeps failing.
At scale
- For this exercise, assume 2,000 facilities, 200,000 residents with about 12 active medications each, and 5,000 provider connections.
- For this exercise, assume about 1 million medication records arrive on a normal day and most repeat data the platform already has. Many pharmacies send a nightly full file between 1 a.m. and 3 a.m., and one file can hold 50,000 records.
- For this exercise, assume a pushed change should appear on the resident's list within 5 minutes, pulled providers are synced at least every hour within each provider's rate limit, and a nightly file is fully applied within 1 hour of arrival.