Inspiration

1 in 5 patients leave hospitals with a medication error. Not because doctors are careless, but because reconciling a complex medication list under time pressure, across fragmented systems, is genuinely hard.

The scale of the problem:

$$ 1{,}500{,}000 \text{ adverse drug events/year} \times \$14{,}000 \text{ avg cost} = \$21\text{B in preventable harm annually} $$

The information to prevent these errors already exists in the EHR. It just isn't assembled and acted on at the right moment. We built DischargeGuard to close that gap.

What it does

DischargeGuard is an MCP server that plugs into clinical workflows through Prompt Opinion. At discharge, it:

  • Pulls the patient's complete medication list from FHIR in real time
  • Normalizes drug names via NLM RxNorm to standard identifiers
  • Cross-references FDA drug interaction data for every medication pair
  • Flags dangerous combinations by severity: HIGH, MODERATE, and LOW
  • Generates a structured PCP handoff note and patient safety card in seconds

How we built it

Built on open standards end-to-end:

  • MCP for tool exposure (7 fully composable tools)
  • HL7 FHIR R4 for patient data (MedicationRequest, AllergyIntolerance, Condition, Observation)
  • SHARP extension spec for patient context propagation through multi-agent call chains
  • NLM RxNorm for drug name normalization to RxCUI identifiers
  • OpenFDA drug labels for interaction detection and severity classification
  • TypeScript + Zod for type safety and input validation
  • Next.js clinical dashboard for demo

Challenges we ran into

  • Broken API mid-build. The NLM RxNav interaction endpoint returned 404. We pivoted to OpenFDA drug labels and built a severity inference engine: contraindicated maps to HIGH, monitor to MODERATE, minor to LOW.
  • Noisy FHIR data. Real-world FHIR resources have missing fields, inconsistent coding, and nulls everywhere. Every tool returns partial data with error notes rather than failing hard.
  • Young ecosystem. MCP is new. SDK docs and actual behavior sometimes diverged. We leaned on the spec directly.

Accomplishments that we're proud of

  • 7 fully functional MCP tools shipped in under 24 hours, each with graceful error handling and SHARP context propagation
  • Drug interaction severity inference from raw FDA label text that catches real dangerous combinations without a dedicated interaction database
  • Production-quality TypeScript with full type safety, Zod validation, and parallel data fetching across FHIR, RxNorm, and OpenFDA

The interaction coverage scales with the number of drugs:

$$ \binom{n}{2} = \frac{n(n-1)}{2} \text{ pairs checked for } n \text{ medications} $$

A patient on 10 medications gets 45 interaction pairs checked automatically.

What we learned

  • The hardest part of healthcare AI is the plumbing. FHIR, SHARP, MCP, and A2A exist so a small team can build something production-ready without custom integrations for every hospital.
  • Constraints make better solutions. Losing RxNav forced us to build a more transparent, explainable interaction engine grounded directly in FDA-approved label text.
  • Standards compliance matters more than features. Proper FHIR R4 resource types and SHARP context propagation are what make this publishable to a real marketplace.

What's next for Discharge Guard

  • Pediatric extension. Dosing errors are 3x more dangerous in children. Weight-based dosing calculations and pediatric-specific thresholds.

$$ \text{Pediatric dose} = \frac{\text{Weight (kg)} \times \text{Adult dose}}{70} $$

  • Prescription tracking. Flag whether the patient actually filled the prescription after discharge.
  • Early readmission signals. Surface patterns that predict a return visit before it happens.
  • PCP loop closure. Automatically notify the primary care physician when a high-risk patient is discharged.

Built With

  • allergyintolerance
  • axios
  • condition
  • hapi-fhir
  • hl7-fhir-r4
  • mcp
  • next.js
  • nlm-rxnorm
  • node.js
  • openfda
  • prompt-opinion
  • react
  • sharp
  • tailwindcss
  • typescript
  • zod
Share this project:

Updates