HAPI FHIR Migration - Hybrid Architecture

VerifiedSafe

Complete guide for migrating to a hybrid architecture using HAPI FHIR as the source of truth for Patient/Practitioner demographic data, with local GDPR storage in PostgreSQL.

Sby Skills Guide Bot
DevelopmentAdvanced
3/11/2026
Claude CodeCursorCodex
#fhir#hapi-fhir#healthcare#data-migration#interoperability

Recommended for

Automated summary

Walks through migrating the core-africare-identity service to a hybrid architecture where HAPI FHIR becomes the source of truth for Patient/Practitioner resources and PostgreSQL keeps GDPR metadata.

Strengths

  • Breaks the migration into six ordered phases (infrastructure, client, mappers, GDPR models, service orchestration, legacy removal) with explicit Poetry commands and file paths.
  • States a clear target architecture splitting responsibilities across HAPI FHIR, PostgreSQL and Keycloak.
  • Lists the modules to build (async HTTP client, config, identifiers, typed exceptions) plus the HAPI_FHIR_BASE_URL and timeout environment variables.
  • Includes a unit-test step for the mappers before wiring the service layer.

Limitations

  • Tightly bound to the core-africare-identity repository: file names, app/ paths and make migrate commands are project-specific.
  • Implementation details are delegated to companion files (CLIENT-SETUP.md, MAPPERS.md, GDPR-MODELS.md, SERVICE-LAYER.md) that are not part of the SKILL.md.
  • Does not cover backfilling existing records or a rollback plan beyond flagging legacy tables as deprecated.
When to use it

Use it when actually implementing the hybrid FHIR architecture, writing Patient/Practitioner mappers, or wiring an HTTP client to HAPI FHIR in this Python service.

When not to use it

Skip it for a different FHIR server, a non-Python/Poetry stack, or a generic FHIR resource-modelling question with no migration involved.

Security analysis

Safe
Quality score82/100

The skill only uses Read, Glob, Grep, Edit, Write, and restricted Bash commands for poetry and git. The instructions contain no destructive, exfiltrating, or obfuscated actions. The referenced bash snippets (poetry add, mkdir, touch, make) are standard development operations and do not pose meaningful security risk within the declared tool restrictions.

No concerns found

How this analysis is made

Examples

Créer le client FHIR async
Implémente la Phase 2 de la migration : crée app/infrastructure/fhir/config.py, identifiers.py, exceptions.py et client.py avec un client HTTP async vers HAPI FHIR (httpx, timeout configurable via HAPI_FHIR_TIMEOUT).
Mapper Patient vers FHIR
Écris app/infrastructure/fhir/mappers/patient_mapper.py pour convertir un PatientCreate Pydantic en ressource FHIR Patient, et ajoute les tests unitaires dans tests/unit/test_fhir_mappers.py.
Orchestrer service + GDPR
Modifie app/services/patient_service.py pour orchestrer HAPI FHIR et les tables PatientGdprMetadata, puis génère la migration Alembic des modèles GDPR.

name: fhir-migration description: Migration du stockage Patient/Practitioner vers HAPI FHIR. Utiliser quand l'utilisateur demande d'implémenter l'architecture hybride FHIR, créer des mappers FHIR, ou intégrer avec HAPI FHIR. allowed-tools: Read, Glob, Grep, Edit, Write, Bash(poetry:), Bash(git:)

Migration HAPI FHIR - core-africare-identity

Ce skill guide la migration du service core-africare-identity vers une architecture hybride avec HAPI FHIR comme source de vérité pour les données démographiques.

Architecture Cible

Client → API (Pydantic) → Service Layer → HAPI FHIR (Patient/Practitioner)
                               ↓
                      PostgreSQL (métadonnées GDPR)
  • HAPI FHIR: Source de vérité pour données démographiques (Patient, Practitioner)
  • PostgreSQL: Métadonnées GDPR locales (soft_deleted_at, correlation_hash, etc.)
  • Keycloak: Authentification et gestion des utilisateurs

Composants à Implémenter

1. Infrastructure FHIR

| Fichier | Description | |---------|-------------| | app/infrastructure/fhir/__init__.py | Exports du module | | app/infrastructure/fhir/client.py | Client HTTP async pour HAPI FHIR | | app/infrastructure/fhir/config.py | Configuration FHIR (URL, timeout) | | app/infrastructure/fhir/identifiers.py | Systèmes d'identifiants FHIR | | app/infrastructure/fhir/exceptions.py | Exceptions FHIR typées |

Voir CLIENT-SETUP.md pour les détails d'implémentation.

2. Mappers Pydantic ↔ FHIR

| Fichier | Description | |---------|-------------| | app/infrastructure/fhir/mappers/__init__.py | Exports des mappers | | app/infrastructure/fhir/mappers/patient_mapper.py | PatientCreate ↔ FHIR Patient | | app/infrastructure/fhir/mappers/professional_mapper.py | ProfessionalCreate ↔ FHIR Practitioner |

Voir MAPPERS.md pour les templates de mappers.

3. Modèles GDPR Locaux

| Fichier | Description | |---------|-------------| | app/models/gdpr_metadata.py | PatientGdprMetadata, ProfessionalGdprMetadata |

Voir GDPR-MODELS.md pour les modèles SQLAlchemy.

4. Service Layer Orchestration

Modifier les services existants pour orchestrer HAPI FHIR + PostgreSQL.

Voir SERVICE-LAYER.md pour le pattern d'orchestration.

Workflow de Migration

Phase 1: Infrastructure (Prérequis)

# 1. Ajouter dépendances
poetry add "fhir.resources>=7.0.0" "httpx>=0.27.0"

# 2. Créer structure répertoires
mkdir -p app/infrastructure/fhir/mappers
touch app/infrastructure/fhir/__init__.py
touch app/infrastructure/fhir/mappers/__init__.py

Phase 2: Client FHIR

  1. Créer app/infrastructure/fhir/config.py - Configuration
  2. Créer app/infrastructure/fhir/identifiers.py - Systèmes d'identifiants
  3. Créer app/infrastructure/fhir/exceptions.py - Exceptions
  4. Créer app/infrastructure/fhir/client.py - Client HTTP async

Phase 3: Mappers

  1. Créer app/infrastructure/fhir/mappers/patient_mapper.py
  2. Créer app/infrastructure/fhir/mappers/professional_mapper.py
  3. Ajouter tests dans tests/unit/test_fhir_mappers.py

Phase 4: Modèles GDPR

  1. Créer app/models/gdpr_metadata.py avec PatientGdprMetadata
  2. Créer migration Alembic: make migrate MESSAGE="Add GDPR metadata tables"
  3. Appliquer migration: make migrate-up

Phase 5: Orchestration Services

  1. Modifier app/services/patient_service.py pour utiliser FHIR + PostgreSQL
  2. Modifier app/services/professional_service.py
  3. Mettre à jour les endpoints API

Phase 6: Suppression Legacy

  1. Marquer tables patients/professionals comme deprecated
  2. Créer migration de suppression
  3. Nettoyer les imports

Variables d'Environnement

# HAPI FHIR
HAPI_FHIR_BASE_URL=http://localhost:8090/fhir
HAPI_FHIR_TIMEOUT=30

# Optionnel: Auth FHIR
HAPI_FHIR_AUTH_TOKEN=

Tests

# Tests unitaires mappers
poetry run pytest tests/unit/test_fhir_mappers.py -v

# Tests intégration FHIR (nécessite HAPI FHIR local)
make test-services-up
poetry run pytest tests/integration/test_fhir_client.py -v
make test-services-down

Ressources

Checklist Migration

  • [ ] Dépendances installées (fhir.resources, httpx)
  • [ ] Client FHIR créé et testé
  • [ ] Mappers Patient et Professional créés
  • [ ] Modèles GDPR créés avec migration
  • [ ] Services refactorisés pour orchestration
  • [ ] Tests unitaires et intégration passent
  • [ ] Tables legacy supprimées
  • [ ] Documentation mise à jour

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/hapi-fhir-migration-hybrid-architecture-mmlj2nxb/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/hapi-fhir-migration-hybrid-architecture-mmlj2nxb' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/hapi-fhir-migration-hybrid-architecture-mmlj2nxb/download' --output '.skill-downloads/hapi-fhir-migration-hybrid-architecture-mmlj2nxb/SKILL.md.part' && mv '.skill-downloads/hapi-fhir-migration-hybrid-architecture-mmlj2nxb/SKILL.md.part' '.skill-downloads/hapi-fhir-migration-hybrid-architecture-mmlj2nxb/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

Tools declared by the author (check availability in your agent): Read, Glob, Grep, Edit, Write, Bash(poetry:*), Bash(git:*)

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/hapi-fhir-migration-hybrid-architecture-mmlj2nxb/SKILL.md' && test -s '.skill-downloads/hapi-fhir-migration-hybrid-architecture-mmlj2nxb/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/fhir-migration' && cp -R '.skill-downloads/hapi-fhir-migration-hybrid-architecture-mmlj2nxb' '.claude/skills/fhir-migration'

Cursor
test -f '.skill-downloads/hapi-fhir-migration-hybrid-architecture-mmlj2nxb/SKILL.md' && test -s '.skill-downloads/hapi-fhir-migration-hybrid-architecture-mmlj2nxb/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/fhir-migration' && cp -R '.skill-downloads/hapi-fhir-migration-hybrid-architecture-mmlj2nxb' '.cursor/skills/fhir-migration'

Codex
test -f '.skill-downloads/hapi-fhir-migration-hybrid-architecture-mmlj2nxb/SKILL.md' && test -s '.skill-downloads/hapi-fhir-migration-hybrid-architecture-mmlj2nxb/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/fhir-migration' && cp -R '.skill-downloads/hapi-fhir-migration-hybrid-architecture-mmlj2nxb' '.agents/skills/fhir-migration'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/hapi-fhir-migration-hybrid-architecture-mmlj2nxb'

openskills read 'hapi-fhir-migration-hybrid-architecture-mmlj2nxb'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/hapi-fhir-migration-hybrid-architecture-mmlj2nxb/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills