Zing Forum

Reading

UniHealth EHR: Edge FHIR Gateway and Event-Driven Architecture for Next-Generation Healthcare

A modern electronic health record system based on FastAPI and FHIR R5 standards, using edge gateways, Kafka event pipelines, and Redis caching to achieve high-performance medical data access with P95 latency below 50 milliseconds.

FHIREHR电子健康档案FastAPIKafkaRedis医疗信息化边缘网关事件驱动架构
Published 2026-04-03 02:13Recent activity 2026-04-03 02:19Estimated read 7 min
UniHealth EHR: Edge FHIR Gateway and Event-Driven Architecture for Next-Generation Healthcare
1

Section 01

UniHealth EHR Project Introduction: Edge FHIR Gateway and Event-Driven Architecture for Next-Generation Healthcare

UniHealth EHR is a next-generation national-level electronic health record system developed by NickEinstein1, designed to address pain points of traditional EHR systems such as data silos, high latency, and poor cross-institutional interoperability. Based on FHIR R5 standards and the FastAPI framework, the system adopts an architecture of edge FHIR gateways, Kafka event-driven pipelines, and Redis caching. Its core goal is to achieve high-performance medical data access with P95 latency below 50 milliseconds, supporting multi-tenant data isolation and real-time clinical decision-making needs.

2

Section 02

Project Background and Challenges in Healthcare Informatization

Traditional EHR systems face challenges such as severe data silos, high response latency, poor cross-institutional interoperability, and difficulty meeting real-time clinical decision-making needs. Healthcare professionals need to quickly access key information like patient medical records, medications, and allergy histories—latency can affect diagnosis and treatment efficiency as well as patient safety. The UniHealth EHR project was born from this context, with low latency and high availability as core goals from its initial design.

3

Section 03

Technical Architecture Overview: Microservices and Event-Driven Design

UniHealth EHR uses a microservices architecture, with core components including:

  1. Edge FHIR Gateway: Based on FastAPI, it handles request reception, authentication, permission verification, and routing, supporting multi-tenant data isolation;
  2. Event-Driven Pipeline: Using Apache Kafka as the message middleware, it implements asynchronous event processing (data synchronization, cache updates, audit logs, etc.) to improve throughput and fault tolerance;
  3. Data Persistence Layer: PostgreSQL serves as the main database for storing core medical data, while Redis acts as a distributed cache layer to reduce database pressure. The system is based on FHIR R5 standards to ensure global compatibility.
4

Section 04

Core Functions and FHIR Standard API Design

The system provides FHIR-compliant RESTful APIs, with core interfaces including:

  • Patient summary query: GET /fhir/r5/Patient/{id}/summary, supporting the encounters parameter to specify the number of recent visit records;
  • Observation index query: /fhir/r5/Patient/{id}/observations;
  • Medication request query: /fhir/r5/Patient/{id}/medication-requests; All interfaces require specifying the medical institution via the X-Facility-Id header to achieve multi-tenant data isolation and permission verification.
5

Section 05

Performance Optimization and Caching Strategy: Achieving P95 Latency <50ms

To achieve the goal of P95 latency below 50 milliseconds, the system optimizes from multiple levels:

  1. Database Optimization: Reasonable indexing, query optimization, and partitioning strategies;
  2. Redis Caching: Caching frequently accessed data, returning directly from the cache after the first load;
  3. Intelligent Cache Invalidation: Triggering cache invalidation via the event pipeline when data changes to ensure data consistency.
6

Section 06

Deployment, Operation, and Privacy & Security Compliance

In terms of deployment, the project uses Docker Compose for containerized orchestration, including Kafka, Redis, PostgreSQL, and application services to ensure environment consistency; load testing is performed via the k6 framework, and CI/CD pipelines are set up to ensure code quality and stability. For security: data transmission is TLS-encrypted, storage is encrypted, access control is based on role and institution fine-grained authorization; emergency access mode is supported and audit logs are recorded to balance privacy and clinical needs.

7

Section 07

Future Outlook: AI Integration and Intelligent Clinical Decision Support

UniHealth EHR Phase 1 focuses on core infrastructure construction; in subsequent phases, LLM and multimodal models will be introduced, and through the MNI ENGINE, functions such as intelligent diagnosis assistance, personalized treatment recommendations, and automated document generation will be implemented, transforming from a data recording tool to an intelligent clinical decision support platform.