Skip to main content
Engineering

Compliance Engineering in a Diagnostics Platform: Consent, Sample Traceability, and Audit Trails

What six years inside one diagnostics product taught us about linking a physical tube of blood to a consented identity, and proving it afterwards.

2026-08-11 · By Filip Lauc

Why diagnostics platforms are harder than generic health apps

A diagnostics platform is harder than a generic health app because it spans the physical world. Software has to track a barcoded tube through shipping, a laboratory, and an analysis pipeline, then bind that physical object to a legally consented person before a single result is shown.

Most health software deals only in records. A diagnostics business deals in objects: kits picked and packed in a warehouse, tubes shipped across borders, samples registered at a lab bench, aliquots processed in batches, raw instrument output mapped back to an order. Each of those handoffs is a place where identity can be lost, duplicated, or attached to the wrong person, and each is a place where a regulator or an auditor will later ask you to show what happened.

That changes the shape of the architecture. The interesting engineering is not the customer portal. It is the set of invariants that hold across ten or more systems: that every sample has exactly one owner, that no result leaves the lab boundary without a valid consent and a release decision, and that every state change is reconstructable months later without relying on anyone's memory.

Linking a physical sample to a consented identity

The link between a physical sample and a person should be a single, explicit, auditable record: a sample identifier issued at kit fulfilment, an activation event where a person claims that identifier under a specific consent version, and a lab registration event that confirms the same identifier arrived. Nothing infers the link implicitly.

In practice the kit ships with an identifier that means nothing on its own. It is a token, not a name. The person who receives it activates it in the portal, and that activation is the moment identity attaches. We record which consent text version they accepted, the timestamp, the scope they granted (results only, research reuse, partner sharing), and the account the identifier is now bound to. Because activation is a discrete event rather than a field update, revocation and re-binding are also events, and the history stays intact.

The identifier itself should be pseudonymous everywhere downstream. Lab systems, batch files, and instrument exports work with the sample identifier and never with names, addresses, or emails. That single decision does most of the heavy lifting for data minimisation: a leaked batch file or a misrouted CSV contains codes, not people. Re-identification happens only in the one service that owns the binding table, behind its own authorisation boundary.

Chain of custody across lab, warehouse, and partner systems

Chain of custody is implemented as an append-only event log per sample, written by every system that touches it. Warehouse, courier integration, lab reception, processing, analysis, and result generation each emit a typed event with actor, timestamp, location, and prior state, so the full journey can be replayed from the record.

The temptation is to keep a status field on the sample and update it. That works until a lab reprocesses a batch, a courier returns a shipment, or two systems disagree about where something is. Modelling custody as events instead of state gives you an ordered narrative, and the current status becomes a projection of that narrative rather than the source of truth. When someone asks why a sample was rejected, the answer is in the log with the actor who recorded it.

Cross-system consistency is the practical difficulty. Lab instruments and warehouse tools are rarely designed to call your API politely. We handle that with idempotent ingestion endpoints keyed on sample identifier plus event type plus external reference, so replayed files and repeated scans do not create duplicate history. Out-of-order events are accepted and ordered by their recorded occurrence time, not their arrival time, with a reconciliation job that flags impossible sequences such as an analysis event for a sample never registered at reception.

  • Kit fulfilment: identifier issued and associated with an order, not yet with a person
  • Activation: person claims the identifier under a named consent version
  • Reception: lab confirms physical arrival, records condition and any rejection reason
  • Processing: batch membership, aliquots, and operator recorded per step
  • Analysis: raw instrument output linked to the sample identifier and run
  • Release: validated result attached to the identifier and cleared for delivery

Result release rules: who sees what, and when

Result release should be an explicit, permissioned decision rather than a side effect of data arriving. A result becomes visible only when it has passed lab validation, the consent covering it is still active, the recipient's entitlement is checked at read time, and a release event has been recorded by an identified actor.

Diagnostics platforms rarely have one audience. The individual sees their own results. A partner clinic or practitioner may see results for people who came through them, but only within the scope the person granted, and often only for a defined period. Research use, where consented, needs aggregate or pseudonymised access with no route back to identity. B2B customers may need order-level status without ever seeing clinical content. Each of those is a different authorisation question against the same underlying record.

We keep the entitlement evaluation server side and re-evaluate it on every read rather than baking visibility into denormalised copies. Precomputed 'results visible to partner X' collections are exactly the structures that go stale when someone withdraws consent. If a person revokes partner sharing at 10:00, the next read at 10:01 must fail the check, not serve a cached projection built the night before. Where caching is unavoidable for performance, the cache key includes the consent version so a revocation invalidates it.

Audit trails that survive an actual audit

An audit trail is useful only if it is append-only, attributed to a specific human or service identity, timestamped from a trusted source, and queryable by subject as well as by time. Logs that live in an application database that engineers can edit, or that only support tail-following, do not satisfy an auditor.

Three properties matter most. First, attribution: every write records who performed it, including internal staff acting through admin tooling and service accounts acting on behalf of an integration. 'System' is not an actor. Second, immutability: audit records go to storage where the application role has append permission and no update or delete permission, with retention configured independently of the application's own retention rules. Third, queryability by data subject, because the questions you get are almost always 'show me everything that happened to this person's data', not 'show me last Tuesday'.

Access to clinical data is itself an auditable event. Reads matter as much as writes in a health context, so every retrieval of a result by staff, partner, or integration is logged with the reason where one is required. This is also what makes internal misuse detectable rather than theoretical.

Deleting data when the result is a medical record

GDPR erasure does not automatically override medical record retention. When a result is a health record subject to a legal retention period, the correct engineering answer is usually to erase or pseudonymise the identity layer and the marketing and behavioural data, while retaining the clinical record in a form that can no longer be attributed to a person by ordinary means.

This is exactly why the identity binding lives in one place. A deletion request removes the account, the contact details, the shipping history, and the binding between person and sample identifier. What remains is a result attached to a code, which the organisation can retain where it has a legal obligation or a legitimate scientific research basis, and which no longer identifies anyone. The deletion itself is recorded in the audit trail, because proving you honoured a request is part of honouring it.

The messy part is downstream copies. Analytics warehouses, email platforms, support desks, partner exports, and backups all hold fragments. We handle this with a deletion orchestration process that fans out to every system holding personal data, tracks per-system acknowledgement, and keeps a record of what could not be erased immediately and why, backups being the classic case where the honest answer is that the data expires with the backup rotation rather than being surgically removed. Documenting that policy up front is far better than discovering it during a data subject request.

Building this incrementally, not all at once

No team ships a complete compliance architecture on day one. The realistic path is to get three things right early, because they are expensive to retrofit: pseudonymous identifiers everywhere downstream, events instead of mutable status fields, and a single service that owns the identity binding. Everything else can be layered on.

Retrofitting is painful in specific, predictable ways. If names travelled into lab exports for two years, you now have personal data in files you do not control. If custody was a status field, you cannot reconstruct history for anything that happened before you switched. If entitlements were denormalised into per-partner collections, unwinding them touches every read path. We have done versions of each of these migrations, and they are all doable, but they cost more than doing it correctly the first time.

The pattern that scales over years is boring: one canonical model for sample identity, typed events at every system boundary, authorisation evaluated at read time, and an audit log nobody can quietly rewrite. Six years into a diagnostics platform, those decisions are the ones that still hold, long after individual services, frameworks, and lab instruments have been replaced around them.

Key Takeaways

  • Bind a physical sample to a person through an explicit activation event that records the consent version, not through an implicit field update.
  • Use pseudonymous sample identifiers in every downstream lab, warehouse, and analytics system, with one service owning the identity binding.
  • Model chain of custody as an append-only event log with idempotent ingestion, so history survives reprocessing, returns, and out-of-order integrations.
  • Evaluate result visibility at read time against live consent, rather than precomputing per-partner projections that go stale on revocation.
  • GDPR erasure in diagnostics usually means deleting the identity layer while retaining a legally required, no-longer-attributable clinical record.

These patterns come from six years as the dedicated engineering team behind the GlycanAge case study, where we built and maintained 10+ interconnected systems spanning laboratory management, warehouse logistics, customer portals, and partner dashboards.

Frequently Asked Questions

What does chain of custody mean in laboratory software?

Chain of custody is the documented, unbroken record of everyone and every system that handled a sample from collection to result. In software it means recording a typed event at each handoff, including actor, timestamp, and location, so the sample's journey can be reconstructed later. It is what lets a lab prove a result belongs to the person it was reported for.

Can a patient request deletion of their lab results under GDPR?

They can request it, but the right to erasure is not absolute. Where a healthcare or diagnostics provider has a legal obligation to retain medical records, or a legitimate research basis under an applicable exemption, the clinical record can be retained. The usual engineering outcome is deleting identifying data and account information while keeping the result in a form that no longer identifies the person.

Do I need an ISO 13485 or IVDR compliant system to build a diagnostics portal?

It depends on what the software does. Software that only handles ordering, logistics, and result presentation is generally treated differently from software that calculates or interprets a diagnostic result, which may fall under IVDR as software as a medical device. Determine the classification with regulatory counsel before architecture decisions, because it drives documentation, validation, and change control requirements.

How should consent versions be stored in a health platform?

Store consent texts as immutable versioned documents and record each acceptance as an event referencing a specific version, timestamp, scope, and the user who accepted it. Never overwrite a consent record when the text changes. This lets you prove exactly what a person agreed to at the moment they agreed to it, and lets you re-prompt only the users affected by a material change.

What is the difference between anonymisation and pseudonymisation for medical data?

Pseudonymised data replaces identifiers with codes but can still be re-linked to a person using a separately held key, so it remains personal data under GDPR. Anonymised data cannot be re-linked by any reasonably likely means and falls outside GDPR. Most diagnostics platforms operate on pseudonymised data internally, because the ability to return a result to the right person is essential.

Filip Lauc

Written by

Filip Lauc

CEO, Jaspero

Filip Lauc is the CEO of Jaspero, a software development agency based in Osijek, Croatia. A full-stack JavaScript developer with over a decade of experience across Angular, Svelte, and Node.js, he leads Jaspero's work as a long-term embedded engineering partner for clients like GlycanAge, where his team has served as the dedicated engineering team for six years.

Let's Build Together

Your vision,
our expertise.

From AI integration to full-stack development, we turn ambitious ideas into products that perform.