Inferensys

Glossary

Criteria-to-Query Translation

The computational process of converting parsed, structured clinical trial eligibility criteria into executable database queries—such as SQL statements or FHIR API calls—to programmatically screen patient repositories for matching candidates.
Engineer reviewing vector database search results on laptop, embeddings visualization on screen, home office coding session.
DEFINITION

What is Criteria-to-Query Translation?

Criteria-to-query translation is the computational process of converting structured, machine-readable clinical trial eligibility criteria into executable database queries to screen patient repositories.

Criteria-to-query translation is the algorithmic bridge between a parsed clinical rule and a data retrieval operation. It takes the logical output of an eligibility criteria parsing engine—structured as atomic conditions, temporal constraints, and value thresholds—and transforms it into a syntactically correct query language such as SQL, FHIR API calls, or a Cohort Definition Language. This process resolves semantic mismatches between clinical concepts and database schemas by mapping standardized ontologies like SNOMED CT or LOINC to specific data warehouse columns and value sets.

The core challenge lies in accurately representing complex clinical logic, including negation, temporal reasoning, and nested boolean operators, within the constraints of a query language. A robust translation engine must handle criteria decomposition, breaking a compound requirement like 'HbA1c > 7.0% within the last 6 months' into discrete data retrieval steps and time-window filters. This deterministic execution is critical for a phenotype execution engine, ensuring that a patient pre-screening process is reproducible, auditable, and directly maps back to the original protocol intent.

MECHANICS OF EXECUTABLE ELIGIBILITY

Key Characteristics of Criteria-to-Query Translation

The core architectural components that transform structured clinical logic into high-performance, executable data retrieval operations against heterogeneous patient repositories.

01

Abstract Syntax Tree Generation

The parsed, structured eligibility criteria are compiled into an Abstract Syntax Tree (AST)—a hierarchical, intermediate representation that models the logical relationships between clinical facts. This AST explicitly captures AND/OR conjunctions, negation scopes, and temporal precedence before any database-specific code is generated. The tree structure allows for logical optimization, such as predicate pushdown, where highly selective filters are evaluated first to minimize the data scanned in subsequent operations.

02

Ontology-Grounded Semantic Expansion

A direct one-to-one mapping of criteria to codes is insufficient. The translation engine must perform ontology-grounded semantic expansion using terminologies like SNOMED CT and RxNorm. For a criterion like 'history of myocardial infarction,' the system expands the query to include all child concepts—subendocardial infarction, STEMI, NSTEMI—and synonymous terms via the ontology's transitive closure. This ensures high recall by accounting for the lexical variability in how clinicians document the same condition.

03

Multi-Dialect Query Synthesis

The system synthesizes the optimized AST into multiple target query dialects simultaneously to support a heterogeneous data fabric. A single eligibility rule set generates:

  • SQL for relational clinical data warehouses
  • FHIR API calls with chained parameters for modern EHRs
  • SPARQL for RDF-based knowledge graphs
  • Elasticsearch DSL for free-text narrative search This multi-dialect capability allows a single trial protocol to screen patients across legacy and modern systems without manual query rewriting.
04

Temporal Constraint Compilation

Complex time-window criteria like 'disease progression within 6 months after platinum-based chemotherapy' are compiled into temporal logic expressions with explicit interval algebra. The translator generates queries that perform clinical event sequencing—joining a patient's timestamped diagnosis and medication administration records to validate the chronological order and the duration constraint. This involves generating SQL window functions or FHIR reverse chaining to ensure the sequence of events matches the protocol's temporal logic.

05

Value Set Binding and Unit Normalization

Quantitative criteria require value set binding to standard terminologies and unit normalization to ensure comparability. A criterion like 'serum creatinine > 1.5 mg/dL' must be translated to query for the correct LOINC code (e.g., 2160-0) and dynamically convert stored values in SI units (μmol/L) to the required conventional units. The translation layer embeds a unit conversion engine that normalizes all numeric lab results at query time to match the protocol's specified units.

06

Query Plan Optimization for Screening

Before execution, the generated query undergoes a cost-based optimization specific to patient screening workloads. The optimizer reorders join operations and filter application based on the cardinality of clinical concepts. A highly selective genomic biomarker filter is executed before a broad age-range filter. The system also generates incremental screening queries that cache intermediate patient cohorts, allowing for rapid re-screening when a single criterion in a protocol amendment changes, rather than re-executing the entire query from scratch.

CRITERIA-TO-QUERY TRANSLATION

Frequently Asked Questions

Explore the technical mechanisms that transform parsed clinical trial eligibility criteria into executable database queries for automated patient screening.

Criteria-to-query translation is the automated process of converting structured, machine-readable eligibility criteria into executable database queries, such as SQL or FHIR API calls, to screen patient repositories. The process begins with parsed criteria—atomic logical conditions extracted from clinical trial protocols. A translation engine maps each criterion to a specific data element in a target data model, such as the OMOP Common Data Model or a FHIR server. For example, a criterion like 'Hemoglobin A1c > 7.0%' is translated into a query selecting patients with a LOINC code 4548-4 and a numeric value exceeding 7.0. The engine resolves complex Boolean logic, temporal constraints, and value sets, generating an optimized query plan that can be executed against a clinical data warehouse to return a cohort of potentially eligible patients.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.