MedExpertMatch Use Cases¶
Last Updated: 2026-01-20
Overview¶
This document describes the core use cases for MedExpertMatch, an AI-powered medical expert recommendation system. Each use case addresses real clinical workflows and demonstrates how the system improves patient care through intelligent specialist matching.
1. Specialist Matching for Complex Inpatient Cases¶
Actor: Attending physician / case manager in a hospital
User Story:
"As an attending physician, I want to quickly find the best specialist in our network for a complex case so that I can
get a timely, high-quality consultation."
Flow (High-Level):
- Physician documents the case in the EMR; a FHIR Bundle (Patient, Condition, Observations, Encounter) is sent to
MedExpertMatch →
MedicalCaseis created and embedded (PgVector)- Alternative: Physician can also enter case information directly via text input (
POST /api/v1/agent/match-from-text), which supports handwritten text (after OCR/transcription) and direct text input without requiring pre-created cases
- Alternative: Physician can also enter case information directly via text input (
- Physician clicks "Find specialist" → EMR calls
POST /api/v1/agent/match/{caseId}orPOST /api/v1/agent/match-from-text - Agent:
- Uses
case-analyzerskill to refine symptoms/urgency - Uses
doctor-matcherskill + Java tools:- Queries candidates from
DoctorRepository - Calls
SemanticGraphRetrievalService.score(case, doctor)which combines:- Vector similarity (40%): PgVector embeddings comparison
- Graph relationships (30%): Apache AGE graph traversal (doctor-case relationships, condition expertise, specialization matching)
- Historical performance (30%): Past outcomes, ratings, success rates
- Queries candidates from
- Uses
- Agent returns a ranked list of
Doctorwith scores and rationales
Sequence Diagram:
Problem Solved:
- Reduces delay to specialist consultation and potentially shortens length of stay
- Replaces ad-hoc "who do I know?" with a consistent data-driven matching process
References:
- Optimizing Specialist Consultation to Reduce Hospital Length of Stay
- Azure AI with Apache AGE Overview
- Apache AGE Overview
Feature: Find Specialist Flow
2. Online Second Opinion / Telehealth¶
Actor: Referring physician or patient via portal
User Story:
"As a doctor or patient, I want to get a second opinion from the most appropriate specialist in the network so I can
confirm or adjust the treatment plan."
Flow:
- User uploads medical records; the portal produces a FHIR Bundle and sends it to MedExpertMatch →
MedicalCasewith typeSECOND_OPINIONis created - Portal calls
POST /api/v1/agent/match/{caseId} - Agent:
case-analyzer: extracts main diagnosis, ICD-10/SNOMED codes, complexitydoctor-matcher+ Semantic Graph Retrieval:- Prefers doctors with strong experience in that diagnosis
- Optionally prioritizes telehealth-enabled doctors
- Response: top specialists with scores, availability, and reasons
Sequence Diagram:
Problem Solved:
- Cuts turnaround time for second opinions from days to minutes
- Increases probability that the case goes to the right sub-specialist, not just a generic "oncologist" / "cardiologist"
References:
Feature: Find Specialist Flow
3. Prioritizing the Consultation Queue¶
Actor: Consultation coordinator / department head
User Story:
"As a consultation coordinator, I want all consult requests prioritized by clinical urgency so specialists see the
sickest patients first."
Flow:
- Departments create consult requests (FHIR ServiceRequest / Encounter) that are mirrored as
MedicalCasewith typeCONSULT_REQUEST - Coordinator opens "Consult queue"; UI calls
POST /api/v1/agent/prioritize-consults - Agent:
- For each open
MedicalCase, usescase-analyzertools:extract_case_symptoms,classify_urgency, mayberisk_score
- Semantic Graph Retrieval computes
priorityScorebased on urgency, complexity, and physician availability
- For each open
- Agent returns a list of consults sorted by
priorityScore(CRITICAL / HIGH / MEDIUM / LOW) and optionally suggested doctors
Sequence Diagram:
Problem Solved:
- Prevents urgent consults from being buried in FIFO queues
- Reduces time-to-specialist for high-risk patients and unnecessary delays in care
References:
Feature: Consultation Queue
4. Network Analytics: "Who is Actually Expert in What"¶
Actor: Chief medical officer / quality & analytics team
User Story:
"As a medical director, I want to see which specialists and facilities truly handle complex cases in specific domains so
I can plan routing and capability development."
Flow:
- MedExpertMatch accumulates:
MedicalCase,ConsultationMatch, outcomes, ratings
- Apache AGE stores a graph:
(Doctor)-[:HANDLED]->(Case)-[:HAS_CONDITION]->(Condition)and links toFacility
- Analyst asks: "Show top experts for ICD-10 I21.9 in the past 2 years"
- UI →
POST /api/v1/agent/network-analytics
- UI →
- Agent skill
network-analyzer:- Calls Java tool
graph_query_top_experts(conditionCode)(Cypher on AGE) - Implemented - Calls Java tool
aggregate_metrics(entityType, entityId, metricType)- Implemented - Aggregates volume, case complexity, outcomes, complications
- Returns ranked doctors and centers with metrics
- Calls Java tool
Sequence Diagram:
Problem Solved:
- Makes real expertise visible instead of implicit, anecdotal knowledge
- Supports data-driven routing policies and mentorship/learning programs
References:
Feature: Network Analytics
5. Human-in-the-Loop Decision Support + Expert Matching¶
Actor: Specialist / consulting physician
User Story:
"As a specialist, I want a structured analysis of the case, differential diagnosis, evidence-based recommendations and a
list of colleagues to discuss with, so I can make a better decision."
Flow:
- Specialist opens a case in EMR and clicks "AI analysis + expert suggestions" → calls:
POST /api/v1/agent/analyze-case/{caseId}POST /api/v1/agent/recommendations/{matchId}
- Agent:
case-analyzer: structured summary, differential diagnosis, ICD-10evidence-retriever: guidelines (search_clinical_guidelines) - Implemented, research papers (query_pubmed) - Implementedrecommendation-engine: diagnostic workup, treatment options, monitoring, follow-up (generate_recommendations) - Implementedclinical-advisor: differential diagnosis (differential_diagnosis) - Implemented, risk assessment (risk_assessment) - Implementeddoctor-matcher: potential colleagues or multidisciplinary team members via Semantic Graph Retrieval
- UI shows:
- Differential diagnosis list
- Key evidence points
- Proposed plan + candidate experts and reasons
Sequence Diagram:
Problem Solved:
- Gives the physician a powerful but transparent AI copilot and expert-network navigator, improving accuracy when human + AI are combined
References:
Feature: Find Specialist Flow, Evidence Retrieval
6. Cross-Organization / Regional Routing¶
Actor: Regional health authority / multi-hospital network
User Story:
"As a regional operator, I want complex cases routed to the most capable centers and specialists so patient outcomes
improve and resources are used effectively."
Flow:
- Local hospitals send FHIR Bundles for complex cases into a central MedExpertMatch instance
- Operator/system calls
POST /api/v1/agent/route-case/{caseId} - Agent:
case-analyzer: identifies diagnosis, severity, required resources (e.g., PCI, ECMO)routing-plannerskill:- Calls
graph_query_candidate_centers(conditionCode)(AGE graph of Facilities, Doctors, Cases) - **Implemented ** - Calls Semantic Graph Retrieval (
semantic_graph_retrieval_route_score) to combine case complexity, outcomes, center capacity, geography - Implemented
- Calls
- Returns ranked facilities with proposed lead specialists and explanation
Sequence Diagram:
Problem Solved:
- Reduces "mismatch" between case complexity and facility level, a known issue in hierarchical health systems
- Makes referrals and transfers transparent, consistent, and measurable
References:
Feature: Regional Routing
Use Case Summary¶
| Use Case | Actor | Key Endpoint | Primary Skills | Problem Solved | Feature |
|---|---|---|---|---|---|
| Specialist Matching | Attending Physician | POST /api/v1/agent/match/{caseId} |
case-analyzer, doctor-matcher | Reduces consultation delay | Find Specialist Flow |
| Second Opinion | Referring Physician/Patient | POST /api/v1/agent/match/{caseId} |
case-analyzer, doctor-matcher | Faster second opinions | Find Specialist Flow |
| Queue Prioritization | Consultation Coordinator | POST /api/v1/agent/prioritize-consults |
case-analyzer | Urgent cases seen first | Consultation Queue |
| Network Analytics | CMO/Analytics Team | POST /api/v1/agent/network-analytics |
network-analyzer | Data-driven expertise mapping | Network Analytics |
| Decision Support | Specialist | POST /api/v1/agent/analyze-case/{caseId} |
case-analyzer, evidence-retriever, recommendation-engine, doctor-matcher | AI copilot for specialists | Find Specialist Flow, Evidence Retrieval |
| Regional Routing | Regional Operator | POST /api/v1/agent/route-case/{caseId} |
case-analyzer, routing-planner | Optimal facility routing | Regional Routing |
Use Case Architecture Overview:
graph TB
subgraph UseCases["Use Cases"]
UC1[Use Case 1:<br/>Specialist Matching]
UC2[Use Case 2:<br/>Second Opinion]
UC3[Use Case 3:<br/>Queue Prioritization]
UC4[Use Case 4:<br/>Network Analytics]
UC5[Use Case 5:<br/>Decision Support]
UC6[Use Case 6:<br/>Regional Routing]
end
subgraph Components["Shared Components"]
SGR[SemanticGraphRetrievalService<br/>Hybrid GraphRAG<br/>40% vector + 30% graph + 30% historical]
Graph[GraphService<br/>Apache AGE]
Vector[PgVector<br/>Embeddings]
LLM[MedGemma<br/>Medical Reasoning]
end
UC1 --> SGR
UC2 --> SGR
UC4 --> Graph
UC6 --> Graph
UC6 --> SGR
SGR --> Graph
SGR --> Vector
UC5 --> LLM
style UC1 fill:#e3f2fd
style UC4 fill:#fff3e0
style UC5 fill:#f3e5f5
style UC6 fill:#e8f5e9
style SGR fill:#fce4ec
style Graph fill:#fff9c4
Technical Components¶
Each use case leverages the following core services:
- MatchingService: Core matching logic combining multiple signals
- SemanticGraphRetrievalService: Semantic Graph Retrieval scoring (embeddings + graph + historical data)
- GraphService: Apache AGE graph queries for relationship traversal
- CaseAnalysisService: MedGemma-powered case analysis and entity extraction
- FHIR Adapters: Convert FHIR Bundles to internal
MedicalCaseentities
Last updated: 2026-01-27