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.
Glossary
Criteria-to-Query Translation

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.
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.
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.
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.
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.
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.
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.
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.
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.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
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.
Related Terms
The translation of structured eligibility criteria into executable database queries is a critical bridge between clinical intent and computational action. These related concepts define the surrounding architecture that makes automated patient screening possible.
Computable Phenotype
A machine-processable definition of a clinical condition expressed as a set of logical expressions and data queries. Computable phenotypes are the direct output of criteria-to-query translation, enabling the identification of patient cohorts from electronic health records.
- Combines ICD-10-CM codes, lab values, and medication orders
- Uses logical operators (AND, OR, NOT) to define inclusion boundaries
- Must handle temporal constraints like 'diagnosis within 6 months'
Eligibility Criteria Parsing
The automated extraction and structuring of complex free-text inclusion and exclusion requirements from clinical trial protocols into a machine-readable format. This upstream process feeds the criteria-to-query pipeline with structured logical predicates.
- Transforms narrative text like 'EGFR-mutant non-small cell lung cancer' into structured fields
- Resolves anaphora and co-reference in multi-sentence criteria
- Outputs JSON or OMOP-compatible structured criteria
Phenotype Execution Engine
A software component that runs a computable phenotype definition against a clinical data repository, resolving logical expressions and temporal constraints to return a patient cohort. This is the runtime environment where translated queries execute.
- Translates phenotype logic into SQL, FHIR, or OMOP CDM queries
- Optimizes query plans for large-scale patient databases
- Returns both cohort lists and individual patient-level eligibility evidence
Temporal Reasoning for Eligibility
The AI capability to interpret and validate time-dependent clinical constraints against a patient's longitudinal record. Criteria-to-query translation must encode complex temporal logic such as washout periods, disease progression timelines, and sequence dependencies.
- Handles constraints like 'no chemotherapy within 28 days of enrollment'
- Requires patient timeline reconstruction from timestamped events
- Uses Allen's interval algebra for temporal relationship validation
Eligibility Criteria Normalization
The process of mapping synonymous clinical terms and varying units of measure within trial criteria to a standard ontology before query generation. Normalization ensures that a criterion like 'HbA1c > 7%' correctly maps to the local lab codes and units in the target database.
- Maps to standard terminologies: SNOMED CT, LOINC, RxNorm
- Handles unit conversion (mg/dL vs mmol/L)
- Resolves semantic equivalence ('heart attack' = 'myocardial infarction')
Cohort Definition Language
A standardized, machine-readable syntax for expressing the complex inclusion and exclusion rules that define a patient group. CDL serves as the intermediate representation between parsed criteria and executable queries, enabling portability across different data models.
- Examples include OHDSI's ATLAS and CQL (Clinical Quality Language)
- Provides version control for phenotype definitions
- Enables sharing of computable definitions across institutions

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us