Inspiration

Clinicians spend 2+ hours per complex patient case searching literature, cross-referencing lab values against treatment protocols, and writing structured briefs. Most existing AI tools either hallucinate clinical recommendations or cost $50,000+ per year. There is no open, inspectable, evidence-grounded pipeline that any clinic can run.

I built ClinicalBrief AI based on a research publication on adaptive health orchestration to prove that a fully agentic, source-cited, confidence-gated clinical intelligence pipeline can be built on open infrastructure — in n8n, without a single line of server code.

What it does

A patient or pharmacy staff member fills a Google Sheet with lab values — HbA1c, LDL, BMI, blood pressure, medications, diagnoses. No app. No login. No technical knowledge required.

When a new row is added, the n8n pipeline fires automatically:

  1. SerpApi queries Google Scholar in real-time using the patient's diagnoses. Three current PubMed publications are retrieved and injected into the agent prompt before any generation happens.
  2. GPT-4o receives the patient lab data + live PubMed evidence + RAG-retrieved clinical protocol guidelines (ADA 2024, ACC/AHA 2023, JNC 8, WHO, KDIGO, USPSTF). It generates a structured, source-cited clinical brief with a confidence score per recommendation.
  3. A Confidence Gate evaluates the combined score. At or above 80%: the brief is sent to Foxit eSign for electronic signature and delivered to the clinician. Below 80%: the full brief is routed to human review. No uncertain brief is ever auto-signed.
  4. The clinician receives an HTML email with the full summary, diagnosis, risk level, numbered recommendations with evidence citations, medications, and physician notes.

How I built it

Stack:

  • n8n (cloud) — workflow orchestration, 14 nodes, fully visual and inspectable
  • GPT-4o — clinical reasoning agent (temperature 0.1 for deterministic output)
  • OpenAI text-embedding-3-small — 1,536-dimension embeddings for RAG
  • SerpApi Google Scholar — real-time PubMed evidence retrieval
  • Nutrient DWS — structured lab data extraction from patient documents
  • Foxit eSign REST API — tamper-evident electronic signing
  • Google Sheets — patient intake form (trigger)
  • Gmail — clinical brief delivery

Confidence scoring:

Two independent scores averaged. Agent score comes from GPT-4o's self-assessment of evidence support. Extraction confidence comes from field-level scores on the lab data. Threshold: 0.80.

RAG knowledge base: 6 clinical protocol documents (ADA 2024, ACC/AHA 2023, JNC 8, WHO Metabolic Syndrome, NKF KDIGO 2023, USPSTF 2024) embedded and stored in n8n vector store. Agent retrieves top-3 matching passages per query using cosine similarity.

Challenges I ran into

  1. SerpApi as an agent tool — toolHttpRequest inside the n8n agent node cannot execute. Fixed by moving SerpApi outside the agent as a regular HTTP node and injecting results into the prompt before the agent runs.
  2. Foxit eSign sandbox endpoint — sandbox returns 404 on the standard envelope endpoint. Pipeline continues with onError: continueRegularOutput so the rest of the workflow completes. Email delivery is unaffected.
  3. In-memory RAG persistence — n8n's in-memory vector store resets on restart. Mitigated with a separate Seed KB workflow that re-loads all 6 documents before each session. Production fix: Supabase pgvector.
  4. Confidence routing — combining two heterogeneous confidence signals (agent self-report + extraction scores) into one routing decision required careful merging logic to avoid false positives in either direction.

Accomplishments that I'm proud of

  • Full 14-node agentic pipeline running end-to-end — Google Sheets trigger to signed email delivery
  • Real-time PubMed evidence retrieval via SerpApi integrated into every brief
  • GPT-4o agent calling RAG tool autonomously (~7 tool calls per execution)
  • Confidence-gated human-in-the-loop — deterministic routing, not a suggestion
  • Three sponsor APIs chained meaningfully — each one's output is required by the next
  • Fully inspectable in n8n — every node, every input, every output traceable

What I learned

Responsible clinical AI is not about the model — it is about the architecture around the model. The SerpApi integration taught me that live retrieval fundamentally changes output quality: the agent citing a 2024 ADA guideline with a real PubMed URL is categorically different from a model generating plausible-sounding advice from training data. The Foxit eSign integration reinforced the core design principle: the agent prepares the document, but a human authorises it. That boundary matters.

What's next for ClinicalBrief AI

  • Real Nutrient DWS PDF extraction — replace simulated extraction with a real uploaded lab PDF processed by Nutrient's Data Extraction API
  • Supabase pgvector — persistent RAG store, no reseed required on restart
  • Foxit correct sandbox endpoint — verify and wire the signing flow end-to-end
  • Multi-patient parallelism — n8n queue mode for concurrent executions
  • Clinician dashboard — Google Sheets audit log → Looker Studio showing confidence trends, review rates, and turnaround times
  • EHR integration — replace Google Sheets trigger with HL7 FHIR webhook

Built With

Share this project:

Updates

Submission history