Back to Search


Author: Houssein Khafaja - 7/9/2018 1:21:37 PM
 1 Like    0 Dislikes  

DHDR-FHIR Android Sample

This is an Android application prototype that makes use of the HL7 HAPI FHIR 3.3.0 Library to connect to Innovation Lab's Digital Health Drug Repository (DHDR). It also connects to Innovation Lab's Provincial Client Registry (PCR) v3.

Table of Contents

Android Features Used

These are the features that were used to put together this project:

  • Multiple Activities
    • Using intents and extending the Parcelable interface to move data
  • List views and custom listview adapters (and with custom XML layouts)
  • Most layouts use the ConstraintLayout (Potrait and Landscape)
  • Extending the AsyncTask class to execute network operations (DHDR and PCR)
    • Uses the ViewHolder pattern for better UI performance
    • Uses built-in HTTP libraries in Android Java to query PCR
  • Displaying Custom Dialogs (popups) for showing progress bars and error messages
  • Uses DatePickerDialog so that users can enter dates as query filters. Date manipulation with Date, SimpleDateFormat and Calendar objects
  • Uses SQLiteOpenHelper to implement a basic local database.

Getting Started

These instructions will get you a copy of the project up and running on your Android Studio's emulator or on your real Android device.


- Android Studio (v3.x)
- Intel systems may be required to install HAXM
- This Git Android Project
- HAPI FHIR Android Library, plus base and structures libraries (included in git project)
- Joda Time Library (included in git project)

Setting up the Dev Environment

Downloading and installing Android Studio

First, download the latest version of Android Studio. The installation process is straightforward, however if you run into any issues, follow the official installation instructions provided.

Importing the DHDR-FHIR project into Android Studio

After cloning or downloading this Git project, go to:

  1. File -> Open in Android Studio's menu bar.
  2. Find and select the project that you just cloned/downloaded and click "OK".

Setting up your debugging environment

Once you have installed Android Studio and you've imported the Android Studio project, you will then need to decide on how you plan on running/debugging your application. There are two ways of doing this:

  1. Run the app on your real Android device over USB.
  2. Run the app in an emulator. This can either be a third-party emulator you find online or it can be Android Studio's built-in emulator.

Note: If you're using an emulator on Android Studio, you first need to create a virtual device image via the AVD manager.

Intel Systems - Installing HAXM

If you need or want Intel's hardware acceleration software to speed up your Android emulation on Android Studio, then follow these instructions. This is highly recommended for developers running Intel CPUs.

Important Notes For Developers

  • Ensure that you have the proper permissions given to your applicaiton by including the following code in your Android Manifest .xml. If you do not include these permissions, your app wont be able to execute network operations.
  • E.G:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="" package="">

    <uses-permission android:name="android.permission.INTERNET"></uses-permission>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
  • You also need to include a few more objects in your build.gradle (Module:app) android {...} block
  • You might need to change "JavaVersion.VERSION_1_8" to your version of Java
android {
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8


Houssein Khafaja - eHealth Ontario co-op - eHealth Ontario


This project is licensed under the MIT License - see the file for details