Case Study

How Shulam Built an MDI Telehealth Pipeline for Ziv Health

50+ medications. 12 webhook events. 28 questionnaires. Sandbox verified. One sprint.

50+
Medications
Auto-mapped on boot
12
Webhook Events
All tested, all 200 OK
28
Questionnaires
Mapped to intake flows
25
Offerings
Synced from MDI catalog
4
Moats
M-ZIV-55 through M-ZIV-58
14
Phase 1 Products
MediVera contract signed

The problem

Ziv Health needed to connect to MD Integrations (MDI) to offer telehealth prescriptions across 8 clinical categories — weight loss, men's health, women's HRT, dermatology, hair loss, erectile dysfunction, longevity, and female hormone therapy. MDI provides the clinical infrastructure: licensed providers, prescription management, and pharmacy fulfillment through MediVera.

But wiring a telehealth pipeline is not a single API call. It means syncing a formulary of 50+ medications, mapping 28 questionnaires to the right clinical categories, creating vouchers at checkout, tracking cases through 5 stages, handling 12 different webhook events, and sending patients real-time shipment notifications. Each piece depends on the others. A missed mapping means a patient gets the wrong questionnaire. A dropped webhook means a prescription ships without notification.

The Ziv team needed the entire pipeline built, tested, and sandbox-verified — and they needed it before the MediVera contract effective date of April 29, 2026.

How Shulam built it — in one sprint

Day 1

MdiOfferingSyncService — auto-map 50+ medications

Built a service that reads MDI's full offering catalog on boot and maps each medication to Ziv Health's internal product IDs. No manual CSV imports. No spreadsheet maintenance. The formulary stays in sync automatically.

Day 2

MdiVoucherService — checkout to voucher to intake

When a patient completes checkout on zivhealth.com, the voucher service creates an MDI voucher, links it to the order, and triggers the intake questionnaire. One purchase, one voucher, one intake — no manual handoff.

Day 3

MdiPatientPortalService — 5-step pipeline tracker

Built GET /portal/orders with a 5-step visual pipeline: order placed, intake submitted, case under review, prescription written, shipment tracking. Patients see exactly where their order stands at all times.

Day 4

MdiAdminOfferingsService — offerings coverage dashboard

Admin dashboard showing which MDI offerings are active, which questionnaires are mapped, and which products have gaps. One screen to see the entire formulary coverage at a glance.

Day 5

Webhook wiring — 12 event types, all 200 OK

Wired MDI's webhook system to receive 12 event types: case created, case updated, prescription written, shipment dispatched, tracking updated, and 7 more. Auth header validation, idempotency checks, and TrackingNotificationService for patient shipment emails. Tested every event via MDI Test Bench.

Day 6

Sandbox E2E — full pipeline verified

POST /api/v1/admin/mdi/sandbox-e2e runs an 8-step health check: auth, offerings, patient creation, vouchers, cases, questionnaire IDs, offering IDs, and webhook config. 100/100 tests pass. Behind Cloudflare Zero Trust + proxy-secret.

The pipeline: 6 stages, fully automated

From the moment a patient adds a medication to their cart to the moment it arrives at their door — every step is tracked, every event is handled, every notification is sent.

🔄
Step 1

Offering Sync

MdiOfferingSyncService reads MDI's catalog on boot and maps 50+ medications to Ziv's product IDs. New meds appear automatically.

🎟️
Step 2

Voucher Creation

Patient completes checkout on zivhealth.com. MdiVoucherService creates a voucher linking the order to an MDI case. Consultation fee ($20 async / $30 sync) billed as a separate line item.

📋
Step 3

Intake Questionnaire

28 questionnaires mapped across 8 categories. The patient answers body profile, medical history, allergies, preferences, HIPAA consent, and MDI compliance — all in one conversational flow.

👨‍⚕️
Step 4

Case Review

MDI's clinical team reviews the case. Webhook events fire as the case progresses: case_created, case_updated, provider_assigned, consultation_completed.

💊
Step 5

Prescription

Provider writes the prescription. MDI dispatches it to MediVera pharmacy (contract signed, DocuSign 5FCA03B0). Webhook: prescription_written, rx_sent_to_pharmacy.

📦
Step 6

Tracking

TrackingNotificationService sends patients shipment updates via email. Webhook events: shipment_dispatched, tracking_updated, delivered. The patient portal shows real-time status.

The souls behind the pipeline

Three Shulam souls were updated to monitor, dispatch, and report on the MDI pipeline. They run autonomously — no manual intervention required.

Peter
Infrastructure Watchdog

Monitors the MDI pipeline health: webhook response times, offering sync failures, voucher creation errors. Fires alerts when any step degrades. Runs the sandbox E2E health check on schedule.

Gabriel
Notification Dispatcher

Dispatches patient-facing notifications: intake reminders, prescription confirmations, shipment tracking emails. Coordinates with TrackingNotificationService for real-time delivery updates.

Hosea
SEO & Content Analyst

Updated with MDI pipeline KPIs: offering coverage %, questionnaire completion rate, and pipeline throughput. Reports weekly on patient acquisition metrics tied to telehealth categories.

Technical architecture

// MDI Pipeline Intelligence — stack
MdiOfferingSyncService → auto-map 50+ meds on boot (formulary sync)
MdiVoucherService → checkout → voucher → intake (BigInt atomic units)
MdiPatientPortalService → GET /portal/orders (5-step pipeline tracker)
MdiAdminOfferingsService→ offerings coverage dashboard (25 offerings)
MDI Webhook Handler → 12 event types, auth header validation
TrackingNotificationService → shipment emails via Postmark
// Sandbox E2E: 8-step health check, 100/100 tests
// Souls: Peter (watchdog) + Gabriel (dispatch) + Hosea (analytics)

The pipeline runs on Ziv Health's Node 22 backend with Express 5, PostgreSQL, and Redis. Every monetary value uses BigInt atomic units (1 USDC = 1,000,000) — no floating-point money anywhere in the pipeline. The consultation fee ($20 async, $30 sync) is stored as 20000000n and 30000000n respectively.

Webhook authentication uses MDI's auth header pattern with constant-time comparison. Every event is idempotent — replaying a webhook produces the same state. The sandbox E2E test verifies all 8 integration points in a single POST request, running behind Cloudflare Zero Trust and proxy-secret middleware.

The patient-facing portal shows a 5-step pipeline tracker: order placed, intake submitted, case under review, prescription written, and shipment tracking. Each step updates in real time as webhook events arrive.

Four competitive moats

M-ZIV-55: Formulary Lock-in

Every medication mapping deepens the integration. Competitors starting from scratch must map all 50+ medications, 28 questionnaires, and 25 offerings before their first prescription ships.

M-ZIV-56: Pipeline Intelligence

Every case that flows through the pipeline generates data: average time-to-prescription, questionnaire completion rates, provider response times. This data compounds into operational intelligence that new entrants cannot replicate.

M-ZIV-57: Webhook Event Graph

12 event types wired, tested, and monitored. Each event triggers downstream actions: notifications, portal updates, analytics. The event graph is the nervous system of the pipeline — rebuilding it takes months.

M-ZIV-58: Pharmacy Network Effect

MediVera contract signed. As more prescriptions flow through, Ziv Health earns volume pricing and priority fulfillment. Each new patient strengthens the pharmacy relationship — a moat that grows with every order.

Need a telehealth pipeline for your platform?

MDI Pipeline Intelligence is included in every Lighthouse plan. From formulary sync to shipment tracking — fully wired in one sprint.

Apply for Lighthouse →