LINKS
Github : https://github.com/Haxous742/MCP-Prompt-Opinion-Hackathon Youtube Demo : https://youtu.be/K3Xxkw4RwWA?si=V9TvJKQnG1Oo5IBC
Inspiration
Every year, nearly 1 in 5 patients is readmitted to the hospital within 30 days of discharge. The root cause is rarely clinical — it's communicational. Discharge summaries are written under time pressure, filled with medical jargon patients don't understand, and disconnected from the live data sitting in the EHR.
We asked a simple question: what if an AI agent could do this in seconds, directly from the patient's FHIR record, in plain language?
That question became the Discharge Agent — an A2A-compliant, FHIR-native AI agent that automates the generation of discharge summaries and patient-facing instructions by reading live clinical data at the moment of discharge.
What It Does
The Discharge Agent connects to a FHIR R4 server and pulls together:
- Active medications and reconciliation notes
- Current diagnoses and conditions
- Recent observations (vitals, labs)
- Demographic context
It then generates two outputs:
- A clinician-facing discharge summary — structured, concise, standards-compliant
- A patient-facing instruction sheet — jargon-free, actionable, readable
Both are produced through a single natural-language request routed via the Prompt Opinion platform, with FHIR credentials injected automatically through the SHARP context extension — no manual token handling required.
How We Built It
The agent is built on Google ADK and communicates over the A2A v1 protocol, making it natively interoperable with any A2A-compliant orchestrator.
Challenges We Faced
- A2A v1 spec drift vs. SDK reality
The a2a-sdk (v0.3.x) had not yet caught up to the A2A v1 specification required by Prompt Opinion. Fields like supportedInterfaces and the new nested securitySchemes format didn't exist in the library. We wrote thin forward-compatibility subclasses (AgentCardV1, AgentExtensionV1) to patch the schema without forking the SDK — a surgical fix that will be removed once the library ships native v1 support.
- Keeping credentials out of the prompt
A naive implementation would pass fhirToken directly into the LLM context. We wanted zero credential exposure to the model. The solution was the extract_fhir_context callback — it intercepts metadata before the model call and stores credentials in session state, where only tool functions can read them. The LLM only ever receives structured data back from tools, never raw auth material.
- Generating clinically useful output, not just summaries
Generic summarisation isn't enough at discharge. We iterated on the agent's system instruction to produce output structured around what clinicians and patients actually need: medication changes, red-flag symptoms to watch for, follow-up timing, and who to call. Getting that structure reliably out of Gemini required careful prompt engineering and tool output formatting.
What We Learned
- Standards are load-bearing. Building on A2A and FHIR R4 from day one meant zero custom glue code to connect to Prompt Opinion. The spec is the integration layer.
- The "last mile" is a UX problem. The hardest part wasn't querying FHIR — it was deciding what to do with the data in a way that reduces cognitive load on a clinician at the end of a 12-hour shift.
- Agent composition compounds value. The Discharge Agent alone is useful. Paired with the Jargon Agent and Dietary Agent in an orchestrated workflow, it becomes a complete post-discharge care package — assembled automatically, no extra engineering required.
Log in or sign up for Devpost to join the conversation.