Skip to main content

Migration & Backward Compatibility

Execution-layer artifact. Companion to ROADMAP.md. Defines backward compatibility rules across slices and migration requirements.

1. Overarching Rules

  1. No breaking changes without a migration window. Every breaking change ships with a migration script, a deprecation period (minimum 1 sprint), and a rollback plan.
  2. Additive changes are always safe. New optional fields, new endpoints, new events, new FHIR search parameters — these never break existing consumers.
  3. FHIR profiles evolve per FHIR versioning rules. New required elements require a new profile version. Existing profiles remain supported.
  4. Offline clients may be behind. Desktop Electron and mobile clients may not update immediately. Server APIs must support N-1 client versions for at least 2 sprints after a new version ships.
  5. Tenant data is never lost. Schema migrations are non-destructive. Columns are deprecated (nullable + hidden), never dropped, for at least 2 milestones.

2. Per-Slice Backward-Compatibility Requirements

S0 → S1 (Platform Foundation → Core Clinical)

ArtifactCompat requirement
Tenant APIS1 adds clinical tenant configuration fields (additive; S0 clients unaffected)
FHIR GatewayS1 adds clinical resource routes (additive; existing /fhir/R4 routes stable)
Event envelopeS1 publishes new clinical event types (additive; existing consumers unaffected)
Desktop SQLiteS1 adds clinical tables to SQLite (additive; S0 tables unchanged)
Sync protocolS1 registers new aggregates for sync (additive; sync protocol unchanged)
AI orchestratorS1 adds clinical prompts (additive; existing prompts unchanged)
Kong routesS1 adds clinical service routes (additive; existing routes stable)
KeycloakS1 adds clinical roles (additive; existing roles unchanged)

Tenant migration: Existing S0 tenants receive S1 capabilities via module licensing activation. No data migration required.

S1 → S2 (Core Clinical → Orders & Diagnostics)

ArtifactCompat requirement
FHIR resourcesS2 adds ServiceRequest, DiagnosticReport (additive; existing Patient, Encounter, etc. unchanged)
Clinical notesS2 may add order-linked note sections (additive optional fields; existing notes unchanged)
Desktop SQLiteS2 adds order/result tables (additive; clinical tables unchanged)
TerminologyS2 deepens code systems (additive data; existing codes unchanged; new codes added)
BillingNew service; no backward compatibility concern
EventsS2 publishes order/result events (additive; existing clinical events unchanged)
Patient chartS2 adds orders/results tabs to chart aggregation (additive; existing tabs unchanged)

Tenant migration: Existing clinics receive orders + billing via module activation. Terminology data seeded incrementally (background job, no downtime).

S2 → S3 (Orders & Diagnostics → Integrated Care)

ArtifactCompat requirement
Orders-CPOES3 adds LIS-specific order routing (additive routing rules; existing order flow unchanged)
ResultsS3 adds LIS-sourced results (same DiagnosticReport format; source field added)
Medication managementS3 adds pharmacy dispensing events (additive; existing prescribing unchanged)
FHIR resourcesS3 adds MedicationDispense (additive; MedicationRequest unchanged)
E-prescribingNew gateway; existing medication workflows unaffected if gateway unavailable
Patient portalNew surface; no backward compatibility concern
Digital communicationNew service; no backward compatibility concern
Desktop SQLiteS3 adds LIS + pharmacy tables (additive)

Tenant migration: Hospitals activate LIS + pharmacy modules. LIS instrument integration requires per-facility configuration (no automated migration). Patient portal requires patient registration and consent opt-in.

S3 → S4 (Integrated Care → Full Platform)

ArtifactCompat requirement
BillingS4 deepens billing with claims + full accounting (additive features; basic billing unchanged)
InsuranceS4 deepens insurance with full claims integration (additive; eligibility checks unchanged)
FHIR resourcesS4 adds ImagingStudy, Claim, ImmunizationRecommendation, CarePlan (additive)
HL7v2New adapter service; no backward compatibility concern for existing FHIR-only workflows
DICOMNew integration; no backward compatibility concern
AI orchestratorS4 adds ONNX local inference (additive capability; cloud AI unchanged)
Population healthNew service; consumes existing clinical data via events (no upstream changes)
Access-policyS4 deepens ABAC (additive policies; existing RBAC unchanged)
Desktop SQLiteS4 adds imaging + billing + pop health tables (additive)

Tenant migration: Hospitals activate PACS, claims, pop health via module licensing. PACS requires DICOM infrastructure (separate deployment step). HL7v2 requires per-partner adapter configuration. Population health computes from existing clinical data (no historical migration needed — computes forward).

S4 → S5 (Full Platform → National Scale)

ArtifactCompat requirement
All APIsS5 hardening: no breaking changes; performance improvements only
Multi-regionNew infrastructure; existing single-region tenants unaffected
Mobile appNew surface; no backward compatibility concern for existing desktop/web users
SMART on FHIRNew capability; existing FHIR gateway endpoints unchanged
FHIR Bulk DataNew export endpoint; existing APIs unchanged
HMISNew reporting layer; consumes existing data (no upstream changes)
White-labelAdditive theming; existing tenants keep current theme unless explicitly changed
DesktopS5 hardening: lazy bundles, a11y improvements (no breaking UX changes)

Tenant migration: Existing tenants may opt into multi-region (requires data migration with scheduled downtime window). Mobile app available as optional client. White-label theming opt-in per tenant admin.


3. FHIR Profile Versioning

RuleDetail
Profile version formatghasi-ehealth-{resource}-v{N} (e.g., ghasi-ehealth-patient-v1)
New optional elementsSame profile version (additive)
New required elementsNew profile version (e.g., v1v2)
Deprecated elementsMarked deprecated in profile; remain in schema for 2 milestones
Removed elementsOnly after 2 milestones of deprecation; requires ADR
Multi-version supportFHIR gateway routes to appropriate handler based on meta.profile

4. Offline Client Versioning

RuleDetail
Desktop Electron updatesAuto-update via Electron updater; user prompted to restart
Forced updateOnly for security-critical patches; user cannot skip
N-1 supportServer APIs support previous client version for 2 sprints
SQLite migrationForward-only; migration scripts run on app startup
Mobile updatesApp store update; forced update for security patches
Sync protocol versioningClient sends protocol version in sync handshake; server adapts response

5. Event Schema Evolution

RuleDetail
Schema formatCloudEvents v1.0 + versioned type field (e.g., ehealth.registration.patient.created.v1)
New event typesSafe to add anytime; no consumer impact
New optional fields in existing eventSafe; consumers must tolerate unknown fields
New required fields in existing eventNew version (e.g., v1v2); dual-publish v1 + v2 during migration window
Removing fieldsNew version; old version published for 2 sprints
Consumer upgradeConsumers must migrate to new version within deprecation window

6. AI Prompt Evolution

RuleDetail
Prompt version format{prompt-id}@{semver} (e.g., clinical-note-assist@1.2.0)
New promptsSafe to add anytime
Prompt content changesNew minor version; A/B testing before full rollout
Prompt schema changesNew major version; old version remains available
Prompt deprecationPer-tenant; admin chooses when to migrate
Prompt regression testingAutomated eval suite runs on every prompt change

7. Database Schema Migration Rules

RuleDetail
Migration toolTypeORM migrations (server) + custom SQLite migrations (desktop)
Migration directionForward-only; no down migrations in production
Column additionsNullable with default; no downtime
Column renamesAdd new column → dual-write → migrate reads → drop old column (3-sprint process)
Table additionsSafe; no downtime
Index additionsCREATE INDEX CONCURRENTLY (no lock)
Data migrationsBackground job; never in transaction with schema change
Rollback planEvery migration has documented rollback procedure (even if "not applicable")