Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix capability typo(s) #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions Sources/Client/FHIROpenServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Models
/**
A very basic FHIRServer implementation that deals with Open FHIR servers in JSON.

It knows its base URL, can fetch and hold on to the cabability statement and perform requests and operations.
It knows its base URL, can fetch and hold on to the capability statement and perform requests and operations.

These methods are of interest to you when you create a subclass:

Expand All @@ -27,19 +27,19 @@ open class FHIROpenServer: FHIRMinimalServer {

// MARK: - Server Capability

/// The server's cabability statement. Must be implicitly fetched using `getCapabilityStatement()`
public final internal(set) var cabability: CapabilityStatement? {
/// The server's capability statement. Must be implicitly fetched using `getCapabilityStatement()`
public final internal(set) var capability: CapabilityStatement? {
didSet {
if let cabability = cabability {
didSetCapabilityStatement(cabability)
if let capability = capability {
didSetCapabilityStatement(capability)
}
}
}

open func didSetCapabilityStatement(_ cabability: CapabilityStatement) {
open func didSetCapabilityStatement(_ capability: CapabilityStatement) {

// look at CapabilityStatementRest entries for security and operation information
if let rests = cabability.rest {
if let rests = capability.rest {
var best: CapabilityStatementRest?
for rest in rests {
if nil == best {
Expand All @@ -60,24 +60,24 @@ open class FHIROpenServer: FHIRMinimalServer {

open func didFindCapabilityStatementRest(_ rest: CapabilityStatementRest) {
if let operations = rest.operation {
cababilityOperations = operations
capabilityOperations = operations
}
}

/**
Executes a `read` action against the server's "metadata" path, as returned from `cababilityStatementPath()`, which should return the
cabability statement.
Executes a `read` action against the server's "metadata" path, as returned from `capabilityStatementPath()`, which should return the
capability statement.
*/
public final func getCapabilityStatement(options: FHIRRequestOption = [.lenient], _ callback: @escaping (_ error: FHIRError?) -> ()) {
if nil != cabability {
if nil != capability {
callback(nil)
return
}

// not yet fetched, fetch it
CapabilityStatement.readFrom("metadata", server: self, options: options) { resource, error in
if let conf = resource as? CapabilityStatement {
self.cabability = conf
self.capability = conf
callback(nil)
}
else {
Expand All @@ -89,15 +89,15 @@ open class FHIROpenServer: FHIRMinimalServer {

// MARK: - Operations

/// The operations the server supports, as specified in the cabability statement.
/// The operations the server supports, as specified in the capability statement.
var operations: [String: OperationDefinition]?

/// Operations as found in the cabability statement.
var cababilityOperations: [CapabilityStatementRestResourceOperation]?
/// Operations as found in the capability statement.
var capabilityOperations: [CapabilityStatementRestResourceOperation]?

/** Find operation with given name. */
func cababilityOperation(_ name: String) -> CapabilityStatementRestResourceOperation? {
if let defs = cababilityOperations {
func capabilityOperation(_ name: String) -> CapabilityStatementRestResourceOperation? {
if let defs = capabilityOperations {
for def in defs {
if name == def.name?.string {
return def
Expand All @@ -111,15 +111,15 @@ open class FHIROpenServer: FHIRMinimalServer {
Retrieve the operation definition with the given name, either from cache or load the OperationDefinition resource.

Once an OperationDefinition has been retrieved, it is cached into the instance's `operations` dictionary. Must be used after the
cabability statement has been fetched, i.e. after using `ready` or `getCapabilityStatement`.
capability statement has been fetched, i.e. after using `ready` or `getCapabilityStatement`.
*/
open func operation(_ name: String, callback: @escaping ((OperationDefinition?) -> Void)) {
if let op = operations?[name] {
callback(op)
}
// TODO resolve a 'canonical' reference
/*
else if let def = cababilityOperation(name) {
else if let def = capabilityOperation(name) {
def.definition?.resolve(OperationDefinition.self) { optop in
if let op = optop {
if nil != self.operations {
Expand Down