MedSync - About the Project (Devpost Submission)
Inspiration
1.5 million Americans are harmed by medication errors every year. Over 7,000 die.
I learned this statistic during my research, and it stopped me in my tracks. Most of these errors happen during care transitionsβwhen patients move from the hospital to home, or from a specialist back to their primary care doctor.
The problem isn't lack of caring. It's time pressure.
Pharmacists and nurses manually reconcile medication lists, checking for duplicates, interactions, and discrepancies across different systems. But with 10 patients waiting and only 5 minutes per chart, critical issues slip through.
I thought: What if AI could pre-screen medication lists and flag the dangerous stuff before human review?
Not to replace pharmacistsβbut to be a safety net. To catch the errors humans miss when they're overwhelmed.
That's why I built MedSync.
What It Does
MedSync is an AI-powered medication reconciliation assistant that analyzes patient medication lists during care transitions and flags safety issues in order of severity:
π΄ CRITICAL Issues (Immediate Action Required)
- Contraindicated drug combinations: ACE inhibitor + ARNi (angioedema risk), duplicate anticoagulants, MAOIs + SSRIs
- Dangerous interactions: Triple antithrombotic therapy, QT prolongation risks
- Extreme dose discrepancies: >2x dose difference that could indicate transcription errors
π‘ WARNINGS (Review Required)
- Duplicate medications: Brand vs generic confusion (Lipitor + Atorvastatin)
- Dose discrepancies: Could be intentional titration or errorβMedSync flags for review
- Moderate drug interactions: Requiring monitoring or dose adjustment
π΅ INFORMATIONAL (For Awareness)
- Orphan medications: Active meds without corresponding diagnoses
- Missing medications: Heart failure without diureticβintentional or gap in care?
- Medications stopped during transition: Highlights changes for clinician awareness
How It Works
- Gathers patient data via FHIRBridge MCP server (medications, conditions, encounters, allergies, labs)
- Analyzes for safety issues using evidence-based guidelines and NLM RxNav API for drug interactions
- Generates structured report with severity classification, confidence scores, and specific recommendations
- Provides context-aware reasoning: Distinguishes errors from intentional changes based on encounter history
How I Built It
Architecture
βββββββββββββββββββ
β MedSync β (Gemini AI + System Prompt)
β Reconciliation β
β Agent β
ββββββββββ¬βββββββββ
β Calls FHIRBridge tools
ββββββββββΌβββββββββ
β FHIRBridge β (MCP Server - 11 FHIR Tools)
β - Medications β
β - Conditions β
β - Encounters β
β - Allergies β
β - Labs β
ββββββββββ¬βββββββββ
β FHIR R4 API + NLM RxNav
ββββββββββΌβββββββββ
β FHIR Server β (HAPI FHIR public test server)
β + Drug DB β
βββββββββββββββββββ
Technology Stack
Agent Layer:
- Gemini - LLM reasoning engine
- Prompt Opinion Platform - A2A-compliant agent hosting
- Comprehensive system prompt - 450+ lines defining reconciliation logic, severity classification, confidence scoring
Data Access Layer:
- FHIRBridge MCP Server - My other hackathon project (11 FHIR R4 tools)
- SHARP Extension Specs - Healthcare context propagation (patient_id, fhir_server_url, access_token)
- FHIR R4 Client - Async HTTP calls to EHR systems
External APIs:
- NLM RxNav - Real-time drug interaction checking
- HAPI FHIR Test Server - Public FHIR endpoint for demo
Key Components
1. System Prompt (reconciliation_a2a_enhanced.md)
This is the brain of MedSync. 450+ lines that define:
- Workflow: Gather Data β Analyze Issues β Generate Report
- Severity classification logic: What makes something CRITICAL vs WARNING vs INFO
- Confidence scoring: HIGH (90-100%), MEDIUM (60-89%), LOW (<60%)
- Known contraindications: ACE-I + ARNi, duplicate anticoagulants, MAOIs + SSRIs/SNRIs
- A2A collaboration protocol: How to request help from other agents
- Evidence-based reasoning: Reference ACC/AHA, CHEST, and other clinical guidelines
Example logic:
#### CRITICAL (π΄) - Immediate Action Required
1. **Contraindicated Combinations**:
- ACE inhibitor + ARNi (e.g., Lisinopril + Sacubitril/Valsartan)
- **Confidence threshold**: Flag as CRITICAL only if >90% certain
2. FHIRBridge Integration
MedSync calls 7 primary FHIRBridge tools:
# Step 1: Gather patient context
get_patient_demographics(patient_id="maria-santos")
get_medication_list(patient_id="maria-santos", status="active")
get_medication_list(patient_id="maria-santos") # All history
get_encounters(patient_id="maria-santos", max_results=5)
get_patient_conditions(patient_id="maria-santos", clinical_status="active")
get_allergies(patient_id="maria-santos")
get_lab_results(patient_id="maria-santos") # If needed for monitoring
# Step 2: Check interactions
check_drug_interactions(medications=["Lisinopril", "Sacubitril/Valsartan", ...])
3. Demo Patient: Maria Santos
I created a realistic test case with planted safety issues:
- 68-year-old female with heart failure
- Recent hospital admission (2024-06-10 to 2024-06-13)
- Planted issues:
- π΄ CRITICAL: Lisinopril (ACE-I) + Sacubitril/Valsartan (ARNi) - contraindicated
- π‘ WARNING: Duplicate Atorvastatin entries
- π΅ INFO: Furosemide dose increased 20mg β 40mg during admission (intentional titration)
4. A2A Capabilities
MedSync can collaborate with other agents:
- Structured JSON output for programmatic consumption
- Confidence scores on every finding
- Agent metadata for discovery
- 5 invokable skills:
reconcile_medications,check_medication_safety,analyze_medication_appropriateness,review_care_transition,flag_high_risk_medications
Example A2A interaction:
@PharmacyAgent: I've detected QT prolongation risk with Azithromycin +
Ondansetron in patient with eGFR 35. Can you provide risk stratification
and safer alternatives?
Challenges I Faced
1. Distinguishing Errors from Intentional Changes
The hardest part of medication reconciliation: is this discrepancy an error or on purpose?
Example: Furosemide dose changed from 20mg β 40mg.
- Could be error (wrong dose prescribed)
- Could be intentional (patient admitted for heart failure exacerbation, diuretic titrated up)
Solution: Context-aware reasoning
- Check
get_encountersfor recent hospital admission - If discharge encounter + heart failure diagnosis + dose increase = likely intentional
- Flag as INFO with explanation: "Dose increased during heart failure admissionβlikely intentional titration, but confirm with patient/clinician"
This required carefully crafting the system prompt to teach the AI how to reason about clinical context.
2. Fuzzy Medication Name Matching
Medications have multiple names:
- "Lisinopril" vs "Lisinopril 10mg" vs "Lisinopril 10 MG Oral Tablet"
- "Lipitor" vs "Atorvastatin" (brand vs generic)
- "Aspirin" vs "ASA" vs "Acetylsalicylic Acid"
If you use exact string matching, you'll miss duplicates.
Solution: Teach the AI flexible matching in the system prompt
Be flexible with medication name matching:
- "Lisinopril" = "Lisinopril 10mg" = "Lisinopril 10 MG Oral Tablet"
- "Lipitor" = "Atorvastatin" (brand vs generic)
- Use fuzzy matching: consider stems, suffixes, brand names
Gemini's language understanding handles this surprisingly wellβbetter than rule-based regex matching.
3. Confidence Scoring for Healthcare
In healthcare, uncertainty is dangerous. If the AI isn't sure, it needs to say so.
I added explicit confidence scoring:
- HIGH (90-100%): Well-documented contraindication with guideline support
- MEDIUM (60-89%): Likely issue but some data ambiguity
- LOW (<60%): Insufficient data, conflicting info, edge case
Challenge: How do you teach an LLM to assess its own confidence?
Solution: Explicit scoring rubric in the prompt
Assign confidence based on:
- Complete patient data available β HIGH
- Limited encounter history β MEDIUM
- Conflicting information β LOW
**Always state confidence explicitly** for CRITICAL and WARNING items.
This makes MedSync's recommendations actionable while being humble about uncertainty.
4. Real-Time Drug Interaction Checking
I wanted real drug interaction data, not mock responses.
NLM provides a free RxNav API, but it's tricky:
- Accepts medication names OR RxNorm codes (not both)
- Returns different JSON structures depending on input
- Rate limits
- Requires fuzzy name matching
Solution: Two-phase lookup
- Resolve medication names to RxNorm RxCUIs using
/approximateTerm - Call
/interaction/listwith RxCUIs - Parse severity and descriptions
This gives MedSync real, evidence-based interaction data.
5. Creating Realistic Demo Data
Test data is usually too clean. Real EHR data is messy.
For Maria Santos, I needed:
- Realistic ICD-10 codes (I11.0 for hypertensive heart disease)
- Proper RxNorm codes for medications
- Valid FHIR encounter structure
- Planted safety issues that look plausible
Solution: Hand-crafted FHIR transaction bundle (400+ lines)
{
"resourceType": "Bundle",
"type": "transaction",
"entry": [
{
"resource": {
"resourceType": "Patient",
"id": "maria-santos",
...
}
},
// + 8 MedicationRequests, 2 Conditions, 1 Encounter
]
}
Uploaded to HAPI FHIR public server for live demo.
6. A2A Protocol Implementation
Prompt Opinion's A2A specs were new to me. I had to:
- Define invokable skills with clear names/descriptions
- Structure JSON output for agent consumption
- Implement agent metadata for discovery
- Design collaboration protocol (
@AgentName:requests)
Solution: Study the spec, create examples, test iteratively.
The A2A-enhanced prompt grew to 450+ lines, but it's production-grade.
What I Learned
Clinical Lessons
Context is everything: The same data point (dose change) means different things in different contexts (titration vs error)
Medication reconciliation is perfect for AI: It requires cross-referencing multiple data sources (meds, conditions, encounters, allergies, labs) under time pressureβexactly what LLMs excel at
Confidence scoring matters in healthcare: "I'm 95% sure this is dangerous" is very different from "I'm 60% sure"βtransparency about uncertainty builds trust
Technical Lessons
System prompts are powerful: 450 lines of carefully crafted instructions turned Gemini into a specialized medication safety expert
FHIR is complex but worth it: Standard compliance means MedSync works with any FHIR R4 server (HAPI, Epic, Cerner)βno vendor lock-in
A2A enables ecosystems: MedSync doesn't have to do everythingβit can collaborate with PharmacyAgent, GuidelinesAgent, PriorAuthAgent
Demo data quality matters: Realistic test cases (like Maria Santos) make the difference between "cool demo" and "I'd actually use this"
Healthcare AI Lessons
Human-in-the-loop is essential: MedSync is an assistant, not a decision-maker. All recommendations require clinician review.
Explainability is non-negotiable: Every finding includes "Why This Matters" and "Evidence"βclinicians need to understand the reasoning
Standards compliance is table stakes: FHIR R4, SHARP, A2Aβusing standards makes integration possible
What's Next for MedSync
Short-term (Next 3 months)
- Integrate with more guidelines databases: UpToDate, Lexicomp, ClinicalKey
- Add allergy-medication checking: Cross-reference patient allergies with current meds (penicillin allergy + amoxicillin)
- Renal/hepatic dose adjustments: Flag medications requiring dose adjustment based on kidney/liver function
- Multi-language support: Spanish, Mandarin for patient-facing reports
Medium-term (6-12 months)
- Longitudinal tracking: Monitor medication changes over time, detect gradual "medication creep"
- Predictive analytics: Machine learning on historical data to predict which patients are high-risk for errors
- Integration with CPOE systems: Real-time alerts when clinician prescribes contraindicated medication
- Mobile app for patients: "Is this medication safe with my other drugs?"
Long-term Vision
- Deploy across hospital systems: Partner with Epic/Cerner to integrate MedSync into EHR workflows
- Expand to other reconciliation types: Diagnosis reconciliation, allergy reconciliation, procedure reconciliation
- Multi-agent collaboration: MedSync + PharmacyAgent + GuidelinesAgent working together for comprehensive safety review
- Continuous learning: Feedback loop where clinician corrections improve MedSync's accuracy
Impact Potential
If deployed across all US hospitals (35 million admissions/year):
Even a 10% reduction in medication errors would prevent:
$$ \text{Adverse Events Prevented} = 1.5M \times 0.10 = 150,000 \text{ per year} $$
$$ \text{Deaths Prevented} = 7,000 \times 0.10 = 700 \text{ per year} $$
$$ \text{Costs Saved} = \$21B \times 0.10 = \$2.1B \text{ per year} $$
But the math doesn't capture the real impact:
- Families that don't lose loved ones to preventable errors
- Patients who avoid hospitalization for adverse drug events
- Pharmacists who can focus on complex cases instead of routine screening
- Clinicians who sleep better knowing there's a safety net
Real Results: Maria Santos Demo
Testing MedSync with the Maria Santos demo patient:
Input: "Reconcile medications for patient ID maria-santos"
Output:
π΄ CRITICAL ISSUE: Contraindicated Medication Combination
Confidence: HIGH (95%)
Medications: Lisinopril 10 MG + Sacubitril/Valsartan 24-26mg
Problem: Concurrent ACE inhibitor + ARNi significantly increases angioedema risk
Why This Matters: This combination is strictly contraindicated per ACC/AHA guidelines.
Angioedema can cause dangerous airway swelling.
Recommendation: Discontinue Lisinopril immediately
Evidence: Both medications active in current med list. Recent hospital discharge
for heart failure. ACE-I should have been stopped before ARNi initiation.
This error could have killed Maria Santos. MedSync caught it in 15 seconds.
Technical Innovation: Confidence Scoring + A2A
MedSync isn't just another chatbot. It's built for production healthcare with:
Confidence Scoring
Every finding includes a confidence level (HIGH/MEDIUM/LOW) based on:
- Data quality (complete vs incomplete patient records)
- Clinical certainty (well-documented contraindication vs edge case)
- Evidence strength (guideline support vs clinical judgment)
Agent-to-Agent (A2A) Compliance
MedSync can:
- Accept invocations from other agents:
@MedSync.reconcile_medications(patient_id="...") - Request help from specialized agents:
@PharmacyAgent: Can you provide renal dosing for... - Return structured JSON: For programmatic consumption by other agents
- Expose capabilities via metadata: For agent discovery
This positions MedSync as infrastructure for an agent ecosystem, not a siloed application.
Why MedSync Matters
Healthcare is drowning in alert fatigue. EHR systems already throw hundreds of low-quality alerts that clinicians ignore.
MedSync is different:
- β High signal-to-noise ratio: Severity classification (CRITICAL/WARNING/INFO) helps clinicians prioritize
- β Context-aware: Distinguishes errors from intentional changes
- β Explainable: Every finding includes "Why This Matters" and evidence
- β Confident but humble: Explicit uncertainty when data is ambiguous
- β Action-oriented: Specific recommendations, not just "review medications"
It's not about more alerts. It's about smarter alerts.
Try It Yourself
- Prompt Opinion Marketplace: Search for "MedSync"
- GitHub: github.com/jamador47/FhirBridge (includes MedSync demo)
- Demo Patient:
maria-santoson HAPI FHIR test server - Test Query: "Reconcile medications for patient ID maria-santos"
Acknowledgments
- Prompt Opinion: For organizing the Agents Assemble Hackathon and building the A2A platform
- Anthropic: For the MCP SDK
- HAPI FHIR: For providing the public test server
- NLM RxNav Team: For free drug interaction API
- HL7 FHIR Community: For creating the interoperability standard
- Pharmacists and nurses everywhere: Who inspired this by showing me what they deal with every day
Built With
- Gemini - LLM reasoning engine
- Prompt Opinion - A2A-compliant agent platform
- FHIRBridge MCP - FHIR R4 data access (my other hackathon project)
- FHIR R4 - Healthcare interoperability standard
- NLM RxNav API - Drug interaction database
- Python - FHIRBridge server implementation
- SHARP Extension Specs - Healthcare context propagation
- HAPI FHIR - Public test server
MedSync: Catching the errors that could kill your patients. Before it's too late.
Built for Agents Assemble Hackathon 2026
Built With
- claude-mcp
- gemini
- promptopinion
Log in or sign up for Devpost to join the conversation.