Enterprise-Scale Healthcare LLM System for Unified Patient Journeys

john_snow_labs · Healthcare · 2024 · source Agentic: yes · promotional bias: med · source-backed · extracted with prompt 0.5.6 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: Healthcare patient-journey analytics

John Snow Labs needed to turn fragmented multimodal medical data into unified patient journeys that clinicians, nurses, administrators, and researchers can query in natural language while preserving PHI security, clinical accuracy, consistency, explainability, and enterprise scale.

Constraints:

Architecture

John Snow Labs built an on-prem or customer-cloud platform that ingests patient data from APIs and files, uses healthcare-specific LLMs to extract clinical entities, assertion status, relations, codes, dates, and summaries, normalizes terms through SNOMED and other terminology systems, deduplicates repeated mentions into a patient knowledge graph, and stores traceable results in an OMOP-based relational database. Natural-language queries are handled by an agent that maps the request to optimized query templates, resolves terminology, adjusts SQL/schema, executes efficient queries, and explains the logic and provenance.

Diagram confidence: explicit (topology described by the source).

flowchart LR
  patient-data-sources["Patient data sources"] --> healthcare-llm-extraction["Healthcare LLM extraction"]
  healthcare-llm-extraction --> terminology-service["Terminology service"]
  healthcare-llm-extraction --> temporal-normalization["Temporal normalization"]
  terminology-service --> deduplication-and-reasoning["Deduplication and reasoning"]
  temporal-normalization --> deduplication-and-reasoning
  deduplication-and-reasoning --> omop-relational-database["OMOP relational database"]
  omop-relational-database --> query-agent["Query agent"]
  query-agent --> rag-query-template-tool["RAG query-template tool"]
  query-agent --> terminology-service
  query-agent --> sql-and-schema-adjustment["SQL and schema adjustment"]
  query-agent --> result-explanation-ui["Result explanation UI"]
  rag-query-template-tool --> sql-and-schema-adjustment
  sql-and-schema-adjustment --> omop-relational-database
  sql-and-schema-adjustment --> result-explanation-ui
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Patient data sources Structured and unstructured medical inputs from EHRs, FHIR resources, PDFs, claims, labs, prescriptions, imaging, and notes. Healthcare LLM extraction
Healthcare LLM extraction Domain-specific models that extract clinical entities, assertion status, relations, codes, and summaries. Terminology service, Temporal normalization
Terminology service Maps extracted concepts and source codes into SNOMED and other clinical terminologies. Deduplication and reasoning
Temporal normalization Turns relative dates in clinical text into absolute dates for timeline and cohort queries. Deduplication and reasoning
Deduplication and reasoning Merges repeated mentions, resolves specificity, averages/chooses measurements, and carries uncertainty forward. OMOP relational database
OMOP relational database Open-standard relational storage for traceable patient journeys, confidence levels, and extracted facts. Query agent
Query agent Multi-step agent that turns natural-language questions into optimized query execution and explanation. RAG query-template tool, Terminology service, SQL and schema adjustment, Result explanation UI
RAG query-template tool Finds similar pre-built optimized query templates for the user request. SQL and schema adjustment
SQL and schema adjustment Adapts selected query templates, fields, and SQL before execution against large tables. OMOP relational database, Result explanation UI
Result explanation UI Shows answers, references, SQL/business logic, and provenance so users can audit why a patient matched. —

Data flow

Raw patient documents and structured resources enter the system, where medical LLMs extract entities and semantic filters. Terminology services map codes, temporal logic resolves relative dates, reasoning merges and deduplicates repeated findings, and the resulting patient knowledge graph is stored in an OMOP relational database. A query agent then maps natural language to optimized query templates, resolves clinical terms, adjusts SQL, runs the query, aggregates results, and explains the business logic.

“what you do is you build that patient Knowledge Graph um at the end H with really with the the fewer notes”transcript, stated
“the first step is we we call a tool that has a rug component that tries to map the query to basically pre-build queries that we know how to run efficiently”transcript, stated

Why this architecture

The architecture rejects a simple long-context or text-to-SQL design because healthcare data is too large, messy, terminology-heavy, and trust-sensitive. Customer-local deployment protects PHI; OMOP gives an open operational data model; medical LLMs handle extraction and reasoning; and the query agent constrains natural-language requests to optimized, explainable query paths.

“having like you know a really long context llm is completely meaningless right because we we're dealing here with you know a billion pages”transcript, stated
“what we've turned into is really building an agent an AI agent that takes multiple steps to really resolve some of the issues I just described”transcript, stated

Models used: Healthcare-specific LLMs · John Snow Labs medical LLMs · SNOMED resolvers · FHIR · OMOP · RAG · SQL-generation/query agents

Scale

Alternatives considered (roads not taken)

Use a proprietary knowledge base or database that does everything.

Rejected because: Enterprise data infrastructure needed an open, scalable, familiar model with tooling around it, so they chose OMOP.

“there was a decision between going with something po proprietary that would do everything we want or something open that would do almost everything we want”transcript, stated

Use long-context LLMs over patient histories.

Rejected because: The system operates at billions-of-documents scale, beyond any practical context-window framing.

“it's really not useful to have a set of documents that can add once into the context of an llm because we're going to deal here with you know millions of patients”transcript, stated

Treat clinical querying as direct text-to-SQL.

Rejected because: Healthcare queries require terminology lookup, schema adjustment, optimized query templates, and explanation beyond what direct SQL generation can reliably do.

“this actually isn't a text to SQL problem right so so initially when you look at you can say okay you ask for all diabetic patient and you translate to a SQL query”transcript, stated

Allow arbitrary generated SQL against massive tables.

Rejected because: Unoptimized queries could hit 200-300 million-row tables and crash shared infrastructure.

“someone is going to do a select star from a table that has 200 or 300 million rows and the whole server is going to come crushing down on everyone”transcript, stated

Patterns

privacy-preserving-processing (security)

The platform runs inside the customer's infrastructure and does not send PHI to external LLMs, John Snow Labs, cloud providers, or OpenAI.

“it does not call any external llm it does not send data to John SBS or to a cloud provider or to open AI or to any one of those everything runs within your environment”transcript, stated

fine-tuning-adaptation (model adaptation)

John Snow Labs uses its own healthcare-specific LLMs fine-tuned and evaluated for clinical summarization, extraction, question answering, and query mapping.

“we train fine tune and use our own medical llms for all of the tasks here”transcript, stated

tool-use-orchestration (agent architecture)

The query agent calls separate tools for RAG query-template matching, terminology resolution, schema adjustment, SQL execution, and presentation.

“right now there are four types of Step there are four steps they probably more in the future H but what we do is when we look at a query”transcript, stated

rag-retrieval (retrieval)

RAG maps a user's natural-language query to pre-built optimized query templates that the system knows how to run.

“we call a tool that has a rug component that tries to map the query to basically pre-build queries that we know how to run efficiently and we know how to run well”transcript, stated

data-quality-loop (data processing)

The system normalizes terminology and dates, deduplicates repeated clinical mentions, and preserves traceability/confidence before storing patient facts.

“there's a lot of very Healthcare specific logic because it's field by field for how we merge data how we D duplicate data and how we deal with uncertainty”transcript, stated

Tradeoffs

Use open OMOP relational infrastructure.

Chose An open OMOP-based relational model over A proprietary data store or knowledge base that did everything.

Rationale: The platform is intended to become enterprise data infrastructure, so it needs open tools, scalability, and operational familiarity.

“if this really is to become an Enterprise data infrastructure it needs to be open it needs to be scalable”transcript, stated

Deploy entirely inside customer infrastructure.

Chose On-prem/customer-cloud execution with no external LLM calls over Calling hosted external LLM APIs for PHI processing.

Rationale: Healthcare PHI and enterprise security requirements require all data and processing to stay inside the customer's perimeter.

“this platform if you deploy it within your organization it's deployed on new infrastructure within your security perimeter”transcript, stated

Use a multi-step query agent.

Chose RAG template matching, terminology lookup, schema adjustment, SQL execution, and explanation over One-shot text-to-SQL against the patient database.

Rationale: Healthcare queries require reasoning over optimized queries, terminologies, schemas, and user explanations.

“because of the complexity of the reasoning that's require here and the fact that really this is a multi-step process that an agent is much better fit to do”transcript, stated

Gotchas (what bit them)

Long-context LLMs are the wrong abstraction for patient-journey scale.

Root cause: The input universe is millions of patients and billions of documents, not a document set that fits into context.

Resolution: Use extraction, normalization, relational storage, and query agents over a patient knowledge graph.

“having like you know a really long context llm is completely meaningless right because we we're dealing here with you know a billion pages”transcript, stated

Repeated clinical mentions can swamp the true patient state.

Root cause: Hospital stays produce many repeated progress notes with symptoms at different specificity levels and temporary relevance.

Resolution: Deduplicate and reason field-by-field to produce the actual diagnoses, measurements, and uncertainty state.

“if I spent three days at the hospital could easily be 30 or 40 progress notes right one every hour one every two hours there going to be a lot of repetition”transcript, stated

Inconsistent answers destroy clinical trust.

Root cause: LLMs can answer the same question differently, which is unacceptable for doctors asking factual yes/no patient questions.

Resolution: Constrain querying through optimized templates, deterministic data stores, consistency requirements, and explanations.

“the fastest ways to lose all credibility with with your user base is is to tell you know doctors look just ask the system if you don't like the answer just ask again”transcript, stated

Clinical text-to-SQL is too complex for generic SQL generation.

Root cause: Even simple healthcare queries require multi-page SQL, joins across clinical tables, and terminology hierarchy reasoning.

Resolution: Use a multi-step agent with template retrieval, terminology service, schema adjustment, optimized SQL, and explanation.

“give me all the diabetic patients could easily become two or three page SQL State you know SQL statements because they require you to join across multiple tables”transcript, stated

Evaluation

Evaluation combines blind physician preference testing of medical LLMs, clinical factuality/relevance/conciseness checks, consistency requirements, query-performance optimization, and explainability/provenance review.

Metrics: Blind physician preference against GPT-4 · Factuality · Clinical relevancy · Conciseness · Query consistency · Query speed and optimized execution · Traceability and explanation quality

“the evaluation was blind meaning we we generate responses with the two models we showed them to practice the medical doct they don't know which answer came from which model”transcript, stated
“we asked them to evalue three things factual factuality right so is is the answer correct right if it's a summary are the fact in the summary not hallucinated”transcript, stated

Outcomes

The system is positioned for 10-30 million patient/year organizations, hundreds of millions of extracted rows, and billions of documents.

“people you know no longer need to know SQL know to use bi tools really more importantly understand very comp very complex schemas”transcript, stated
“the model wins almost at the 2 to1 ratio on on all of these Dimensions”transcript, stated