22
33## Overview
44
5- This implementation demonstrates how to share core FML (FHIR Mapping Language) business logic between Kotlin/JVM/Android and Node.js/JavaScript platforms using Kotlin Multiplatform.
5+ This implementation demonstrates how to share core FML (FHIR Mapping Language) business logic between Kotlin/JVM/Android and Node.js/JavaScript platforms using Kotlin Multiplatform with ** kotlin-fhirpath ** for cross-platform FHIRPath evaluation .
66
77## Architecture
88
@@ -15,13 +15,13 @@ This implementation demonstrates how to share core FML (FHIR Mapping Language) b
1515
16162 . ** StructureMap Executor** (` src/commonMain/kotlin/org/litlfred/fmlrunner/executor/ ` )
1717 - Executes StructureMaps on input data
18- - Uses platform-specific FHIRPath engines
18+ - Uses ** kotlin-fhirpath ** for cross-platform FHIRPath evaluation
1919 - Provides validation and transformation capabilities
2020
21- 3 . ** FHIRPath Engine** (` src/commonMain/ kotlin/org/litlfred/fmlrunner/ fhirpath/ ` )
22- - Cross-platform interface for FHIRPath evaluation
23- - Basic implementation for JS
24- - HAPI FHIR integration for JVM/Android (when available)
21+ 3 . ** FHIRPath Engine** (kotlin- fhirpath library )
22+ - Cross-platform FHIRPath evaluation using kotlin-fhirpath
23+ - Replaces Node.js fhirpath dependency entirely
24+ - Consistent FHIRPath behavior across JVM and JavaScript platforms
2525
26264 . ** Core Types** (` src/commonMain/kotlin/org/litlfred/fmlrunner/types/ ` )
2727 - Shared FHIR resource definitions
@@ -31,14 +31,25 @@ This implementation demonstrates how to share core FML (FHIR Mapping Language) b
3131### Platform-Specific Implementations
3232
3333#### JVM/Android
34- - Uses HAPI FHIR libraries for full FHIRPath support
34+ - Uses kotlin-fhirpath for full FHIRPath support
3535- Access to complete FHIR validation capabilities
36- - Can leverage Java ecosystem libraries
36+ - Can leverage additional Java ecosystem libraries
3737
3838#### JavaScript/Node.js
3939- Compiles to JavaScript modules
40- - Uses basic FHIRPath implementation
41- - Integrates with existing TypeScript codebase
40+ - Uses kotlin-fhirpath compiled to JavaScript
41+ - No dependency on Node.js fhirpath library
42+
43+ ## Dependencies
44+
45+ ### Kotlin Multiplatform
46+ - ** kotlin-fhirpath** : ` com.github.jingtang10:kotlin-fhirpath:0.1.0 `
47+ - ** kotlinx.serialization** : For cross-platform data serialization
48+ - ** kotlinx.datetime** : For date/time handling
49+
50+ ### Removed Dependencies
51+ - ❌ Node.js ` fhirpath ` library (replaced by kotlin-fhirpath)
52+ - ❌ Custom FHIRPath implementations
4253
4354## Usage
4455
@@ -59,7 +70,7 @@ const result = runner.compileFml(`
5970 }
6071` );
6172
62- // Execute transformation
73+ // Execute transformation with kotlin-fhirpath
6374const execResult = runner .executeStructureMap (
6475 " http://example.org/StructureMap/Patient" ,
6576 ' {"name": "John Doe", "active": true}'
@@ -83,7 +94,7 @@ val result = runner.compileFml("""
8394 }
8495""" )
8596
86- // Execute transformation
97+ // Execute transformation with kotlin-fhirpath
8798val execResult = runner.executeStructureMap(
8899 " http://example.org/StructureMap/Patient" ,
89100 """ {"name": "John Doe", "active": true}"""
@@ -133,39 +144,49 @@ The existing TypeScript FmlRunner has been updated to use the Kotlin core via a
133144 - Maintains TypeScript services for extended functionality
134145 - Provides backward compatibility
135146
136- ## Future Enhancements
147+ ## FHIRPath Integration
137148
138- 1 . ** Full HAPI FHIR Integration**
139- - Add complete HAPI FHIR dependencies
140- - Implement advanced FHIRPath evaluation
141- - Support complex FHIR resource validation
149+ ### kotlin-fhirpath Benefits
150+ - ** Cross-Platform** : Single FHIRPath implementation for all platforms
151+ - ** Consistent** : Same FHIRPath behavior on JVM and JavaScript
152+ - ** Maintained** : Official kotlin-fhir ecosystem library
153+ - ** Performance** : Optimized for each target platform
154+
155+ ### Migration from Node.js fhirpath
156+ - ✅ Removed ` fhirpath ` dependency from package.json
157+ - ✅ Updated imports to use kotlin-fhirpath
158+ - ✅ Updated TypeScript files to indicate Kotlin core usage
159+ - ✅ Consistent FHIRPath evaluation across platforms
160+
161+ ## Future Enhancements
142162
143- 2 . ** JavaScript FHIRPath Engine**
144- - Integrate with existing Node.js fhirpath library
145- - Provide feature parity between platforms
163+ 1 . ** Full kotlin-fhir Integration**
164+ - Add complete kotlin-fhir dependencies
165+ - Implement advanced FHIR resource validation
166+ - Support complex FHIR operations
146167
147- 3 . ** Advanced StructureMap Features**
168+ 2 . ** Advanced StructureMap Features**
148169 - Support for dependent rules
149170 - Complex transformation functions
150171 - Nested group execution
151172
152- 4 . ** Performance Optimization**
173+ 3 . ** Performance Optimization**
153174 - Compilation caching
154175 - Execution optimization
155176 - Memory management improvements
156177
157178## Benefits
158179
159- 1 . ** Code Reuse** : Single implementation of core logic
160- 2 . ** Consistency** : Same behavior across platforms
180+ 1 . ** Code Reuse** : Single implementation of core logic using kotlin-fhirpath
181+ 2 . ** Consistency** : Same FHIRPath behavior across platforms
1611823 . ** Maintainability** : Single source of truth for business logic
1621834 . ** Type Safety** : Shared type definitions
163- 5 . ** Testing ** : Common test suite for all platforms
184+ 5 . ** No Node.js Dependencies ** : Fully self-contained Kotlin implementation
164185
165186## Examples
166187
167188See ` src/commonTest/kotlin/org/litlfred/fmlrunner/FmlRunnerTest.kt ` for comprehensive examples of:
168189- FML compilation
169- - StructureMap execution
190+ - StructureMap execution with kotlin-fhirpath
170191- Error handling
171192- Cross-platform compatibility testing
0 commit comments