FHIRSearch

open class FHIRSearch

Instances of this class can perform searches on a server.

TODO: needs a refresh!!

Searches are instantiated from MongoDB-like query constructs, like:

let srch = Patient.search(["address": "Boston", "gender": "male", "given": ["$exact": "Willis"]])

Then srch.perform() will run the following URL query against the server:

"Patient?address=Boston&gender=male&given:exact=Willis"
  • Search must define a resource type to which the search is applied.

    Declaration

    Swift

    open var profileType: Resource.Type?
  • The sorting to request, in FHIR-format (family,-birthdate).

    Declaration

    Swift

    open var sort: String?
  • The number of results to return per page; leave nil to let the server decide.

    Declaration

    Swift

    open var pageCount: Int?
  • Returns true if there are more search results to be fetched.

    Declaration

    Swift

    open var hasMore: Bool
  • Designated initializer.

    Declaration

    Swift

    public init(query: Any)
  • Convenience initializer.

    Declaration

    Swift

    public convenience init(type: Resource.Type, query: Any)
  • Creates the relative server path and query URL string.

    Declaration

    Swift

    open func construct() -> String
  • Performs a GET on the server after constructing the query URL, returning an error or a bundle resource with the callback.

    Calling this method will always restart search, not fetch subsequent pages.

    Declaration

    Swift

    open func perform(_ server: FHIRServer, callback: @escaping FHIRSearchBundleErrorCallback)

    Parameters

    server

    The FHIRServer instance on which to perform the search

    callback

    The callback, receives the response Bundle or an Error message describing what went wrong

  • Attempts to retrieve the next page of search results. If there are none, the callback is called immediately with no bundle and no error.

    Declaration

    Swift

    open func nextPage(_ server: FHIRServer, callback: @escaping FHIRSearchBundleErrorCallback)

    Parameters

    server

    The FHIRServer instance on which to perform the search

    callback

    The callback, receives the response Bundle or an Error message describing what went wrong