medOS Migration
Internal scope — legacy HIS data migration toolkit and source-system adapters. Not a public-facing API surface.
medOS Migration is the onboarding engine for hospitals moving off another HIS product. It owns the full inbound pipeline — discovering a source schema, extracting and transforming records, deduplicating and validating them, bulk-loading into medOS, then reconciling source against target to prove the migration was complete. It is built as a NestJS/Moleculer service (ever-api-migration) and runs as an internal job runner rather than a live request-serving API.
Responsibilities
- Schema discovery — introspect a source database, list tables and columns, and propose field mappings.
- Extraction & transformation — pull source rows through dialect-aware adapters and reshape them into medOS entity shapes.
- Deduplication & validation — collapse duplicate patient/encounter records and validate transformed data before load.
- Bulk load — write migrated records into medOS, with idempotent re-runs.
- Reconciliation — compare source and target row counts and checksums; surface gaps.
- Dead-letter handling — capture records that fail any stage into a dead-letter queue for human review and re-drive.
- EHR-to-EHR sync — adapter-based synchronization from named source EHR systems.
- Country & tenant awareness — apply per-country profiles (names, dates, encoding, validators) and keep migrations tenant-scoped.
Major modules
| Module | Purpose |
|---|---|
migrationJob | Migration job lifecycle — create, run, track, resume |
schemaDiscovery | Source-schema introspection and mapping proposals |
extraction | Source data extraction through dialect adapters |
transform | Data transformation engine (source shape to medOS shape) |
load | Bulk loader into medOS entities |
dedup | Record deduplication |
reconcile | Source vs. target reconciliation and gap reporting |
validation | Pre-load data validators and report generation |
ehrSync | EHR-to-EHR synchronization |
dlq | Dead-letter queue for failed records |
fieldReview / mappingStudio | Human-in-the-loop field mapping and review |
country | Per-country profile resolution |
tenant | Multi-tenant scoping |
capability | Adapter / connector capability reporting |
airbyte | Airbyte-style connector integration |
dbt | dbt-style transformation hooks |
Source adapters
The service resolves a source system through an adapter framework. Built-in adapters cover both raw SQL sources and named EHR products.
Database sources
Dialect presets cover Oracle, MySQL, PostgreSQL and MSSQL — including per-version pagination and connection-style quirks.
Source EHR products
A shared adapter framework wraps named source EHR systems behind one extraction contract.
Country profiles
Per-country profiles handle name formats, date conventions, character encoding and field validators.
Pipeline flow
source DB / EHR / file
│
▼
┌─────────────────┐
│ schemaDiscovery │ introspect + propose mappings
└────────┬────────┘
▼
┌─────────────────┐
│ extraction │ dialect / EHR adapter
└────────┬────────┘
▼
┌─────────────────┐ ┌──────────┐
│ transform │───▶│ dedup │
└────────┬────────┘ └────┬─────┘
▼ ▼
┌─────────────────┐ ┌──────────┐
│ validation │───▶│ dlq │ failed records
└────────┬────────┘ └──────────┘
▼
┌─────────────────┐
│ load │ bulk write into medOS
└────────┬────────┘
▼
┌─────────────────┐
│ reconcile │ source ⇄ target counts/checksums
└─────────────────┘
Each stage is driven by a migrationJob, so a run can be re-driven from the dead-letter queue without re-extracting clean records.
Integration notes
- The service consumes source databases (SQL dialects above), flat files (file adapter), and named EHR systems through the adapter framework.
- It writes into medOS via the standard backend write paths; it does not write to Supabase read-model tables directly.
- Country behavior is data-driven via the country registry and per-country profiles — adding a region is a profile, not new service code.
- A synthetic-data generator is available for building test corpora per country.
Related catalog items
SYS-10— Legacy Data Migration ToolkitSYS-9— Tenant Provisioning