Skip to main content
WIP EUPL-1.2Healthcare Services

MedBook

Electronic clinical file - Self-hosted FHIR R4 + GDPR for EU clinics and primary care physicians

Status
WIP
License
EUPL-1.2
Category
Healthcare Services
Updated

Project status

Description

MedBook is an electronic health record (EHR) system designed for small to medium-sized clinics, specialist outpatient departments, and primary care physicians in the EU who want to own their patient data without relying on SaaS cloud services. The architecture is based on Clean Architecture 4-layer Spring Boot 3.4 with domain JPA-agnostic, Angular 21 SSR with standalone components and signals, PostgreSQL 16 with encryption (pgcrypto) and complete audit trail via Hibernate Envers. The data model is designed around FHIR R4 (Patient, Practitioner, Observation, Condition, MedicationStatement, AllergyIntolerance, Procedure, DiagnosticReport) with mapping JPA entity ↔ FHIR Resource via HAPI FHIR library, ensuring interoperability with national healthcare systems. Security is first-class: Keycloak SSO with OIDC, RBAC (doctor, nurse, secretary, admin), immutable audit log for every access to patient data (who, what, when, why), configurable session timeout, password policy NIST 800-63B compliant. GDPR consent is managed through a dedicated schema (granular consent by category of data: history, allergies, tests, medication therapy), with revocable flags and right to erasure implemented as anonymization (no hard delete, to avoid breaking referential integrity of prescriptions and scripts). Licensed under EUPL-1.2 for explicit alignment with the EU public sector standard and compatibility with FSE 2.0 Italian, AgID, and eHealth Network directives. Deployed via Docker Compose or systemd unit, targeting a single doctor or cluster of 2-20 concurrent users. The philosophy is "data sovereignty by design": data lives on the customer's VPS, no external analytics, no telemetry, and no CDN for medical bundles.

Key Features

  • Data model FHIR R4 native

    JPA entity mapped to FHIR Resource (Patient, Observation, Condition, MedicationStatement) via HAPI FHIR, export bundle in JSON/XML standard.

  • Complete audit trail with Hibernate Envers.

    Each patient data access tracked (operator, timestamp, action, IP, reason), immutable audit tables, GDPR audit timeline queries.

  • Keycloak SSO with fine-grained RBAC

    OIDC Integration, 4 predefined roles (Doctor/Nurse/Secretary/Admin), configurable permission matrix, role-based session timeout.

  • GDPR Consent Management

    Granular consent for data category, traceable revocation, right to oblivion as anonymization, automatic export of Data Subject Access Request.

  • Frontend Angular 21 Server-Side Rendering

    Standalone components, reactive signals, OnPush change detection, pre-render for public pages (about, login), optimized bundle for LTE.

  • Encryption at rest using pgcrypto

    Sensitive columns (tax ID, history, allergies) encrypted with PGCrypto PGP_SYM_ENCRYPT, master key in KMS or env var hardened.

  • Automated encrypted backups

    Dump encrypted with GPG, configurable retention, Hetzner Storage Box option, guided restore testing in documentation.

  • Deploy a hardened systemd version

    Run with NoNewPrivileges, ProtectSystem=strict, PrivateTmp, no Docker needed, use alternative Docker Compose if preferred.

Angular + Spring Boot on top of a PostgreSQL database hosted in the cloud via AWS or Google Cloud Platform

  • Spring Boot 3.4
  • Java 21
  • Angular 21
  • PostgreSQL 16
  • HAPI FHIR R4
  • Keycloak
  • Hibernate Envers
  • pgcrypto
  • Docker Compose

Use cases

  • Basic medical clinic that wants to digitize patient files without relying on US-based SaaS.
  • Specialized clinic small (2-20 users) with need for FHIR R4 export to external labs and specialists
  • Dentist or physiotherapist clinic that manages patient records and treatment plans with strict GDPR constraints.
  • Researchers who need an open-source EHR for small local clinical studies

Road Map

  1. v0.1.0Scheduled

    Core EHR: Patient, Practitioner, and Audit Information

    • FHIR Patient and Practitioner Model mapped to JPA
    • CRUD endpoint with Keycloak SSO and RBAC base
    • Active Hibernate Envers audit trail on sensitive entities
    • Frontend Angular login and patient dashboard
  2. v0.5.0Scheduled

    Observation and Treatment Plan

    • FHIR Observation, Condition, and Medication Statement
    • Export patient data in various formats through the "/fhir/Patient/
    • PGCrypto encryption on ancestry/allergy columns
    • GDPR Consent - Revoke - Export DSAR Data
  3. v1.0.0Scheduled

    FSE 2.0 IT Integration and Production Deployment

    • National FSE 2.0 Gateway Connector
    • Automated encrypted backups with test restores
    • Complete MkDocs documentation and VPS deployment guide
    • Security audit pre-release + penetration testing (post MVP delay)

Who is it for

  • For Developers - Senior
  • Decision Maker/Founder

Quick start

Start the project locally with four commands, requires Docker and GitHub Desktop is not required but a git client like SourceTree or Visual Studio Code's built-in one will do just fine though.

# Quick start (work-in-progress, repo non ancora pubblicato)
# git clone https://github.com/<tba>/medbook.git
# cd medbook
# cp .env.example .env  # configura DB, Keycloak, KMS
# docker compose up -d  # postgres + keycloak + medbook-backend + medbook-frontend

Contribute to the project

MedBook is open source. Open an issue, propose a pull request or leave a star on GitHub: every contribution, no matter how small, is welcome.

  • ⭐ Leave a star if it's useful
  • 🐛 Report bugs or suggest features via issue
  • 🔧 Send a pull request with fixes or improvements
  • 📣 Share the project if you find it interesting