Inspiration
Primary care physicians managing chronic disease panels face an impossible cognitive load. In a typical 15-minute visit, a doctor must mentally cross-reference ADA diabetes guidelines, ACC/AHA hypertension targets, KDIGO kidney disease staging, screen for dangerous drug interactions, and generate a visit action plan — all while talking to the patient. Studies show that physicians adhere to evidence-based guidelines only 50–60% of the time, not from negligence, but from the sheer volume of information required at the point of care.
We built ChronicCare Copilot to close that gap — bringing ADA 2024, ACC/AHA 2017, and KDIGO 2022 guidelines directly into the clinical workflow as an intelligent, real-time copilot.
What it does
ChronicCare Copilot is an MCP-powered clinical decision support server that gives primary care physicians a complete chronic disease assessment in seconds. For any patient with diabetes, hypertension, or CKD, it runs four tools in sequence:
Tool 1 — summarize_patient_context
Pulls demographics, active conditions (ICD-10), medications, vitals, and 8 key lab values directly from the FHIR R4 server in real time:
| Lab | LOINC Code | Target |
|---|---|---|
| HbA1c | 4548-4 | $< 7.0\%$ |
| LDL Cholesterol | 2089-1 | $< 100 \text{ mg/dL}$ |
| eGFR | 33914-3 | Monitor trend |
| UACR | 9318-7 | $< 30 \text{ mg/g}$ |
| Systolic BP | 8480-6 | $< 130 \text{ mmHg}$ |
| Diastolic BP | 8462-4 | $< 80 \text{ mmHg}$ |
| BMI | 39156-5 | $18.5 - 24.9 \text{ kg/m}^2$ |
| Potassium | 2823-3 | $3.5 - 5.0 \text{ mEq/L}$ |
Tool 2 — get_care_gaps
Runs patient data through three major clinical guidelines simultaneously, returning gaps prioritised by severity (HIGH / MODERATE / LOW) with specific guideline references.
Key thresholds applied:
| Metric | Threshold | Action | Guideline |
|---|---|---|---|
| HbA1c | ≥ 7.0% | Gap flagged | ADA 2024, Section 6.2 |
| Blood Pressure | ≥ 130/80 mmHg | Gap flagged | ACC/AHA 2017 |
| LDL Cholesterol | ≥ 100 mg/dL | Gap flagged | ADA 2024, Section 10.7 |
| eGFR | < 60 mL/min/1.73m² | Monitoring doubled | KDIGO 2022 |
| UACR | ≥ 30 mg/g | Albuminuria flagged | KDIGO 2022 |
| eGFR | < 30 mL/min/1.73m² | Nephrology referral | KDIGO 2022 |
Tool 3 — check_drug_interactions
Normalises medications via RxNorm, queries OpenFDA, and applies a curated safety-net of 8 critical drug pairs common in chronic disease patients — including:
- Metformin + iodinated contrast → lactic acidosis risk
- ACE inhibitor + potassium-sparing diuretic → hyperkalemia
- Dual RAAS blockade (ACE-I + ARB) → AKI, hypotension
- NSAIDs + ACE inhibitor → "triple whammy" AKI
Tool 4 — suggest_next_steps
Synthesises all findings into a visit-ready action plan — today's lab orders with LOINC codes, specific medication changes with drug names and doses, and a guideline-based follow-up interval.
How we built it
Architecture
Prompt Opinion Platform (Agent Layer) → Passes SHARP context headers on every tool call:
X-Patient-ID— FHIR patient resource IDX-FHIR-Server-URL— workspace FHIR proxy base URLX-FHIR-Access-Token— short-lived JWT bearer token
ChronicCare Copilot MCP Server (Python / Starlette / uvicorn)
| Module | Role |
|---|---|
tools/summarize_patient.py |
FHIR queries — demographics, labs, vitals, meds |
tools/care_gaps.py |
Guideline orchestrator across all 3 guidelines |
tools/drug_interactions.py |
RxNorm normalisation + OpenFDA interaction check |
tools/suggest_next_steps.py |
Visit action plan generator |
guidelines/ada_2024.py |
ADA Standards of Care 2024 rule engine |
guidelines/jnc_hypertension.py |
ACC/AHA 2017 hypertension rule engine |
guidelines/ckd_kdigo.py |
KDIGO 2022 CKD rule engine |
fhir_client.py |
Async FHIR R4 REST client with functional shim layer |
FHIR Queries Made Per Assessment
GET /Patient/{id}— demographicsGET /Condition?patient={id}&clinical-status=active— active diagnosesGET /MedicationRequest?patient={id}&status=active— current medicationsGET /Observation?patient={id}&category=laboratory&code={loinc}— lab resultsGET /Observation?patient={id}&category=vital-signs— vitals and BP
Tech Stack
| Layer | Technology |
|---|---|
| MCP Server | Python 3.12, Starlette, uvicorn |
| FHIR Client | httpx (async), FHIR R4 REST |
| Drug Interactions | RxNorm API + OpenFDA API |
| Guideline Engine | Rule-based Python (ADA 2024, ACC/AHA 2017, KDIGO 2022) |
| Platform | Prompt Opinion (MCP + A2A + SHARP extension) |
| Tunnel | ngrok (streamable HTTP) |
| Data Standard | FHIR R4, LOINC, ICD-10-CM, RxNorm, SNOMED CT |
SHARP Context Propagation
The Prompt Opinion platform passes FHIR credentials as HTTP headers on every tool call: X-Patient-ID: {patient FHIR resource ID} X-FHIR-Server-URL: {workspace FHIR proxy base URL} X-FHIR-Access-Token: {short-lived JWT bearer token}
Our transport layer extracts these headers and injects them into every tool invocation, ensuring all FHIR calls are made with the correct patient scope and authorisation.
Challenges we ran into
MCP transport compatibility — Prompt Opinion expects streamable HTTP JSON-RPC (POST-based), not the SSE transport we initially built. Diagnosing the
405 Method Not Allowederrors and rebuilding the transport layer required significant iteration and reverse-engineering of the platform's MCP handshake sequence (initialize→notifications/initialized→tools/list→tools/call).SHARP extension declaration — The
ai.promptopinion/fhir-contextextension syntax is not widely documented. We had to determine the exact JSON structure required in theinitializeresponsecapabilitiesblock to make the FHIR context toggle appear in the platform UI.FHIR header injection — The platform passes FHIR context as HTTP headers rather than tool arguments. The agent was initially guessing patient IDs from context; we overrode arguments at the transport layer to always use the authoritative header values.
Guideline deduplication — A patient with both diabetes and CKD triggers overlapping gaps from two guideline sets. Implementing correct deduplication by
gap_idwhile preserving the highest-severity instance required careful orchestration logic.FHIR server variability — Different FHIR servers return BP as a panel Observation (
LOINC 55284-4) with components, or as individual systolic/diastolic observations. We implemented both patterns with automatic fallback.
Accomplishments that we're proud of
Live FHIR pipeline — Our tools make real-time FHIR R4 calls against the Prompt Opinion FHIR proxy, parsing actual patient resources and returning clinically accurate assessments with sub-5-second response times.
Three guidelines, one pass — ADA 2024, ACC/AHA 2017, and KDIGO 2022 evaluated simultaneously on a single patient, with 15 care gaps correctly identified on our synthetic patient Maria Santos (T2DM + HTN + CKD Stage 3):
- 7 HIGH: HbA1c 8.4% > 7.0%, BP 148/92 > 130/80 mmHg, UACR 340 mg/g (severely increased), missing statin, missing ACE-I/ARB, Stage 2 hypertension, overdue HbA1c
- 7 MODERATE: LDL 118 mg/dL, eGFR monitoring, UACR monitoring, lipid panel overdue, eye exam, BP check overdue, KDIGO BP target
- 1 LOW: Foot exam not on file.
Clinical safety net — 8 curated drug interaction pairs specific to chronic disease patients, including the critical metformin + iodinated contrast interaction (lactic acidosis risk) and dual RAAS blockade warning.
SHARP-compliant architecture — Full FHIR context propagation via the
ai.promptopinion/fhir-contextextension, declaring 4 SMART scopes (patient/Patient.rs,patient/Condition.rs,patient/MedicationRequest.rs,patient/Observation.rs). Stateless, multi-tenant safe design.
What we learned
The MCP protocol's transport layer matters enormously for platform compatibility — SSE and streamable HTTP are fundamentally different and not interchangeable at the application layer.
Clinical guideline engines require careful attention to overlapping conditions, severity tiering, and deduplication — naive implementations produce duplicate or conflicting recommendations that would confuse rather than help physicians.
FHIR R4 resource structures vary significantly between servers. Robust null-safety, fallback patterns, and handling of both
valueQuantityandcomponent[]observation formats are essential for production reliability.The gap between working in isolation and working inside a platform is where most integration time goes. SHARP context propagation, token handling, and MCP handshake correctness were all problems that only surfaced during platform integration.
Short-lived JWT tokens require fresh acquisition per session — token caching strategies are essential for production MCP servers integrated with OAuth-protected FHIR servers.
What's next for ChronicCare Copilot — Clinical AI for Primary Care
Expanded guideline coverage — ACC/AHA heart failure guidelines (2022), USPSTF preventive care recommendations, and HEDIS quality measures for diabetes ($\text{HbA1c} < 8\%$) and hypertension ($\text{BP} < 140/90$) panel reporting.
Trend analysis — Move beyond single-point-in-time values to detect clinically significant trends. For example, eGFR decline rate:
$$\Delta\text{eGFR} = \frac{\text{eGFR}{t_1} - \text{eGFR}{t_2}}{t_2 - t_1} < -5 \text{ mL/min/year} \Rightarrow \text{accelerated CKD progression alert}$$
- Cardiovascular risk scoring — Integrate ACC/AHA 10-year ASCVD risk calculator directly into the care gaps engine:
$$\text{ASCVD Risk} = 1 - S_0(t)^{\exp(\sum \beta_i X_i - \bar{\mu})}$$
to personalise statin and antihypertensive recommendations based on individual cardiovascular risk rather than condition-only thresholds.
EHR order integration — Connect today's orders directly to EHR order entry via SMART on FHIR, eliminating the manual transcription step after the assessment.
Panel management dashboard — Extend to population health: surface all patients in a physician's panel with open HIGH-severity gaps, enabling proactive outreach and recall scheduling.
Multilingual patient summaries — Generate care gap explanations in the patient's preferred language, addressing health equity in diverse primary care populations.
Validated outcomes study — Partner with a primary care practice to measure the impact on guideline adherence rates, time-to-treatment-intensification, and patient outcomes over 12 months.
Log in or sign up for Devpost to join the conversation.