-
Notifications
You must be signed in to change notification settings - Fork 47
Operations
Pascal Pfiffner edited this page Apr 2, 2015
·
3 revisions
FHIR supports extended operations on the RESTful API.
The Swift framework supports these with the FHIROperation class, which has a typealias to $
for neat semantics.
To simply perform the $everything
operation on an existing Patient resource you would do:
patient.perform($("everything")) { resource, error in
// check error
// `resource` is an instance of the expected profile
}
On success resource
in this case will contain a Bundle with everything the server holds pertaining to the patient.
More complex operations with input parameters to come.
Our Server class has an implementation to support operations by validating them against the server's conformance statement first.
The $everything
example shown above cascades into.
Each step that might fail will result in the callback being called with the respective error message and a nil resource.
- Instantiate FHIROperation with the correct operation name:
$("everything")
- Calling
patient.perform(operation:callback:)
:- Sets the operation's
instance
property to the resource - Sets the operation's
context
property to be .Instance - Calls the resource's server
perform(operation:callback:)
method, which – assuming the server's conformance statement has been grabbed – then:- Retrieves the OperationDefinition resource from the server (unless it has been cached before)
- Calls the operation's
validateWith(definition:error:)
method and on success - Calls the operation's
perform(server:callback:)
method which:- Creates the correct REST path relative to the server
- TODO: Adds input parameters to the request
- Calls the server's
getJSON(path:callback:)
which on success returns a resource in its FHIRServerJSONResponse response. - Instantiates the correct resource class to return with the callback
- Sets the operation's