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 anyDeclaration
Swift
public required init(json: FHIRJSON, owner: FHIRAbstractBase? = nil) throwsParameters
jsonThe JSON element to use to populate the receiver
ownerIf 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 callingtry context.validate().Declaration
Swift
public required init(json: FHIRJSON, owner: FHIRAbstractBase? = nil, context: inout FHIRInstantiationContext)Parameters
jsonThe JSON element to use to populate the receiver
ownerIf the receiver is an element or a resource in another resource, this references that “owner”
contextAn 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
ownerAn optional owner of the element or resource
-
FHIRAbstractBase simply forwards to
self.init(json:owner:). UseFHIRAbstractResource’s implementation if you wish to inspect the json forresourceType, which will then use the factory method.Declaration
Swift
public class func instantiate(from json: FHIRJSON, owner: FHIRAbstractBase?, context: inout FHIRInstantiationContext) -> SelfParameters
jsonA FHIRJSON decoded from a JSON response
ownerThe FHIRAbstractBase owning the new instance, if appropriate
contextAn 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
FHIRJSONTypebut is needed to be picked up by the classes.Declaration
Swift
public final func populateAndFinalize(from json: FHIRJSON, context: inout FHIRInstantiationContext)Parameters
jsonThe JSON element to use to populate the receiver
contextAn 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
jsonThe JSON element to use to populate the receiver
contextThe instantiation context to use
-
Represent the receiver in FHIRJSON, ready to be used for JSON serialization.
Declaration
Swift
public final func asJSON() throws -> JSONTypeReturn 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]) -> JSONTypeParameters
errorsThe 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
jsonThe FHIRJSON representation to populate
withKeyThe key to use
errorsAn 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
_resolveddictionary.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 onReferenceinstead.Declaration
Swift
public func didResolveReference(_ refid: String, resolved: Resource)Parameters
refidThe reference identifier as String
resolvedThe 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
DomainResourceinstance 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
-
Undocumented
Declaration
Swift
open class FHIRAbstractBase: FHIRJSONType, CustomStringConvertible, CustomDebugStringConvertible
View on GitHub
Install in Dash
FHIRAbstractBase Class Reference