Skip to content
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.

Usage

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.

Details

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.

  1. Instantiate FHIROperation with the correct operation name: $("everything")
  2. Calling patient.perform(operation:callback:):
    1. Sets the operation's instance property to the resource
    2. Sets the operation's context property to be .Instance
    3. Calls the resource's server perform(operation:callback:) method, which – assuming the server's conformance statement has been grabbed – then:
      1. Retrieves the OperationDefinition resource from the server (unless it has been cached before)
      2. Calls the operation's validateWith(definition:error:) method and on success
      3. Calls the operation's perform(server:callback:) method which:
        1. Creates the correct REST path relative to the server
        2. TODO: Adds input parameters to the request
        3. Calls the server's getJSON(path:callback:) which on success returns a resource in its FHIRServerJSONResponse response.
        4. Instantiates the correct resource class to return with the callback
Clone this wiki locally