Getting Started
This page describes how to configure an Android Studio project to use the FHIR Engine Library, and simple examples of how to use the library.
This guide is intended for developers who are familiar with basic Android development with Kotlin, and proficient in working with FHIR concepts and resources.
Dependencies
The FHIR Engine Library is available through Google's Maven repository, which should be already configured for Android projects created in Android Studio 3.0 and higher.
Add the following dependency to your module's app-level build.gradle
file, typically app/build.gradle
:
dependencies {
implementation("com.google.android.fhir:engine:0.1.0-beta02")
}
In the same file, add the following APK packaging options:
android {
// ...
packagingOptions {
resources.excludes.addAll(listOf("META-INF/ASL-2.0.txt", "META-INF/LGPL-3.0.txt"))
}
}
The minimum API level supported is 24. The library also requires Android Gradle Plugin version 4.0.0 or later for Java 8+ API desugaring support.
Initialize and get a FHIR Engine
To use a FHIR Engine instance, first call FhirEngineProvider.init()
with a FhirEngineConfiguration
. This must be done only once; we recommend doing this in the onCreate()
function of your Application
class.
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
FhirEngineProvider.init(
FhirEngineConfiguration(
enableEncryptionIfSupported = true,
RECREATE_AT_OPEN
)
)
}
}
When you need to use a FhirEngine
, make sure to call the method FhirEngineProvider.getInstance(Context)
:
val fhirEngine = FhirEngineProvider.getInstance(this)
See FhirApplication in the demo app for a sample implementation.