Tools: Ultimate Guide: From FHIR Events to Explainable Agentic AI: Building a Clinical Followโ€‘Up Demo with InterSystems IRIS for Health

Tools: Ultimate Guide: From FHIR Events to Explainable Agentic AI: Building a Clinical Followโ€‘Up Demo with InterSystems IRIS for Health

๐ŸŽฌ What This Demo Produces

๐ŸŽฏ What Problem Does This Solve?

๐Ÿงช Demo Scenario: CKD + Rising Creatinine

โฑ๏ธ From Event to Evidence: The Complete Journey

๐Ÿง  Architecture Overview

Key Principle

High-Level Flow

Visual Components

๐Ÿค– Why CrewAI? Understanding Multi-Agent Architecture

1. Context Agent

2. Guidelines Agent

3. Reasoning Agent

Why Multi-Agent Instead of Single LLM Call?

๐Ÿ”„ Interoperability Production

๐Ÿ” Explainability: Proving the AI's Reasoning

Example Queries

๐Ÿฉบ Publishing Results as FHIR DiagnosticReport

๐Ÿš€ Try It Yourself

๐ŸŽฏ What You've Learned

๐Ÿ”ฎ Beyond Lab Results: What Else Can You Automate?

๐Ÿš€ Conclusion 10:47 AM โ€” Jose Garcia's creatinine test results arrive at the hospital FHIR server.

2.1 mg/dL โ€” a 35% increase from last month. No chatbot. No manual prompts. No black-box reasoning. This is event-driven clinical decision support with full explainability: โœ… Triggered automatically by FHIR eventsโœ… Multi-agent reasoning (context, guidelines, recommendations)โœ… Complete audit trail in SQL (every decision, every evidence source)โœ… FHIR-native outputs (DiagnosticReport published to server) You'll learn: ๐Ÿ–‹๏ธ How to orchestrate agentic AI workflows within production-grade interoperability systems โ€” and why explainability matters more than accuracy alone. When Jose's abnormal creatinine observation arrives, the system automatically generates: INPUT: FHIR Observation (creatinine 2.1 mg/dL, status: HIGH) OUTPUT: FHIR DiagnosticReport containing: AUDIT TRAIL: Every decision, recommendation, and evidence citation persisted in SQL tables for compliance and review. Most AI demos in healthcare focus on: In real clinical environments, what matters is: This demo answers a simple but realistic question: What happens when a new abnormal lab result arrives โ€” and how can we automate the initial clinical assessment while maintaining transparency? The demo is based on a common healthcare use case: Patient: Jose Garcia (MRN-1000001) The >30% progressive increase requires clinical follow-up. Instead of waiting for manual review, the system automatically: Follow a single lab result through the system: From event to actionable recommendations. InterSystems IRIS for Health is the orchestrator and system of record. The AI agents are external capabilities that are governed, triggered, and integrated by the IRIS platform. IRIS owns the data, the workflow, and the audit trail โ€” the agents provide specialized reasoning. The demo includes a Gradio web UI for interactive demonstration: This makes the complete flow visible and understandable. CrewAI is a multi-agent orchestration framework that enables specialized AI agents to collaborate on complex tasks. In this demo, three agents work sequentially: Role: Gather patient clinical history from FHIR server Output: Structured patient context for reasoning Role: Search clinical knowledge base using RAG (Retrieval-Augmented Generation) Output: Evidence-based clinical guidance Role: Synthesize recommendations from context + guidelines Output: Risk assessment + actionable follow-up plan Agentic workflows provide: โœ… Better structured reasoning โ€” Each agent has a focused responsibilityโœ… Tool use โ€” Agents can query FHIR, search vector databases, analyze trendsโœ… Explainable decision chains โ€” Each step is traceableโœ… Separation of concerns โ€” Context โ‰  Guidelines โ‰  Reasoning Critical: IRIS orchestrates the agents โ€” CrewAI is used as a library, not the platform. IRIS owns persistence, orchestration, FHIR integration, and audit trails. The workflow is managed by three IRIS components: Business Service (FHIRObservationIn)Triggered automatically when FHIR Observation is POSTed Business Process (FollowUpAI)Orchestrates three-step workflow: One of the most critical aspects of clinical AI is proving why a recommendation was made. IRIS persists everything in a minimal, queryable SQL model: "What cases were evaluated today?" "Why did the agent recommend nephrotoxic medication review?" Every recommendation has: You can answer "Why did the AI recommend this?" with SQL queries and evidence citations. The final step closes the loop: AI outputs become part of the clinical record. The system publishes a FHIR DiagnosticReport containing: This makes the AI output: The DiagnosticReport is not a separate "AI system output" โ€” it's a first-class clinical document that follows the same standards as lab reports and radiology findings. Quick Start (15 minutes): Load sample patient data (Jose Garcia with CKD history)Follow the README setup instructions Open browser to http://localhost:7860 POST an abnormal lab value and watch: Query the results using IRIS SQL Explorer or Management Portal ๐Ÿ’ฌ Questions or feedback? Reply to this post โ€” I'd love to hear about your use cases. If you've followed along, you now understand how to: โœ… Trigger AI workflows from FHIR events โ€” No manual initiation requiredโœ… Orchestrate multi-agent systems with CrewAI โ€” Context, Guidelines, Reasoning agentsโœ… Build explainable AI with SQL audit trails โ€” Every decision is traceableโœ… Publish AI outputs as FHIR resources โ€” Interoperable clinical documents

โœ… Integrate agentic AI with IRIS Interoperability โ€” Production-grade orchestration This pattern applies to many clinical scenarios: The architecture is the same: event โ†’ context โ†’ evidence โ†’ reasoning โ†’ action. This demo shows how Agentic AI can be safely and effectively integrated into real clinical workflows using InterSystems IRIS for Health. We move from AI experiments to platform-grade clinical AI. โญ Star the repo: https://github.com/intersystems-ib/iris-health-fhir-agentic-demo ๐Ÿงช Try the demo with your own clinical guidelines ๐Ÿ’ฌ Share your use case โ€” What clinical event would you automate first? Templates let you quickly answer FAQs or store snippets for re-use. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse

Code Block

Copy

SELECT CaseId, PatientRef, RiskLevel, Confidence, ReasoningSummary FROM clinicalai_data.Cases WHERE CreatedAt >= CURRENT_DATE ORDER BY CreatedAt DESC SELECT CaseId, PatientRef, RiskLevel, Confidence, ReasoningSummary FROM clinicalai_data.Cases WHERE CreatedAt >= CURRENT_DATE ORDER BY CreatedAt DESC SELECT CaseId, PatientRef, RiskLevel, Confidence, ReasoningSummary FROM clinicalai_data.Cases WHERE CreatedAt >= CURRENT_DATE ORDER BY CreatedAt DESC CaseId: CSE-20260108-001 PatientRef: Patient/1 (Jose Garcia) RiskLevel: medium-high Confidence: high ReasoningSummary: The patient with stage 3 chronic kidney disease and hypertension demonstrates a sustained and progressive increase in serum creatinine over 90 days... CaseId: CSE-20260108-001 PatientRef: Patient/1 (Jose Garcia) RiskLevel: medium-high Confidence: high ReasoningSummary: The patient with stage 3 chronic kidney disease and hypertension demonstrates a sustained and progressive increase in serum creatinine over 90 days... CaseId: CSE-20260108-001 PatientRef: Patient/1 (Jose Garcia) RiskLevel: medium-high Confidence: high ReasoningSummary: The patient with stage 3 chronic kidney disease and hypertension demonstrates a sustained and progressive increase in serum creatinine over 90 days... SELECT e.GuidelineId, e.Similarity, e.Excerpt FROM clinicalai_data.CaseEvidences e WHERE e.CaseId = 'b344f121-db68-4cd6-8877-1855c3d547ff' ORDER BY e.Similarity DESC SELECT e.GuidelineId, e.Similarity, e.Excerpt FROM clinicalai_data.CaseEvidences e WHERE e.CaseId = 'b344f121-db68-4cd6-8877-1855c3d547ff' ORDER BY e.Similarity DESC SELECT e.GuidelineId, e.Similarity, e.Excerpt FROM clinicalai_data.CaseEvidences e WHERE e.CaseId = 'b344f121-db68-4cd6-8877-1855c3d547ff' ORDER BY e.Similarity DESC GuidelineId: ckd_creatinine_guideline_demo Similarity: 0.66 Excerpt: "Recommended actions include repeat serum creatinine testing within 7โ€“14 days, review of current medications for nephrotoxicity, assessment of contributing factors, and close monitoring of renal function." GuidelineId: ckd_creatinine_guideline_demo Similarity: 0.66 Excerpt: "Recommended actions include repeat serum creatinine testing within 7โ€“14 days, review of current medications for nephrotoxicity, assessment of contributing factors, and close monitoring of renal function." GuidelineId: ckd_creatinine_guideline_demo Similarity: 0.66 Excerpt: "Recommended actions include repeat serum creatinine testing within 7โ€“14 days, review of current medications for nephrotoxicity, assessment of contributing factors, and close monitoring of renal function." git clone https://github.com/intersystems-ib/iris-health-fhir-agentic-demo cd iris-health-fhir-agentic-demo git clone https://github.com/intersystems-ib/iris-health-fhir-agentic-demo cd iris-health-fhir-agentic-demo git clone https://github.com/intersystems-ib/iris-health-fhir-agentic-demo cd iris-health-fhir-agentic-demo docker-compose up -d docker-compose up -d docker-compose up -d python run_ui.py python run_ui.py python run_ui.py - Most systems: โŒ The result sits in a queue until a clinician reviews it manually โ€” hours or days later. - This system: ๐Ÿ‘ An AI agent evaluates the trend, consults clinical guidelines, and generates evidence-based recommendations โ€” in seconds, automatically. - InterSystems IRIS for Health โ€” Orchestration, FHIR, persistence, vector search - CrewAI โ€” Multi-agent framework for structured reasoning - Risk Level: Medium-High (confidence: 85%) - Recommendations: โš ๏ธ Repeat creatinine in 7โ€“14 days ๐Ÿ’Š Review nephrotoxic medications (currently on Ibuprofen) ๐Ÿ“Š Monitor renal function closely - โš ๏ธ Repeat creatinine in 7โ€“14 days - ๐Ÿ’Š Review nephrotoxic medications (currently on Ibuprofen) - ๐Ÿ“Š Monitor renal function closely - Evidence Used: Patient context: CKD Stage 3 + progressive creatinine rise (>30%) Clinical guidelines: KDIGO section on AKI management in CKD Lab trend analysis: 1.6 โ†’ 1.9 โ†’ 2.1 mg/dL over 3 months - Patient context: CKD Stage 3 + progressive creatinine rise (>30%) - Clinical guidelines: KDIGO section on AKI management in CKD - Lab trend analysis: 1.6 โ†’ 1.9 โ†’ 2.1 mg/dL over 3 months - โš ๏ธ Repeat creatinine in 7โ€“14 days - ๐Ÿ’Š Review nephrotoxic medications (currently on Ibuprofen) - ๐Ÿ“Š Monitor renal function closely - Patient context: CKD Stage 3 + progressive creatinine rise (>30%) - Clinical guidelines: KDIGO section on AKI management in CKD - Lab trend analysis: 1.6 โ†’ 1.9 โ†’ 2.1 mg/dL over 3 months - Chat interfaces for asking questions - Unstructured text outputs - Opaque reasoning ("trust the AI") - Reacting to clinical events automatically - Understanding complete patient context - Providing explainable recommendations with evidence - Persisting decisions for audit and compliance - Conditions: Chronic Kidney Disease (CKD Stage 3), Hypertension - Medications: Ibuprofen (NSAID), Lisinopril - Lab history: 3 months ago: 1.6 mg/dL 1 month ago: 1.9 mg/dL Today: 2.1 mg/dL โ† triggers workflow - 3 months ago: 1.6 mg/dL - 1 month ago: 1.9 mg/dL - Today: 2.1 mg/dL โ† triggers workflow - 3 months ago: 1.6 mg/dL - 1 month ago: 1.9 mg/dL - Today: 2.1 mg/dL โ† triggers workflow - Detects the event (FHIR Observation POST) - Retrieves patient context (conditions, medications, lab history) - Consults clinical guidelines via RAG (vector search) - Performs agentic reasoning across three specialized agents - Produces explainable recommendations with evidence citations - FHIR Observation posted to IRIS server - Interoperability Production triggered - Context Agent queries patient history from FHIR - Guidelines Agent searches vector database (clinical documents) - Reasoning Agent synthesizes 3 recommendations - Results persisted to SQL (Cases, CaseRecommendations, CaseEvidences) - FHIR DiagnosticReport published to server - Complete โ€” Full audit trail available for review - FHIR Observation โ†’ POSTed to IRIS FHIR server - Interaction Strategy โ†’ Detects clinical event - Interoperability Production โ†’ Orchestrates workflow - Business Operation โ†’ Calls Agentic AI REST service (FastAPI) - Agents Execute โ†’ Context retrieval, guideline search, reasoning - Results Return โ†’ Structured JSON back to IRIS - Persistence โ†’ SQL tables store cases, recommendations, evidence - Publishing โ†’ FHIR DiagnosticReport created and stored - Post lab values and trigger the workflow - Watch real-time agent progress - View recommendations and evidence citations - Query SQL audit tables - Access IRIS Production message viewer - Fetch patient demographics and conditions - Retrieve historical lab results (creatinine trends) - Collect active medications - Identify risk factors (NSAID use + CKD) - Query IRIS vector database with semantic search - Find relevant guideline sections (clinical protocols, etc.) - Retrieve evidence chunks with similarity scores - Provide citations for recommendations - Analyze lab trends (>30% increase = significant) - Identify risk factors (CKD + NSAID + progressive rise) - Apply clinical decision rules - Generate structured recommendations with confidence levels - Business Service (FHIRObservationIn) Triggered automatically when FHIR Observation is POSTed - Business Process (FollowUpAI) Orchestrates three-step workflow: Call agent service Persist results to SQL Publish DiagnosticReport - Call agent service - Persist results to SQL - Publish DiagnosticReport - Business Operations ClinicalAgenticOperation โ†’ REST call to FastAPI/CrewAI ClinicalAiPersistence โ†’ SQL table writes ClinicalReportPublisher โ†’ FHIR DiagnosticReport POST - ClinicalAgenticOperation โ†’ REST call to FastAPI/CrewAI - ClinicalAiPersistence โ†’ SQL table writes - ClinicalReportPublisher โ†’ FHIR DiagnosticReport POST - Call agent service - Persist results to SQL - Publish DiagnosticReport - ClinicalAgenticOperation โ†’ REST call to FastAPI/CrewAI - ClinicalAiPersistence โ†’ SQL table writes - ClinicalReportPublisher โ†’ FHIR DiagnosticReport POST - Cases โ€” What happened (patient, observation, risk level, confidence) - CaseRecommendations โ€” What to do (action type, description, timeframe) - CaseEvidences โ€” Why (guideline citations, similarity scores, text excerpts) - The clinical context used - The guidelines consulted - The similarity scores showing relevance - The reasoning chain from data to decision - Subject: Patient reference (Jose Garcia) - Result: Link to triggering Observation (creatinine 2.1) - Conclusion: Risk level + reasoning summary - PresentedForm: Human-readable recommendations (Base64-encoded) - Extensions: Case ID, confidence score, model metadata - Interoperable โ€” Standard FHIR resource - Consumable โ€” Accessible via FHIR API by EHRs, portals, apps - Auditable โ€” Part of the permanent clinical record - Queryable โ€” GET /DiagnosticReport?result=Observation/14 - Clone the repository - Start IRIS container - Load sample patient data (Jose Garcia with CKD history) Follow the README setup instructions - Run the Gradio UI - POST an abnormal lab value and watch: Real-time agent progress Evidence retrieval from vector database Recommendations generated with confidence scores SQL audit trail queries - Real-time agent progress - Evidence retrieval from vector database - Recommendations generated with confidence scores - SQL audit trail queries - Query the results using IRIS SQL Explorer or Management Portal - Real-time agent progress - Evidence retrieval from vector database - Recommendations generated with confidence scores - SQL audit trail queries - Medication reconciliation alerts โ€” Detect drug-drug interactions or contraindications - Care gap identification โ€” Missing screenings based on age, conditions, guidelines - Risk stratification triggers โ€” Identify high-risk patients for intervention - Clinical trial matching โ€” Find eligible patients based on inclusion criteria - Event-driven interoperability โ€” React to clinical events automatically - Agentic reasoning โ€” Multi-agent collaboration with tool use - SQL persistence โ€” Full audit trails for compliance - FHIR-native outputs โ€” Standard clinical documents