FHIRAbstractBase

open class FHIRAbstractBase: FHIRJSONType, CustomStringConvertible, CustomDebugStringConvertible

Abstract superclass for all FHIR data elements.

  • The type of the resource or element.

    Declaration

    Swift

    open class var resourceType: String
  • The parent/owner of the receiver, if any. Used to dereference resources.

    Declaration

    Swift

    public weak var _owner: FHIRAbstractBase?
  • Whether this element/resource is (part of) a subsetted/summarized resource.

    Declaration

    Swift

    public var _isSummaryResource: Bool
  • Throwing initializer, made “required” so instantiation with a metatype is possible.

    Forwards to populate(from:context:) and then validates the instantiation, throwing on error.

    Throws

    FHIRValidationError, if any

    Declaration

    Swift

    public required init(json: FHIRJSON, owner: FHIRAbstractBase? = nil) throws

    Parameters

    json

    The JSON element to use to populate the receiver

    owner

    If the receiver is an element or a resource in another resource, this references that “owner”

  • Designated initializer, made “required” so instantiation with a metatype is possible.

    Forwards to populate(from:context:). You can then validate the instantiation yourself by calling try context.validate().

    Declaration

    Swift

    public required init(json: FHIRJSON, owner: FHIRAbstractBase? = nil, context: inout FHIRInstantiationContext)

    Parameters

    json

    The JSON element to use to populate the receiver

    owner

    If the receiver is an element or a resource in another resource, this references that “owner”

    context

    An in-out parameter for the instantiation context

  • Basic initializer for easy construction of new instances in code.

    Declaration

    Swift

    public init(owner: FHIRAbstractBase? = nil)

    Parameters

    owner

    An optional owner of the element or resource

  • FHIRAbstractBase simply forwards to self.init(json:owner:). Use FHIRAbstractResource’s implementation if you wish to inspect the json for resourceType, which will then use the factory method.

    Declaration

    Swift

    public class func instantiate(from json: FHIRJSON, owner: FHIRAbstractBase?, context: inout FHIRInstantiationContext) -> Self

    Parameters

    json

    A FHIRJSON decoded from a JSON response

    owner

    The FHIRAbstractBase owning the new instance, if appropriate

    context

    An in-out parameter for the instantiation context

    Return Value

    An instance of self, instantiated from the given JSON dictionary

  • Will populate instance variables - overriding existing ones - with values found in the supplied JSON. Calls populate(json:context:), which is what you should override instead.

    This is an exact copy of what’s implemented as an extension to FHIRJSONType but is needed to be picked up by the classes.

    Declaration

    Swift

    public final func populateAndFinalize(from json: FHIRJSON, context: inout FHIRInstantiationContext)

    Parameters

    json

    The JSON element to use to populate the receiver

    context

    An in-out parameter being filled with key names used.

  • The main function to perform the actual JSON parsing, to be overridden by subclasses.

    Declaration

    Swift

    public func populate(from json: FHIRJSON, context: inout FHIRInstantiationContext)

    Parameters

    json

    The JSON element to use to populate the receiver

    context

    The instantiation context to use

  • Represent the receiver in FHIRJSON, ready to be used for JSON serialization.

    Declaration

    Swift

    public final func asJSON() throws -> JSONType

    Return Value

    The FHIRJSON reperesentation of the receiver

  • Represent the receiver in FHIRJSON, ready to be used for JSON serialization. Non-throwing version that you can use if you want to handle errors yourself or ignore them altogether. Otherwise, just use asJSON() throws.

    Declaration

    Swift

    public final func asJSON(errors: inout [FHIRValidationError]) -> JSONType

    Parameters

    errors

    The array that will be filled with FHIRValidationError instances, if there are any

    Return Value

    The FHIRJSON reperesentation of the receiver

  • Represent the receiver in FHIRJSON, ready to be used for JSON serialization. Non-throwing version that you can use if you want to handle errors yourself or ignore them altogether. Otherwise, just use asJSON() throws.

    Declaration

    Swift

    public final func decorate(json: inout FHIRJSON, withKey key: String, errors: inout [FHIRValidationError])

    Parameters

    json

    The FHIRJSON representation to populate

    withKey

    The key to use

    errors

    An in-out array to be stuffed with validation errors encountered along the way

  • Undocumented

    Declaration

    Swift

    open class FHIRAbstractBase: FHIRJSONType, CustomStringConvertible, CustomDebugStringConvertible
  • Returns the resolved reference with the given id, if it has been resolved already.

    Declaration

    Swift

    public func resolvedReference(_ refid: String) -> Resource?
  • Stores the resolved reference into the _resolved dictionary.

    This method is public because it’s used in an extension in our client. You likely don’t need to use it explicitly, use the resolve(type:callback:) method on Reference instead.

    Declaration

    Swift

    public func didResolveReference(_ refid: String, resolved: Resource)

    Parameters

    refid

    The reference identifier as String

    resolved

    The resource that was resolved

  • The resource owning the receiver; used during reference resolving and to look up the instance’s _server, if any.

    Declaration

    Swift

    open var _owningResource: DomainResource?

    Return Value

    The owning DomainResource instance or nil

  • Returns the receiver’s owning Bundle, if it has one.

    Declaration

    Swift

    open var _owningBundle: Bundle?

    Return Value

    The owning Bundle instance or nil

  • Declaration

    Swift

    open var description: String
  • The debug description pretty-prints the Element/Resource’s JSON representation.

    Declaration

    Swift

    open var debugDescription: String