-
Notifications
You must be signed in to change notification settings - Fork 47
Home
Pascal Pfiffner edited this page Apr 2, 2015
·
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
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 MedicationPrescription resources:
import SMART
// create the client
let smart = Client(
baseURL: "https://fhir-api-dstu2.smarthealthit.org",
settings: [
"client_id": "my_mobile_app",
"redirect": "smartapp://callback", // must be registered
]
)
// authorize, then search for prescriptions
smart.authorize() { patient, error in
if nil != error || nil == patient {
// report error
}
else {
MedicationPrescription.search(["patient": patient.id])
.perform(smart.server) { bundle, error in
if nil != error {
// report error
}
else {
var meds = [MedicationPrescription]()
if let entries = bundle?.entry {
for entry in entries {
if let med = entry.resource as? MedicationPrescription {
meds.append(med)
}
}
}
// now `meds` holds all known patient prescriptions
}
}
}
}