Latest 4.0.0
Homepage https://github.com/smart-on-fhir/Swift-SMART
License Apache 2
Platforms ios 11.0, osx 10.13
Authors

SMART

Swift-SMART is a full client implementation of the 🔥FHIR specification for building apps that interact with healthcare data through SMART on FHIR.
Written in Swift 4.2 it is compatible with iOS 11 and macOS 10.13 and newer and requires Xcode 10 or newer.

Versioning

Due to the complications of combining two volatile technologies, here’s an overview of which version numbers use which Swift and FHIR versions.

  • The master branch should always compile and is on (point releases of) these main versions.
  • The develop branch should be on versions corresponding to the latest freezes and may be updated from time to time with the latest and greatest CI build.

See tags/releases.

Version Swift FHIR  
4.0 4.2 4.0.0-a53ec6ee1b R4
3.2 3.2 3.0.0.11832 STU 3
3.0 3.0 3.0.0.11832 STU 3
2.9 3.0 1.6.0.9663 STU 3 Ballot, Sep 2016
2.8 3.0 1.0.2.7202 DSTU 2 (+ technical errata)
2.4 2.2 1.6.0.9663 STU 3 Ballot, Sep 2016
2.3 2.3 1.0.2.7202 DSTU 2 (+ technical errata)
2.2.3 2.2 1.0.2.7202 DSTU 2 (+ technical errata)
2.2 2.0-2.2 1.0.2.7202 DSTU 2 (+ technical errata)
2.1 2.0-2.2 1.0.1.7108 DSTU 2
2.0 2.0-2.2 0.5.0.5149 DSTU 2 Ballot, May 2015
1.0 1.2 0.5.0.5149 DSTU 2 Ballot, May 2015
0.2 1.1 0.5.0.5149 DSTU 2 Ballot, May 2015
0.1 1.0 0.0.81.2382 DSTU 1

Resources

QuickStart

See the programming guide for more code examples and details.

The following is the minimal setup working against our reference implementation.
It is assuming that you don’t have a client_id and on first authentication will register the client with our server, then proceed to retrieve a token.
If you know your client-id you can specify it in the settings dict.
The app must also register the redirect URL scheme so it can be notified when authentication completes.

import SMART

// create the client
let smart = Client(
    baseURL: URL(string: "https://fhir-api-dstu2.smarthealthit.org")!,
    settings: [
        //"client_id": "my_mobile_app",       // if you have one
        "redirect": "smartapp://callback",    // must be registered
    ]
)

// authorize, then search for prescriptions
smart.authorize() { patient, error in
    if nil != error || nil == patient {
        // report error
    }
    else {
        MedicationOrder.search(["patient": patient!.id])
        .perform(smart.server) { bundle, error in
            if nil != error {
                // report error
            }
            else {
                var meds = bundle?.entry?
                    .filter() { return $0.resource is MedicationOrder }
                    .map() { return $0.resource as! MedicationOrder }

                // now `meds` holds all the patient's orders (or is nil)
            }
        }
    }
}

For authorization to work with Safari/SFViewController, you also need to:

  1. register the scheme (such as smartapp in the example here) in your app’s Info.plist and
  2. intercept the callback in your app delegate, like so:
class AppDelegate: UIResponder, UIApplicationDelegate {

    func application(_ app: UIApplication, open url: URL,
        options: [UIApplicationOpenURLOptionsKey: Any] = [:]) -> Bool {

        // "smart" is your SMART `Client` instance
        if smart.awaitingAuthCallback {
            return smart.didRedirect(to: url)
        }
        return false
    }
}

Installation

The suggested approach is to add Swift-SMART as a git submodule to your project.
Find detailed instructions on how this is done on the Installation page.

The framework can also be installed via Carthage and is also available via CocoaPods under the name “SMART”.

License

This work is Apache 2 licensed: NOTICE.txt.
FHIR® is the registered trademark of HL7 and is used with the permission of HL7.

Latest podspec

{
    "name": "SMART",
    "version": "4.0.0",
    "summary": "Swift SMART on FHIR framework for iOS and OS X",
    "description": "Swift SMART on FHIR framework for iOS and OS X.nnSwift-SMART is a full client implementation of the ud83dudd25FHIR specification for building apps thatninteract with healthcare data through [**SMART on FHIR**](http://docs.smarthealthit.org).nnStart with `import SMART` in your source files. Code documentation is available from withinnXcode (ALT + click on symbols) and on [smart-on-fhir.github.io/Swift-SMART/](http://smart-on-fhir.github.io/Swift-SMART/).",
    "homepage": "https://github.com/smart-on-fhir/Swift-SMART",
    "documentation_url": "http://docs.smarthealthit.org/Swift-SMART/",
    "license": "Apache 2",
    "authors": {
        "Pascal Pfiffner": "[email protected]"
    },
    "source": {
        "git": "https://github.com/smart-on-fhir/Swift-SMART.git",
        "tag": "4.0.0",
        "submodules": true
    },
    "prepare_command": "git submodule update --init --recursive",
    "platforms": {
        "ios": "11.0",
        "osx": "10.13"
    },
    "pod_target_xcconfig": {
        "OTHER_SWIFT_FLAGS": "-DNO_MODEL_IMPORT -DNO_MODULE_IMPORT -DNO_KEYCHAIN_IMPORT"
    },
    "source_files": [
        "Sources/Client/*.swift",
        "Swift-FHIR/Sources/Models/*.swift",
        "Swift-FHIR/Sources/Client/DomainResource+Containment.swift",
        "Swift-FHIR/Sources/Client/Element+Extensions.swift",
        "Swift-FHIR/Sources/Client/FHIRBaseRequestHandler.swift",
        "Swift-FHIR/Sources/Client/FHIRMinimalServer.swift",
        "Swift-FHIR/Sources/Client/FHIROpenServer.swift",
        "Swift-FHIR/Sources/Client/FHIROperation.swift",
        "Swift-FHIR/Sources/Client/FHIRSearch.swift",
        "Swift-FHIR/Sources/Client/FHIRServerDataResponse.swift",
        "Swift-FHIR/Sources/Client/FHIRString+Localization.swift",
        "Swift-FHIR/Sources/Client/Patient+SMART.swift",
        "Swift-FHIR/Sources/Client/Reference+Resolving.swift",
        "Swift-FHIR/Sources/Client/Resource+Instantiation.swift",
        "Swift-FHIR/Sources/Client/Resource+Operation.swift",
        "Swift-FHIR/Sources/Client/Resource+REST.swift",
        "Swift-FHIR/Sources/Client/ValueSet+Localization.swift",
        "OAuth2/SwiftKeychain/Keychain/Keychain.swift",
        "OAuth2/Sources/Base/*.swift",
        "OAuth2/Sources/Flows/*.swift"
    ],
    "ios": {
        "source_files": [
            "Sources/iOS/*.swift",
            "OAuth2/Sources/iOS/*.swift"
        ]
    },
    "osx": {
        "source_files": [
            "Sources/macOS/*.swift",
            "OAuth2/Sources/macOS/*.swift"
        ]
    }
}

Pin It on Pinterest

Share This