cd /news/artificial-intelligence/how-i-built-an-ontology-driven-data-… · home › topics › artificial-intelligence › article
[ARTICLE · art-175038] src=pub.towardsai.net ↗ pub= topic=artificial-intelligence verified=true sentiment=· neutral

How I Built an Ontology-Driven Data Application from Fragmented Healthcare Data

A practitioner built an ontology-driven data application that connects fragmented hospital records across patient administration, pathology, pharmacy, theatres and finance without replacing the departmental systems that own them, according to a first-person account of the architecture. The design ingests data via database extracts, REST APIs, Change Data Capture (CDC) and event streams into an append-only raw landing tier for replay, then applies deterministic transformation steps in SQL, Python or Spark. Identity resolution retains original patient identifiers rather than treating them as interchangeable, and AI is connected through ontology-grounded retrieval so care and operational teams can follow a patient journey without manually joining departmental exports.

recommendation

Ground AI retrieval in a shared business-object ontology over an append-only raw tier rather than flat extracts, so patient-journey queries stay consistent and replayable when transformation logic changes.

more in playbook: Retrieval and RAG
by read11 min views5 publishedNov 23, 2026

Hospitals generate enormous amounts of operational data, but that does not necessarily mean they have a connected view of their operations. Patient administration, pathology, pharmacy, theatres and finance often operate through separate applications, each recording a different part of a patient’s journey. The challenge is not simply to consolidate these records into a warehouse. It is to establish the relationships between them and make that information useful across operational applications and AI. In this article, I explain how I approached this problem by bringing fragmented hospital data into a shared ontology-driven architecture. I describe how I organised the data pipelines, modelled real-world entities as business objects, separated analytical storage from operational serving, and connected AI through ontology-grounded retrieval. The objective was to create a consistent operational view without replacing the departmental systems responsible for the underlying records.

I started with a practical question: could a care or operational team follow a patient’s journey without manually joining exports from several departmental systems? Consider a patient arriving at an emergency department with a suspected infection. A clinician requests a swab, the specimen is collected and sent to pathology, and the laboratory records the result. The patient is subsequently admitted to a ward, where medication is prescribed and administered. Each department captures a legitimate part of the patient’s journey, but no single departmental application necessarily presents the complete sequence. The challenge is more complicated than joining tables. The same patient may have different identifiers across systems. Timestamps may represent specimen collection, laboratory receipt, result publication or medication administration. Clinical terminology can also differ, and a medication order is not evidence that a dose was actually administered.

A spreadsheet can temporarily bring these records together, but it creates another copy of the data, another place for business logic to diverge and uncertainty about which extract is current. I therefore approached the problem from the perspective of the patient journey rather than individual departmental databases. I needed to identify the entities involved, understand how they related to one another, establish which system owned each piece of information and determine how users would consume the connected information. The objective was not to build another reporting layer. It was to create a shared operational context.

The first part of the architecture was integrating the information without losing its original meaning or provenance. Patient administration supplied identity and encounter information. Laboratory systems supplied specimen and diagnostic information. Prescribing and electronic medication administration systems supplied medication requests and administration records. Other departmental systems contributed their respective operational records. Because these systems expose information differently, the ingestion architecture needed to accommodate database extracts, REST APIs, Change Data Capture (CDC) and event streams. I treated the incoming records as source evidence rather than immediately overwriting them with a newly created canonical representation. An append-only raw landing tier provides a reliable record of what arrived and makes replay possible when transformation logic changes or downstream processing fails. From there, I organised transformation into deterministic processing steps. These could be implemented using SQL, Python or Spark, depending on the workload and platform.

The transformation process covered several important responsibilities:

Identity resolution required particular attention. A patient might have different identifiers in the patient administration and laboratory systems. Rather than treating those identifiers as interchangeable, I retained the original identifiers and established a canonical patient identity through governed matching rules. High-confidence matches could be linked, while ambiguous records required further investigation. An incorrect patient match would make the supposedly connected operational view misleading. I also considered data lineage and provenance. It should be possible to trace an important object property back to its originating source field and the transformation that produced it. W3C PROV-O provides a useful vocabulary for representing the entities, activities and agents involved in data provenance [1].

Once the data foundation was established, the next step was representing the hospital information through a shared business model. This is where the ontology became central to the architecture. Instead of allowing every application to work directly with departmental tables, I modelled the important real-world entities as Object Types, defined their Properties and established explicit Link Types between them.

The core object types included:

Object TypePurposePatientRepresents the individual receiving careEncounterRepresents a hospital attendance or admissionLocationRepresents the ward or clinical locationSpecimenRepresents a collected blood sample or swabObservationRepresents an individual clinical or laboratory observationDiagnosticReportRepresents interpreted diagnostic findingsMedicationRequestRepresents prescribed medicationMedicationAdministrationRepresents medication actually administered The relationships are what make this model useful.

A Patient can have multiple Encounters. An Encounter can take place at a Location and involve several Specimens. A Specimen can be associated with a DiagnosticReport, which may contain several Observations.

MedicationRequest and MedicationAdministration are deliberately separate. One represents what was prescribed; the other represents what was actually given. These distinctions matter operationally. An application should not interpret a prescription as proof that a patient received the medication.

I used Link Types to make these relationships explicit rather than leaving every application to reconstruct the same joins independently. Properties retain the information required by downstream applications, including identifiers, statuses, timestamps, source references and relevant operational attributes.

The result is a connected representation of the patient journey rather than a collection of unrelated departmental records. One important distinction is that the ontology does not automatically replace the source systems as the authoritative record. Pathology can remain authoritative for a verified laboratory result, while the electronic medication administration record remains authoritative for a recorded dose. The ontology provides a common way to locate, relate and interpret those facts.

I separated the requirements of historical analysis from those of interactive applications. Columnar data formats and lakehouse table formats such as Parquet, Apache Iceberg and Delta Lake are useful for large scans, transformations and historical queries. However, they are not automatically the best serving mechanism for every low-latency object lookup or multi-hop relationship traversal. This led to a design with distinct but synchronised data projections.

The analytical store retains raw and curated history, supports replay and performs large-scale computation. The operational object index serves canonical business objects and their relationships to applications. Instead of reconstructing complex relationships through independent SQL queries, applications can retrieve objects and navigate their connections. The vector index supports similarity search over unstructured information such as clinical notes, policies and operational narratives, where that information is available and authorised for use. The important point is that these components have different responsibilities. They are not three competing systems of record. The ontology provides the shared semantic model across the architecture. It defines what a Patient or Encounter means, how those objects relate and how applications should interact with them, independently of the physical storage mechanism.

Synchronisation introduces additional engineering responsibilities. CDC delays, late-arriving events, deletes, schema changes and failed index updates can leave an operational projection behind its source. I therefore treated freshness metadata, replay, reconciliation, dead-letter handling and monitoring as core design requirements. An operational index is only useful when users can understand how current its information is and engineers have a mechanism to repair divergence.

The value of the object model becomes clearer when applications start consuming it. An ontology-bound application can work directly with Patient, Encounter and Specimen objects rather than independently rebuilding joins and business rules in its own SQL. For example, a care-coordination application could display a patient’s current encounter, associated specimens, diagnostic reports, medication requests and recorded administrations. Users could filter by status, navigate relationships and investigate outstanding activities within one governed interface. This reduces the need to export information into spreadsheets simply to make it usable. However, retrieving information is only one part of the architecture. Operational applications must also support controlled actions.

I treated an action such as Reassign_Order as a governed command rather than a direct update to a replicated database table. The command should validate the current state, check the user’s authorisation, apply relevant business rules, invoke the system responsible for the order and record the outcome. Once the source system produces an update, the resulting event can refresh the operational object projection. Idempotency keys help make retries safe, while concurrency controls help prevent an older update from overwriting a newer decision. Transactional guarantees across independent departmental systems should never be assumed without an implementation that explicitly provides them. Governance must also follow the objects into every application and retrieval interface. Role-Based Access Control (RBAC) assigns permissions according to roles. Attribute-Based Access Control (ABAC) can consider additional context, including the user, requested object, action and purpose of access [2].

For example, a user may be permitted to establish that a laboratory result exists without necessarily being authorised to view its clinical details. The same restrictions must apply to application queries, object properties, operational actions and AI retrieval. Hiding information in an application interface is not sufficient if the underlying retrieval service can still expose it. I did not treat the ontology as another vector database. Vector similarity is useful for finding relevant text, but it does not prove that two records belong to the same patient or admission.

Consider the relationship:

Patient → Encounter → Specimen → DiagnosticReport

If this information is flattened into independent text chunks, the relationships needed to answer a structured question may be lost. A retrieval system might find a relevant laboratory result without reliably establishing which encounter or patient it belongs to. Ontology-grounded retrieval approaches this differently. The model interprets the user’s question and identifies the relevant patient, encounter or event. A policy check limits the accessible objects. Graph traversal follows explicit relationships to retrieve the relevant specimen and diagnostic report. Vector search can provide supporting narrative context, while structured queries and deterministic functions calculate exact counts, date intervals and aggregations. The language model then receives the retrieved evidence and produces a contextualised response, with source and freshness information available for inspection. This division of responsibility is deliberate. The language model helps interpret intent and formulate a retrieval plan. Deterministic functions perform exact calculations against governed data. Graph relationships establish structural context, while vector retrieval provides semantic discovery across unstructured information. Retrieval-Augmented Generation provides a mechanism for grounding language generation in external evidence [3], while graph-based retrieval approaches demonstrate how explicit relationships can improve the retrieval of connected information [4]. Permission enforcement must happen before unauthorised evidence reaches the model. Caches, logs, embeddings and generated summaries also require appropriate controls. These safeguards reduce risk, but they do not justify claims of zero leakage.

The central lesson is that connecting systems is not the same as connecting meaning. A pipeline can successfully move records while leaving patient identity, event semantics and relationships unresolved. An ontology cannot independently repair poor source data. The difficult engineering work remains identity resolution, terminology mapping, event-time interpretation, duplicate handling, provenance and agreement about which system owns each operational state. I would evaluate this architecture using operational measures as well as pipeline throughput. Relevant measures include identity-match errors, unlinked events, object-index freshness, lineage coverage, reconciliation failures, action retries, denied-access tests and the time required to complete the target workflow.

A useful application should make filtering, exception handling and operational tracking safer and easier than exporting another spreadsheet. If it is slower or less transparent than the existing workaround, people will continue using the workaround. Although this implementation focuses on healthcare, the architectural pattern is applicable elsewhere. Aircraft maintenance connects aircraft, components, defects, work orders and flight rotations. Financial investigations connect customers, accounts, transactions, alerts and cases. Retail fulfilment connects products, suppliers, inventory, orders and returns. The business objects change, but the engineering problem remains similar: important processes cross application boundaries, and users need a reliable way to understand those relationships.

I built this architecture around a simple premise: an organisation should not have to reconstruct the meaning of its operations every time someone asks a question that crosses departmental boundaries. By preserving source records, resolving identities, modelling shared objects and relationships, and exposing those objects through governed applications, fragmented hospital data can become a connected operational resource. The ontology provides applications and AI with a common context. Pipelines keep that context aligned with source systems. Access policies govern who can see and change information, while controlled actions route decisions back to the systems that own the operational state. The outcome is not one giant database or a replacement for every departmental application. It is a coherent operational layer across systems that remain specialised. That is the difference between centralising data and making it usable across an organisation: centralisation brings records together; an ontology-driven architecture makes their identities, relationships, provenance and permitted actions meaningful in the context of the work being done.

[1] W3C, PROV-O: The PROV Ontology, W3C Recommendation, 2013. [2] V. C. Hu, D. Ferraiolo, D. Kuhn et al., Guide to Attribute Based Access Control (ABAC) Definition and Considerations, NIST Special Publication 800–162, 2014, updated 2019.

[3] P. Lewis et al., Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks, Advances in Neural Information Processing Systems 33, 2020.

[4] D. Edge et al., From Local to Global: A Graph RAG Approach to Query-Focused Summarization, 2024. How I Built an Ontology-Driven Data Application from Fragmented Healthcare Data was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.

── more in #artificial-intelligence 4 stories · sorted by recency
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/how-i-built-an-ontol…] indexed:0 read:11min 2026-11-23 · —