Transforming FHIR into an OWL Knowledge Graph for Schema-Grounded Natural-Language Querying and Exploratory Data Analysis
FHIR was designed for transactional interoperability but is less well suited to querying and exploratory analysis because its resource-centric structure distributes meaning across deeply nested resources. To address this limitation, we transformed MIMIC-IV Demo FHIR data into an OWL-compliant knowledge graph by flattening nested elements, normalizing repeating arrays, resolving inter-resource references, and promoting frequently queried attributes to direct properties. We also aligned diagnosis and procedure codes to ICD-9-CM and ICD-10-CM terminologies and developed a schema-grounded NL2SPARQL interface for natural-language querying. Structural validation was performed with SHACL and OWL reasoning. Across a curated evaluation set, NL2SPARQL achieved a mean accuracy exceeding 95% relative to expert-authored queries. These results suggest that ontologizing FHIR can improve analytic accessibility while preserving clinically meaningful assertions.