Pascal Pfiffner edited this page Jan 27, 2016 · 12 revisions

Swift-SMART is a full client implementation of the 🔥FHIR specification written in Swift.

It contains classes representing all default profiles (i.e. data models) and provides an implementation of Client and Server objects to communicate with a FHIR server. Authorization with servers protected by OAuth2 is supported out of the box.

Other Resources

QuickStart

To get you off the ground quickly, here's how you instantiate a Client handle, have the user login and select a patient, then fetch that patient's MedicationOrder resources:

import SMART

// create the client
let smart = Client(
    baseURL: "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 {
                let meds = bundle?.entry?
                    .filter() { return $0.resource is MedicationOrder }
                    .map() { return $0.resource as! MedicationOrder }
                
                // now `meds` holds all known patient prescriptions
            }
        }
    }
}
Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.