Artificial intelligence-assisted pharmacoepidemiology in pregnancy: a privacy-preserving workflow for bias control in a national primary-care database
Year: 2026
Type: preprint
Abstract: Purpose: Studies of medicines in pregnancy on routine data must control biases (immortal time bias, confounding by indication and others), keep protected data within the licensed environment and program every analysis. Within the ADVANCE project, we describe a workflow in which investigators formulate clinical questions and analysis plans, an AI coding agent writes and refines locally executed code, and correctness is tested by implementation in two languages. Methods: An extract of THIN Italy was restricted to women aged 15-44 years at extraction with pregnancy-related records and to 19 Anatomical Therapeutic Chemical (ATC) classes chosen in advance. Each line went from clinical question and literature framing to an analysis plan within a common episode-level design (early-pregnancy exposure window, composite outcome of pregnancy loss or preterm birth, cluster-robust errors), implementation in Python and Stata, parity check and interpretation against expectation. Results: Of 19,332 episodes, 13,809 in 11,998 women were analysable and 1,678 (12.2%) ended in spontaneous abortion, unspecified loss or preterm birth. Five successive versions of the common design, each applied to all lines, corrected eleven defects; better case ascertainment raised the analysable population from 4,294 women to 13,809 episodes and lowered recorded spontaneous abortion from 26.9% to 11.2%. An audit against 100 methodological papers found 22 pitfalls, none unaddressed. Fourteen lines reached parity under the final design; three questions were downgraded where data were insufficient. Conclusions: Leaving questions and design to investigators and confining an AI agent to implementation verified by parity allowed a bias-controlled design to be refined and applied to every answerable question.
Source: medRxiv
Institution: University of Florence
Language: English
Field: Medicine
Domain: Health Sciences
Open Access status: green
OpenAlex ID: W7242525981
Cites:
Cited by:
Related to:
