Skip to content

[OpenSRP] Migrate Engine to KMP#2949

Closed
FikriMilano wants to merge 3 commits intoohs-foundation:masterfrom
opensrp:2948-migrate-fhir-engine-to-kmp
Closed

[OpenSRP] Migrate Engine to KMP#2949
FikriMilano wants to merge 3 commits intoohs-foundation:masterfrom
opensrp:2948-migrate-fhir-engine-to-kmp

Conversation

@FikriMilano
Copy link
Copy Markdown
Member

@FikriMilano FikriMilano commented Mar 12, 2026

IMPORTANT: All PRs must be linked to an issue (except for extremely trivial and straightforward changes).

Fixes #2948

Description
Introduces engine-kmp, a new Kotlin Multiplatform module that ports the FHIR Engine to run on Android, iOS, and Desktop, JS/Wasm.

The migration replaces JVM-only dependencies (HAPI FHIR, Room Android, java.time, java.util.UUID, Timber, Gson) with multiplatform equivalents (kotlin-fhir, Room KMP, kotlinx-datetime, kotlin.uuid, Kermit, kotlinx-serialization).

What's done:

  1. Create engine-kmp module

    • KMP module targeting Android, iOS x3, Desktop/JVM
    • Sample app proving Room KMP + Compose Multiplatform work together
    • Build config with platform-specific source sets
  2. Core data model & interfaces

    • FhirEngine.kt — main interface with 12 suspend methods + search/count extensions
    • Database.kt — internal DB interface
    • LocalChange.kt, FhirEngineConfiguration.kt, DateProvider.kt, ContentTypes.kt
    • MoreResources.kt — resource type registry replacing JVM reflection (Class.forName() to KClass)
    • Logging.kt — Kermit-based logging facade replacing Timber
  3. Indexing

    • 9 index entity data classes (StringIndex, DateIndex, DateTimeIndex, NumberIndex, QuantityIndex, TokenIndex, ReferenceIndex, UriIndex, PositionIndex)
    • ResourceIndices container with Builder pattern
    • ResourceIndexer — indexes FHIR resources using kotlin-fhir's FhirPathEngine.forR4()

Alternative(s) considered
Have you considered any alternatives? And if so, why have you chosen the approach in this PR?

Type
Migration

Screenshots (if applicable)

Checklist

  • I have read and acknowledged the Code of conduct.
  • I have read the Contributing page.
  • I have signed the Google Individual CLA, or I am covered by my company's Corporate CLA.
  • I have discussed my proposed solution with code owners in the linked issue(s) and we have agreed upon the general approach.
  • I have run ./gradlew spotlessApply and ./gradlew spotlessCheck to check my code follows the style guide of this project.
  • I have run ./gradlew check and ./gradlew connectedCheck to test my changes locally.
  • I have built and run the demo app(s) to verify my change fixes the issue and/or does not break the demo app(s).

@FikriMilano FikriMilano self-assigned this Mar 12, 2026
@FikriMilano FikriMilano requested a review from a team as a code owner March 12, 2026 08:43
@FikriMilano FikriMilano requested review from ktarasenko and removed request for a team March 12, 2026 08:43
@FikriMilano FikriMilano changed the title Migrate fhir engine to kmp Migrate Engine to KMP Mar 12, 2026
@ellykits
Copy link
Copy Markdown
Contributor

@FikriMilano Can you recreate this via your own fork instead of OpenSRP's?

@FikriMilano
Copy link
Copy Markdown
Member Author

moved to personal fork
#2952

@github-project-automation github-project-automation Bot moved this from New to Complete in Android FHIR SDK Mar 16, 2026
@FikriMilano FikriMilano changed the title Migrate Engine to KMP [OpenSRP] Migrate Engine to KMP Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate FHIR Engine to Kotlin Multiplatform (KMP)

2 participants