Simple SMART on FHIR / Argonaut iOS sample app that fetches a couple of resources
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
App Update Swift-SMART submodule Mar 14, 2017
SoF-Demo.xcodeproj Small fixes Feb 24, 2017
Swift-SMART @ e251904 Fix Swift 3.2 compile error Mar 16, 2018
.gitignore Merge branch 'master' into feature/swift-2.0 Jul 28, 2015
.gitmodules Submodule swap Mar 26, 2015
Endpoints.swift Updates for STU3 Feb 22, 2017
README.md

README.md

SMART on FHIR

An iOS sample app using SMART on FHIR via our iOS SMART on FHIR framework.

Installation

  1. Checkout the source code:

    git clone --recursive https://github.com/smart-on-fhir/SoF-Demo.git
  2. Open the project file SoF-Demo.xcodeproj in Xcode 8+.

  3. Select an iPhone simulator and press Run.

The master branch is currently on Swift 3.0 and the STU-3 (3.0.0.11832) version of FHIR (version 3.0.0 of the SMART framework).
Check the develop branch for bleeding edge updates, if any, and the tags for older releases.

What's Happening?

This app allows you to specify to which FHIR server you want to connect (bookmark icon top right) and will then let you log in. During login you'll be selecting a patient, after which a handful of resource types belonging to this very patient will be downloaded.

There are two places where custom code performs interesting tasks:

App Delegate

Sets up an EndpointProvider instance that defines which FHIR endpoints (servers) will be available in the app. Right now these are hardcoded, starting at line 25 in AppDelegate.swift.

The app delegate also listens to OAuth2 callbacks in application(_:open:options:) since we'll be using an embedded Safari View Controller to perform the OAuth dance.

Master View Controller

This class is totally overblown and performs these things, aside from setting up the UI:

  • Choose the endpoint with selectEndpoint() (~ line 101), which displays a list of available endpoints as configured in the app delegate
  • Login and select a patient with selectPatient() (~ line 139), which works once an endpoint has been selected and hands off to the SMART client's authorize() method
  • Once a patient has been selected, loads all resources of the selected patient with loadResources() (~ line 179); this method performs a FHIR search operation for all resource types that have been defined in EndpointProvider

In the end, you'll see a list of FHIR resource types and the number of resources available to this patient. The app will only load the first page of search results, so the number of resources may be capped at 50.

NOTE that not all servers support searching for patients without specifying search parameters, hence the native patient list may be empty.

List and Detail View Controller

These are handed resources to either show them in a list or display their JSON representation in full.