Unified Peripartum Database with Natural-Language-to-SQL Capabilities at Udine University Hospital: Design and Prototype

Doriana Armenise, Ginevra Battello, Andrea Brunello, Lorenza Driul, Angelo Montanari, Elisa Rizzante, Nicola Saccomanno, Andrea Salvador, Serena Xodo, Silvia ZermanoarXiv 2025 · DOI · arXiv

Introduction: The Digital Archipelago in Obstetrics

In modern obstetrics, a patient’s medical journey is often fragmented across a "digital archipelago." Data resides in disparate electronic health record (EHR) modules, standalone spreadsheets, laboratory systems, and cardiotocography (CTG) device archives. This fragmentation hinders clinicians from obtaining a holistic view of patient history and complicates reproducible research. Existing systems are typically optimized for daily operations rather than analytical "secondary use." Furthermore, the technical barrier of writing SQL queries often prevents medical personnel from directly exploring centralized data.

Figure 1: Comparison of current fragmented data silos versus the proposed unified system with an NL2SQL layer.

Researchers at Udine University Hospital addressed these challenges by developing a unified relational database that consolidates peripartum data—from maternal history to real-time labor monitoring and neonatal outcomes—integrated with a natural-language-to-SQL (NL2SQL) layer.

Methodology: From Conceptual Design to NL2SQL Integration

The development followed a rigorous database design lifecycle involving three primary stages:

1. Conceptual and Logical Modeling

The team co-designed an Entity-Relationship (ER) diagram with clinicians to accurately capture the nuances of the peripartum domain. A key challenge was modeling the relationship between a single patient and multiple pregnancies. The resulting logical schema, implemented in PostgreSQL, utilized "synthetic IDs" for pregnancies to simplify complex joins.

Figure 3: The logical relational schema implemented in PostgreSQL, illustrating the "union-type" approach for examinations and the complex relationships between clinical entities.

A notable design choice was the "union-type" strategy for examinations. Rather than creating a fragmented hierarchy of different exam types, the authors consolidated them into a single relation. This simplified the schema while maintaining the ability to store diverse, type-specific data points.

2. The NL2SQL Layer

To make the database accessible to non-technical users, a two-part module was implemented:

  • Frontend: SQLChat, a web-based interface providing a familiar conversational paradigm.
  • Backend: XiYanSQL-QwenCoder-32B-2504, a high-performance open-source Large Language Model (LLM) specialized in SQL generation.

3. Constraint Enforcement

Beyond standard schema rules, the system employs database triggers to enforce clinical logic. For instance, triggers ensure every pregnancy record is linked to at least one examination or delivery, maintaining data integrity for research purposes.

Results: Bridging the Technical Gap

The prototype was populated with data migrated from the Obstetrics Clinic of Udine University Hospital and tested against eight clinical queries of moderate complexity.

The system successfully translated seven out of eight queries correctly. It demonstrated a robust ability to handle multi-table joins—such as linking Patient to Pregnancy, Delivery, and Newborn—which are traditionally difficult for non-experts. In one instance, the system perfectly automated a complex SQL task: calculating the average interval between labor induction and delivery by extracting epochs from timestamps.

For benchmarking, the underlying XiYanSQL model achieved a 67.14% performance score on the BIRD (Big Bench for Large-scale Database Grounding) dataset, outperforming general-purpose models like GPT-4 in specific SQL generation tasks.

Discussion and Future Directions

The project highlights that co-design is essential; involving clinicians in the ER modeling phase ensured the database structure reflected actual obstetric workflows. By lowering the "audit barrier," the NL2SQL layer transforms the database from a passive storage bin into an active clinical tool. Clinicians can now perform complex data audits—such as identifying newborns with specific pH levels or counting C-sections within a timeframe—using simple prompts.

Limitations and Future Work

Despite its success, the NL2SQL model can struggle with ambiguous requests. Future work will focus on "schema enrichment," adding descriptive comments directly into the SQL schema to help the LLM understand hidden constraints and clinical context. Additionally, the authors aim to evolve the system into a hub for publishing anonymized datasets to foster broader reproducible research in perinatal care.

Summary updated

Abstract

The fragmentation of obstetric information across electronic health record modules, device repositories, and laboratory systems, as it is common in hospitals, hinders both intrapartum care and reproducible research. In this work, we present a practical blueprint for transforming heterogeneous peripartum records into computable, queryable assets by designing and prototyping a unified peripartum relational database with natural-language-to-SQL (NL2SQL) capabilities at the Obstetrics Clinic of Udine University Hospital. Requirements were co-defined with clinicians and formalized as an Entity-Relationship diagram, from which the logical schema and SQL implementation of the database were then derived. The latter integrates heterogeneous sources to connect maternal anamnestic and longitudinal history, current-pregnancy findings, intrapartum course, and delivery and neonatal outcomes. The NL2SQL layer enables clinicians to pose natural-language queries to the system, lowering barriers to audit and exploratory analysis.
BibTeX
@misc{armenise2025unified,
  author = {Doriana Armenise and Ginevra Battello and Andrea Brunello and Lorenza Driul and Angelo Montanari and Elisa Rizzante and Nicola Saccomanno and Andrea Salvador and Serena Xodo and Silvia Zermano},
  title = {{Unified Peripartum Database with Natural-Language-to-SQL Capabilities at Udine University Hospital: Design and Prototype}},
  year = {2025},
  eprint = {2510.16388},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2510.16388},
}
Figure