-
Notifications
You must be signed in to change notification settings - Fork 47
Home
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.
- Technical Documentation of classes, properties and methods
- Medication List sample app
- SMART on FHIR API documentation
- FHIR documentation
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
}
}
}
}