Medical supply EDI integration: moving a distributor off middleware without losing an order
A US wholesale distributor sells 85,211 SKUs from 38 suppliers to clinics on contract prices. We connected its suppliers, online store, CRM and accounting into one record, and moved its supplier EDI from a third-party middleware onto a direct AS2 link it owns.
November 29, 2026 · 11 min read · Jitendra Choudhary, CTO & Co-Founder
The business: integration is the operation
A medical supply distributor's margin is thin and its stock mostly sits with other companies, so every sale depends on another company's system answering.
The client sells medical supplies wholesale to US clinics, practices and other licensed providers. Many buy on buying-group contracts, so each clinic has its own price for the same box of gloves. Most of what the client sells ships from distributors and makers. A sale is only finished when those companies take the order, confirm it, ship it and invoice it.
One number shaped every decision. The store lists 85,211 SKUs from 38 suppliers and 369 manufacturers, and one national distributor supplies about 99% of them. That distributor got a direct, fully tracked EDI link. The other suppliers run through a clean manual path, and one order can use both.
Explore our healthcare interoperability solutions for supplier, payer and EHR data exchange.
We started as the build team for phase 1 and stayed on as the client's technical partner. A team of about eight runs the platform with the client's operators, in short cycles planned against what sales and operations need next. The client owns the code, the cloud account, the runbooks and the debug logs.
What a clinic or MSO buying supplies gets
- Its own contract price on every line, set per site and ship-to address.
- A savings quote built from its own purchase history, accepted without a login.
- Backorder dates and tracking numbers on the order page, straight from the supplier.
- Reorders by text or chat, with every cart change confirmed by the buyer.
- Prescription and license-gated items routed to a rep, never added by a bot. See our pharmacy integration work for prescription flows.
Why the first EDI integration was not enough
The middleware delivered orders, but the team could not see how, could not split an order, and heard about failures from the clinics.
| Before: integration middleware | After: direct EDI the team owns |
|---|---|
| Checked for ready orders every few minutes and took each order whole | Saving an order starts the EDI pipeline, nothing polls |
| An order with items from two suppliers had no clean path | Each order splits into one purchase order per supplier |
| Retries and errors lived in someone else's tool | Every message has a state in the platform's own database |
| Orders could sit in processing with nobody told | A supplier that goes quiet raises an alert before the clinic calls |
| A license fee, plus middleware work for every new supplier | A new supplier is a partner record and a test round |
Every arrow is a stored message with a state.
The old website chatbot had the same problem. In a sample of 28 real chats, about 40% asked for the price and stock of a known item, and about a fifth each asked for order status or specifications. The platform held that data. The chatbot could not reach it, so each chat became a ticket.
The cutover: nine days on a live supplier link
Moving EDI off middleware means getting another company's gateway to trust yours while real orders keep moving. This is the record from the team's debug log.
We moved the flow into the platform. Saving an order now splits it into one purchase order per supplier and sends each over AS2, the signed and encrypted channel suppliers use for X12 EDI. The old middleware endpoint now returns an error, so a forgotten job fails loudly.
| Date (2026) | What happened |
|---|---|
| May 18 | A new production certificate is created for the direct link. |
| May 25 | Cutover starts. The distributor is still receiving live orders through the old middleware address. |
| May 26 | The first receipts fail. The new private key is deployed and decryption works within the hour. Then a new error: messages arrive without a signature we can verify. |
| May 29 | A test purchase order is rejected as "authentication failed". Our own tracker still marked it as sent, and we logged that as a bug. |
| June 1 | An audit of every certificate shows the cause. The distributor's production channel still trusted the old middleware's certificate. Its test channel had been updated, production had not. |
| June 2 | The right certificate is installed and both directions verify. One setting remains on the distributor's side: signing its outbound messages. |
Our first explanation, that the distributor was not signing, turned out to be wrong. We tested it against the logs and dropped it when the certificate evidence came in.
We could have made the last error go away by accepting unsigned messages. That would also let anyone send a forged order or invoice. The check stayed on.
Direct EDI went live on June 2, 2026. In June, 52 of 112 orders (46%) went to the supplier by EDI. By October it was 163 of 185 (88%), with order confirmations, ship notices and invoices coming back the same way.
Orders placed versus orders sent by direct EDI. November is left out because it is not over.
See how we run integration monitoring and support after go-live.
The five EDI messages behind every drop-ship order
EDI is the fixed text format companies use to swap orders, receipts, shipping notices and invoices. These five carry every drop-ship order.
| Message | Sent by | What the platform does with it |
|---|---|---|
| 850 Purchase order | Platform | One per supplier, with a control number unique to that partner. Order 58213 part 0 is sent as 58213-0. |
| 997 Receipt | Supplier | Stored with a duplicate-proof key, so a resent copy is processed once. |
| 855 Line answers | Supplier | Accepted lines and backorder dates. The clinic sees the date on its order page. |
| 856 Shipping notice | Supplier | Tracking for the part that shipped. No 856 after a 997 raises a daily alert. |
| 810 Invoice | Supplier | Checked against the order before customer invoices go to accounting. |
The operations view lists only orders that need a person. Recreated screen, sample data.
One order, every reply.
Winning a clinic from its purchase history
Clinics already have a supplier, so a rep has to prove savings on what they buy today, line by line.
A rep uploads the clinic's usage file. Each line is matched by the maker's part number first, then by meaning, then checked by an AI model that scores its confidence. Uncertain lines go to the rep, never straight onto the quote. Every match is priced at that clinic's contract price, and prescription and license-gated items are held back as "Contact sales".
See how our healthcare AI agents handle matching and checking work with a person in the loop.
Review: the rep checks only what needs an eye. Recreated from the real product with sample data.
The quote, with what cannot be sold online.
The clinic accepts with no login, and the cart fills in one step.
A 549-line usage file goes from upload to a priced quote in about 2.5 minutes (median of 5 runs, 2.3 to 3.3 minutes). An 8,319-line file covering eight months took 22 minutes. On the 549-line file, 83% of lines (453) matched with high confidence and 90% (494) got a usable match. Only 10% came back weak, and three later runs of the same file landed between 88% and 93% usable.
QA ran the same real file and found three pricing faults. Each one is now a guard in the pricing code.
| Lines hit | What went wrong | The guard now |
|---|---|---|
| 32 | A bare container word such as "Bottle" or "Kit" with no count blanked the clinic's current price, so the saving looked far bigger than it was. One disinfectant alone hid $2,339.84 a month of spend. | A bare container counts as a pack of one. |
| 68 | A roll of 1,200 sheets was read as 1,200 rolls. One line would have quoted $876,148. | When the two per-unit prices differ tenfold or more, the line stops and is marked as a pack-size conflict. |
| 13 | Low-confidence "different form" matches reached quotes, such as glucagon matched to an epinephrine kit. | Different-form matches under 60% go to the not-quotable list. |
A line can hit more than one guard, so the three counts do not add up.
Guards like these come from our healthcare quality engineering practice: test the real file, then turn each fault into a rule.
Assistants that read the real system
The same integrations feed a web assistant and SMS ordering, so they answer from the clinic's own prices, live stock and real orders.
In November 2026 the web assistant resolved 62% of real chats with no person involved (88 of 142). 6% needed a person and 32% ended unresolved, usually because the shopper left or asked for something the store does not carry. It has handled 2,865 chats since August 2025.
The assistant reads the same live catalog, contract prices and order records the store uses. It can suggest cart changes, and the buyer confirms each one. A license-gated item is never added by a bot. It goes to a rep, who can take over any chat and hand it back.
Recreated screens, sample data.
What the platform expects to go wrong
Most of the work in an integration is the cases nobody draws on the whiteboard.
| Situation | What happens |
|---|---|
| A supplier accepts but never ships | A daily check finds receipts with no shipping notice and alerts the team. |
| The same reply arrives twice | It is processed once. |
| A reply has no clear sender | It is matched by order, then PO number, then the item's supplier. |
| A receipt hides a rejection | The tracker reads the receipt, not just the HTTP status. |
| A message arrives unsigned | It is refused. |
| The supplier's server is down | Three retries a minute apart, then an exception for a person. |
| One line is backordered | The date reaches the clinic's order page. |
| An order spans EDI and manual suppliers | It is split and flagged as EDI plus manual. |
| A supplier changes its pack size | Units convert to one base unit, and ordered items keep their SKU. |
| A huge stock file arrives at night | It is split into chunks on its own worker pool, away from orders. |
How it is built
One Django core holds products, prices, customers and orders, with separate worker pools for supplier intake, EDI and urgent work.
A big stock load never slows an order. Changes go out once to the store, the CRM, two marketplaces and Google Shopping. It runs on AWS Kubernetes, built with Terraform, with a preview environment for every change.
Discover our healthcare product engineering approach to platforms like this one.
Follow 1 to 10 from supplier file to invoice.
| Measure | Count, from the code on Nov 29, 2026 |
|---|---|
| Codebases | 7 |
| Data models | 78 |
| API routes | About 311 |
| Background tasks | 81, in 4 worker pools with 20 schedules |
| Test files | 253, of which 17 cover EDI |
| Backend code | About 104,000 lines of Python |
Results
Every figure comes from the production database, the live store or the QA record, pulled by the client team on Nov 29, 2026.
What the numbers mean for the business
Between June and October 2026, monthly orders grew 65% while the hand-placed orders the team had to chase fell by almost two thirds.
The growth went to the direct EDI link, not to the operations team. Every extra order that reached the supplier by EDI arrived with a tracked receipt, line answers, a ship notice and an invoice, instead of an email or a phone call. The hand-placed orders that remain are for suppliers without EDI.
On the sales side, a rep can price a clinic's full eight months of purchases in about 22 minutes and a typical file in under 3. That turns a usage file into a savings quote on the same call, while the clinic is still interested.
Hand-placed orders are orders placed minus orders sent by EDI. They include orders for suppliers that have no EDI link.
Eight questions to ask before your own EDI cutover
The checklist we now run with every distributor, supplier or clearinghouse connection.
| Question | Why it matters |
|---|---|
| Which suppliers carry most of your SKUs, and which can do EDI? | Here one distributor carried about 99% of SKUs, so one deep link covered most orders. |
| Can an order with items from two suppliers be split today? | Middleware that sends whole orders leaves mixed orders with no clean path. |
| Where do you see a receipt that never became a ship notice? | If nobody sees it, the clinic finds out first. |
| Does your tracker read the delivery receipt or only the HTTP status? | A delivery receipt can carry a rejection, as it did during this cutover. |
| Which certificate does each partner channel trust, in test and in production? | Updating the test channel did not update production. |
| Do you refuse unsigned messages? | Accepting them hides errors and lets anyone send a forged order. |
| Can a new supplier go live without middleware work? | It should be a partner record and a test round. |
| Does every sales channel read the same price, or its own copy? | Copies drift, and a contract buyer who sees list price stops trusting the store. |
We open-sourced the patterns
x12-edi-kit is a free Python library that builds and reads 850, 855, 856, 810 and 997 messages, with AS2, control numbers, order splitting and missing-shipment alerts.
It is a clean-room rewrite of what made this connection reliable, with no client code or data, and 107 tests. Engineers can check how we work before they talk to us: github.com/Nirmitee-tech/x12-edi-kit.
The same X12 skills, on the claims side
The X12 format that carries these purchase orders also carries healthcare claims (837), payments (835), eligibility checks (270 and 271), prior authorization (278) and benefit enrollment files (834).
The hard parts are the same: partner certificates, control numbers, receipts that hide rejections and a tracker that tells the truth. Related: payer and clearinghouse integration, real-time eligibility verification, RCM integration, our claims intelligence and clearinghouse case study, the open-source clearinghouse simulator, and our earlier B2B medical supply marketplace case study.
The client and its suppliers are not named. Screens are recreations of the real product with sample data. Figures come from the production database, the live store and QA records, pulled by the client team on Nov 29, 2026.














