An iOS sample app using SMART on FHIR via our iOS SMART on FHIR framework.
-
Checkout the source code:
git clone --recursive https://github.com/smart-on-fhir/SoF-Demo.git
-
Open the project file
SoF-Demo.xcodeproj
in Xcode 8+. -
Select an iPhone simulator and press Run.
The master
branch is currently on Swift 4.2 and the R4 (4.0.0-a53ec6ee1b
) version of FHIR (version 4.0.0
of the SMART framework).
Check the develop
branch for bleeding edge updates, if any, and the tags for older releases.
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:
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.
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'sauthorize()
method - Once a patient has been selected, loads all resources of the selected patient with
loadResources()
(~ line 179); this method performs a FHIRsearch
operation for all resource types that have been defined inEndpointProvider
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.
These are handed resources to either show them in a list or display their JSON representation in full.