Clinical research requests skip hand-written SQL: an agentic pipeline matched analyst cohorts across 50 pediatric orthopedic queries
Synopsis
Natural-language data requests in clinical research used to require staff to translate them into computable rules, pick data sources and write institution-specific queries. A large-language-model multi-agent pipeline decomposes each investigator request into source-specific tasks, generates and executes SQL, then combines structured records with clinical-note adjudication. Of 50 pediatric orthopedic requests, 43 completed manual review, with adjusted median positive predictive value 0.93, sensitivity within the observed union 0.92 and F1 0.90.
Interpretation
A multi-agent pipeline now carries a clinical research data request end to end: it reads the investigator's natural-language request, decides which evidence sources are needed, generates and runs institutional SQL, and adjudicates clinical notes against that study's criteria. Previously research staff, informaticians and data analysts translated each request into computable rules, chose data sources, wrote institution-specific queries and interpreted results; earlier LLM work stayed largely on benchmark datasets, offline experiments or a single phenotype, and reported overly broad rules, overly restrictive rules and incorrect concept mapping. The comparator was historical cohorts built by expert data analysts with conventional methods, across 50 pediatric orthopedic requests submitted between mid-2024 and mid-2026; 43 completed manual review and entered the adjusted analysis, where median per-request PPV was 0.93 (95% CI 0.88–0.98), sensitivity within the observed union 0.92 (95% CI 0.90–0.95) and F1 0.90 (95% CI 0.87–0.94).
The pipeline routes first and then retrieves per source: a router agent decides whether a request involves billing codes, clinical notes or imaging, summary agents extract retrieval criteria for each source, and concept-specific SQL agents fill stored templates to build the query. An SQL template is a reusable, concept-specific query pattern reflecting the institution's database schema and querying conventions, prepared by a data analyst with an AI chat agent in three stages: assembling historical queries, internal documentation and table profiles, drafting with expert feedback, then saving the template fixed for later use. Generated SQL passes a Snowflake EXPLAIN compilation check, and failing queries return to the generation agent with the database error for up to three retries; for requests needing note review, a prompt-generation agent turns inclusion and exclusion criteria into a study-specific prompt, notes are judged individually, decisions aggregate at the patient level, and supporting evidence is retained for human review.
Perspective
The evaluation is a single-center, retrospective pediatric orthopedics setting with 50 requests submitted between mid-2024 and mid-2026, and retrieval is limited to billing codes, clinical notes and imaging, with medication, laboratory and pathology retrieval explicitly left to future work.
Historical analyst cohorts are themselves imperfect eligibility references, and the adjusted metrics extrapolate eligibility rates estimated from sampled discordant patients to the full discordant sets, so they depend on the size and representativeness of the annotated samples and do not establish absolute sensitivity in the underlying patient population; incomplete requests, ambiguous terminology, longitudinal reasoning and clinical facts recorded outside the available EHR can all affect the generated workflow.
