High Availability, Offline-First Architecture & Runtime Guarantees in Clinical Practice Software
Engineering resilient medical software: local-first SQLite, Conflict-free Replicated Data Types (CRDTs), and zero-data-loss guarantees for rural clinics.
The Failure of Pure Cloud-Only Architectures in Healthcare
Traditional enterprise software transitioned from on-premise servers to pure multi-tenant cloud web applications. While this simplified deployment for vendors, it created catastrophic single-point-of-failure vulnerabilities for frontline clinical practitioners. When the internet drops:
- Clinicians lose access to patient allergies, past medical histories, and active medications.
- Consultation documentation halts or reverts to disorganized paper notes requiring manual re-entry.
- Prescriptions cannot be generated, and appointment flow freezes, crippling rural practice efficiency.
In clinical medicine, software availability is a patient safety parameter. A modern clinical platform must provide deterministic runtime guarantees: the application must remain 100% operational regardless of whether it is connected to gigabit fibre, a flaky 4G connection, or completely offline.
The Local-First / Offline-First Architectural Paradigm
The solution is an Offline-First / Local-First architecture. Rather than treating the browser or desktop app as a thin client querying remote REST APIs, the client holds a fully functional local relational database (e.g. SQLite embedded via WASM or native bindings):
- Local Read & Write Execution: Every consultation entry, clinical note, diagnosis, and billing item writes immediately to the local encrypted SQLite database with microsecond latency. The UI updates instantaneously with zero network dependency.
- Append-Only Event Sourcing: Clinical actions are recorded as immutable, cryptographically signed event streams (e.g.
PatientDiagnosedEvent,PrescriptionCreatedEvent), ensuring an unalterable audit trail. - Background Asynchronous Sync: A background synchronization engine monitors network connectivity, streaming batched changes to the distributed cloud replica whenever a connection is established.
Conflict-Free Replicated Data Types (CRDTs) & Multi-Master Sync
The cardinal computer science challenge of distributed offline-first systems is resolving concurrent edits. For example, if a clinic nurse records an immunisation on an iPad while a GP simultaneously updates clinical notes on a desktop during a network disconnection, how are the records merged without data loss?
Instead of blunt 'last-write-wins' (which silently overwrites clinical data), robust clinical platforms implement Conflict-free Replicated Data Types (CRDTs):
- State-based & Operation-based CRDTs: Mathematical data structures that guarantee eventual consistency across all nodes without central coordination.
- Field-Level Merging: Non-conflicting attributes (e.g. blood pressure recorded by nurse vs asthma note entered by doctor) merge deterministically.
- Deterministic Conflict Resolution: Where true simultaneous semantic conflicts occur (e.g. conflicting medication dosages), the conflict is explicitly flagged and preserved in the clinical record for human clinician verification, ensuring zero silent data loss.
Cryptographic Audit Trails & Electronic Prescribing Integrity
In Australia, electronic prescriptions require compliance with Australian Digital Health Agency (ADHA) conformance profiles and PBS statutory rules. When operating offline:
- Local cryptographic keypairs generate digital signatures verifying the clinician's identity and timestamp.
- The system queues outbound Electronic Transfer of Prescriptions (eRx / MediSecure tokens) into an idempotent local outbox, dispatching barcode tokens to the national prescription delivery service the moment connectivity returns.