From 903b62b8e864159d3f9deb827dae8cab10b6ee06 Mon Sep 17 00:00:00 2001 From: Pascal Pfiffner Date: Fri, 16 Sep 2016 11:32:16 +0200 Subject: [PATCH] More Swift 3 adaptations --- .../Client/DomainResource+Containment.swift | 4 +- Sources/Client/FHIROpenServer.swift | 61 +++++++++++-------- Sources/Client/FHIROperation.swift | 12 ++-- Sources/Client/FHIRSearch.swift | 17 ++++-- Sources/Client/FHIRServerDataResponse.swift | 51 ++++++++++------ Sources/Client/FHIRServerRequestHandler.swift | 33 +++++----- Sources/Client/Resource+Instantiation.swift | 19 +++++- Sources/Client/Resource+REST.swift | 34 +++++------ Sources/Models/Account.swift | 2 +- Sources/Models/AllergyIntolerance.swift | 6 +- Sources/Models/Appointment.swift | 8 +-- Sources/Models/AppointmentResponse.swift | 4 +- Sources/Models/AuditEvent.swift | 18 +++--- Sources/Models/BackboneElement.swift | 2 +- Sources/Models/Basic.swift | 2 +- Sources/Models/BodySite.swift | 6 +- Sources/Models/Bundle.swift | 6 +- Sources/Models/CarePlan.swift | 30 ++++----- Sources/Models/Claim.swift | 26 ++++---- Sources/Models/ClaimResponse.swift | 28 ++++----- Sources/Models/ClinicalImpression.swift | 16 ++--- Sources/Models/CodeableConcept.swift | 2 +- Sources/Models/Communication.swift | 10 +-- Sources/Models/CommunicationRequest.swift | 10 +-- Sources/Models/Composition.swift | 16 ++--- Sources/Models/ConceptMap.swift | 14 ++--- Sources/Models/Condition.swift | 10 +-- Sources/Models/Conformance.swift | 32 +++++----- Sources/Models/Contract.swift | 40 ++++++------ Sources/Models/Coverage.swift | 4 +- Sources/Models/DataElement.swift | 12 ++-- Sources/Models/DetectedIssue.swift | 4 +- Sources/Models/Device.swift | 6 +- Sources/Models/DeviceComponent.swift | 4 +- Sources/Models/DeviceMetric.swift | 2 +- Sources/Models/DeviceUseRequest.swift | 6 +- Sources/Models/DeviceUseStatement.swift | 4 +- Sources/Models/DiagnosticOrder.swift | 18 +++--- Sources/Models/DiagnosticReport.swift | 16 ++--- Sources/Models/DocumentManifest.swift | 10 +-- Sources/Models/DocumentReference.swift | 16 ++--- Sources/Models/DomainResource.swift | 6 +- Sources/Models/Element.swift | 2 +- Sources/Models/ElementDefinition.swift | 8 +-- Sources/Models/EligibilityRequest.swift | 2 +- Sources/Models/EligibilityResponse.swift | 2 +- Sources/Models/Encounter.swift | 30 ++++----- Sources/Models/EnrollmentRequest.swift | 2 +- Sources/Models/EnrollmentResponse.swift | 2 +- Sources/Models/EpisodeOfCare.swift | 14 ++--- Sources/Models/ExplanationOfBenefit.swift | 2 +- Sources/Models/FHIRAbstractBase.swift | 22 ++----- Sources/Models/FHIRAbstractResource.swift | 12 ++-- Sources/Models/FHIRServer.swift | 6 +- Sources/Models/FHIRServerResponse.swift | 30 ++++++--- Sources/Models/FHIRTypes.swift | 2 +- Sources/Models/FamilyMemberHistory.swift | 4 +- Sources/Models/Flag.swift | 2 +- Sources/Models/Goal.swift | 10 +-- Sources/Models/Group.swift | 6 +- Sources/Models/HealthcareService.swift | 20 +++--- Sources/Models/ImagingObjectSelection.swift | 8 +-- Sources/Models/ImagingStudy.swift | 14 ++--- Sources/Models/Immunization.swift | 14 ++--- .../Models/ImmunizationRecommendation.swift | 10 +-- Sources/Models/ImplementationGuide.swift | 16 ++--- Sources/Models/List.swift | 4 +- Sources/Models/Location.swift | 4 +- Sources/Models/Media.swift | 2 +- Sources/Models/Medication.swift | 6 +- Sources/Models/MedicationAdministration.swift | 8 +-- Sources/Models/MedicationDispense.swift | 10 +-- Sources/Models/MedicationOrder.swift | 4 +- Sources/Models/MedicationStatement.swift | 12 ++-- Sources/Models/MessageHeader.swift | 4 +- Sources/Models/Meta.swift | 4 +- Sources/Models/NamingSystem.swift | 8 +-- Sources/Models/NutritionOrder.swift | 24 ++++---- Sources/Models/Observation.swift | 12 ++-- Sources/Models/OperationDefinition.swift | 8 +-- Sources/Models/OperationOutcome.swift | 2 +- Sources/Models/Order.swift | 4 +- Sources/Models/OrderResponse.swift | 4 +- Sources/Models/Organization.swift | 10 +-- Sources/Models/Parameters.swift | 4 +- Sources/Models/Patient.swift | 22 +++---- Sources/Models/PaymentNotice.swift | 2 +- Sources/Models/PaymentReconciliation.swift | 6 +- Sources/Models/Person.swift | 10 +-- Sources/Models/Practitioner.swift | 22 +++---- Sources/Models/Procedure.swift | 20 +++--- Sources/Models/ProcedureRequest.swift | 6 +- Sources/Models/ProcessRequest.swift | 4 +- Sources/Models/ProcessResponse.swift | 6 +- Sources/Models/Provenance.swift | 12 ++-- Sources/Models/Questionnaire.swift | 16 ++--- Sources/Models/QuestionnaireResponse.swift | 8 +-- Sources/Models/ReferralRequest.swift | 8 +-- Sources/Models/RelatedPerson.swift | 8 +-- Sources/Models/RiskAssessment.swift | 4 +- Sources/Models/Schedule.swift | 4 +- Sources/Models/SearchParameter.swift | 4 +- Sources/Models/Signature.swift | 2 +- Sources/Models/Slot.swift | 2 +- Sources/Models/Specimen.swift | 12 ++-- Sources/Models/StructureDefinition.swift | 16 ++--- Sources/Models/Subscription.swift | 4 +- Sources/Models/Substance.swift | 8 +-- Sources/Models/SupplyDelivery.swift | 2 +- Sources/Models/SupplyRequest.swift | 2 +- Sources/Models/TestScript.swift | 26 ++++---- Sources/Models/ValueSet.swift | 28 ++++----- Sources/Models/VisionPrescription.swift | 4 +- Tests/ResourceTests.swift | 6 +- fhir-parser | 2 +- 115 files changed, 661 insertions(+), 616 deletions(-) diff --git a/Sources/Client/DomainResource+Containment.swift b/Sources/Client/DomainResource+Containment.swift index dacca182..37250c30 100644 --- a/Sources/Client/DomainResource+Containment.swift +++ b/Sources/Client/DomainResource+Containment.swift @@ -45,7 +45,7 @@ extension DomainResource { - parameter display: The string that will become the reference's `display` - returns: A `Reference` instance pointing to the contained resource (as "#id") */ - public func contain(resource: Resource, withDisplay display: String? = nil) throws -> Reference { + open func contain(resource: Resource, withDisplay display: String? = nil) throws -> Reference { guard resource !== self else { throw FHIRError.resourceCannotContainItself } @@ -98,7 +98,7 @@ extension DomainResource { - parameter display: The string that will become the reference's `display` - returns: A `Reference`, ready for use */ - public func reference(resource: Resource, withDisplay display: String? = nil) throws -> Reference { + open func reference(resource: Resource, withDisplay display: String? = nil) throws -> Reference { let ref = Reference(json: nil, owner: self) ref.display = display diff --git a/Sources/Client/FHIROpenServer.swift b/Sources/Client/FHIROpenServer.swift index ead2f7ed..fc7e6528 100644 --- a/Sources/Client/FHIROpenServer.swift +++ b/Sources/Client/FHIROpenServer.swift @@ -19,8 +19,8 @@ It knows its base URL, can fetch and hold on to the conformance statement and pe These methods are of interest to you when you create a subclass: -- `handlerForRequest(ofType:resource:)`: what kind of handler your server wants to use. Returns `FHIRServerJSONRequestHandler`. -- `configurableRequest(forURL:)`: the SMART framework returns a request that already has an Authorization headers set, if needed. +- `handlerForRequest(withMethod:resource:)`: what kind of handler your server wants to use. Returns `FHIRServerJSONRequestHandler`. +- `configurableRequest(for:)`: the SMART framework returns a request that already has an Authorization headers set, if needed. */ open class FHIROpenServer: FHIRServer { @@ -50,8 +50,10 @@ open class FHIROpenServer: FHIRServer { This method simply creates an absolute URL from the receiver's `baseURL` and the given path. A chance for subclasses to mess with URL generation if needed. + + - parameter for: The path in the absolute URL */ - open func absoluteURLForPath(_ path: String, handler: FHIRServerRequestHandler) -> URL? { + open func absoluteURL(for path: String, handler: FHIRServerRequestHandler) -> URL? { return URL(string: path, relativeTo: baseURL) } @@ -60,13 +62,19 @@ open class FHIROpenServer: FHIRServer { /** Perform a request of given type against the given path with the (optional) given resource and headers. + + - parameter method: The HTTP method type of the request + - parameter path: The relative path on the server to be interacting against + - parameter resource: The resource to be involved in the request, if any + - parameter additonalHeaders: The headers to set on the request + - parameter callback: A callback, likely called asynchronously, returning a response instance */ - open func performRequest(ofType type: FHIRRequestType, path: String, resource: Resource?, additionalHeaders: FHIRRequestHeaders? = nil, callback: @escaping ((_ response: FHIRServerResponse) -> Void)) { - if let handler = handlerForRequest(type, resource: resource, headers: additionalHeaders) { - performRequest(againstPath: path, handler: handler, callback: callback) + open func performRequest(_ method: FHIRRequestMethod, path: String, resource: Resource?, additionalHeaders: FHIRRequestHeaders? = nil, callback: @escaping ((FHIRServerResponse) -> Void)) { + if let handler = handlerForRequest(withMethod: method, resource: resource, headers: additionalHeaders) { + performRequest(against: path, handler: handler, callback: callback) } else { - let res = FHIRServerRequestHandler.noneAvailable(forType: type) + let res = FHIRServerRequestHandler.noneAvailable(for: method) callback(res) } } @@ -79,12 +87,12 @@ open class FHIROpenServer: FHIRServer { Request handlers are responsible for constructing an URLRequest that correctly performs the desired REST interaction. - - parameter ofType: The type of the request (GET, PUT, POST or DELETE) + - parameter method: The request method (GET, PUT, POST or DELETE) - parameter resource: The resource to be involved in the request, if any - - returns: An appropriate `FHIRServerRequestHandler`, for example a _FHIRServerJSONRequestHandler_ if sending and receiving JSON + - returns: An appropriate `FHIRServerRequestHandler`, for example a _FHIRServerJSONRequestHandler_ if sending and receiving JSON */ - open func handlerForRequest(_ ofType: FHIRRequestType, resource: Resource?, headers: FHIRRequestHeaders? = nil) -> FHIRServerRequestHandler? { - let handler = FHIRServerJSONRequestHandler(ofType, resource: resource) + open func handlerForRequest(withMethod method: FHIRRequestMethod, resource: Resource?, headers: FHIRRequestHeaders? = nil) -> FHIRServerRequestHandler? { + let handler = FHIRServerJSONRequestHandler(method, resource: resource) if let headers = headers { handler.add(headers: headers) } @@ -94,38 +102,37 @@ open class FHIROpenServer: FHIRServer { /** Pre-prepare a mutable URLRequest that the handler subsequently prepares and performs. - - parameter forURL: The url to use for the request + - parameter url: The url to use for the request */ - open func configurableRequest(forURL url: URL) -> URLRequest { + open func configurableRequest(for url: URL) -> URLRequest { return URLRequest(url: url) } - /** Method to execute a request against a given relative URL with a given request/response handler. - - parameter againstPath: The path, relative to the server's base; may include URL query and URL fragment (!) - - parameter handler: The RequestHandler that prepares the request and processes the response - - parameter callback: The callback to execute; NOT guaranteed to be performed on the main thread! + - parameter path: The path, relative to the server's base; may include URL query and URL fragment (!) + - parameter handler: The RequestHandler that prepares the request and processes the response + - parameter callback: The callback to execute; NOT guaranteed to be performed on the main thread! */ - open func performRequest(againstPath path: String, handler: R, callback: @escaping ((_ response: FHIRServerResponse) -> Void)) { - guard let url = absoluteURLForPath(path, handler: handler) else { + open func performRequest(against path: String, handler: R, callback: @escaping ((FHIRServerResponse) -> Void)) { + guard let url = absoluteURL(for: path, handler: handler) else { let res = handler.notSent("Failed to parse path «\(path)» relative to server base URL") callback(res) return } - performRequest(withURL: url, handler: handler, callback: callback) + performRequest(on: url, handler: handler, callback: callback) } /** Method to execute a request against a given absolute URL with a given request/response handler. - - parameter withURL: The full URL; may include query parts and fragment (!) + - parameter url: The full URL; may include query parts and fragment (!) - parameter handler: The RequestHandler that prepares the request and processes the response - parameter callback: The callback to execute; NOT guaranteed to be performed on the main thread! */ - open func performRequest(withURL url: URL, handler: R, callback: @escaping ((_ response: FHIRServerResponse) -> Void)) { - var request = configurableRequest(forURL: url) + open func performRequest(on url: URL, handler: R, callback: @escaping ((FHIRServerResponse) -> Void)) { + var request = configurableRequest(for: url) do { try handler.prepare(request: &request) self.performPreparedRequest(request, handler: handler, callback: callback) @@ -145,7 +152,7 @@ open class FHIROpenServer: FHIRServer { - parameter handler: The RequestHandler that prepares the request and processes the response - parameter callback: The callback to execute; NOT guaranteed to be performed on the main thread! */ - open func performPreparedRequest(_ request: URLRequest, handler: R, callback: @escaping ((_ response: FHIRServerResponse) -> Void)) { + open func performPreparedRequest(_ request: URLRequest, handler: R, callback: @escaping ((FHIRServerResponse) -> Void)) { performPreparedRequest(request, withSession: URLSession(), handler: handler, callback: callback) } @@ -157,9 +164,9 @@ open class FHIROpenServer: FHIRServer { - parameter handler: The RequestHandler that prepares the request and processes the response - parameter callback: The callback to execute; NOT guaranteed to be performed on the main thread! */ - open func performPreparedRequest(_ request: URLRequest, withSession session: URLSession, handler: R, callback: @escaping ((_ response: FHIRServerResponse) -> Void)) { + open func performPreparedRequest(_ request: URLRequest, withSession session: URLSession, handler: R, callback: @escaping ((FHIRServerResponse) -> Void)) { let task = session.dataTask(with: request) { data, response, error in - let res = handler.response(response, data: data, error: error as NSError?) + let res = handler.response(with: response, data: data, error: error) callback(res) } task.resume() @@ -293,7 +300,7 @@ open class FHIROpenServer: FHIRServer { - parameter operation: The operation instance to perform - parameter callback: The callback to call when the request ends (success or failure) */ - open func perform(_ operation: FHIROperation, callback: @escaping ((_ response: FHIRServerResponse) -> Void)) { + open func perform(_ operation: FHIROperation, callback: @escaping ((FHIRServerResponse) -> Void)) { self.operation(operation.name) { definition in if let def = definition { do { diff --git a/Sources/Client/FHIROperation.swift b/Sources/Client/FHIROperation.swift index 3081e6fb..be054f8a 100644 --- a/Sources/Client/FHIROperation.swift +++ b/Sources/Client/FHIROperation.swift @@ -13,16 +13,16 @@ import Models /** - The context an operation is to be performed against. - */ +The context an operation is to be performed against. +*/ public enum FHIROperationContext { case none, system, resourceType, instance } /** - Named operations to be performed against a FHIR REST endpoint. - */ +Named operations to be performed against a FHIR REST endpoint. +*/ open class FHIROperation: CustomStringConvertible { /// The name of the operation. @@ -116,7 +116,7 @@ open class FHIROperation: CustomStringConvertible { if "in" == param.use { // have the parameter, validate it - if let _ = inParams?[param.name!] { + if nil != inParams?[param.name!] { leftover.removeValue(forKey: param.name!) // TODO: actually validate! @@ -165,7 +165,7 @@ open class FHIROperation: CustomStringConvertible { */ open func perform(onServer server: FHIRServer, callback: @escaping ((_ response: FHIRServerResponse) -> Void)) throws { let path = try serverPath() - server.performRequest(ofType: .GET, path: path, resource: nil, additionalHeaders: nil, callback: callback) + server.performRequest(.GET, path: path, resource: nil, additionalHeaders: nil, callback: callback) } diff --git a/Sources/Client/FHIRSearch.swift b/Sources/Client/FHIRSearch.swift index d759f5d7..98f8e774 100644 --- a/Sources/Client/FHIRSearch.swift +++ b/Sources/Client/FHIRSearch.swift @@ -9,12 +9,17 @@ import Foundation #if !NO_MODEL_IMPORT import Models +public typealias FHIRSearchBundleErrorCallback = ((Models.Bundle?, FHIRError?) -> Void) +#else +public typealias FHIRSearchBundleErrorCallback = ((Bundle?, FHIRError?) -> Void) #endif /** 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"]]) @@ -101,9 +106,9 @@ open class FHIRSearch Calling this method will always restart search, not fetch subsequent pages. - parameter server: The FHIRServer instance on which to perform the search - - parameter callback: The callback, receives the response Bundle or an NSError message describing what went wrong + - parameter callback: The callback, receives the response Bundle or an Error message describing what went wrong */ - open func perform(_ server: FHIRServer, callback: @escaping ((_ bundle: Bundle?, _ error: FHIRError?) -> Void)) { + open func perform(_ server: FHIRServer, callback: @escaping FHIRSearchBundleErrorCallback) { if nil == profileType { callback(nil, FHIRError.searchResourceTypeNotDefined) return @@ -118,9 +123,9 @@ open class FHIRSearch with no bundle and no error. - parameter server: The FHIRServer instance on which to perform the search - - parameter callback: The callback, receives the response Bundle or an NSError message describing what went wrong + - parameter callback: The callback, receives the response Bundle or an Error message describing what went wrong */ - open func nextPage(_ server: FHIRServer, callback: @escaping ((_ bundle: Bundle?, _ error: FHIRError?) -> Void)) { + open func nextPage(_ server: FHIRServer, callback: @escaping FHIRSearchBundleErrorCallback) { if let next = nextPageURL?.absoluteString { performSearch(server, queryPath: next, callback: callback) } @@ -129,14 +134,14 @@ open class FHIRSearch } } - func performSearch(_ server: FHIRServer, queryPath: String, callback: @escaping ((_ bundle: Bundle?, _ error: FHIRError?) -> Void)) { + func performSearch(_ server: FHIRServer, queryPath: String, callback: @escaping FHIRSearchBundleErrorCallback) { if busy { callback(nil, nil) return } busy = true - server.performRequest(ofType: .GET, path: queryPath, resource: nil, additionalHeaders: nil) { response in + server.performRequest(.GET, path: queryPath, resource: nil, additionalHeaders: nil) { response in self.busy = false if let error = response.error { diff --git a/Sources/Client/FHIRServerDataResponse.swift b/Sources/Client/FHIRServerDataResponse.swift index c6be1093..6fe4e7c1 100644 --- a/Sources/Client/FHIRServerDataResponse.swift +++ b/Sources/Client/FHIRServerDataResponse.swift @@ -71,6 +71,11 @@ extension FHIRServerResponse { } } + /** Initializes with a no-response error. */ + public static func noneReceived() -> Self { + return self.init(error: FHIRError.noResponseReceived) + } + /// Nicely format status code, response headers and response body (if any). public var debugDescription: String { var msg = "HTTP 1.1 \(status)" @@ -99,13 +104,13 @@ open class FHIRServerDataResponse: FHIRServerResponse { open var body: Data? /// The request's operation outcome, if any. - open internal(set) var outcome: OperationOutcome? + public internal(set) var outcome: OperationOutcome? /// The error encountered, if any. open var error: FHIRError? /** - Instantiate a FHIRServerResponse from an NS(HTTP)URLResponse, NSData and an optional NSError. + Instantiate a FHIRServerResponse from a (HTTP)URLResponse, Data and an optional Error. */ public required init(response: URLResponse, data: Data?, error: Error?) { var status = 0 @@ -128,10 +133,13 @@ open class FHIRServerDataResponse: FHIRServerResponse { // was there an error? if let error = error as? NSError, NSURLErrorDomain == error.domain { - self.error = FHIRError.requestError(status, NSURLErrorHumanize(error)) + self.error = FHIRError.requestError(status, error.humanized) + } + else if let error = error as? FHIRError { + self.error = error } else if let error = error { - self.error = FHIRError.error("\(error)") + self.error = FHIRError.error(error.localizedDescription) } self.status = status @@ -143,7 +151,7 @@ open class FHIRServerDataResponse: FHIRServerResponse { self.status = 0 self.headers = [String: String]() if NSURLErrorDomain == (error as NSError).domain { - self.error = FHIRError.requestError(status, NSURLErrorHumanize(error as NSError)) + self.error = FHIRError.requestError(status, (error as NSError).humanized) } else if let error = error as? FHIRError { self.error = error @@ -156,12 +164,12 @@ open class FHIRServerDataResponse: FHIRServerResponse { // MARK: - Responses - open func responseResource(_ expectType: T.Type) -> T? { + open func responseResource(ofType: T.Type) -> T? { return nil } /** Initializes with a no-response error. */ - open class func noneReceived() -> Self { + public final class func noneReceived() -> Self { return self.init(error: FHIRError.noResponseReceived) } @@ -169,9 +177,9 @@ open class FHIRServerDataResponse: FHIRServerResponse { The base method does not actually know how to handle the data to update a resource, but it will still throw `FHIRError.ResponseNoResourceReceived` if body is nil. - - parameter resource: The resource to apply the response data to + - parameter to: The resource to apply the response data to */ - open func applyBody(to resource: Resource) throws { + open func applyBody(to: Resource) throws { guard nil != body else { throw FHIRError.responseNoResourceReceived } @@ -198,7 +206,7 @@ open class FHIRServerJSONResponse: FHIRServerDataResponse { do { let json = try JSONSerialization.jsonObject(with: data, options: []) as? FHIRJSON self.json = json - self.outcome = responseResource(OperationOutcome.self) + self.outcome = responseResource(ofType: OperationOutcome.self) // inspect OperationOutcome if there was an error if status >= 400 { @@ -214,7 +222,7 @@ open class FHIRServerJSONResponse: FHIRServerDataResponse { catch let error as NSError { // Cocoa error 3840 is JSON parsing error; some error responses may not return JSON, don't report an error on those if 3840 != error.code || NSCocoaErrorDomain != error.domain || status < 400 { - let raw = NSString(data: data, encoding: String.Encoding.utf8.rawValue) as? String ?? "" + let raw = String(data: data, encoding: String.Encoding.utf8) ?? "" self.error = FHIRError.jsonParsingError(error.localizedDescription, raw) } } @@ -235,7 +243,7 @@ open class FHIRServerJSONResponse: FHIRServerDataResponse { Uses FHIRElement's factory method to instantiate a resource from the response JSON, if any, and returns that resource if it is indeed of the expected type. */ - open override func responseResource(_ expectType: T.Type) -> T? { + override open func responseResource(ofType: T.Type) -> T? { if let json = json { let resource = Resource.instantiate(from: json, owner: nil) return resource as? T @@ -251,7 +259,7 @@ open class FHIRServerJSONResponse: FHIRServerDataResponse { - parameter resource: The resource to apply the response data to */ - open override func applyBody(to resource: Resource) throws { + override open func applyBody(to resource: Resource) throws { guard let json = json else { throw FHIRError.responseNoResourceReceived } @@ -270,12 +278,14 @@ open class FHIRServerJSONResponse: FHIRServerDataResponse { // MARK: - -/** -Return a human-readable, localized string for error codes of the NSURLErrorDomain. -*/ -func NSURLErrorHumanize(_ error: NSError) -> String { - assert(NSURLErrorDomain == error.domain, "Can only use this function with errors in the NSURLErrorDomain") - switch error.code { +extension NSError { + + /** + Return a human-readable, localized string for error codes of the NSURLErrorDomain (!!). + */ + public var humanized: String { + assert(NSURLErrorDomain == domain, "Can only use this function with errors in the NSURLErrorDomain") + switch code { case NSURLErrorBadURL: return "The URL was malformed".fhir_localized case NSURLErrorTimedOut: return "The connection timed out".fhir_localized case NSURLErrorUnsupportedURL: return "The URL scheme is not supported".fhir_localized @@ -284,7 +294,8 @@ func NSURLErrorHumanize(_ error: NSError) -> String { case NSURLErrorNetworkConnectionLost: return "The network connection was lost".fhir_localized case NSURLErrorDNSLookupFailed: return "The connection failed because the DNS lookup failed".fhir_localized case NSURLErrorHTTPTooManyRedirects: return "The HTTP connection failed due to too many redirects".fhir_localized - default: return error.localizedDescription + default: return localizedDescription + } } } diff --git a/Sources/Client/FHIRServerRequestHandler.swift b/Sources/Client/FHIRServerRequestHandler.swift index 919bd0c1..b50a97cc 100644 --- a/Sources/Client/FHIRServerRequestHandler.swift +++ b/Sources/Client/FHIRServerRequestHandler.swift @@ -15,7 +15,8 @@ import Models /** Base for different request/response handlers. -Would love to make this a protocol but since it has an associated type it cannot be used nicely, hence a class. +Would love to make this a protocol but since it has an associated type which does cannot be used for initialization from subclasses -- the +associated type of the class that implements the method is always used -- it cannot be used nicely. Hence a class. */ open class FHIRServerRequestHandler { @@ -23,8 +24,8 @@ open class FHIRServerRequestHandler { return FHIRRequestHeaders() } - /// The HTTP type of the request. - open let method: FHIRRequestType + /// The HTTP method of the request. + open let method: FHIRRequestMethod /// Headers to be used on the request. open var headers: FHIRRequestHeaders @@ -35,7 +36,7 @@ open class FHIRServerRequestHandler { /// The receiver may hold on to a resource that supplies the request's body data. open var resource: Resource? - public init(_ method: FHIRRequestType, resource: Resource? = nil) { + public init(_ method: FHIRRequestMethod, resource: Resource? = nil) { self.method = method self.headers = type(of: self).defaultHeaders self.resource = resource @@ -69,7 +70,7 @@ open class FHIRServerRequestHandler { /** Give the request type a chance to prepare/alter the URL request. - Typically the FHIRRequestType instance sets the correct HTTPMethod as well as correct FHIR headers. + Typically the FHIRRequestMethod instance sets the correct HTTPMethod as well as correct FHIR headers. */ open func prepare(request: inout URLRequest) throws { try prepareData() @@ -86,8 +87,12 @@ open class FHIRServerRequestHandler { /** Instantiate an object of ResponseType-type based on the response and data that we get. + + - parameter response: The URLResponse that was received + - parameter data: Response data + - parameter error: Error in the response */ - open func response(_ response: URLResponse?, data inData: Data? = nil, error: Error? = nil) -> FHIRServerResponse { + open func response(with response: URLResponse?, data inData: Data? = nil, error: Error? = nil) -> FHIRServerResponse { if let res = response { return type(of: self).ResponseType.init(response: res, data: inData, error: error) } @@ -107,10 +112,10 @@ open class FHIRServerRequestHandler { /** Convenience method to indicate that no request handler for the given type is available. - - parameter forType: The request type + - parameter method: The request type */ - open class func noneAvailable(forType type: FHIRRequestType) -> FHIRServerResponse { - return ResponseType.init(error: FHIRError.noRequestHandlerAvailable(type.rawValue)) + open class func noneAvailable(for method: FHIRRequestMethod) -> FHIRServerResponse { + return ResponseType.init(error: FHIRError.noRequestHandlerAvailable(method.rawValue)) } } @@ -142,7 +147,7 @@ open class FHIRServerJSONRequestHandler: FHIRServerRequestHandler { } // for GET requests we don't have data, which is fine too } - open override func prepare(request: inout URLRequest) throws { + override open func prepare(request: inout URLRequest) throws { switch method { case .PUT: headers[.contentType] = "application/json+fhir; charset=utf-8" @@ -154,7 +159,7 @@ open class FHIRServerJSONRequestHandler: FHIRServerRequestHandler { try super.prepare(request: &request) } - open override class var ResponseType: FHIRServerResponse.Type { + override open class var ResponseType: FHIRServerResponse.Type { return FHIRServerJSONResponse.self } } @@ -170,7 +175,7 @@ open class FHIRServerDataRequestHandler: FHIRServerRequestHandler { open let contentType: String - init(_ type: FHIRRequestType, contentType: String) { + init(_ type: FHIRRequestMethod, contentType: String) { self.contentType = contentType super.init(type, resource: nil) } @@ -178,7 +183,7 @@ open class FHIRServerDataRequestHandler: FHIRServerRequestHandler { override open func prepareData() throws { } - open override func prepare(request: inout URLRequest) throws { + override open func prepare(request: inout URLRequest) throws { switch method { case .GET: headers[.accept] = contentType @@ -193,7 +198,7 @@ open class FHIRServerDataRequestHandler: FHIRServerRequestHandler { try super.prepare(request: &request) } - open override class var ResponseType: FHIRServerResponse.Type { + override open class var ResponseType: FHIRServerResponse.Type { return FHIRServerDataResponse.self } } diff --git a/Sources/Client/Resource+Instantiation.swift b/Sources/Client/Resource+Instantiation.swift index 609c7b11..e7c61c20 100644 --- a/Sources/Client/Resource+Instantiation.swift +++ b/Sources/Client/Resource+Instantiation.swift @@ -36,10 +36,23 @@ public extension Foundation.Bundle { - parameter name: The filename, without ".json" extension, to read the resource from - parameter type: The type the resource is expected to be; must be a subclass of `Resource` - - returns: A Resource subclass corresponding to the "resourceType" entry, as specified under `type` + - returns: A Resource subclass corresponding to the "resourceType" entry, as specified under `type` */ public func fhir_bundledResource(_ name: String, type: T.Type) throws -> T { - if let url = url(forResource: name, withExtension: "json"), let data = try? Data(contentsOf: url) { + return try fhir_bundledResource(name, subdirectory: nil, type: type) + } + + /** + Attempts to read a JSON file with the given name (without ".json") from the given directory. Parses the JSON and instantiates a FHIR + resource corresponding to "resourceType". + + - parameter name: The filename, without ".json" extension, to read the resource from + - parameter subdirectory: The directory name to search for the resource; `nil` for top level + - parameter type: The type the resource is expected to be; must be a subclass of `Resource` + - returns: A Resource subclass corresponding to the "resourceType" entry, as specified under `type` + */ + public func fhir_bundledResource(_ name: String, subdirectory: String?, type: T.Type) throws -> T { + if let url = url(forResource: name, withExtension: "json", subdirectory: subdirectory), let data = try? Data(contentsOf: url) { if let json = try JSONSerialization.jsonObject(with: data, options: []) as? FHIRJSON { if let resource = Resource.instantiate(from: json, owner: nil) as? T { return resource @@ -48,7 +61,7 @@ public extension Foundation.Bundle { } throw FHIRError.resourceFailedToInstantiate(url.description) } - throw FHIRError.resourceFailedToInstantiate(name) + throw FHIRError.resourceFailedToInstantiate((nil == subdirectory) ? "\(name).json" : "\(subdirectory!)/\(name).json") } } diff --git a/Sources/Client/Resource+REST.swift b/Sources/Client/Resource+REST.swift index f463a6c5..cae68f5b 100644 --- a/Sources/Client/Resource+REST.swift +++ b/Sources/Client/Resource+REST.swift @@ -13,10 +13,10 @@ import Models /// The block signature for server interaction callbacks that return an error. -public typealias FHIRErrorCallback = ((_ error: FHIRError?) -> Void) +public typealias FHIRErrorCallback = ((FHIRError?) -> Void) /// The block signature for most server interaction callbacks that return a resource and an error. -public typealias FHIRResourceErrorCallback = ((_ resource: Resource?, _ error: FHIRError?) -> Void) +public typealias FHIRResourceErrorCallback = ((Resource?, FHIRError?) -> Void) /** @@ -105,11 +105,11 @@ public extension Resource { - parameter callback: The callback to execute once done. The callback is NOT guaranteed to be executed on the main thread! */ public class func readFrom(_ path: String, server: FHIRServer, callback: @escaping FHIRResourceErrorCallback) { - server.performRequest(ofType: .GET, path: path, resource: nil, additionalHeaders: nil) { response in + server.performRequest(.GET, path: path, resource: nil, additionalHeaders: nil) { response in if let error = response.error { callback(nil, error) } - else if let resource = response.responseResource(Resource.self) { + else if let resource = response.responseResource(ofType: Resource.self) { resource._server = server do { try response.applyHeaders(to: resource) @@ -148,7 +148,7 @@ public extension Resource { } let headers = FHIRRequestHeaders([.prefer: "return=minimal"]) - server.performRequest(ofType: .POST, path: relativeURLBase(), resource: self, additionalHeaders: headers) { response in + server.performRequest(.POST, path: relativeURLBase(), resource: self, additionalHeaders: headers) { response in if nil == response.error { self._server = server do { @@ -183,7 +183,7 @@ public extension Resource { } let headers = FHIRRequestHeaders([.prefer: "return=representation"]) - server.performRequest(ofType: .POST, path: relativeURLBase(), resource: self, additionalHeaders: headers) { response in + server.performRequest(.POST, path: relativeURLBase(), resource: self, additionalHeaders: headers) { response in if nil == response.error { self._server = server do { @@ -227,11 +227,11 @@ public extension Resource { - parameter callback: The callback to execute once done. The callback is NOT guaranteed to be executed on the main thread! */ - public func update(_ callback: @escaping FHIRErrorCallback) { + public func update(callback: @escaping FHIRErrorCallback) { if let server = _server { do { let path = try relativeURLPath() - server.performRequest(ofType: .PUT, path: path, resource: self, additionalHeaders: nil) { response in + server.performRequest(.PUT, path: path, resource: self, additionalHeaders: nil) { response in do { try response.applyHeaders(to: self) } @@ -255,7 +255,7 @@ public extension Resource { This method forwards to the `delete` class method, substituting the receiver's path and server. */ - public func delete(_ callback: @escaping FHIRErrorCallback) { + public func delete(callback: @escaping FHIRErrorCallback) { if let server = _server { do { let path = try relativeURLPath() @@ -276,7 +276,7 @@ public extension Resource { This implementation issues a DELETE call against the given path on the given server. */ public class func delete(_ path: String, server: FHIRServer, callback: @escaping FHIRErrorCallback) { - server.performRequest(ofType: .DELETE, path: path, resource: nil, additionalHeaders: nil) { response in + server.performRequest(.DELETE, path: path, resource: nil, additionalHeaders: nil) { response in // TODO: should we do some header inspection (response.headers)? callback(response.error) } @@ -293,7 +293,7 @@ public extension Resource { public func search(_ query: Any) -> FHIRSearch { if let _ = self.id { NSLog("UNFINISHED, must add '_id' reference to search expression") - //return FHIRSearch(subject: "_id", reference: myID, type: self.dynamicType) + //return FHIRSearch(subject: "_id", reference: myID, type: type(of: self)) } return FHIRSearch(type: type(of: self), query: query) } @@ -311,11 +311,11 @@ public extension Resource { /** Perform a given operation on the receiver. */ - public func perform(_ operation: FHIROperation, callback: @escaping FHIRResourceErrorCallback) { + public func perform(operation: FHIROperation, callback: @escaping FHIRResourceErrorCallback) { if let server = _server { if let server = server as? FHIROpenServer { operation.instance = self - type(of: self)._perform(operation, server: server, callback: callback) + type(of: self)._perform(operation: operation, server: server, callback: callback) } else { callback(nil, FHIRError.error("Must be living on a FHIROpenServer or subclass")) @@ -329,18 +329,18 @@ public extension Resource { /** Perform a given operation on the receiving type. */ - public class func perform(_ operation: FHIROperation, server: FHIROpenServer, callback: @escaping FHIRResourceErrorCallback) { + public class func perform(operation: FHIROperation, server: FHIROpenServer, callback: @escaping FHIRResourceErrorCallback) { operation.type = self - _perform(operation, server: server, callback: callback) + _perform(operation: operation, server: server, callback: callback) } - class func _perform(_ operation: FHIROperation, server: FHIROpenServer, callback: @escaping FHIRResourceErrorCallback) { + class func _perform(operation: FHIROperation, server: FHIROpenServer, callback: @escaping FHIRResourceErrorCallback) { server.perform(operation) { response in if let error = response.error { callback(nil, error) } else { - let resource = response.responseResource(Resource.self) + let resource = response.responseResource(ofType: Resource.self) resource?._server = server callback(resource, nil) } diff --git a/Sources/Models/Account.swift b/Sources/Models/Account.swift index f1d2fb64..808ed187 100644 --- a/Sources/Models/Account.swift +++ b/Sources/Models/Account.swift @@ -184,7 +184,7 @@ public class Account: DomainResource { json["description"] = description_fhir.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let name = self.name { json["name"] = name.asJSON() diff --git a/Sources/Models/AllergyIntolerance.swift b/Sources/Models/AllergyIntolerance.swift index b2672d41..c0fd481e 100644 --- a/Sources/Models/AllergyIntolerance.swift +++ b/Sources/Models/AllergyIntolerance.swift @@ -224,7 +224,7 @@ public class AllergyIntolerance: DomainResource { json["criticality"] = criticality.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let lastOccurence = self.lastOccurence { json["lastOccurence"] = lastOccurence.asJSON() @@ -239,7 +239,7 @@ public class AllergyIntolerance: DomainResource { json["patient"] = patient.asJSON() } if let reaction = self.reaction { - json["reaction"] = AllergyIntoleranceReaction.asJSONArray(reaction) + json["reaction"] = reaction.map() { $0.asJSON() } } if let recordedDate = self.recordedDate { json["recordedDate"] = recordedDate.asJSON() @@ -406,7 +406,7 @@ public class AllergyIntoleranceReaction: BackboneElement { json["exposureRoute"] = exposureRoute.asJSON() } if let manifestation = self.manifestation { - json["manifestation"] = CodeableConcept.asJSONArray(manifestation) + json["manifestation"] = manifestation.map() { $0.asJSON() } } if let note = self.note { json["note"] = note.asJSON() diff --git a/Sources/Models/Appointment.swift b/Sources/Models/Appointment.swift index 6cfee9b2..ccbf6111 100644 --- a/Sources/Models/Appointment.swift +++ b/Sources/Models/Appointment.swift @@ -201,13 +201,13 @@ public class Appointment: DomainResource { json["end"] = end.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let minutesDuration = self.minutesDuration { json["minutesDuration"] = minutesDuration.asJSON() } if let participant = self.participant { - json["participant"] = AppointmentParticipant.asJSONArray(participant) + json["participant"] = participant.map() { $0.asJSON() } } if let priority = self.priority { json["priority"] = priority.asJSON() @@ -216,7 +216,7 @@ public class Appointment: DomainResource { json["reason"] = reason.asJSON() } if let slot = self.slot { - json["slot"] = Reference.asJSONArray(slot) + json["slot"] = slot.map() { $0.asJSON() } } if let start = self.start { json["start"] = start.asJSON() @@ -326,7 +326,7 @@ public class AppointmentParticipant: BackboneElement { json["status"] = status.asJSON() } if let type = self.type { - json["type"] = CodeableConcept.asJSONArray(type) + json["type"] = type.map() { $0.asJSON() } } return json diff --git a/Sources/Models/AppointmentResponse.swift b/Sources/Models/AppointmentResponse.swift index acb39211..d8f30b70 100644 --- a/Sources/Models/AppointmentResponse.swift +++ b/Sources/Models/AppointmentResponse.swift @@ -155,13 +155,13 @@ public class AppointmentResponse: DomainResource { json["end"] = end.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let participantStatus = self.participantStatus { json["participantStatus"] = participantStatus.asJSON() } if let participantType = self.participantType { - json["participantType"] = CodeableConcept.asJSONArray(participantType) + json["participantType"] = participantType.map() { $0.asJSON() } } if let start = self.start { json["start"] = start.asJSON() diff --git a/Sources/Models/AuditEvent.swift b/Sources/Models/AuditEvent.swift index 7b4610dc..10695f26 100644 --- a/Sources/Models/AuditEvent.swift +++ b/Sources/Models/AuditEvent.swift @@ -105,10 +105,10 @@ public class AuditEvent: DomainResource { json["event"] = event.asJSON() } if let object = self.object { - json["object"] = AuditEventObject.asJSONArray(object) + json["object"] = object.map() { $0.asJSON() } } if let participant = self.participant { - json["participant"] = AuditEventParticipant.asJSONArray(participant) + json["participant"] = participant.map() { $0.asJSON() } } if let source = self.source { json["source"] = source.asJSON() @@ -255,10 +255,10 @@ public class AuditEventEvent: BackboneElement { json["outcomeDesc"] = outcomeDesc.asJSON() } if let purposeOfEvent = self.purposeOfEvent { - json["purposeOfEvent"] = Coding.asJSONArray(purposeOfEvent) + json["purposeOfEvent"] = purposeOfEvent.map() { $0.asJSON() } } if let subtype = self.subtype { - json["subtype"] = Coding.asJSONArray(subtype) + json["subtype"] = subtype.map() { $0.asJSON() } } if let type = self.type { json["type"] = type.asJSON() @@ -417,7 +417,7 @@ public class AuditEventObject: BackboneElement { json["description"] = description_fhir.asJSON() } if let detail = self.detail { - json["detail"] = AuditEventObjectDetail.asJSONArray(detail) + json["detail"] = detail.map() { $0.asJSON() } } if let identifier = self.identifier { json["identifier"] = identifier.asJSON() @@ -438,7 +438,7 @@ public class AuditEventObject: BackboneElement { json["role"] = role.asJSON() } if let securityLabel = self.securityLabel { - json["securityLabel"] = Coding.asJSONArray(securityLabel) + json["securityLabel"] = securityLabel.map() { $0.asJSON() } } if let type = self.type { json["type"] = type.asJSON() @@ -710,7 +710,7 @@ public class AuditEventParticipant: BackboneElement { json["policy"] = arr } if let purposeOfUse = self.purposeOfUse { - json["purposeOfUse"] = Coding.asJSONArray(purposeOfUse) + json["purposeOfUse"] = purposeOfUse.map() { $0.asJSON() } } if let reference = self.reference { json["reference"] = reference.asJSON() @@ -719,7 +719,7 @@ public class AuditEventParticipant: BackboneElement { json["requestor"] = requestor.asJSON() } if let role = self.role { - json["role"] = CodeableConcept.asJSONArray(role) + json["role"] = role.map() { $0.asJSON() } } if let userId = self.userId { json["userId"] = userId.asJSON() @@ -868,7 +868,7 @@ public class AuditEventSource: BackboneElement { json["site"] = site.asJSON() } if let type = self.type { - json["type"] = Coding.asJSONArray(type) + json["type"] = type.map() { $0.asJSON() } } return json diff --git a/Sources/Models/BackboneElement.swift b/Sources/Models/BackboneElement.swift index 5b217dae..89b4134a 100644 --- a/Sources/Models/BackboneElement.swift +++ b/Sources/Models/BackboneElement.swift @@ -48,7 +48,7 @@ public class BackboneElement: Element { var json = super.asJSON() if let modifierExtension = self.modifierExtension { - json["modifierExtension"] = Extension.asJSONArray(modifierExtension) + json["modifierExtension"] = modifierExtension.map() { $0.asJSON() } } return json diff --git a/Sources/Models/Basic.swift b/Sources/Models/Basic.swift index 500790a4..28bac861 100644 --- a/Sources/Models/Basic.swift +++ b/Sources/Models/Basic.swift @@ -115,7 +115,7 @@ public class Basic: DomainResource { json["created"] = created.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let subject = self.subject { json["subject"] = subject.asJSON() diff --git a/Sources/Models/BodySite.swift b/Sources/Models/BodySite.swift index 24fbdc9c..661b672f 100644 --- a/Sources/Models/BodySite.swift +++ b/Sources/Models/BodySite.swift @@ -124,13 +124,13 @@ public class BodySite: DomainResource { json["description"] = description_fhir.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let image = self.image { - json["image"] = Attachment.asJSONArray(image) + json["image"] = image.map() { $0.asJSON() } } if let modifier = self.modifier { - json["modifier"] = CodeableConcept.asJSONArray(modifier) + json["modifier"] = modifier.map() { $0.asJSON() } } if let patient = self.patient { json["patient"] = patient.asJSON() diff --git a/Sources/Models/Bundle.swift b/Sources/Models/Bundle.swift index 88580932..10166233 100644 --- a/Sources/Models/Bundle.swift +++ b/Sources/Models/Bundle.swift @@ -105,10 +105,10 @@ public class Bundle: Resource { var json = super.asJSON() if let entry = self.entry { - json["entry"] = BundleEntry.asJSONArray(entry) + json["entry"] = entry.map() { $0.asJSON() } } if let link = self.link { - json["link"] = BundleLink.asJSONArray(link) + json["link"] = link.map() { $0.asJSON() } } if let signature = self.signature { json["signature"] = signature.asJSON() @@ -228,7 +228,7 @@ public class BundleEntry: BackboneElement { json["fullUrl"] = fullUrl.asJSON() } if let link = self.link { - json["link"] = BundleLink.asJSONArray(link) + json["link"] = link.map() { $0.asJSON() } } if let request = self.request { json["request"] = request.asJSON() diff --git a/Sources/Models/CarePlan.swift b/Sources/Models/CarePlan.swift index 27800ef3..f9bfe568 100644 --- a/Sources/Models/CarePlan.swift +++ b/Sources/Models/CarePlan.swift @@ -238,16 +238,16 @@ public class CarePlan: DomainResource { var json = super.asJSON() if let activity = self.activity { - json["activity"] = CarePlanActivity.asJSONArray(activity) + json["activity"] = activity.map() { $0.asJSON() } } if let addresses = self.addresses { - json["addresses"] = Reference.asJSONArray(addresses) + json["addresses"] = addresses.map() { $0.asJSON() } } if let author = self.author { - json["author"] = Reference.asJSONArray(author) + json["author"] = author.map() { $0.asJSON() } } if let category = self.category { - json["category"] = CodeableConcept.asJSONArray(category) + json["category"] = category.map() { $0.asJSON() } } if let context = self.context { json["context"] = context.asJSON() @@ -256,10 +256,10 @@ public class CarePlan: DomainResource { json["description"] = description_fhir.asJSON() } if let goal = self.goal { - json["goal"] = Reference.asJSONArray(goal) + json["goal"] = goal.map() { $0.asJSON() } } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let modified = self.modified { json["modified"] = modified.asJSON() @@ -268,13 +268,13 @@ public class CarePlan: DomainResource { json["note"] = note.asJSON() } if let participant = self.participant { - json["participant"] = CarePlanParticipant.asJSONArray(participant) + json["participant"] = participant.map() { $0.asJSON() } } if let period = self.period { json["period"] = period.asJSON() } if let relatedPlan = self.relatedPlan { - json["relatedPlan"] = CarePlanRelatedPlan.asJSONArray(relatedPlan) + json["relatedPlan"] = relatedPlan.map() { $0.asJSON() } } if let status = self.status { json["status"] = status.asJSON() @@ -283,7 +283,7 @@ public class CarePlan: DomainResource { json["subject"] = subject.asJSON() } if let support = self.support { - json["support"] = Reference.asJSONArray(support) + json["support"] = support.map() { $0.asJSON() } } return json @@ -367,13 +367,13 @@ public class CarePlanActivity: BackboneElement { var json = super.asJSON() if let actionResulting = self.actionResulting { - json["actionResulting"] = Reference.asJSONArray(actionResulting) + json["actionResulting"] = actionResulting.map() { $0.asJSON() } } if let detail = self.detail { json["detail"] = detail.asJSON() } if let progress = self.progress { - json["progress"] = Annotation.asJSONArray(progress) + json["progress"] = progress.map() { $0.asJSON() } } if let reference = self.reference { json["reference"] = reference.asJSON() @@ -649,13 +649,13 @@ public class CarePlanActivityDetail: BackboneElement { json["description"] = description_fhir.asJSON() } if let goal = self.goal { - json["goal"] = Reference.asJSONArray(goal) + json["goal"] = goal.map() { $0.asJSON() } } if let location = self.location { json["location"] = location.asJSON() } if let performer = self.performer { - json["performer"] = Reference.asJSONArray(performer) + json["performer"] = performer.map() { $0.asJSON() } } if let productCodeableConcept = self.productCodeableConcept { json["productCodeableConcept"] = productCodeableConcept.asJSON() @@ -670,10 +670,10 @@ public class CarePlanActivityDetail: BackboneElement { json["quantity"] = quantity.asJSON() } if let reasonCode = self.reasonCode { - json["reasonCode"] = CodeableConcept.asJSONArray(reasonCode) + json["reasonCode"] = reasonCode.map() { $0.asJSON() } } if let reasonReference = self.reasonReference { - json["reasonReference"] = Reference.asJSONArray(reasonReference) + json["reasonReference"] = reasonReference.map() { $0.asJSON() } } if let scheduledPeriod = self.scheduledPeriod { json["scheduledPeriod"] = scheduledPeriod.asJSON() diff --git a/Sources/Models/Claim.swift b/Sources/Models/Claim.swift index 3d9c2cb7..172a5a0d 100644 --- a/Sources/Models/Claim.swift +++ b/Sources/Models/Claim.swift @@ -404,25 +404,25 @@ public class Claim: DomainResource { json["accidentType"] = accidentType.asJSON() } if let additionalMaterials = self.additionalMaterials { - json["additionalMaterials"] = Coding.asJSONArray(additionalMaterials) + json["additionalMaterials"] = additionalMaterials.map() { $0.asJSON() } } if let condition = self.condition { - json["condition"] = Coding.asJSONArray(condition) + json["condition"] = condition.map() { $0.asJSON() } } if let coverage = self.coverage { - json["coverage"] = ClaimCoverage.asJSONArray(coverage) + json["coverage"] = coverage.map() { $0.asJSON() } } if let created = self.created { json["created"] = created.asJSON() } if let diagnosis = self.diagnosis { - json["diagnosis"] = ClaimDiagnosis.asJSONArray(diagnosis) + json["diagnosis"] = diagnosis.map() { $0.asJSON() } } if let enterer = self.enterer { json["enterer"] = enterer.asJSON() } if let exception = self.exception { - json["exception"] = Coding.asJSONArray(exception) + json["exception"] = exception.map() { $0.asJSON() } } if let facility = self.facility { json["facility"] = facility.asJSON() @@ -431,16 +431,16 @@ public class Claim: DomainResource { json["fundsReserve"] = fundsReserve.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let interventionException = self.interventionException { - json["interventionException"] = Coding.asJSONArray(interventionException) + json["interventionException"] = interventionException.map() { $0.asJSON() } } if let item = self.item { - json["item"] = ClaimItem.asJSONArray(item) + json["item"] = item.map() { $0.asJSON() } } if let missingTeeth = self.missingTeeth { - json["missingTeeth"] = ClaimMissingTeeth.asJSONArray(missingTeeth) + json["missingTeeth"] = missingTeeth.map() { $0.asJSON() } } if let organization = self.organization { json["organization"] = organization.asJSON() @@ -993,7 +993,7 @@ public class ClaimItem: BackboneElement { json["bodySite"] = bodySite.asJSON() } if let detail = self.detail { - json["detail"] = ClaimItemDetail.asJSONArray(detail) + json["detail"] = detail.map() { $0.asJSON() } } if let diagnosisLinkId = self.diagnosisLinkId { var arr = [Any]() @@ -1006,7 +1006,7 @@ public class ClaimItem: BackboneElement { json["factor"] = factor.asJSON() } if let modifier = self.modifier { - json["modifier"] = Coding.asJSONArray(modifier) + json["modifier"] = modifier.map() { $0.asJSON() } } if let net = self.net { json["net"] = net.asJSON() @@ -1033,7 +1033,7 @@ public class ClaimItem: BackboneElement { json["serviceDate"] = serviceDate.asJSON() } if let subSite = self.subSite { - json["subSite"] = Coding.asJSONArray(subSite) + json["subSite"] = subSite.map() { $0.asJSON() } } if let type = self.type { json["type"] = type.asJSON() @@ -1232,7 +1232,7 @@ public class ClaimItemDetail: BackboneElement { json["service"] = service.asJSON() } if let subDetail = self.subDetail { - json["subDetail"] = ClaimItemDetailSubDetail.asJSONArray(subDetail) + json["subDetail"] = subDetail.map() { $0.asJSON() } } if let type = self.type { json["type"] = type.asJSON() diff --git a/Sources/Models/ClaimResponse.swift b/Sources/Models/ClaimResponse.swift index dd979d42..31104afd 100644 --- a/Sources/Models/ClaimResponse.swift +++ b/Sources/Models/ClaimResponse.swift @@ -348,10 +348,10 @@ public class ClaimResponse: DomainResource { var json = super.asJSON() if let addItem = self.addItem { - json["addItem"] = ClaimResponseAddItem.asJSONArray(addItem) + json["addItem"] = addItem.map() { $0.asJSON() } } if let coverage = self.coverage { - json["coverage"] = ClaimResponseCoverage.asJSONArray(coverage) + json["coverage"] = coverage.map() { $0.asJSON() } } if let created = self.created { json["created"] = created.asJSON() @@ -360,19 +360,19 @@ public class ClaimResponse: DomainResource { json["disposition"] = disposition.asJSON() } if let error = self.error { - json["error"] = ClaimResponseError.asJSONArray(error) + json["error"] = error.map() { $0.asJSON() } } if let form = self.form { json["form"] = form.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let item = self.item { - json["item"] = ClaimResponseItem.asJSONArray(item) + json["item"] = item.map() { $0.asJSON() } } if let note = self.note { - json["note"] = ClaimResponseNote.asJSONArray(note) + json["note"] = note.map() { $0.asJSON() } } if let organization = self.organization { json["organization"] = organization.asJSON() @@ -539,10 +539,10 @@ public class ClaimResponseAddItem: BackboneElement { var json = super.asJSON() if let adjudication = self.adjudication { - json["adjudication"] = ClaimResponseAddItemAdjudication.asJSONArray(adjudication) + json["adjudication"] = adjudication.map() { $0.asJSON() } } if let detail = self.detail { - json["detail"] = ClaimResponseAddItemDetail.asJSONArray(detail) + json["detail"] = detail.map() { $0.asJSON() } } if let fee = self.fee { json["fee"] = fee.asJSON() @@ -728,7 +728,7 @@ public class ClaimResponseAddItemDetail: BackboneElement { var json = super.asJSON() if let adjudication = self.adjudication { - json["adjudication"] = ClaimResponseAddItemDetailAdjudication.asJSONArray(adjudication) + json["adjudication"] = adjudication.map() { $0.asJSON() } } if let fee = self.fee { json["fee"] = fee.asJSON() @@ -1190,10 +1190,10 @@ public class ClaimResponseItem: BackboneElement { var json = super.asJSON() if let adjudication = self.adjudication { - json["adjudication"] = ClaimResponseItemAdjudication.asJSONArray(adjudication) + json["adjudication"] = adjudication.map() { $0.asJSON() } } if let detail = self.detail { - json["detail"] = ClaimResponseItemDetail.asJSONArray(detail) + json["detail"] = detail.map() { $0.asJSON() } } if let noteNumber = self.noteNumber { var arr = [Any]() @@ -1369,13 +1369,13 @@ public class ClaimResponseItemDetail: BackboneElement { var json = super.asJSON() if let adjudication = self.adjudication { - json["adjudication"] = ClaimResponseItemDetailAdjudication.asJSONArray(adjudication) + json["adjudication"] = adjudication.map() { $0.asJSON() } } if let sequenceLinkId = self.sequenceLinkId { json["sequenceLinkId"] = sequenceLinkId.asJSON() } if let subDetail = self.subDetail { - json["subDetail"] = ClaimResponseItemDetailSubDetail.asJSONArray(subDetail) + json["subDetail"] = subDetail.map() { $0.asJSON() } } return json @@ -1529,7 +1529,7 @@ public class ClaimResponseItemDetailSubDetail: BackboneElement { var json = super.asJSON() if let adjudication = self.adjudication { - json["adjudication"] = ClaimResponseItemDetailSubDetailAdjudication.asJSONArray(adjudication) + json["adjudication"] = adjudication.map() { $0.asJSON() } } if let sequenceLinkId = self.sequenceLinkId { json["sequenceLinkId"] = sequenceLinkId.asJSON() diff --git a/Sources/Models/ClinicalImpression.swift b/Sources/Models/ClinicalImpression.swift index be44cfa2..23a3be23 100644 --- a/Sources/Models/ClinicalImpression.swift +++ b/Sources/Models/ClinicalImpression.swift @@ -269,7 +269,7 @@ public class ClinicalImpression: DomainResource { var json = super.asJSON() if let action = self.action { - json["action"] = Reference.asJSONArray(action) + json["action"] = action.map() { $0.asJSON() } } if let assessor = self.assessor { json["assessor"] = assessor.asJSON() @@ -281,22 +281,22 @@ public class ClinicalImpression: DomainResource { json["description"] = description_fhir.asJSON() } if let finding = self.finding { - json["finding"] = ClinicalImpressionFinding.asJSONArray(finding) + json["finding"] = finding.map() { $0.asJSON() } } if let investigations = self.investigations { - json["investigations"] = ClinicalImpressionInvestigations.asJSONArray(investigations) + json["investigations"] = investigations.map() { $0.asJSON() } } if let patient = self.patient { json["patient"] = patient.asJSON() } if let plan = self.plan { - json["plan"] = Reference.asJSONArray(plan) + json["plan"] = plan.map() { $0.asJSON() } } if let previous = self.previous { json["previous"] = previous.asJSON() } if let problem = self.problem { - json["problem"] = Reference.asJSONArray(problem) + json["problem"] = problem.map() { $0.asJSON() } } if let prognosis = self.prognosis { json["prognosis"] = prognosis.asJSON() @@ -305,10 +305,10 @@ public class ClinicalImpression: DomainResource { json["protocol"] = protocol_fhir.asJSON() } if let resolved = self.resolved { - json["resolved"] = CodeableConcept.asJSONArray(resolved) + json["resolved"] = resolved.map() { $0.asJSON() } } if let ruledOut = self.ruledOut { - json["ruledOut"] = ClinicalImpressionRuledOut.asJSONArray(ruledOut) + json["ruledOut"] = ruledOut.map() { $0.asJSON() } } if let status = self.status { json["status"] = status.asJSON() @@ -464,7 +464,7 @@ public class ClinicalImpressionInvestigations: BackboneElement { json["code"] = code.asJSON() } if let item = self.item { - json["item"] = Reference.asJSONArray(item) + json["item"] = item.map() { $0.asJSON() } } return json diff --git a/Sources/Models/CodeableConcept.swift b/Sources/Models/CodeableConcept.swift index 948ae9b7..d601a68e 100644 --- a/Sources/Models/CodeableConcept.swift +++ b/Sources/Models/CodeableConcept.swift @@ -60,7 +60,7 @@ public class CodeableConcept: Element { var json = super.asJSON() if let coding = self.coding { - json["coding"] = Coding.asJSONArray(coding) + json["coding"] = coding.map() { $0.asJSON() } } if let text = self.text { json["text"] = text.asJSON() diff --git a/Sources/Models/Communication.swift b/Sources/Models/Communication.swift index 617030d3..96045f36 100644 --- a/Sources/Models/Communication.swift +++ b/Sources/Models/Communication.swift @@ -199,22 +199,22 @@ public class Communication: DomainResource { json["encounter"] = encounter.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let medium = self.medium { - json["medium"] = CodeableConcept.asJSONArray(medium) + json["medium"] = medium.map() { $0.asJSON() } } if let payload = self.payload { - json["payload"] = CommunicationPayload.asJSONArray(payload) + json["payload"] = payload.map() { $0.asJSON() } } if let reason = self.reason { - json["reason"] = CodeableConcept.asJSONArray(reason) + json["reason"] = reason.map() { $0.asJSON() } } if let received = self.received { json["received"] = received.asJSON() } if let recipient = self.recipient { - json["recipient"] = Reference.asJSONArray(recipient) + json["recipient"] = recipient.map() { $0.asJSON() } } if let requestDetail = self.requestDetail { json["requestDetail"] = requestDetail.asJSON() diff --git a/Sources/Models/CommunicationRequest.swift b/Sources/Models/CommunicationRequest.swift index b9ff1dbe..57be9093 100644 --- a/Sources/Models/CommunicationRequest.swift +++ b/Sources/Models/CommunicationRequest.swift @@ -223,22 +223,22 @@ public class CommunicationRequest: DomainResource { json["encounter"] = encounter.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let medium = self.medium { - json["medium"] = CodeableConcept.asJSONArray(medium) + json["medium"] = medium.map() { $0.asJSON() } } if let payload = self.payload { - json["payload"] = CommunicationRequestPayload.asJSONArray(payload) + json["payload"] = payload.map() { $0.asJSON() } } if let priority = self.priority { json["priority"] = priority.asJSON() } if let reason = self.reason { - json["reason"] = CodeableConcept.asJSONArray(reason) + json["reason"] = reason.map() { $0.asJSON() } } if let recipient = self.recipient { - json["recipient"] = Reference.asJSONArray(recipient) + json["recipient"] = recipient.map() { $0.asJSON() } } if let requestedOn = self.requestedOn { json["requestedOn"] = requestedOn.asJSON() diff --git a/Sources/Models/Composition.swift b/Sources/Models/Composition.swift index 97b42ac5..63edd741 100644 --- a/Sources/Models/Composition.swift +++ b/Sources/Models/Composition.swift @@ -237,10 +237,10 @@ public class Composition: DomainResource { var json = super.asJSON() if let attester = self.attester { - json["attester"] = CompositionAttester.asJSONArray(attester) + json["attester"] = attester.map() { $0.asJSON() } } if let author = self.author { - json["author"] = Reference.asJSONArray(author) + json["author"] = author.map() { $0.asJSON() } } if let class_fhir = self.class_fhir { json["class"] = class_fhir.asJSON() @@ -258,13 +258,13 @@ public class Composition: DomainResource { json["encounter"] = encounter.asJSON() } if let event = self.event { - json["event"] = CompositionEvent.asJSONArray(event) + json["event"] = event.map() { $0.asJSON() } } if let identifier = self.identifier { json["identifier"] = identifier.asJSON() } if let section = self.section { - json["section"] = CompositionSection.asJSONArray(section) + json["section"] = section.map() { $0.asJSON() } } if let status = self.status { json["status"] = status.asJSON() @@ -437,10 +437,10 @@ public class CompositionEvent: BackboneElement { var json = super.asJSON() if let code = self.code { - json["code"] = CodeableConcept.asJSONArray(code) + json["code"] = code.map() { $0.asJSON() } } if let detail = self.detail { - json["detail"] = Reference.asJSONArray(detail) + json["detail"] = detail.map() { $0.asJSON() } } if let period = self.period { json["period"] = period.asJSON() @@ -580,7 +580,7 @@ public class CompositionSection: BackboneElement { json["emptyReason"] = emptyReason.asJSON() } if let entry = self.entry { - json["entry"] = Reference.asJSONArray(entry) + json["entry"] = entry.map() { $0.asJSON() } } if let mode = self.mode { json["mode"] = mode.asJSON() @@ -589,7 +589,7 @@ public class CompositionSection: BackboneElement { json["orderedBy"] = orderedBy.asJSON() } if let section = self.section { - json["section"] = CompositionSection.asJSONArray(section) + json["section"] = section.map() { $0.asJSON() } } if let text = self.text { json["text"] = text.asJSON() diff --git a/Sources/Models/ConceptMap.swift b/Sources/Models/ConceptMap.swift index 4e6ff4ab..a014f75b 100644 --- a/Sources/Models/ConceptMap.swift +++ b/Sources/Models/ConceptMap.swift @@ -274,7 +274,7 @@ public class ConceptMap: DomainResource { var json = super.asJSON() if let contact = self.contact { - json["contact"] = ConceptMapContact.asJSONArray(contact) + json["contact"] = contact.map() { $0.asJSON() } } if let copyright = self.copyright { json["copyright"] = copyright.asJSON() @@ -286,7 +286,7 @@ public class ConceptMap: DomainResource { json["description"] = description_fhir.asJSON() } if let element = self.element { - json["element"] = ConceptMapElement.asJSONArray(element) + json["element"] = element.map() { $0.asJSON() } } if let experimental = self.experimental { json["experimental"] = experimental.asJSON() @@ -322,7 +322,7 @@ public class ConceptMap: DomainResource { json["url"] = url.asJSON() } if let useContext = self.useContext { - json["useContext"] = CodeableConcept.asJSONArray(useContext) + json["useContext"] = useContext.map() { $0.asJSON() } } if let version = self.version { json["version"] = version.asJSON() @@ -387,7 +387,7 @@ public class ConceptMapContact: BackboneElement { json["name"] = name.asJSON() } if let telecom = self.telecom { - json["telecom"] = ContactPoint.asJSONArray(telecom) + json["telecom"] = telecom.map() { $0.asJSON() } } return json @@ -464,7 +464,7 @@ public class ConceptMapElement: BackboneElement { json["codeSystem"] = codeSystem.asJSON() } if let target = self.target { - json["target"] = ConceptMapElementTarget.asJSONArray(target) + json["target"] = target.map() { $0.asJSON() } } return json @@ -589,13 +589,13 @@ public class ConceptMapElementTarget: BackboneElement { json["comments"] = comments.asJSON() } if let dependsOn = self.dependsOn { - json["dependsOn"] = ConceptMapElementTargetDependsOn.asJSONArray(dependsOn) + json["dependsOn"] = dependsOn.map() { $0.asJSON() } } if let equivalence = self.equivalence { json["equivalence"] = equivalence.asJSON() } if let product = self.product { - json["product"] = ConceptMapElementTargetDependsOn.asJSONArray(product) + json["product"] = product.map() { $0.asJSON() } } return json diff --git a/Sources/Models/Condition.swift b/Sources/Models/Condition.swift index 4c5135a7..313f517f 100644 --- a/Sources/Models/Condition.swift +++ b/Sources/Models/Condition.swift @@ -376,7 +376,7 @@ public class Condition: DomainResource { json["asserter"] = asserter.asJSON() } if let bodySite = self.bodySite { - json["bodySite"] = CodeableConcept.asJSONArray(bodySite) + json["bodySite"] = bodySite.map() { $0.asJSON() } } if let category = self.category { json["category"] = category.asJSON() @@ -394,10 +394,10 @@ public class Condition: DomainResource { json["encounter"] = encounter.asJSON() } if let evidence = self.evidence { - json["evidence"] = ConditionEvidence.asJSONArray(evidence) + json["evidence"] = evidence.map() { $0.asJSON() } } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let notes = self.notes { json["notes"] = notes.asJSON() @@ -489,7 +489,7 @@ public class ConditionEvidence: BackboneElement { json["code"] = code.asJSON() } if let detail = self.detail { - json["detail"] = Reference.asJSONArray(detail) + json["detail"] = detail.map() { $0.asJSON() } } return json @@ -548,7 +548,7 @@ public class ConditionStage: BackboneElement { var json = super.asJSON() if let assessment = self.assessment { - json["assessment"] = Reference.asJSONArray(assessment) + json["assessment"] = assessment.map() { $0.asJSON() } } if let summary = self.summary { json["summary"] = summary.asJSON() diff --git a/Sources/Models/Conformance.swift b/Sources/Models/Conformance.swift index 7e116c75..2ef6ebca 100644 --- a/Sources/Models/Conformance.swift +++ b/Sources/Models/Conformance.swift @@ -317,7 +317,7 @@ public class Conformance: DomainResource { json["acceptUnknown"] = acceptUnknown.asJSON() } if let contact = self.contact { - json["contact"] = ConformanceContact.asJSONArray(contact) + json["contact"] = contact.map() { $0.asJSON() } } if let copyright = self.copyright { json["copyright"] = copyright.asJSON() @@ -329,7 +329,7 @@ public class Conformance: DomainResource { json["description"] = description_fhir.asJSON() } if let document = self.document { - json["document"] = ConformanceDocument.asJSONArray(document) + json["document"] = document.map() { $0.asJSON() } } if let experimental = self.experimental { json["experimental"] = experimental.asJSON() @@ -351,13 +351,13 @@ public class Conformance: DomainResource { json["kind"] = kind.asJSON() } if let messaging = self.messaging { - json["messaging"] = ConformanceMessaging.asJSONArray(messaging) + json["messaging"] = messaging.map() { $0.asJSON() } } if let name = self.name { json["name"] = name.asJSON() } if let profile = self.profile { - json["profile"] = Reference.asJSONArray(profile) + json["profile"] = profile.map() { $0.asJSON() } } if let publisher = self.publisher { json["publisher"] = publisher.asJSON() @@ -366,7 +366,7 @@ public class Conformance: DomainResource { json["requirements"] = requirements.asJSON() } if let rest = self.rest { - json["rest"] = ConformanceRest.asJSONArray(rest) + json["rest"] = rest.map() { $0.asJSON() } } if let software = self.software { json["software"] = software.asJSON() @@ -440,7 +440,7 @@ public class ConformanceContact: BackboneElement { json["name"] = name.asJSON() } if let telecom = self.telecom { - json["telecom"] = ContactPoint.asJSONArray(telecom) + json["telecom"] = telecom.map() { $0.asJSON() } } return json @@ -697,10 +697,10 @@ public class ConformanceMessaging: BackboneElement { json["documentation"] = documentation.asJSON() } if let endpoint = self.endpoint { - json["endpoint"] = ConformanceMessagingEndpoint.asJSONArray(endpoint) + json["endpoint"] = endpoint.map() { $0.asJSON() } } if let event = self.event { - json["event"] = ConformanceMessagingEvent.asJSONArray(event) + json["event"] = event.map() { $0.asJSON() } } if let reliableCache = self.reliableCache { json["reliableCache"] = reliableCache.asJSON() @@ -1106,19 +1106,19 @@ public class ConformanceRest: BackboneElement { json["documentation"] = documentation.asJSON() } if let interaction = self.interaction { - json["interaction"] = ConformanceRestInteraction.asJSONArray(interaction) + json["interaction"] = interaction.map() { $0.asJSON() } } if let mode = self.mode { json["mode"] = mode.asJSON() } if let operation = self.operation { - json["operation"] = ConformanceRestOperation.asJSONArray(operation) + json["operation"] = operation.map() { $0.asJSON() } } if let resource = self.resource { - json["resource"] = ConformanceRestResource.asJSONArray(resource) + json["resource"] = resource.map() { $0.asJSON() } } if let searchParam = self.searchParam { - json["searchParam"] = ConformanceRestResourceSearchParam.asJSONArray(searchParam) + json["searchParam"] = searchParam.map() { $0.asJSON() } } if let security = self.security { json["security"] = security.asJSON() @@ -1471,7 +1471,7 @@ public class ConformanceRestResource: BackboneElement { json["conditionalUpdate"] = conditionalUpdate.asJSON() } if let interaction = self.interaction { - json["interaction"] = ConformanceRestResourceInteraction.asJSONArray(interaction) + json["interaction"] = interaction.map() { $0.asJSON() } } if let profile = self.profile { json["profile"] = profile.asJSON() @@ -1487,7 +1487,7 @@ public class ConformanceRestResource: BackboneElement { json["searchInclude"] = arr } if let searchParam = self.searchParam { - json["searchParam"] = ConformanceRestResourceSearchParam.asJSONArray(searchParam) + json["searchParam"] = searchParam.map() { $0.asJSON() } } if let searchRevInclude = self.searchRevInclude { var arr = [Any]() @@ -1820,7 +1820,7 @@ public class ConformanceRestSecurity: BackboneElement { var json = super.asJSON() if let certificate = self.certificate { - json["certificate"] = ConformanceRestSecurityCertificate.asJSONArray(certificate) + json["certificate"] = certificate.map() { $0.asJSON() } } if let cors = self.cors { json["cors"] = cors.asJSON() @@ -1829,7 +1829,7 @@ public class ConformanceRestSecurity: BackboneElement { json["description"] = description_fhir.asJSON() } if let service = self.service { - json["service"] = CodeableConcept.asJSONArray(service) + json["service"] = service.map() { $0.asJSON() } } return json diff --git a/Sources/Models/Contract.swift b/Sources/Models/Contract.swift index 10f0e052..8857851d 100644 --- a/Sources/Models/Contract.swift +++ b/Sources/Models/Contract.swift @@ -264,19 +264,19 @@ public class Contract: DomainResource { var json = super.asJSON() if let action = self.action { - json["action"] = CodeableConcept.asJSONArray(action) + json["action"] = action.map() { $0.asJSON() } } if let actionReason = self.actionReason { - json["actionReason"] = CodeableConcept.asJSONArray(actionReason) + json["actionReason"] = actionReason.map() { $0.asJSON() } } if let actor = self.actor { - json["actor"] = ContractActor.asJSONArray(actor) + json["actor"] = actor.map() { $0.asJSON() } } if let applies = self.applies { json["applies"] = applies.asJSON() } if let authority = self.authority { - json["authority"] = Reference.asJSONArray(authority) + json["authority"] = authority.map() { $0.asJSON() } } if let bindingAttachment = self.bindingAttachment { json["bindingAttachment"] = bindingAttachment.asJSON() @@ -285,10 +285,10 @@ public class Contract: DomainResource { json["bindingReference"] = bindingReference.asJSON() } if let domain = self.domain { - json["domain"] = Reference.asJSONArray(domain) + json["domain"] = domain.map() { $0.asJSON() } } if let friendly = self.friendly { - json["friendly"] = ContractFriendly.asJSONArray(friendly) + json["friendly"] = friendly.map() { $0.asJSON() } } if let identifier = self.identifier { json["identifier"] = identifier.asJSON() @@ -297,28 +297,28 @@ public class Contract: DomainResource { json["issued"] = issued.asJSON() } if let legal = self.legal { - json["legal"] = ContractLegal.asJSONArray(legal) + json["legal"] = legal.map() { $0.asJSON() } } if let rule = self.rule { - json["rule"] = ContractRule.asJSONArray(rule) + json["rule"] = rule.map() { $0.asJSON() } } if let signer = self.signer { - json["signer"] = ContractSigner.asJSONArray(signer) + json["signer"] = signer.map() { $0.asJSON() } } if let subType = self.subType { - json["subType"] = CodeableConcept.asJSONArray(subType) + json["subType"] = subType.map() { $0.asJSON() } } if let subject = self.subject { - json["subject"] = Reference.asJSONArray(subject) + json["subject"] = subject.map() { $0.asJSON() } } if let term = self.term { - json["term"] = ContractTerm.asJSONArray(term) + json["term"] = term.map() { $0.asJSON() } } if let type = self.type { json["type"] = type.asJSON() } if let valuedItem = self.valuedItem { - json["valuedItem"] = ContractValuedItem.asJSONArray(valuedItem) + json["valuedItem"] = valuedItem.map() { $0.asJSON() } } return json @@ -389,7 +389,7 @@ public class ContractActor: BackboneElement { json["entity"] = entity.asJSON() } if let role = self.role { - json["role"] = CodeableConcept.asJSONArray(role) + json["role"] = role.map() { $0.asJSON() } } return json @@ -887,19 +887,19 @@ public class ContractTerm: BackboneElement { var json = super.asJSON() if let action = self.action { - json["action"] = CodeableConcept.asJSONArray(action) + json["action"] = action.map() { $0.asJSON() } } if let actionReason = self.actionReason { - json["actionReason"] = CodeableConcept.asJSONArray(actionReason) + json["actionReason"] = actionReason.map() { $0.asJSON() } } if let actor = self.actor { - json["actor"] = ContractTermActor.asJSONArray(actor) + json["actor"] = actor.map() { $0.asJSON() } } if let applies = self.applies { json["applies"] = applies.asJSON() } if let group = self.group { - json["group"] = ContractTerm.asJSONArray(group) + json["group"] = group.map() { $0.asJSON() } } if let identifier = self.identifier { json["identifier"] = identifier.asJSON() @@ -920,7 +920,7 @@ public class ContractTerm: BackboneElement { json["type"] = type.asJSON() } if let valuedItem = self.valuedItem { - json["valuedItem"] = ContractTermValuedItem.asJSONArray(valuedItem) + json["valuedItem"] = valuedItem.map() { $0.asJSON() } } return json @@ -991,7 +991,7 @@ public class ContractTermActor: BackboneElement { json["entity"] = entity.asJSON() } if let role = self.role { - json["role"] = CodeableConcept.asJSONArray(role) + json["role"] = role.map() { $0.asJSON() } } return json diff --git a/Sources/Models/Coverage.swift b/Sources/Models/Coverage.swift index cfdc5f2f..e43bbf28 100644 --- a/Sources/Models/Coverage.swift +++ b/Sources/Models/Coverage.swift @@ -207,7 +207,7 @@ public class Coverage: DomainResource { json["bin"] = bin.asJSON() } if let contract = self.contract { - json["contract"] = Reference.asJSONArray(contract) + json["contract"] = contract.map() { $0.asJSON() } } if let dependent = self.dependent { json["dependent"] = dependent.asJSON() @@ -216,7 +216,7 @@ public class Coverage: DomainResource { json["group"] = group.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let issuer = self.issuer { json["issuer"] = issuer.asJSON() diff --git a/Sources/Models/DataElement.swift b/Sources/Models/DataElement.swift index cf07bf6d..7fe6cb30 100644 --- a/Sources/Models/DataElement.swift +++ b/Sources/Models/DataElement.swift @@ -217,7 +217,7 @@ public class DataElement: DomainResource { var json = super.asJSON() if let contact = self.contact { - json["contact"] = DataElementContact.asJSONArray(contact) + json["contact"] = contact.map() { $0.asJSON() } } if let copyright = self.copyright { json["copyright"] = copyright.asJSON() @@ -226,16 +226,16 @@ public class DataElement: DomainResource { json["date"] = date.asJSON() } if let element = self.element { - json["element"] = ElementDefinition.asJSONArray(element) + json["element"] = element.map() { $0.asJSON() } } if let experimental = self.experimental { json["experimental"] = experimental.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let mapping = self.mapping { - json["mapping"] = DataElementMapping.asJSONArray(mapping) + json["mapping"] = mapping.map() { $0.asJSON() } } if let name = self.name { json["name"] = name.asJSON() @@ -253,7 +253,7 @@ public class DataElement: DomainResource { json["url"] = url.asJSON() } if let useContext = self.useContext { - json["useContext"] = CodeableConcept.asJSONArray(useContext) + json["useContext"] = useContext.map() { $0.asJSON() } } if let version = self.version { json["version"] = version.asJSON() @@ -318,7 +318,7 @@ public class DataElementContact: BackboneElement { json["name"] = name.asJSON() } if let telecom = self.telecom { - json["telecom"] = ContactPoint.asJSONArray(telecom) + json["telecom"] = telecom.map() { $0.asJSON() } } return json diff --git a/Sources/Models/DetectedIssue.swift b/Sources/Models/DetectedIssue.swift index 3a551338..68d15a2b 100644 --- a/Sources/Models/DetectedIssue.swift +++ b/Sources/Models/DetectedIssue.swift @@ -172,10 +172,10 @@ public class DetectedIssue: DomainResource { json["identifier"] = identifier.asJSON() } if let implicated = self.implicated { - json["implicated"] = Reference.asJSONArray(implicated) + json["implicated"] = implicated.map() { $0.asJSON() } } if let mitigation = self.mitigation { - json["mitigation"] = DetectedIssueMitigation.asJSONArray(mitigation) + json["mitigation"] = mitigation.map() { $0.asJSON() } } if let patient = self.patient { json["patient"] = patient.asJSON() diff --git a/Sources/Models/Device.swift b/Sources/Models/Device.swift index 353b9732..704eb0f2 100644 --- a/Sources/Models/Device.swift +++ b/Sources/Models/Device.swift @@ -241,13 +241,13 @@ public class Device: DomainResource { var json = super.asJSON() if let contact = self.contact { - json["contact"] = ContactPoint.asJSONArray(contact) + json["contact"] = contact.map() { $0.asJSON() } } if let expiry = self.expiry { json["expiry"] = expiry.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let location = self.location { json["location"] = location.asJSON() @@ -265,7 +265,7 @@ public class Device: DomainResource { json["model"] = model.asJSON() } if let note = self.note { - json["note"] = Annotation.asJSONArray(note) + json["note"] = note.map() { $0.asJSON() } } if let owner = self.owner { json["owner"] = owner.asJSON() diff --git a/Sources/Models/DeviceComponent.swift b/Sources/Models/DeviceComponent.swift index 3f069f21..89a25917 100644 --- a/Sources/Models/DeviceComponent.swift +++ b/Sources/Models/DeviceComponent.swift @@ -186,7 +186,7 @@ public class DeviceComponent: DomainResource { json["measurementPrinciple"] = measurementPrinciple.asJSON() } if let operationalStatus = self.operationalStatus { - json["operationalStatus"] = CodeableConcept.asJSONArray(operationalStatus) + json["operationalStatus"] = operationalStatus.map() { $0.asJSON() } } if let parameterGroup = self.parameterGroup { json["parameterGroup"] = parameterGroup.asJSON() @@ -195,7 +195,7 @@ public class DeviceComponent: DomainResource { json["parent"] = parent.asJSON() } if let productionSpecification = self.productionSpecification { - json["productionSpecification"] = DeviceComponentProductionSpecification.asJSONArray(productionSpecification) + json["productionSpecification"] = productionSpecification.map() { $0.asJSON() } } if let source = self.source { json["source"] = source.asJSON() diff --git a/Sources/Models/DeviceMetric.swift b/Sources/Models/DeviceMetric.swift index 54506872..40b944e7 100644 --- a/Sources/Models/DeviceMetric.swift +++ b/Sources/Models/DeviceMetric.swift @@ -173,7 +173,7 @@ public class DeviceMetric: DomainResource { var json = super.asJSON() if let calibration = self.calibration { - json["calibration"] = DeviceMetricCalibration.asJSONArray(calibration) + json["calibration"] = calibration.map() { $0.asJSON() } } if let category = self.category { json["category"] = category.asJSON() diff --git a/Sources/Models/DeviceUseRequest.swift b/Sources/Models/DeviceUseRequest.swift index d112142b..b2990909 100644 --- a/Sources/Models/DeviceUseRequest.swift +++ b/Sources/Models/DeviceUseRequest.swift @@ -254,10 +254,10 @@ public class DeviceUseRequest: DomainResource { json["encounter"] = encounter.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let indication = self.indication { - json["indication"] = CodeableConcept.asJSONArray(indication) + json["indication"] = indication.map() { $0.asJSON() } } if let notes = self.notes { var arr = [Any]() @@ -273,7 +273,7 @@ public class DeviceUseRequest: DomainResource { json["priority"] = priority.asJSON() } if let prnReason = self.prnReason { - json["prnReason"] = CodeableConcept.asJSONArray(prnReason) + json["prnReason"] = prnReason.map() { $0.asJSON() } } if let recordedOn = self.recordedOn { json["recordedOn"] = recordedOn.asJSON() diff --git a/Sources/Models/DeviceUseStatement.swift b/Sources/Models/DeviceUseStatement.swift index e439bea1..765e53b4 100644 --- a/Sources/Models/DeviceUseStatement.swift +++ b/Sources/Models/DeviceUseStatement.swift @@ -203,10 +203,10 @@ public class DeviceUseStatement: DomainResource { json["device"] = device.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let indication = self.indication { - json["indication"] = CodeableConcept.asJSONArray(indication) + json["indication"] = indication.map() { $0.asJSON() } } if let notes = self.notes { var arr = [Any]() diff --git a/Sources/Models/DiagnosticOrder.swift b/Sources/Models/DiagnosticOrder.swift index 8ea8c4dc..6553d394 100644 --- a/Sources/Models/DiagnosticOrder.swift +++ b/Sources/Models/DiagnosticOrder.swift @@ -192,16 +192,16 @@ public class DiagnosticOrder: DomainResource { json["encounter"] = encounter.asJSON() } if let event = self.event { - json["event"] = DiagnosticOrderEvent.asJSONArray(event) + json["event"] = event.map() { $0.asJSON() } } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let item = self.item { - json["item"] = DiagnosticOrderItem.asJSONArray(item) + json["item"] = item.map() { $0.asJSON() } } if let note = self.note { - json["note"] = Annotation.asJSONArray(note) + json["note"] = note.map() { $0.asJSON() } } if let orderer = self.orderer { json["orderer"] = orderer.asJSON() @@ -210,10 +210,10 @@ public class DiagnosticOrder: DomainResource { json["priority"] = priority.asJSON() } if let reason = self.reason { - json["reason"] = CodeableConcept.asJSONArray(reason) + json["reason"] = reason.map() { $0.asJSON() } } if let specimen = self.specimen { - json["specimen"] = Reference.asJSONArray(specimen) + json["specimen"] = specimen.map() { $0.asJSON() } } if let status = self.status { json["status"] = status.asJSON() @@ -222,7 +222,7 @@ public class DiagnosticOrder: DomainResource { json["subject"] = subject.asJSON() } if let supportingInformation = self.supportingInformation { - json["supportingInformation"] = Reference.asJSONArray(supportingInformation) + json["supportingInformation"] = supportingInformation.map() { $0.asJSON() } } return json @@ -439,10 +439,10 @@ public class DiagnosticOrderItem: BackboneElement { json["code"] = code.asJSON() } if let event = self.event { - json["event"] = DiagnosticOrderEvent.asJSONArray(event) + json["event"] = event.map() { $0.asJSON() } } if let specimen = self.specimen { - json["specimen"] = Reference.asJSONArray(specimen) + json["specimen"] = specimen.map() { $0.asJSON() } } if let status = self.status { json["status"] = status.asJSON() diff --git a/Sources/Models/DiagnosticReport.swift b/Sources/Models/DiagnosticReport.swift index 8d53536c..1e88e0fd 100644 --- a/Sources/Models/DiagnosticReport.swift +++ b/Sources/Models/DiagnosticReport.swift @@ -294,7 +294,7 @@ public class DiagnosticReport: DomainResource { json["code"] = code.asJSON() } if let codedDiagnosis = self.codedDiagnosis { - json["codedDiagnosis"] = CodeableConcept.asJSONArray(codedDiagnosis) + json["codedDiagnosis"] = codedDiagnosis.map() { $0.asJSON() } } if let conclusion = self.conclusion { json["conclusion"] = conclusion.asJSON() @@ -309,13 +309,13 @@ public class DiagnosticReport: DomainResource { json["encounter"] = encounter.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let image = self.image { - json["image"] = DiagnosticReportImage.asJSONArray(image) + json["image"] = image.map() { $0.asJSON() } } if let imagingStudy = self.imagingStudy { - json["imagingStudy"] = Reference.asJSONArray(imagingStudy) + json["imagingStudy"] = imagingStudy.map() { $0.asJSON() } } if let issued = self.issued { json["issued"] = issued.asJSON() @@ -324,16 +324,16 @@ public class DiagnosticReport: DomainResource { json["performer"] = performer.asJSON() } if let presentedForm = self.presentedForm { - json["presentedForm"] = Attachment.asJSONArray(presentedForm) + json["presentedForm"] = presentedForm.map() { $0.asJSON() } } if let request = self.request { - json["request"] = Reference.asJSONArray(request) + json["request"] = request.map() { $0.asJSON() } } if let result = self.result { - json["result"] = Reference.asJSONArray(result) + json["result"] = result.map() { $0.asJSON() } } if let specimen = self.specimen { - json["specimen"] = Reference.asJSONArray(specimen) + json["specimen"] = specimen.map() { $0.asJSON() } } if let status = self.status { json["status"] = status.asJSON() diff --git a/Sources/Models/DocumentManifest.swift b/Sources/Models/DocumentManifest.swift index 8fa0f3c0..71479241 100644 --- a/Sources/Models/DocumentManifest.swift +++ b/Sources/Models/DocumentManifest.swift @@ -191,10 +191,10 @@ public class DocumentManifest: DomainResource { var json = super.asJSON() if let author = self.author { - json["author"] = Reference.asJSONArray(author) + json["author"] = author.map() { $0.asJSON() } } if let content = self.content { - json["content"] = DocumentManifestContent.asJSONArray(content) + json["content"] = content.map() { $0.asJSON() } } if let created = self.created { json["created"] = created.asJSON() @@ -203,16 +203,16 @@ public class DocumentManifest: DomainResource { json["description"] = description_fhir.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let masterIdentifier = self.masterIdentifier { json["masterIdentifier"] = masterIdentifier.asJSON() } if let recipient = self.recipient { - json["recipient"] = Reference.asJSONArray(recipient) + json["recipient"] = recipient.map() { $0.asJSON() } } if let related = self.related { - json["related"] = DocumentManifestRelated.asJSONArray(related) + json["related"] = related.map() { $0.asJSON() } } if let source = self.source { json["source"] = source.asJSON() diff --git a/Sources/Models/DocumentReference.swift b/Sources/Models/DocumentReference.swift index ebdb958a..235ad931 100644 --- a/Sources/Models/DocumentReference.swift +++ b/Sources/Models/DocumentReference.swift @@ -264,13 +264,13 @@ public class DocumentReference: DomainResource { json["authenticator"] = authenticator.asJSON() } if let author = self.author { - json["author"] = Reference.asJSONArray(author) + json["author"] = author.map() { $0.asJSON() } } if let class_fhir = self.class_fhir { json["class"] = class_fhir.asJSON() } if let content = self.content { - json["content"] = DocumentReferenceContent.asJSONArray(content) + json["content"] = content.map() { $0.asJSON() } } if let context = self.context { json["context"] = context.asJSON() @@ -288,7 +288,7 @@ public class DocumentReference: DomainResource { json["docStatus"] = docStatus.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let indexed = self.indexed { json["indexed"] = indexed.asJSON() @@ -297,10 +297,10 @@ public class DocumentReference: DomainResource { json["masterIdentifier"] = masterIdentifier.asJSON() } if let relatesTo = self.relatesTo { - json["relatesTo"] = DocumentReferenceRelatesTo.asJSONArray(relatesTo) + json["relatesTo"] = relatesTo.map() { $0.asJSON() } } if let securityLabel = self.securityLabel { - json["securityLabel"] = CodeableConcept.asJSONArray(securityLabel) + json["securityLabel"] = securityLabel.map() { $0.asJSON() } } if let status = self.status { json["status"] = status.asJSON() @@ -380,7 +380,7 @@ public class DocumentReferenceContent: BackboneElement { json["attachment"] = attachment.asJSON() } if let format = self.format { - json["format"] = Coding.asJSONArray(format) + json["format"] = format.map() { $0.asJSON() } } return json @@ -502,7 +502,7 @@ public class DocumentReferenceContext: BackboneElement { json["encounter"] = encounter.asJSON() } if let event = self.event { - json["event"] = CodeableConcept.asJSONArray(event) + json["event"] = event.map() { $0.asJSON() } } if let facilityType = self.facilityType { json["facilityType"] = facilityType.asJSON() @@ -514,7 +514,7 @@ public class DocumentReferenceContext: BackboneElement { json["practiceSetting"] = practiceSetting.asJSON() } if let related = self.related { - json["related"] = DocumentReferenceContextRelated.asJSONArray(related) + json["related"] = related.map() { $0.asJSON() } } if let sourcePatientInfo = self.sourcePatientInfo { json["sourcePatientInfo"] = sourcePatientInfo.asJSON() diff --git a/Sources/Models/DomainResource.swift b/Sources/Models/DomainResource.swift index 8351d7a8..233f35de 100644 --- a/Sources/Models/DomainResource.swift +++ b/Sources/Models/DomainResource.swift @@ -84,13 +84,13 @@ public class DomainResource: Resource { var json = super.asJSON() if let contained = self.contained { - json["contained"] = Resource.asJSONArray(contained) + json["contained"] = contained.map() { $0.asJSON() } } if let extension_fhir = self.extension_fhir { - json["extension"] = Extension.asJSONArray(extension_fhir) + json["extension"] = extension_fhir.map() { $0.asJSON() } } if let modifierExtension = self.modifierExtension { - json["modifierExtension"] = Extension.asJSONArray(modifierExtension) + json["modifierExtension"] = modifierExtension.map() { $0.asJSON() } } if let text = self.text { json["text"] = text.asJSON() diff --git a/Sources/Models/Element.swift b/Sources/Models/Element.swift index c4786d7e..5eee7036 100644 --- a/Sources/Models/Element.swift +++ b/Sources/Models/Element.swift @@ -60,7 +60,7 @@ public class Element: FHIRAbstractBase { var json = super.asJSON() if let extension_fhir = self.extension_fhir { - json["extension"] = Extension.asJSONArray(extension_fhir) + json["extension"] = extension_fhir.map() { $0.asJSON() } } if let id = self.id { json["id"] = id.asJSON() diff --git a/Sources/Models/ElementDefinition.swift b/Sources/Models/ElementDefinition.swift index 0d5bbf8b..f6c13c52 100644 --- a/Sources/Models/ElementDefinition.swift +++ b/Sources/Models/ElementDefinition.swift @@ -2734,7 +2734,7 @@ public class ElementDefinition: Element { json["binding"] = binding.asJSON() } if let code = self.code { - json["code"] = Coding.asJSONArray(code) + json["code"] = code.map() { $0.asJSON() } } if let comments = self.comments { json["comments"] = comments.asJSON() @@ -2747,7 +2747,7 @@ public class ElementDefinition: Element { json["condition"] = arr } if let constraint = self.constraint { - json["constraint"] = ElementDefinitionConstraint.asJSONArray(constraint) + json["constraint"] = constraint.map() { $0.asJSON() } } if let defaultValueAddress = self.defaultValueAddress { json["defaultValueAddress"] = defaultValueAddress.asJSON() @@ -3059,7 +3059,7 @@ public class ElementDefinition: Element { json["label"] = label.asJSON() } if let mapping = self.mapping { - json["mapping"] = ElementDefinitionMapping.asJSONArray(mapping) + json["mapping"] = mapping.map() { $0.asJSON() } } if let max = self.max { json["max"] = max.asJSON() @@ -3399,7 +3399,7 @@ public class ElementDefinition: Element { json["slicing"] = slicing.asJSON() } if let type = self.type { - json["type"] = ElementDefinitionType.asJSONArray(type) + json["type"] = type.map() { $0.asJSON() } } return json diff --git a/Sources/Models/EligibilityRequest.swift b/Sources/Models/EligibilityRequest.swift index 4cc157f4..105c543b 100644 --- a/Sources/Models/EligibilityRequest.swift +++ b/Sources/Models/EligibilityRequest.swift @@ -124,7 +124,7 @@ public class EligibilityRequest: DomainResource { json["created"] = created.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let organization = self.organization { json["organization"] = organization.asJSON() diff --git a/Sources/Models/EligibilityResponse.swift b/Sources/Models/EligibilityResponse.swift index 460b07b5..30d15cae 100644 --- a/Sources/Models/EligibilityResponse.swift +++ b/Sources/Models/EligibilityResponse.swift @@ -162,7 +162,7 @@ public class EligibilityResponse: DomainResource { json["disposition"] = disposition.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let organization = self.organization { json["organization"] = organization.asJSON() diff --git a/Sources/Models/Encounter.swift b/Sources/Models/Encounter.swift index 1ef5b7f4..a4f2e13a 100644 --- a/Sources/Models/Encounter.swift +++ b/Sources/Models/Encounter.swift @@ -280,31 +280,31 @@ public class Encounter: DomainResource { json["class"] = class_fhir.asJSON() } if let episodeOfCare = self.episodeOfCare { - json["episodeOfCare"] = Reference.asJSONArray(episodeOfCare) + json["episodeOfCare"] = episodeOfCare.map() { $0.asJSON() } } if let hospitalization = self.hospitalization { json["hospitalization"] = hospitalization.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let incomingReferral = self.incomingReferral { - json["incomingReferral"] = Reference.asJSONArray(incomingReferral) + json["incomingReferral"] = incomingReferral.map() { $0.asJSON() } } if let indication = self.indication { - json["indication"] = Reference.asJSONArray(indication) + json["indication"] = indication.map() { $0.asJSON() } } if let length = self.length { json["length"] = length.asJSON() } if let location = self.location { - json["location"] = EncounterLocation.asJSONArray(location) + json["location"] = location.map() { $0.asJSON() } } if let partOf = self.partOf { json["partOf"] = partOf.asJSON() } if let participant = self.participant { - json["participant"] = EncounterParticipant.asJSONArray(participant) + json["participant"] = participant.map() { $0.asJSON() } } if let patient = self.patient { json["patient"] = patient.asJSON() @@ -316,7 +316,7 @@ public class Encounter: DomainResource { json["priority"] = priority.asJSON() } if let reason = self.reason { - json["reason"] = CodeableConcept.asJSONArray(reason) + json["reason"] = reason.map() { $0.asJSON() } } if let serviceProvider = self.serviceProvider { json["serviceProvider"] = serviceProvider.asJSON() @@ -325,10 +325,10 @@ public class Encounter: DomainResource { json["status"] = status.asJSON() } if let statusHistory = self.statusHistory { - json["statusHistory"] = EncounterStatusHistory.asJSONArray(statusHistory) + json["statusHistory"] = statusHistory.map() { $0.asJSON() } } if let type = self.type { - json["type"] = CodeableConcept.asJSONArray(type) + json["type"] = type.map() { $0.asJSON() } } return json @@ -496,16 +496,16 @@ public class EncounterHospitalization: BackboneElement { json["admitSource"] = admitSource.asJSON() } if let admittingDiagnosis = self.admittingDiagnosis { - json["admittingDiagnosis"] = Reference.asJSONArray(admittingDiagnosis) + json["admittingDiagnosis"] = admittingDiagnosis.map() { $0.asJSON() } } if let destination = self.destination { json["destination"] = destination.asJSON() } if let dietPreference = self.dietPreference { - json["dietPreference"] = CodeableConcept.asJSONArray(dietPreference) + json["dietPreference"] = dietPreference.map() { $0.asJSON() } } if let dischargeDiagnosis = self.dischargeDiagnosis { - json["dischargeDiagnosis"] = Reference.asJSONArray(dischargeDiagnosis) + json["dischargeDiagnosis"] = dischargeDiagnosis.map() { $0.asJSON() } } if let dischargeDisposition = self.dischargeDisposition { json["dischargeDisposition"] = dischargeDisposition.asJSON() @@ -520,10 +520,10 @@ public class EncounterHospitalization: BackboneElement { json["reAdmission"] = reAdmission.asJSON() } if let specialArrangement = self.specialArrangement { - json["specialArrangement"] = CodeableConcept.asJSONArray(specialArrangement) + json["specialArrangement"] = specialArrangement.map() { $0.asJSON() } } if let specialCourtesy = self.specialCourtesy { - json["specialCourtesy"] = CodeableConcept.asJSONArray(specialCourtesy) + json["specialCourtesy"] = specialCourtesy.map() { $0.asJSON() } } return json @@ -686,7 +686,7 @@ public class EncounterParticipant: BackboneElement { json["period"] = period.asJSON() } if let type = self.type { - json["type"] = CodeableConcept.asJSONArray(type) + json["type"] = type.map() { $0.asJSON() } } return json diff --git a/Sources/Models/EnrollmentRequest.swift b/Sources/Models/EnrollmentRequest.swift index a59e9d32..0825aaa5 100644 --- a/Sources/Models/EnrollmentRequest.swift +++ b/Sources/Models/EnrollmentRequest.swift @@ -179,7 +179,7 @@ public class EnrollmentRequest: DomainResource { json["created"] = created.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let organization = self.organization { json["organization"] = organization.asJSON() diff --git a/Sources/Models/EnrollmentResponse.swift b/Sources/Models/EnrollmentResponse.swift index e1803ca0..dece906c 100644 --- a/Sources/Models/EnrollmentResponse.swift +++ b/Sources/Models/EnrollmentResponse.swift @@ -162,7 +162,7 @@ public class EnrollmentResponse: DomainResource { json["disposition"] = disposition.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let organization = self.organization { json["organization"] = organization.asJSON() diff --git a/Sources/Models/EpisodeOfCare.swift b/Sources/Models/EpisodeOfCare.swift index 82a0fba6..6688de40 100644 --- a/Sources/Models/EpisodeOfCare.swift +++ b/Sources/Models/EpisodeOfCare.swift @@ -186,13 +186,13 @@ public class EpisodeOfCare: DomainResource { json["careManager"] = careManager.asJSON() } if let careTeam = self.careTeam { - json["careTeam"] = EpisodeOfCareCareTeam.asJSONArray(careTeam) + json["careTeam"] = careTeam.map() { $0.asJSON() } } if let condition = self.condition { - json["condition"] = Reference.asJSONArray(condition) + json["condition"] = condition.map() { $0.asJSON() } } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let managingOrganization = self.managingOrganization { json["managingOrganization"] = managingOrganization.asJSON() @@ -204,16 +204,16 @@ public class EpisodeOfCare: DomainResource { json["period"] = period.asJSON() } if let referralRequest = self.referralRequest { - json["referralRequest"] = Reference.asJSONArray(referralRequest) + json["referralRequest"] = referralRequest.map() { $0.asJSON() } } if let status = self.status { json["status"] = status.asJSON() } if let statusHistory = self.statusHistory { - json["statusHistory"] = EpisodeOfCareStatusHistory.asJSONArray(statusHistory) + json["statusHistory"] = statusHistory.map() { $0.asJSON() } } if let type = self.type { - json["type"] = CodeableConcept.asJSONArray(type) + json["type"] = type.map() { $0.asJSON() } } return json @@ -290,7 +290,7 @@ public class EpisodeOfCareCareTeam: BackboneElement { json["period"] = period.asJSON() } if let role = self.role { - json["role"] = CodeableConcept.asJSONArray(role) + json["role"] = role.map() { $0.asJSON() } } return json diff --git a/Sources/Models/ExplanationOfBenefit.swift b/Sources/Models/ExplanationOfBenefit.swift index 7bd13ab7..5cf7d9d5 100644 --- a/Sources/Models/ExplanationOfBenefit.swift +++ b/Sources/Models/ExplanationOfBenefit.swift @@ -163,7 +163,7 @@ public class ExplanationOfBenefit: DomainResource { json["disposition"] = disposition.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let organization = self.organization { json["organization"] = organization.asJSON() diff --git a/Sources/Models/FHIRAbstractBase.swift b/Sources/Models/FHIRAbstractBase.swift index e26152ce..16453cac 100644 --- a/Sources/Models/FHIRAbstractBase.swift +++ b/Sources/Models/FHIRAbstractBase.swift @@ -8,11 +8,11 @@ /** - * Abstract superclass for all FHIR data elements. - */ +Abstract superclass for all FHIR data elements. +*/ open class FHIRAbstractBase: CustomStringConvertible { - /// The name of the resource or element. + /// The type of the resource or element. open class var resourceType: String { get { return "FHIRAbstractBase" } } @@ -85,16 +85,6 @@ open class FHIRAbstractBase: CustomStringConvertible { return FHIRJSON() } - /** - Calls `asJSON()` on all elements in the array and returns the resulting array full of FHIRJSON dictionaries. - - - parameter array: The array of elements to map to FHIRJSON - - returns: An array of FHIRJSON elements representing the given resources - */ - open class func asJSONArray(_ array: [FHIRAbstractBase]) -> [FHIRJSON] { - return array.map() { $0.asJSON() } - } - // MARK: - Factories @@ -130,7 +120,7 @@ open class FHIRAbstractBase: CustomStringConvertible { // MARK: - Resolving References /** Returns the resolved reference with the given id, if it has been resolved already. */ - open func resolvedReference(_ refid: String) -> Resource? { + public func resolvedReference(_ refid: String) -> Resource? { if let resolved = _resolved?[refid] { return resolved } @@ -146,7 +136,7 @@ open class FHIRAbstractBase: CustomStringConvertible { - parameter refid: The reference identifier as String - parameter resolved: The resource that was resolved */ - open func didResolveReference(_ refid: String, resolved: Resource) { + public func didResolveReference(_ refid: String, resolved: Resource) { if nil != _resolved { _resolved![refid] = resolved } @@ -188,7 +178,7 @@ open class FHIRAbstractBase: CustomStringConvertible { } - // MARK: - Printable + // MARK: - CustomStringConvertible open var description: String { return "<\(type(of: self).resourceType)>" diff --git a/Sources/Models/FHIRAbstractResource.swift b/Sources/Models/FHIRAbstractResource.swift index 698fef4e..de14074b 100644 --- a/Sources/Models/FHIRAbstractResource.swift +++ b/Sources/Models/FHIRAbstractResource.swift @@ -10,15 +10,15 @@ import Foundation /** - * Abstract superclass for all FHIR resource models. - */ +Abstract superclass for all FHIR resource models. +*/ open class FHIRAbstractResource: FHIRAbstractBase { /// A specific version id, if the instance was created using `vread`. - open var _versionId: String? + public var _versionId: String? /// If this instance lives on a server, this property represents that server. - open var _server: FHIRServer? { + public var _server: FHIRServer? { get { return __server ?? owningResource?._server } set { __server = newValue } } @@ -33,7 +33,7 @@ open class FHIRAbstractResource: FHIRAbstractBase { The Resource, in contrast to the base element, definitely wants "resourceType" to be present. Will return an error complaining about it missing if it's not present. */ - open override func populate(from json: FHIRJSON?, presentKeys: inout Set) -> [FHIRJSONError]? { + override open func populate(from json: FHIRJSON?, presentKeys: inout Set) -> [FHIRJSONError]? { guard let json = json else { return nil } @@ -56,7 +56,7 @@ open class FHIRAbstractResource: FHIRAbstractBase { } - // MARK: - Printable + // MARK: - CustomStringConvertible override open var description: String { return "<\(type(of: self).resourceType)> \(__server?.baseURL.absoluteString ?? "nil")" diff --git a/Sources/Models/FHIRServer.swift b/Sources/Models/FHIRServer.swift index fc8663c7..85666a14 100644 --- a/Sources/Models/FHIRServer.swift +++ b/Sources/Models/FHIRServer.swift @@ -12,7 +12,7 @@ import Foundation /** Struct to describe REST request types, with a convenience method to make a request FHIR compliant. */ -public enum FHIRRequestType: String { +public enum FHIRRequestMethod: String { case GET = "GET" case PUT = "PUT" case POST = "POST" @@ -112,12 +112,12 @@ public protocol FHIRServer { /* Execute a request of given type against the given path, which is relative to the receiver's `baseURL`, with the given resource (if any). - - parameter ofType: The HTTP method type of the request + - parameter method: The HTTP method type of the request - parameter path: The relative path on the server to be interacting against - parameter resource: The resource to be involved in the request, if any - parameter additonalHeaders: The headers to set on the request - parameter callback: A callback, likely called asynchronously, returning a response instance */ - func performRequest(ofType: FHIRRequestType, path: String, resource: Resource?, additionalHeaders: FHIRRequestHeaders?, callback: @escaping ((_ response: FHIRServerResponse) -> Void)) + func performRequest(_ method: FHIRRequestMethod, path: String, resource: Resource?, additionalHeaders: FHIRRequestHeaders?, callback: @escaping ((FHIRServerResponse) -> Void)) } diff --git a/Sources/Models/FHIRServerResponse.swift b/Sources/Models/FHIRServerResponse.swift index 5f56657d..5984b462 100644 --- a/Sources/Models/FHIRServerResponse.swift +++ b/Sources/Models/FHIRServerResponse.swift @@ -32,26 +32,35 @@ public protocol FHIRServerResponse { /** - Instantiate a FHIRServerResponse from an (HTTP)URLResponse, Data and an Error. + Instantiate a FHIRServerResponse from an URLResponse, Data and an Error. */ init(response: URLResponse, data: Data?, error: Error?) + /** + Instantiate a response that only represents an error, possibly because it wasn't even sent. + */ init(error: Error) // MARK: - Responses - func responseResource(_ expectType: T.Type) -> T? + /** + Extract the resource of the given type from the response, if possible. + + - parameter ofType: The type of resource to extract + - returns: The resource that was found in the response if it is of the desired type, nil otherwise + */ + func responseResource(ofType: T.Type) -> T? /** The response should inspect response headers and update resource data like `id` and `meta` accordingly. This method must not be called if the response has a non-nil error. - - throws: The method should only throw on severe cases, like if Location headers were returned that don't match the resource type - - parameter resource: The resource to apply response data to + - throws: The method should only throw on severe cases, like if Location headers were returned that don't match the resource type + - parameter to: The resource to apply response data to */ - func applyHeaders(to resource: Resource) throws + func applyHeaders(to: Resource) throws /** The response should apply response body data to the given resource. It should throw `FHIRError.ResponseNoResourceReceived` if there was @@ -59,12 +68,15 @@ public protocol FHIRServerResponse { This method must not be called if the response has a non-nil error. - - throws: The method should throw if resource data was returned that doesn't match the given resource's type, but also if there was no - response data at all (`FHIRError.ResponseNoResourceReceived` in that case) - - parameter resource: The resource to apply response data to + - throws: The method should throw if resource data was returned that doesn't match the given resource's type, but also if there + was no response data at all (`FHIRError.ResponseNoResourceReceived` in that case) + - parameter to: The resource to apply response data to */ - func applyBody(to resource: Resource) throws + func applyBody(to: Resource) throws + /** + Represent a response that was not received. + */ static func noneReceived() -> Self } diff --git a/Sources/Models/FHIRTypes.swift b/Sources/Models/FHIRTypes.swift index 2382d3f2..130567f6 100644 --- a/Sources/Models/FHIRTypes.swift +++ b/Sources/Models/FHIRTypes.swift @@ -82,7 +82,7 @@ Execute a `print()`, prepending filename, line and function/method name, if `DEB */ public func fhir_logIfDebug(_ message: @autoclosure () -> String, function: String = #function, file: String = #file, line: Int = #line) { #if DEBUG - print("SwiftFHIR [\(file.lastPathComponent):\(line)] \(function) \(message())") + print("SwiftFHIR [\((file as NSString).lastPathComponent):\(line)] \(function) \(message())") #endif } diff --git a/Sources/Models/FamilyMemberHistory.swift b/Sources/Models/FamilyMemberHistory.swift index 7906f097..d8db85c5 100644 --- a/Sources/Models/FamilyMemberHistory.swift +++ b/Sources/Models/FamilyMemberHistory.swift @@ -312,7 +312,7 @@ public class FamilyMemberHistory: DomainResource { json["bornString"] = bornString.asJSON() } if let condition = self.condition { - json["condition"] = FamilyMemberHistoryCondition.asJSONArray(condition) + json["condition"] = condition.map() { $0.asJSON() } } if let date = self.date { json["date"] = date.asJSON() @@ -336,7 +336,7 @@ public class FamilyMemberHistory: DomainResource { json["gender"] = gender.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let name = self.name { json["name"] = name.asJSON() diff --git a/Sources/Models/Flag.swift b/Sources/Models/Flag.swift index 34e17af5..32519994 100644 --- a/Sources/Models/Flag.swift +++ b/Sources/Models/Flag.swift @@ -161,7 +161,7 @@ public class Flag: DomainResource { json["encounter"] = encounter.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let period = self.period { json["period"] = period.asJSON() diff --git a/Sources/Models/Goal.swift b/Sources/Models/Goal.swift index efe13b81..5f3fca6d 100644 --- a/Sources/Models/Goal.swift +++ b/Sources/Models/Goal.swift @@ -242,25 +242,25 @@ public class Goal: DomainResource { var json = super.asJSON() if let addresses = self.addresses { - json["addresses"] = Reference.asJSONArray(addresses) + json["addresses"] = addresses.map() { $0.asJSON() } } if let author = self.author { json["author"] = author.asJSON() } if let category = self.category { - json["category"] = CodeableConcept.asJSONArray(category) + json["category"] = category.map() { $0.asJSON() } } if let description_fhir = self.description_fhir { json["description"] = description_fhir.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let note = self.note { - json["note"] = Annotation.asJSONArray(note) + json["note"] = note.map() { $0.asJSON() } } if let outcome = self.outcome { - json["outcome"] = GoalOutcome.asJSONArray(outcome) + json["outcome"] = outcome.map() { $0.asJSON() } } if let priority = self.priority { json["priority"] = priority.asJSON() diff --git a/Sources/Models/Group.swift b/Sources/Models/Group.swift index f1631149..7ef75459 100644 --- a/Sources/Models/Group.swift +++ b/Sources/Models/Group.swift @@ -150,16 +150,16 @@ public class Group: DomainResource { json["actual"] = actual.asJSON() } if let characteristic = self.characteristic { - json["characteristic"] = GroupCharacteristic.asJSONArray(characteristic) + json["characteristic"] = characteristic.map() { $0.asJSON() } } if let code = self.code { json["code"] = code.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let member = self.member { - json["member"] = GroupMember.asJSONArray(member) + json["member"] = member.map() { $0.asJSON() } } if let name = self.name { json["name"] = name.asJSON() diff --git a/Sources/Models/HealthcareService.swift b/Sources/Models/HealthcareService.swift index f07b6885..54eba59f 100644 --- a/Sources/Models/HealthcareService.swift +++ b/Sources/Models/HealthcareService.swift @@ -313,16 +313,16 @@ public class HealthcareService: DomainResource { json["availabilityExceptions"] = availabilityExceptions.asJSON() } if let availableTime = self.availableTime { - json["availableTime"] = HealthcareServiceAvailableTime.asJSONArray(availableTime) + json["availableTime"] = availableTime.map() { $0.asJSON() } } if let characteristic = self.characteristic { - json["characteristic"] = CodeableConcept.asJSONArray(characteristic) + json["characteristic"] = characteristic.map() { $0.asJSON() } } if let comment = self.comment { json["comment"] = comment.asJSON() } if let coverageArea = self.coverageArea { - json["coverageArea"] = Reference.asJSONArray(coverageArea) + json["coverageArea"] = coverageArea.map() { $0.asJSON() } } if let eligibility = self.eligibility { json["eligibility"] = eligibility.asJSON() @@ -334,13 +334,13 @@ public class HealthcareService: DomainResource { json["extraDetails"] = extraDetails.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let location = self.location { json["location"] = location.asJSON() } if let notAvailable = self.notAvailable { - json["notAvailable"] = HealthcareServiceNotAvailable.asJSONArray(notAvailable) + json["notAvailable"] = notAvailable.map() { $0.asJSON() } } if let photo = self.photo { json["photo"] = photo.asJSON() @@ -359,7 +359,7 @@ public class HealthcareService: DomainResource { json["publicKey"] = publicKey.asJSON() } if let referralMethod = self.referralMethod { - json["referralMethod"] = CodeableConcept.asJSONArray(referralMethod) + json["referralMethod"] = referralMethod.map() { $0.asJSON() } } if let serviceCategory = self.serviceCategory { json["serviceCategory"] = serviceCategory.asJSON() @@ -368,13 +368,13 @@ public class HealthcareService: DomainResource { json["serviceName"] = serviceName.asJSON() } if let serviceProvisionCode = self.serviceProvisionCode { - json["serviceProvisionCode"] = CodeableConcept.asJSONArray(serviceProvisionCode) + json["serviceProvisionCode"] = serviceProvisionCode.map() { $0.asJSON() } } if let serviceType = self.serviceType { - json["serviceType"] = HealthcareServiceServiceType.asJSONArray(serviceType) + json["serviceType"] = serviceType.map() { $0.asJSON() } } if let telecom = self.telecom { - json["telecom"] = ContactPoint.asJSONArray(telecom) + json["telecom"] = telecom.map() { $0.asJSON() } } return json @@ -609,7 +609,7 @@ public class HealthcareServiceServiceType: BackboneElement { var json = super.asJSON() if let specialty = self.specialty { - json["specialty"] = CodeableConcept.asJSONArray(specialty) + json["specialty"] = specialty.map() { $0.asJSON() } } if let type = self.type { json["type"] = type.asJSON() diff --git a/Sources/Models/ImagingObjectSelection.swift b/Sources/Models/ImagingObjectSelection.swift index b6a32366..568da0f7 100644 --- a/Sources/Models/ImagingObjectSelection.swift +++ b/Sources/Models/ImagingObjectSelection.swift @@ -159,7 +159,7 @@ public class ImagingObjectSelection: DomainResource { json["patient"] = patient.asJSON() } if let study = self.study { - json["study"] = ImagingObjectSelectionStudy.asJSONArray(study) + json["study"] = study.map() { $0.asJSON() } } if let title = self.title { json["title"] = title.asJSON() @@ -264,7 +264,7 @@ public class ImagingObjectSelectionStudy: BackboneElement { json["imagingStudy"] = imagingStudy.asJSON() } if let series = self.series { - json["series"] = ImagingObjectSelectionStudySeries.asJSONArray(series) + json["series"] = series.map() { $0.asJSON() } } if let uid = self.uid { json["uid"] = uid.asJSON() @@ -350,7 +350,7 @@ public class ImagingObjectSelectionStudySeries: BackboneElement { var json = super.asJSON() if let instance = self.instance { - json["instance"] = ImagingObjectSelectionStudySeriesInstance.asJSONArray(instance) + json["instance"] = instance.map() { $0.asJSON() } } if let uid = self.uid { json["uid"] = uid.asJSON() @@ -456,7 +456,7 @@ public class ImagingObjectSelectionStudySeriesInstance: BackboneElement { var json = super.asJSON() if let frames = self.frames { - json["frames"] = ImagingObjectSelectionStudySeriesInstanceFrames.asJSONArray(frames) + json["frames"] = frames.map() { $0.asJSON() } } if let sopClass = self.sopClass { json["sopClass"] = sopClass.asJSON() diff --git a/Sources/Models/ImagingStudy.swift b/Sources/Models/ImagingStudy.swift index a8e5f23f..9a06e84b 100644 --- a/Sources/Models/ImagingStudy.swift +++ b/Sources/Models/ImagingStudy.swift @@ -261,13 +261,13 @@ public class ImagingStudy: DomainResource { json["description"] = description_fhir.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let interpreter = self.interpreter { json["interpreter"] = interpreter.asJSON() } if let modalityList = self.modalityList { - json["modalityList"] = Coding.asJSONArray(modalityList) + json["modalityList"] = modalityList.map() { $0.asJSON() } } if let numberOfInstances = self.numberOfInstances { json["numberOfInstances"] = numberOfInstances.asJSON() @@ -276,19 +276,19 @@ public class ImagingStudy: DomainResource { json["numberOfSeries"] = numberOfSeries.asJSON() } if let order = self.order { - json["order"] = Reference.asJSONArray(order) + json["order"] = order.map() { $0.asJSON() } } if let patient = self.patient { json["patient"] = patient.asJSON() } if let procedure = self.procedure { - json["procedure"] = Reference.asJSONArray(procedure) + json["procedure"] = procedure.map() { $0.asJSON() } } if let referrer = self.referrer { json["referrer"] = referrer.asJSON() } if let series = self.series { - json["series"] = ImagingStudySeries.asJSONArray(series) + json["series"] = series.map() { $0.asJSON() } } if let started = self.started { json["started"] = started.asJSON() @@ -490,7 +490,7 @@ public class ImagingStudySeries: BackboneElement { json["description"] = description_fhir.asJSON() } if let instance = self.instance { - json["instance"] = ImagingStudySeriesInstance.asJSONArray(instance) + json["instance"] = instance.map() { $0.asJSON() } } if let laterality = self.laterality { json["laterality"] = laterality.asJSON() @@ -631,7 +631,7 @@ public class ImagingStudySeriesInstance: BackboneElement { var json = super.asJSON() if let content = self.content { - json["content"] = Attachment.asJSONArray(content) + json["content"] = content.map() { $0.asJSON() } } if let number = self.number { json["number"] = number.asJSON() diff --git a/Sources/Models/Immunization.swift b/Sources/Models/Immunization.swift index acda57d1..11bc23e6 100644 --- a/Sources/Models/Immunization.swift +++ b/Sources/Models/Immunization.swift @@ -330,7 +330,7 @@ public class Immunization: DomainResource { json["explanation"] = explanation.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let location = self.location { json["location"] = location.asJSON() @@ -342,7 +342,7 @@ public class Immunization: DomainResource { json["manufacturer"] = manufacturer.asJSON() } if let note = self.note { - json["note"] = Annotation.asJSONArray(note) + json["note"] = note.map() { $0.asJSON() } } if let patient = self.patient { json["patient"] = patient.asJSON() @@ -351,7 +351,7 @@ public class Immunization: DomainResource { json["performer"] = performer.asJSON() } if let reaction = self.reaction { - json["reaction"] = ImmunizationReaction.asJSONArray(reaction) + json["reaction"] = reaction.map() { $0.asJSON() } } if let reported = self.reported { json["reported"] = reported.asJSON() @@ -369,7 +369,7 @@ public class Immunization: DomainResource { json["status"] = status.asJSON() } if let vaccinationProtocol = self.vaccinationProtocol { - json["vaccinationProtocol"] = ImmunizationVaccinationProtocol.asJSONArray(vaccinationProtocol) + json["vaccinationProtocol"] = vaccinationProtocol.map() { $0.asJSON() } } if let vaccineCode = self.vaccineCode { json["vaccineCode"] = vaccineCode.asJSON() @@ -434,10 +434,10 @@ public class ImmunizationExplanation: BackboneElement { var json = super.asJSON() if let reason = self.reason { - json["reason"] = CodeableConcept.asJSONArray(reason) + json["reason"] = reason.map() { $0.asJSON() } } if let reasonNotGiven = self.reasonNotGiven { - json["reasonNotGiven"] = CodeableConcept.asJSONArray(reasonNotGiven) + json["reasonNotGiven"] = reasonNotGiven.map() { $0.asJSON() } } return json @@ -683,7 +683,7 @@ public class ImmunizationVaccinationProtocol: BackboneElement { json["seriesDoses"] = seriesDoses.asJSON() } if let targetDisease = self.targetDisease { - json["targetDisease"] = CodeableConcept.asJSONArray(targetDisease) + json["targetDisease"] = targetDisease.map() { $0.asJSON() } } return json diff --git a/Sources/Models/ImmunizationRecommendation.swift b/Sources/Models/ImmunizationRecommendation.swift index 66fbb2ef..95486a56 100644 --- a/Sources/Models/ImmunizationRecommendation.swift +++ b/Sources/Models/ImmunizationRecommendation.swift @@ -86,13 +86,13 @@ public class ImmunizationRecommendation: DomainResource { var json = super.asJSON() if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let patient = self.patient { json["patient"] = patient.asJSON() } if let recommendation = self.recommendation { - json["recommendation"] = ImmunizationRecommendationRecommendation.asJSONArray(recommendation) + json["recommendation"] = recommendation.map() { $0.asJSON() } } return json @@ -241,7 +241,7 @@ public class ImmunizationRecommendationRecommendation: BackboneElement { json["date"] = date.asJSON() } if let dateCriterion = self.dateCriterion { - json["dateCriterion"] = ImmunizationRecommendationRecommendationDateCriterion.asJSONArray(dateCriterion) + json["dateCriterion"] = dateCriterion.map() { $0.asJSON() } } if let doseNumber = self.doseNumber { json["doseNumber"] = doseNumber.asJSON() @@ -253,10 +253,10 @@ public class ImmunizationRecommendationRecommendation: BackboneElement { json["protocol"] = protocol_fhir.asJSON() } if let supportingImmunization = self.supportingImmunization { - json["supportingImmunization"] = Reference.asJSONArray(supportingImmunization) + json["supportingImmunization"] = supportingImmunization.map() { $0.asJSON() } } if let supportingPatientInformation = self.supportingPatientInformation { - json["supportingPatientInformation"] = Reference.asJSONArray(supportingPatientInformation) + json["supportingPatientInformation"] = supportingPatientInformation.map() { $0.asJSON() } } if let vaccineCode = self.vaccineCode { json["vaccineCode"] = vaccineCode.asJSON() diff --git a/Sources/Models/ImplementationGuide.swift b/Sources/Models/ImplementationGuide.swift index 233bec1a..ab38cfba 100644 --- a/Sources/Models/ImplementationGuide.swift +++ b/Sources/Models/ImplementationGuide.swift @@ -273,7 +273,7 @@ public class ImplementationGuide: DomainResource { json["binary"] = arr } if let contact = self.contact { - json["contact"] = ImplementationGuideContact.asJSONArray(contact) + json["contact"] = contact.map() { $0.asJSON() } } if let copyright = self.copyright { json["copyright"] = copyright.asJSON() @@ -282,7 +282,7 @@ public class ImplementationGuide: DomainResource { json["date"] = date.asJSON() } if let dependency = self.dependency { - json["dependency"] = ImplementationGuideDependency.asJSONArray(dependency) + json["dependency"] = dependency.map() { $0.asJSON() } } if let description_fhir = self.description_fhir { json["description"] = description_fhir.asJSON() @@ -294,13 +294,13 @@ public class ImplementationGuide: DomainResource { json["fhirVersion"] = fhirVersion.asJSON() } if let global = self.global { - json["global"] = ImplementationGuideGlobal.asJSONArray(global) + json["global"] = global.map() { $0.asJSON() } } if let name = self.name { json["name"] = name.asJSON() } if let package = self.package { - json["package"] = ImplementationGuidePackage.asJSONArray(package) + json["package"] = package.map() { $0.asJSON() } } if let page = self.page { json["page"] = page.asJSON() @@ -315,7 +315,7 @@ public class ImplementationGuide: DomainResource { json["url"] = url.asJSON() } if let useContext = self.useContext { - json["useContext"] = CodeableConcept.asJSONArray(useContext) + json["useContext"] = useContext.map() { $0.asJSON() } } if let version = self.version { json["version"] = version.asJSON() @@ -380,7 +380,7 @@ public class ImplementationGuideContact: BackboneElement { json["name"] = name.asJSON() } if let telecom = self.telecom { - json["telecom"] = ContactPoint.asJSONArray(telecom) + json["telecom"] = telecom.map() { $0.asJSON() } } return json @@ -621,7 +621,7 @@ public class ImplementationGuidePackage: BackboneElement { json["name"] = name.asJSON() } if let resource = self.resource { - json["resource"] = ImplementationGuidePackageResource.asJSONArray(resource) + json["resource"] = resource.map() { $0.asJSON() } } return json @@ -928,7 +928,7 @@ public class ImplementationGuidePage: BackboneElement { json["package"] = arr } if let page = self.page { - json["page"] = ImplementationGuidePage.asJSONArray(page) + json["page"] = page.map() { $0.asJSON() } } if let source = self.source { json["source"] = source.asJSON() diff --git a/Sources/Models/List.swift b/Sources/Models/List.swift index 7868b439..8c22fc9b 100644 --- a/Sources/Models/List.swift +++ b/Sources/Models/List.swift @@ -217,10 +217,10 @@ public class List: DomainResource { json["encounter"] = encounter.asJSON() } if let entry = self.entry { - json["entry"] = ListEntry.asJSONArray(entry) + json["entry"] = entry.map() { $0.asJSON() } } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let mode = self.mode { json["mode"] = mode.asJSON() diff --git a/Sources/Models/Location.swift b/Sources/Models/Location.swift index e7a485cc..4277b47a 100644 --- a/Sources/Models/Location.swift +++ b/Sources/Models/Location.swift @@ -187,7 +187,7 @@ public class Location: DomainResource { json["description"] = description_fhir.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let managingOrganization = self.managingOrganization { json["managingOrganization"] = managingOrganization.asJSON() @@ -211,7 +211,7 @@ public class Location: DomainResource { json["status"] = status.asJSON() } if let telecom = self.telecom { - json["telecom"] = ContactPoint.asJSONArray(telecom) + json["telecom"] = telecom.map() { $0.asJSON() } } if let type = self.type { json["type"] = type.asJSON() diff --git a/Sources/Models/Media.swift b/Sources/Models/Media.swift index c12b0e92..607d039d 100644 --- a/Sources/Models/Media.swift +++ b/Sources/Models/Media.swift @@ -207,7 +207,7 @@ public class Media: DomainResource { json["height"] = height.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let operator_fhir = self.operator_fhir { json["operator"] = operator_fhir.asJSON() diff --git a/Sources/Models/Medication.swift b/Sources/Models/Medication.swift index 3e39f1a7..29d4e667 100644 --- a/Sources/Models/Medication.swift +++ b/Sources/Models/Medication.swift @@ -171,7 +171,7 @@ public class MedicationPackage: BackboneElement { json["container"] = container.asJSON() } if let content = self.content { - json["content"] = MedicationPackageContent.asJSONArray(content) + json["content"] = content.map() { $0.asJSON() } } return json @@ -313,13 +313,13 @@ public class MedicationProduct: BackboneElement { var json = super.asJSON() if let batch = self.batch { - json["batch"] = MedicationProductBatch.asJSONArray(batch) + json["batch"] = batch.map() { $0.asJSON() } } if let form = self.form { json["form"] = form.asJSON() } if let ingredient = self.ingredient { - json["ingredient"] = MedicationProductIngredient.asJSONArray(ingredient) + json["ingredient"] = ingredient.map() { $0.asJSON() } } return json diff --git a/Sources/Models/MedicationAdministration.swift b/Sources/Models/MedicationAdministration.swift index 55c28bec..6a1af3b3 100644 --- a/Sources/Models/MedicationAdministration.swift +++ b/Sources/Models/MedicationAdministration.swift @@ -255,7 +255,7 @@ public class MedicationAdministration: DomainResource { var json = super.asJSON() if let device = self.device { - json["device"] = Reference.asJSONArray(device) + json["device"] = device.map() { $0.asJSON() } } if let dosage = self.dosage { json["dosage"] = dosage.asJSON() @@ -270,7 +270,7 @@ public class MedicationAdministration: DomainResource { json["encounter"] = encounter.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let medicationCodeableConcept = self.medicationCodeableConcept { json["medicationCodeableConcept"] = medicationCodeableConcept.asJSON() @@ -291,10 +291,10 @@ public class MedicationAdministration: DomainResource { json["prescription"] = prescription.asJSON() } if let reasonGiven = self.reasonGiven { - json["reasonGiven"] = CodeableConcept.asJSONArray(reasonGiven) + json["reasonGiven"] = reasonGiven.map() { $0.asJSON() } } if let reasonNotGiven = self.reasonNotGiven { - json["reasonNotGiven"] = CodeableConcept.asJSONArray(reasonNotGiven) + json["reasonNotGiven"] = reasonNotGiven.map() { $0.asJSON() } } if let status = self.status { json["status"] = status.asJSON() diff --git a/Sources/Models/MedicationDispense.swift b/Sources/Models/MedicationDispense.swift index d37bc56d..593e103a 100644 --- a/Sources/Models/MedicationDispense.swift +++ b/Sources/Models/MedicationDispense.swift @@ -254,7 +254,7 @@ public class MedicationDispense: DomainResource { var json = super.asJSON() if let authorizingPrescription = self.authorizingPrescription { - json["authorizingPrescription"] = Reference.asJSONArray(authorizingPrescription) + json["authorizingPrescription"] = authorizingPrescription.map() { $0.asJSON() } } if let daysSupply = self.daysSupply { json["daysSupply"] = daysSupply.asJSON() @@ -266,7 +266,7 @@ public class MedicationDispense: DomainResource { json["dispenser"] = dispenser.asJSON() } if let dosageInstruction = self.dosageInstruction { - json["dosageInstruction"] = MedicationDispenseDosageInstruction.asJSONArray(dosageInstruction) + json["dosageInstruction"] = dosageInstruction.map() { $0.asJSON() } } if let identifier = self.identifier { json["identifier"] = identifier.asJSON() @@ -287,7 +287,7 @@ public class MedicationDispense: DomainResource { json["quantity"] = quantity.asJSON() } if let receiver = self.receiver { - json["receiver"] = Reference.asJSONArray(receiver) + json["receiver"] = receiver.map() { $0.asJSON() } } if let status = self.status { json["status"] = status.asJSON() @@ -626,10 +626,10 @@ public class MedicationDispenseSubstitution: BackboneElement { var json = super.asJSON() if let reason = self.reason { - json["reason"] = CodeableConcept.asJSONArray(reason) + json["reason"] = reason.map() { $0.asJSON() } } if let responsibleParty = self.responsibleParty { - json["responsibleParty"] = Reference.asJSONArray(responsibleParty) + json["responsibleParty"] = responsibleParty.map() { $0.asJSON() } } if let type = self.type { json["type"] = type.asJSON() diff --git a/Sources/Models/MedicationOrder.swift b/Sources/Models/MedicationOrder.swift index 09e4df58..b5e6d164 100644 --- a/Sources/Models/MedicationOrder.swift +++ b/Sources/Models/MedicationOrder.swift @@ -263,13 +263,13 @@ public class MedicationOrder: DomainResource { json["dispenseRequest"] = dispenseRequest.asJSON() } if let dosageInstruction = self.dosageInstruction { - json["dosageInstruction"] = MedicationOrderDosageInstruction.asJSONArray(dosageInstruction) + json["dosageInstruction"] = dosageInstruction.map() { $0.asJSON() } } if let encounter = self.encounter { json["encounter"] = encounter.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let medicationCodeableConcept = self.medicationCodeableConcept { json["medicationCodeableConcept"] = medicationCodeableConcept.asJSON() diff --git a/Sources/Models/MedicationStatement.swift b/Sources/Models/MedicationStatement.swift index 5d85c5e6..3dd3abcf 100644 --- a/Sources/Models/MedicationStatement.swift +++ b/Sources/Models/MedicationStatement.swift @@ -17,7 +17,9 @@ import Foundation * future. The source of this information can be the patient, significant other (such as a family member or spouse), * or a clinician. A common scenario where this information is captured is during the history taking process during a * patient visit or stay. The medication information may come from e.g. the patient's memory, from a prescription - * bottle, or from a list of medications the patient, clinician or other party maintains The primary difference + * bottle, or from a list of medications the patient, clinician or other party maintains + +The primary difference * between a medication statement and a medication administration is that the medication administration has complete * administration information and is based on actual administration information from the person who administered the * medication. A medication statement is often, if not always, less specific. There is no required date/time when the @@ -264,7 +266,7 @@ public class MedicationStatement: DomainResource { json["dateAsserted"] = dateAsserted.asJSON() } if let dosage = self.dosage { - json["dosage"] = MedicationStatementDosage.asJSONArray(dosage) + json["dosage"] = dosage.map() { $0.asJSON() } } if let effectiveDateTime = self.effectiveDateTime { json["effectiveDateTime"] = effectiveDateTime.asJSON() @@ -273,7 +275,7 @@ public class MedicationStatement: DomainResource { json["effectivePeriod"] = effectivePeriod.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let informationSource = self.informationSource { json["informationSource"] = informationSource.asJSON() @@ -297,13 +299,13 @@ public class MedicationStatement: DomainResource { json["reasonForUseReference"] = reasonForUseReference.asJSON() } if let reasonNotTaken = self.reasonNotTaken { - json["reasonNotTaken"] = CodeableConcept.asJSONArray(reasonNotTaken) + json["reasonNotTaken"] = reasonNotTaken.map() { $0.asJSON() } } if let status = self.status { json["status"] = status.asJSON() } if let supportingInformation = self.supportingInformation { - json["supportingInformation"] = Reference.asJSONArray(supportingInformation) + json["supportingInformation"] = supportingInformation.map() { $0.asJSON() } } if let wasNotTaken = self.wasNotTaken { json["wasNotTaken"] = wasNotTaken.asJSON() diff --git a/Sources/Models/MessageHeader.swift b/Sources/Models/MessageHeader.swift index 6d81e42e..135a571c 100644 --- a/Sources/Models/MessageHeader.swift +++ b/Sources/Models/MessageHeader.swift @@ -190,10 +190,10 @@ public class MessageHeader: DomainResource { json["author"] = author.asJSON() } if let data = self.data { - json["data"] = Reference.asJSONArray(data) + json["data"] = data.map() { $0.asJSON() } } if let destination = self.destination { - json["destination"] = MessageHeaderDestination.asJSONArray(destination) + json["destination"] = destination.map() { $0.asJSON() } } if let enterer = self.enterer { json["enterer"] = enterer.asJSON() diff --git a/Sources/Models/Meta.swift b/Sources/Models/Meta.swift index 7fa2aa7b..e9c25e3e 100644 --- a/Sources/Models/Meta.swift +++ b/Sources/Models/Meta.swift @@ -107,10 +107,10 @@ public class Meta: Element { json["profile"] = arr } if let security = self.security { - json["security"] = Coding.asJSONArray(security) + json["security"] = security.map() { $0.asJSON() } } if let tag = self.tag { - json["tag"] = Coding.asJSONArray(tag) + json["tag"] = tag.map() { $0.asJSON() } } if let versionId = self.versionId { json["versionId"] = versionId.asJSON() diff --git a/Sources/Models/NamingSystem.swift b/Sources/Models/NamingSystem.swift index f8a10b2b..7e8567f3 100644 --- a/Sources/Models/NamingSystem.swift +++ b/Sources/Models/NamingSystem.swift @@ -218,7 +218,7 @@ public class NamingSystem: DomainResource { var json = super.asJSON() if let contact = self.contact { - json["contact"] = NamingSystemContact.asJSONArray(contact) + json["contact"] = contact.map() { $0.asJSON() } } if let date = self.date { json["date"] = date.asJSON() @@ -248,13 +248,13 @@ public class NamingSystem: DomainResource { json["type"] = type.asJSON() } if let uniqueId = self.uniqueId { - json["uniqueId"] = NamingSystemUniqueId.asJSONArray(uniqueId) + json["uniqueId"] = uniqueId.map() { $0.asJSON() } } if let usage = self.usage { json["usage"] = usage.asJSON() } if let useContext = self.useContext { - json["useContext"] = CodeableConcept.asJSONArray(useContext) + json["useContext"] = useContext.map() { $0.asJSON() } } return json @@ -316,7 +316,7 @@ public class NamingSystemContact: BackboneElement { json["name"] = name.asJSON() } if let telecom = self.telecom { - json["telecom"] = ContactPoint.asJSONArray(telecom) + json["telecom"] = telecom.map() { $0.asJSON() } } return json diff --git a/Sources/Models/NutritionOrder.swift b/Sources/Models/NutritionOrder.swift index e084ee13..c86bb680 100644 --- a/Sources/Models/NutritionOrder.swift +++ b/Sources/Models/NutritionOrder.swift @@ -193,7 +193,7 @@ public class NutritionOrder: DomainResource { var json = super.asJSON() if let allergyIntolerance = self.allergyIntolerance { - json["allergyIntolerance"] = Reference.asJSONArray(allergyIntolerance) + json["allergyIntolerance"] = allergyIntolerance.map() { $0.asJSON() } } if let dateTime = self.dateTime { json["dateTime"] = dateTime.asJSON() @@ -205,13 +205,13 @@ public class NutritionOrder: DomainResource { json["enteralFormula"] = enteralFormula.asJSON() } if let excludeFoodModifier = self.excludeFoodModifier { - json["excludeFoodModifier"] = CodeableConcept.asJSONArray(excludeFoodModifier) + json["excludeFoodModifier"] = excludeFoodModifier.map() { $0.asJSON() } } if let foodPreferenceModifier = self.foodPreferenceModifier { - json["foodPreferenceModifier"] = CodeableConcept.asJSONArray(foodPreferenceModifier) + json["foodPreferenceModifier"] = foodPreferenceModifier.map() { $0.asJSON() } } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let oralDiet = self.oralDiet { json["oralDiet"] = oralDiet.asJSON() @@ -226,7 +226,7 @@ public class NutritionOrder: DomainResource { json["status"] = status.asJSON() } if let supplement = self.supplement { - json["supplement"] = NutritionOrderSupplement.asJSONArray(supplement) + json["supplement"] = supplement.map() { $0.asJSON() } } return json @@ -376,7 +376,7 @@ public class NutritionOrderEnteralFormula: BackboneElement { json["additiveType"] = additiveType.asJSON() } if let administration = self.administration { - json["administration"] = NutritionOrderEnteralFormulaAdministration.asJSONArray(administration) + json["administration"] = administration.map() { $0.asJSON() } } if let administrationInstruction = self.administrationInstruction { json["administrationInstruction"] = administrationInstruction.asJSON() @@ -595,22 +595,22 @@ public class NutritionOrderOralDiet: BackboneElement { var json = super.asJSON() if let fluidConsistencyType = self.fluidConsistencyType { - json["fluidConsistencyType"] = CodeableConcept.asJSONArray(fluidConsistencyType) + json["fluidConsistencyType"] = fluidConsistencyType.map() { $0.asJSON() } } if let instruction = self.instruction { json["instruction"] = instruction.asJSON() } if let nutrient = self.nutrient { - json["nutrient"] = NutritionOrderOralDietNutrient.asJSONArray(nutrient) + json["nutrient"] = nutrient.map() { $0.asJSON() } } if let schedule = self.schedule { - json["schedule"] = Timing.asJSONArray(schedule) + json["schedule"] = schedule.map() { $0.asJSON() } } if let texture = self.texture { - json["texture"] = NutritionOrderOralDietTexture.asJSONArray(texture) + json["texture"] = texture.map() { $0.asJSON() } } if let type = self.type { - json["type"] = CodeableConcept.asJSONArray(type) + json["type"] = type.map() { $0.asJSON() } } return json @@ -839,7 +839,7 @@ public class NutritionOrderSupplement: BackboneElement { json["quantity"] = quantity.asJSON() } if let schedule = self.schedule { - json["schedule"] = Timing.asJSONArray(schedule) + json["schedule"] = schedule.map() { $0.asJSON() } } if let type = self.type { json["type"] = type.asJSON() diff --git a/Sources/Models/Observation.swift b/Sources/Models/Observation.swift index 5264aa23..b3406fc1 100644 --- a/Sources/Models/Observation.swift +++ b/Sources/Models/Observation.swift @@ -421,7 +421,7 @@ public class Observation: DomainResource { json["comments"] = comments.asJSON() } if let component = self.component { - json["component"] = ObservationComponent.asJSONArray(component) + json["component"] = component.map() { $0.asJSON() } } if let dataAbsentReason = self.dataAbsentReason { json["dataAbsentReason"] = dataAbsentReason.asJSON() @@ -439,7 +439,7 @@ public class Observation: DomainResource { json["encounter"] = encounter.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let interpretation = self.interpretation { json["interpretation"] = interpretation.asJSON() @@ -451,13 +451,13 @@ public class Observation: DomainResource { json["method"] = method.asJSON() } if let performer = self.performer { - json["performer"] = Reference.asJSONArray(performer) + json["performer"] = performer.map() { $0.asJSON() } } if let referenceRange = self.referenceRange { - json["referenceRange"] = ObservationReferenceRange.asJSONArray(referenceRange) + json["referenceRange"] = referenceRange.map() { $0.asJSON() } } if let related = self.related { - json["related"] = ObservationRelated.asJSONArray(related) + json["related"] = related.map() { $0.asJSON() } } if let specimen = self.specimen { json["specimen"] = specimen.asJSON() @@ -704,7 +704,7 @@ public class ObservationComponent: BackboneElement { json["dataAbsentReason"] = dataAbsentReason.asJSON() } if let referenceRange = self.referenceRange { - json["referenceRange"] = ObservationReferenceRange.asJSONArray(referenceRange) + json["referenceRange"] = referenceRange.map() { $0.asJSON() } } if let valueAttachment = self.valueAttachment { json["valueAttachment"] = valueAttachment.asJSON() diff --git a/Sources/Models/OperationDefinition.swift b/Sources/Models/OperationDefinition.swift index fee274c5..f5b5f523 100644 --- a/Sources/Models/OperationDefinition.swift +++ b/Sources/Models/OperationDefinition.swift @@ -300,7 +300,7 @@ public class OperationDefinition: DomainResource { json["code"] = code.asJSON() } if let contact = self.contact { - json["contact"] = OperationDefinitionContact.asJSONArray(contact) + json["contact"] = contact.map() { $0.asJSON() } } if let date = self.date { json["date"] = date.asJSON() @@ -327,7 +327,7 @@ public class OperationDefinition: DomainResource { json["notes"] = notes.asJSON() } if let parameter = self.parameter { - json["parameter"] = OperationDefinitionParameter.asJSONArray(parameter) + json["parameter"] = parameter.map() { $0.asJSON() } } if let publisher = self.publisher { json["publisher"] = publisher.asJSON() @@ -414,7 +414,7 @@ public class OperationDefinitionContact: BackboneElement { json["name"] = name.asJSON() } if let telecom = self.telecom { - json["telecom"] = ContactPoint.asJSONArray(telecom) + json["telecom"] = telecom.map() { $0.asJSON() } } return json @@ -593,7 +593,7 @@ public class OperationDefinitionParameter: BackboneElement { json["name"] = name.asJSON() } if let part = self.part { - json["part"] = OperationDefinitionParameter.asJSONArray(part) + json["part"] = part.map() { $0.asJSON() } } if let profile = self.profile { json["profile"] = profile.asJSON() diff --git a/Sources/Models/OperationOutcome.swift b/Sources/Models/OperationOutcome.swift index 75f6e9c6..f3c1bf3a 100644 --- a/Sources/Models/OperationOutcome.swift +++ b/Sources/Models/OperationOutcome.swift @@ -57,7 +57,7 @@ public class OperationOutcome: DomainResource { var json = super.asJSON() if let issue = self.issue { - json["issue"] = OperationOutcomeIssue.asJSONArray(issue) + json["issue"] = issue.map() { $0.asJSON() } } return json diff --git a/Sources/Models/Order.swift b/Sources/Models/Order.swift index 31568a76..5ce291d1 100644 --- a/Sources/Models/Order.swift +++ b/Sources/Models/Order.swift @@ -154,10 +154,10 @@ public class Order: DomainResource { json["date"] = date.asJSON() } if let detail = self.detail { - json["detail"] = Reference.asJSONArray(detail) + json["detail"] = detail.map() { $0.asJSON() } } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let reasonCodeableConcept = self.reasonCodeableConcept { json["reasonCodeableConcept"] = reasonCodeableConcept.asJSON() diff --git a/Sources/Models/OrderResponse.swift b/Sources/Models/OrderResponse.swift index 0f812c82..ecc63fdc 100644 --- a/Sources/Models/OrderResponse.swift +++ b/Sources/Models/OrderResponse.swift @@ -137,10 +137,10 @@ public class OrderResponse: DomainResource { json["description"] = description_fhir.asJSON() } if let fulfillment = self.fulfillment { - json["fulfillment"] = Reference.asJSONArray(fulfillment) + json["fulfillment"] = fulfillment.map() { $0.asJSON() } } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let orderStatus = self.orderStatus { json["orderStatus"] = orderStatus.asJSON() diff --git a/Sources/Models/Organization.swift b/Sources/Models/Organization.swift index dad07e3f..3bb4d072 100644 --- a/Sources/Models/Organization.swift +++ b/Sources/Models/Organization.swift @@ -137,13 +137,13 @@ public class Organization: DomainResource { json["active"] = active.asJSON() } if let address = self.address { - json["address"] = Address.asJSONArray(address) + json["address"] = address.map() { $0.asJSON() } } if let contact = self.contact { - json["contact"] = OrganizationContact.asJSONArray(contact) + json["contact"] = contact.map() { $0.asJSON() } } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let name = self.name { json["name"] = name.asJSON() @@ -152,7 +152,7 @@ public class Organization: DomainResource { json["partOf"] = partOf.asJSON() } if let telecom = self.telecom { - json["telecom"] = ContactPoint.asJSONArray(telecom) + json["telecom"] = telecom.map() { $0.asJSON() } } if let type = self.type { json["type"] = type.asJSON() @@ -245,7 +245,7 @@ public class OrganizationContact: BackboneElement { json["purpose"] = purpose.asJSON() } if let telecom = self.telecom { - json["telecom"] = ContactPoint.asJSONArray(telecom) + json["telecom"] = telecom.map() { $0.asJSON() } } return json diff --git a/Sources/Models/Parameters.swift b/Sources/Models/Parameters.swift index 8ea2627c..c59806b2 100644 --- a/Sources/Models/Parameters.swift +++ b/Sources/Models/Parameters.swift @@ -49,7 +49,7 @@ public class Parameters: Resource { var json = super.asJSON() if let parameter = self.parameter { - json["parameter"] = ParametersParameter.asJSONArray(parameter) + json["parameter"] = parameter.map() { $0.asJSON() } } return json @@ -528,7 +528,7 @@ public class ParametersParameter: BackboneElement { json["name"] = name.asJSON() } if let part = self.part { - json["part"] = ParametersParameter.asJSONArray(part) + json["part"] = part.map() { $0.asJSON() } } if let resource = self.resource { json["resource"] = resource.asJSON() diff --git a/Sources/Models/Patient.swift b/Sources/Models/Patient.swift index cb672ed7..c3e5a036 100644 --- a/Sources/Models/Patient.swift +++ b/Sources/Models/Patient.swift @@ -268,7 +268,7 @@ public class Patient: DomainResource { json["active"] = active.asJSON() } if let address = self.address { - json["address"] = Address.asJSONArray(address) + json["address"] = address.map() { $0.asJSON() } } if let animal = self.animal { json["animal"] = animal.asJSON() @@ -277,13 +277,13 @@ public class Patient: DomainResource { json["birthDate"] = birthDate.asJSON() } if let careProvider = self.careProvider { - json["careProvider"] = Reference.asJSONArray(careProvider) + json["careProvider"] = careProvider.map() { $0.asJSON() } } if let communication = self.communication { - json["communication"] = PatientCommunication.asJSONArray(communication) + json["communication"] = communication.map() { $0.asJSON() } } if let contact = self.contact { - json["contact"] = PatientContact.asJSONArray(contact) + json["contact"] = contact.map() { $0.asJSON() } } if let deceasedBoolean = self.deceasedBoolean { json["deceasedBoolean"] = deceasedBoolean.asJSON() @@ -295,10 +295,10 @@ public class Patient: DomainResource { json["gender"] = gender.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let link = self.link { - json["link"] = PatientLink.asJSONArray(link) + json["link"] = link.map() { $0.asJSON() } } if let managingOrganization = self.managingOrganization { json["managingOrganization"] = managingOrganization.asJSON() @@ -313,13 +313,13 @@ public class Patient: DomainResource { json["multipleBirthInteger"] = multipleBirthInteger.asJSON() } if let name = self.name { - json["name"] = HumanName.asJSONArray(name) + json["name"] = name.map() { $0.asJSON() } } if let photo = self.photo { - json["photo"] = Attachment.asJSONArray(photo) + json["photo"] = photo.map() { $0.asJSON() } } if let telecom = self.telecom { - json["telecom"] = ContactPoint.asJSONArray(telecom) + json["telecom"] = telecom.map() { $0.asJSON() } } return json @@ -608,10 +608,10 @@ public class PatientContact: BackboneElement { json["period"] = period.asJSON() } if let relationship = self.relationship { - json["relationship"] = CodeableConcept.asJSONArray(relationship) + json["relationship"] = relationship.map() { $0.asJSON() } } if let telecom = self.telecom { - json["telecom"] = ContactPoint.asJSONArray(telecom) + json["telecom"] = telecom.map() { $0.asJSON() } } return json diff --git a/Sources/Models/PaymentNotice.swift b/Sources/Models/PaymentNotice.swift index 36bca6c0..a68e0223 100644 --- a/Sources/Models/PaymentNotice.swift +++ b/Sources/Models/PaymentNotice.swift @@ -169,7 +169,7 @@ public class PaymentNotice: DomainResource { json["created"] = created.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let organization = self.organization { json["organization"] = organization.asJSON() diff --git a/Sources/Models/PaymentReconciliation.swift b/Sources/Models/PaymentReconciliation.swift index 01c43718..829b0700 100644 --- a/Sources/Models/PaymentReconciliation.swift +++ b/Sources/Models/PaymentReconciliation.swift @@ -228,7 +228,7 @@ public class PaymentReconciliation: DomainResource { json["created"] = created.asJSON() } if let detail = self.detail { - json["detail"] = PaymentReconciliationDetail.asJSONArray(detail) + json["detail"] = detail.map() { $0.asJSON() } } if let disposition = self.disposition { json["disposition"] = disposition.asJSON() @@ -237,10 +237,10 @@ public class PaymentReconciliation: DomainResource { json["form"] = form.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let note = self.note { - json["note"] = PaymentReconciliationNote.asJSONArray(note) + json["note"] = note.map() { $0.asJSON() } } if let organization = self.organization { json["organization"] = organization.asJSON() diff --git a/Sources/Models/Person.swift b/Sources/Models/Person.swift index 4fa02a72..e4d3c051 100644 --- a/Sources/Models/Person.swift +++ b/Sources/Models/Person.swift @@ -159,7 +159,7 @@ public class Person: DomainResource { json["active"] = active.asJSON() } if let address = self.address { - json["address"] = Address.asJSONArray(address) + json["address"] = address.map() { $0.asJSON() } } if let birthDate = self.birthDate { json["birthDate"] = birthDate.asJSON() @@ -168,22 +168,22 @@ public class Person: DomainResource { json["gender"] = gender.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let link = self.link { - json["link"] = PersonLink.asJSONArray(link) + json["link"] = link.map() { $0.asJSON() } } if let managingOrganization = self.managingOrganization { json["managingOrganization"] = managingOrganization.asJSON() } if let name = self.name { - json["name"] = HumanName.asJSONArray(name) + json["name"] = name.map() { $0.asJSON() } } if let photo = self.photo { json["photo"] = photo.asJSON() } if let telecom = self.telecom { - json["telecom"] = ContactPoint.asJSONArray(telecom) + json["telecom"] = telecom.map() { $0.asJSON() } } return json diff --git a/Sources/Models/Practitioner.swift b/Sources/Models/Practitioner.swift index 20ff7a4d..59c80ce8 100644 --- a/Sources/Models/Practitioner.swift +++ b/Sources/Models/Practitioner.swift @@ -171,34 +171,34 @@ public class Practitioner: DomainResource { json["active"] = active.asJSON() } if let address = self.address { - json["address"] = Address.asJSONArray(address) + json["address"] = address.map() { $0.asJSON() } } if let birthDate = self.birthDate { json["birthDate"] = birthDate.asJSON() } if let communication = self.communication { - json["communication"] = CodeableConcept.asJSONArray(communication) + json["communication"] = communication.map() { $0.asJSON() } } if let gender = self.gender { json["gender"] = gender.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let name = self.name { json["name"] = name.asJSON() } if let photo = self.photo { - json["photo"] = Attachment.asJSONArray(photo) + json["photo"] = photo.map() { $0.asJSON() } } if let practitionerRole = self.practitionerRole { - json["practitionerRole"] = PractitionerPractitionerRole.asJSONArray(practitionerRole) + json["practitionerRole"] = practitionerRole.map() { $0.asJSON() } } if let qualification = self.qualification { - json["qualification"] = PractitionerQualification.asJSONArray(qualification) + json["qualification"] = qualification.map() { $0.asJSON() } } if let telecom = self.telecom { - json["telecom"] = ContactPoint.asJSONArray(telecom) + json["telecom"] = telecom.map() { $0.asJSON() } } return json @@ -305,10 +305,10 @@ public class PractitionerPractitionerRole: BackboneElement { var json = super.asJSON() if let healthcareService = self.healthcareService { - json["healthcareService"] = Reference.asJSONArray(healthcareService) + json["healthcareService"] = healthcareService.map() { $0.asJSON() } } if let location = self.location { - json["location"] = Reference.asJSONArray(location) + json["location"] = location.map() { $0.asJSON() } } if let managingOrganization = self.managingOrganization { json["managingOrganization"] = managingOrganization.asJSON() @@ -320,7 +320,7 @@ public class PractitionerPractitionerRole: BackboneElement { json["role"] = role.asJSON() } if let specialty = self.specialty { - json["specialty"] = CodeableConcept.asJSONArray(specialty) + json["specialty"] = specialty.map() { $0.asJSON() } } return json @@ -413,7 +413,7 @@ public class PractitionerQualification: BackboneElement { json["code"] = code.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let issuer = self.issuer { json["issuer"] = issuer.asJSON() diff --git a/Sources/Models/Procedure.swift b/Sources/Models/Procedure.swift index 2ee54a0d..38e7566f 100644 --- a/Sources/Models/Procedure.swift +++ b/Sources/Models/Procedure.swift @@ -330,7 +330,7 @@ public class Procedure: DomainResource { var json = super.asJSON() if let bodySite = self.bodySite { - json["bodySite"] = CodeableConcept.asJSONArray(bodySite) + json["bodySite"] = bodySite.map() { $0.asJSON() } } if let category = self.category { json["category"] = category.asJSON() @@ -339,19 +339,19 @@ public class Procedure: DomainResource { json["code"] = code.asJSON() } if let complication = self.complication { - json["complication"] = CodeableConcept.asJSONArray(complication) + json["complication"] = complication.map() { $0.asJSON() } } if let encounter = self.encounter { json["encounter"] = encounter.asJSON() } if let focalDevice = self.focalDevice { - json["focalDevice"] = ProcedureFocalDevice.asJSONArray(focalDevice) + json["focalDevice"] = focalDevice.map() { $0.asJSON() } } if let followUp = self.followUp { - json["followUp"] = CodeableConcept.asJSONArray(followUp) + json["followUp"] = followUp.map() { $0.asJSON() } } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let location = self.location { json["location"] = location.asJSON() @@ -360,7 +360,7 @@ public class Procedure: DomainResource { json["notPerformed"] = notPerformed.asJSON() } if let notes = self.notes { - json["notes"] = Annotation.asJSONArray(notes) + json["notes"] = notes.map() { $0.asJSON() } } if let outcome = self.outcome { json["outcome"] = outcome.asJSON() @@ -372,19 +372,19 @@ public class Procedure: DomainResource { json["performedPeriod"] = performedPeriod.asJSON() } if let performer = self.performer { - json["performer"] = ProcedurePerformer.asJSONArray(performer) + json["performer"] = performer.map() { $0.asJSON() } } if let reasonCodeableConcept = self.reasonCodeableConcept { json["reasonCodeableConcept"] = reasonCodeableConcept.asJSON() } if let reasonNotPerformed = self.reasonNotPerformed { - json["reasonNotPerformed"] = CodeableConcept.asJSONArray(reasonNotPerformed) + json["reasonNotPerformed"] = reasonNotPerformed.map() { $0.asJSON() } } if let reasonReference = self.reasonReference { json["reasonReference"] = reasonReference.asJSON() } if let report = self.report { - json["report"] = Reference.asJSONArray(report) + json["report"] = report.map() { $0.asJSON() } } if let request = self.request { json["request"] = request.asJSON() @@ -396,7 +396,7 @@ public class Procedure: DomainResource { json["subject"] = subject.asJSON() } if let used = self.used { - json["used"] = Reference.asJSONArray(used) + json["used"] = used.map() { $0.asJSON() } } return json diff --git a/Sources/Models/ProcedureRequest.swift b/Sources/Models/ProcedureRequest.swift index e4dfbc75..b148bafe 100644 --- a/Sources/Models/ProcedureRequest.swift +++ b/Sources/Models/ProcedureRequest.swift @@ -271,7 +271,7 @@ public class ProcedureRequest: DomainResource { json["asNeededCodeableConcept"] = asNeededCodeableConcept.asJSON() } if let bodySite = self.bodySite { - json["bodySite"] = CodeableConcept.asJSONArray(bodySite) + json["bodySite"] = bodySite.map() { $0.asJSON() } } if let code = self.code { json["code"] = code.asJSON() @@ -280,10 +280,10 @@ public class ProcedureRequest: DomainResource { json["encounter"] = encounter.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let notes = self.notes { - json["notes"] = Annotation.asJSONArray(notes) + json["notes"] = notes.map() { $0.asJSON() } } if let orderedOn = self.orderedOn { json["orderedOn"] = orderedOn.asJSON() diff --git a/Sources/Models/ProcessRequest.swift b/Sources/Models/ProcessRequest.swift index f82f317b..a47ee334 100644 --- a/Sources/Models/ProcessRequest.swift +++ b/Sources/Models/ProcessRequest.swift @@ -251,7 +251,7 @@ public class ProcessRequest: DomainResource { json["exclude"] = arr } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let include = self.include { var arr = [Any]() @@ -261,7 +261,7 @@ public class ProcessRequest: DomainResource { json["include"] = arr } if let item = self.item { - json["item"] = ProcessRequestItem.asJSONArray(item) + json["item"] = item.map() { $0.asJSON() } } if let nullify = self.nullify { json["nullify"] = nullify.asJSON() diff --git a/Sources/Models/ProcessResponse.swift b/Sources/Models/ProcessResponse.swift index 5b6d58cd..824404cc 100644 --- a/Sources/Models/ProcessResponse.swift +++ b/Sources/Models/ProcessResponse.swift @@ -198,16 +198,16 @@ public class ProcessResponse: DomainResource { json["disposition"] = disposition.asJSON() } if let error = self.error { - json["error"] = Coding.asJSONArray(error) + json["error"] = error.map() { $0.asJSON() } } if let form = self.form { json["form"] = form.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let notes = self.notes { - json["notes"] = ProcessResponseNotes.asJSONArray(notes) + json["notes"] = notes.map() { $0.asJSON() } } if let organization = self.organization { json["organization"] = organization.asJSON() diff --git a/Sources/Models/Provenance.swift b/Sources/Models/Provenance.swift index 2b6f556b..f507cb15 100644 --- a/Sources/Models/Provenance.swift +++ b/Sources/Models/Provenance.swift @@ -178,10 +178,10 @@ public class Provenance: DomainResource { json["activity"] = activity.asJSON() } if let agent = self.agent { - json["agent"] = ProvenanceAgent.asJSONArray(agent) + json["agent"] = agent.map() { $0.asJSON() } } if let entity = self.entity { - json["entity"] = ProvenanceEntity.asJSONArray(entity) + json["entity"] = entity.map() { $0.asJSON() } } if let location = self.location { json["location"] = location.asJSON() @@ -197,16 +197,16 @@ public class Provenance: DomainResource { json["policy"] = arr } if let reason = self.reason { - json["reason"] = CodeableConcept.asJSONArray(reason) + json["reason"] = reason.map() { $0.asJSON() } } if let recorded = self.recorded { json["recorded"] = recorded.asJSON() } if let signature = self.signature { - json["signature"] = Signature.asJSONArray(signature) + json["signature"] = signature.map() { $0.asJSON() } } if let target = self.target { - json["target"] = Reference.asJSONArray(target) + json["target"] = target.map() { $0.asJSON() } } return json @@ -303,7 +303,7 @@ public class ProvenanceAgent: BackboneElement { json["actor"] = actor.asJSON() } if let relatedAgent = self.relatedAgent { - json["relatedAgent"] = ProvenanceAgentRelatedAgent.asJSONArray(relatedAgent) + json["relatedAgent"] = relatedAgent.map() { $0.asJSON() } } if let role = self.role { json["role"] = role.asJSON() diff --git a/Sources/Models/Questionnaire.swift b/Sources/Models/Questionnaire.swift index cf7f31ee..9dd80623 100644 --- a/Sources/Models/Questionnaire.swift +++ b/Sources/Models/Questionnaire.swift @@ -152,7 +152,7 @@ public class Questionnaire: DomainResource { json["group"] = group.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let publisher = self.publisher { json["publisher"] = publisher.asJSON() @@ -168,7 +168,7 @@ public class Questionnaire: DomainResource { json["subjectType"] = arr } if let telecom = self.telecom { - json["telecom"] = ContactPoint.asJSONArray(telecom) + json["telecom"] = telecom.map() { $0.asJSON() } } if let version = self.version { json["version"] = version.asJSON() @@ -302,16 +302,16 @@ public class QuestionnaireGroup: BackboneElement { var json = super.asJSON() if let concept = self.concept { - json["concept"] = Coding.asJSONArray(concept) + json["concept"] = concept.map() { $0.asJSON() } } if let group = self.group { - json["group"] = QuestionnaireGroup.asJSONArray(group) + json["group"] = group.map() { $0.asJSON() } } if let linkId = self.linkId { json["linkId"] = linkId.asJSON() } if let question = self.question { - json["question"] = QuestionnaireGroupQuestion.asJSONArray(question) + json["question"] = question.map() { $0.asJSON() } } if let repeats = self.repeats { json["repeats"] = repeats.asJSON() @@ -466,16 +466,16 @@ public class QuestionnaireGroupQuestion: BackboneElement { var json = super.asJSON() if let concept = self.concept { - json["concept"] = Coding.asJSONArray(concept) + json["concept"] = concept.map() { $0.asJSON() } } if let group = self.group { - json["group"] = QuestionnaireGroup.asJSONArray(group) + json["group"] = group.map() { $0.asJSON() } } if let linkId = self.linkId { json["linkId"] = linkId.asJSON() } if let option = self.option { - json["option"] = Coding.asJSONArray(option) + json["option"] = option.map() { $0.asJSON() } } if let options = self.options { json["options"] = options.asJSON() diff --git a/Sources/Models/QuestionnaireResponse.swift b/Sources/Models/QuestionnaireResponse.swift index d1b728bc..2af66225 100644 --- a/Sources/Models/QuestionnaireResponse.swift +++ b/Sources/Models/QuestionnaireResponse.swift @@ -285,13 +285,13 @@ public class QuestionnaireResponseGroup: BackboneElement { var json = super.asJSON() if let group = self.group { - json["group"] = QuestionnaireResponseGroup.asJSONArray(group) + json["group"] = group.map() { $0.asJSON() } } if let linkId = self.linkId { json["linkId"] = linkId.asJSON() } if let question = self.question { - json["question"] = QuestionnaireResponseGroupQuestion.asJSONArray(question) + json["question"] = question.map() { $0.asJSON() } } if let subject = self.subject { json["subject"] = subject.asJSON() @@ -371,7 +371,7 @@ public class QuestionnaireResponseGroupQuestion: BackboneElement { var json = super.asJSON() if let answer = self.answer { - json["answer"] = QuestionnaireResponseGroupQuestionAnswer.asJSONArray(answer) + json["answer"] = answer.map() { $0.asJSON() } } if let linkId = self.linkId { json["linkId"] = linkId.asJSON() @@ -580,7 +580,7 @@ public class QuestionnaireResponseGroupQuestionAnswer: BackboneElement { var json = super.asJSON() if let group = self.group { - json["group"] = QuestionnaireResponseGroup.asJSONArray(group) + json["group"] = group.map() { $0.asJSON() } } if let valueAttachment = self.valueAttachment { json["valueAttachment"] = valueAttachment.asJSON() diff --git a/Sources/Models/ReferralRequest.swift b/Sources/Models/ReferralRequest.swift index 2c71e903..415e6a13 100644 --- a/Sources/Models/ReferralRequest.swift +++ b/Sources/Models/ReferralRequest.swift @@ -253,7 +253,7 @@ public class ReferralRequest: DomainResource { json["fulfillmentTime"] = fulfillmentTime.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let patient = self.patient { json["patient"] = patient.asJSON() @@ -265,13 +265,13 @@ public class ReferralRequest: DomainResource { json["reason"] = reason.asJSON() } if let recipient = self.recipient { - json["recipient"] = Reference.asJSONArray(recipient) + json["recipient"] = recipient.map() { $0.asJSON() } } if let requester = self.requester { json["requester"] = requester.asJSON() } if let serviceRequested = self.serviceRequested { - json["serviceRequested"] = CodeableConcept.asJSONArray(serviceRequested) + json["serviceRequested"] = serviceRequested.map() { $0.asJSON() } } if let specialty = self.specialty { json["specialty"] = specialty.asJSON() @@ -280,7 +280,7 @@ public class ReferralRequest: DomainResource { json["status"] = status.asJSON() } if let supportingInformation = self.supportingInformation { - json["supportingInformation"] = Reference.asJSONArray(supportingInformation) + json["supportingInformation"] = supportingInformation.map() { $0.asJSON() } } if let type = self.type { json["type"] = type.asJSON() diff --git a/Sources/Models/RelatedPerson.swift b/Sources/Models/RelatedPerson.swift index e2f2a92a..75a950b4 100644 --- a/Sources/Models/RelatedPerson.swift +++ b/Sources/Models/RelatedPerson.swift @@ -166,7 +166,7 @@ public class RelatedPerson: DomainResource { var json = super.asJSON() if let address = self.address { - json["address"] = Address.asJSONArray(address) + json["address"] = address.map() { $0.asJSON() } } if let birthDate = self.birthDate { json["birthDate"] = birthDate.asJSON() @@ -175,7 +175,7 @@ public class RelatedPerson: DomainResource { json["gender"] = gender.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let name = self.name { json["name"] = name.asJSON() @@ -187,13 +187,13 @@ public class RelatedPerson: DomainResource { json["period"] = period.asJSON() } if let photo = self.photo { - json["photo"] = Attachment.asJSONArray(photo) + json["photo"] = photo.map() { $0.asJSON() } } if let relationship = self.relationship { json["relationship"] = relationship.asJSON() } if let telecom = self.telecom { - json["telecom"] = ContactPoint.asJSONArray(telecom) + json["telecom"] = telecom.map() { $0.asJSON() } } return json diff --git a/Sources/Models/RiskAssessment.swift b/Sources/Models/RiskAssessment.swift index fd8aaf6f..d37ca6d9 100644 --- a/Sources/Models/RiskAssessment.swift +++ b/Sources/Models/RiskAssessment.swift @@ -156,7 +156,7 @@ public class RiskAssessment: DomainResource { var json = super.asJSON() if let basis = self.basis { - json["basis"] = Reference.asJSONArray(basis) + json["basis"] = basis.map() { $0.asJSON() } } if let condition = self.condition { json["condition"] = condition.asJSON() @@ -180,7 +180,7 @@ public class RiskAssessment: DomainResource { json["performer"] = performer.asJSON() } if let prediction = self.prediction { - json["prediction"] = RiskAssessmentPrediction.asJSONArray(prediction) + json["prediction"] = prediction.map() { $0.asJSON() } } if let subject = self.subject { json["subject"] = subject.asJSON() diff --git a/Sources/Models/Schedule.swift b/Sources/Models/Schedule.swift index 5177188f..fe37d512 100644 --- a/Sources/Models/Schedule.swift +++ b/Sources/Models/Schedule.swift @@ -109,13 +109,13 @@ public class Schedule: DomainResource { json["comment"] = comment.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let planningHorizon = self.planningHorizon { json["planningHorizon"] = planningHorizon.asJSON() } if let type = self.type { - json["type"] = CodeableConcept.asJSONArray(type) + json["type"] = type.map() { $0.asJSON() } } return json diff --git a/Sources/Models/SearchParameter.swift b/Sources/Models/SearchParameter.swift index f6a24342..8e086848 100644 --- a/Sources/Models/SearchParameter.swift +++ b/Sources/Models/SearchParameter.swift @@ -251,7 +251,7 @@ public class SearchParameter: DomainResource { json["code"] = code.asJSON() } if let contact = self.contact { - json["contact"] = SearchParameterContact.asJSONArray(contact) + json["contact"] = contact.map() { $0.asJSON() } } if let date = self.date { json["date"] = date.asJSON() @@ -353,7 +353,7 @@ public class SearchParameterContact: BackboneElement { json["name"] = name.asJSON() } if let telecom = self.telecom { - json["telecom"] = ContactPoint.asJSONArray(telecom) + json["telecom"] = telecom.map() { $0.asJSON() } } return json diff --git a/Sources/Models/Signature.swift b/Sources/Models/Signature.swift index 6f40c4be..7465ec18 100644 --- a/Sources/Models/Signature.swift +++ b/Sources/Models/Signature.swift @@ -144,7 +144,7 @@ public class Signature: Element { json["contentType"] = contentType.asJSON() } if let type = self.type { - json["type"] = Coding.asJSONArray(type) + json["type"] = type.map() { $0.asJSON() } } if let when = self.when { json["when"] = when.asJSON() diff --git a/Sources/Models/Slot.swift b/Sources/Models/Slot.swift index 39d69643..62df6eae 100644 --- a/Sources/Models/Slot.swift +++ b/Sources/Models/Slot.swift @@ -160,7 +160,7 @@ public class Slot: DomainResource { json["freeBusyType"] = freeBusyType.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let overbooked = self.overbooked { json["overbooked"] = overbooked.asJSON() diff --git a/Sources/Models/Specimen.swift b/Sources/Models/Specimen.swift index edef2697..d3db15ef 100644 --- a/Sources/Models/Specimen.swift +++ b/Sources/Models/Specimen.swift @@ -171,13 +171,13 @@ public class Specimen: DomainResource { json["collection"] = collection.asJSON() } if let container = self.container { - json["container"] = SpecimenContainer.asJSONArray(container) + json["container"] = container.map() { $0.asJSON() } } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let parent = self.parent { - json["parent"] = Reference.asJSONArray(parent) + json["parent"] = parent.map() { $0.asJSON() } } if let receivedTime = self.receivedTime { json["receivedTime"] = receivedTime.asJSON() @@ -189,7 +189,7 @@ public class Specimen: DomainResource { json["subject"] = subject.asJSON() } if let treatment = self.treatment { - json["treatment"] = SpecimenTreatment.asJSONArray(treatment) + json["treatment"] = treatment.map() { $0.asJSON() } } if let type = self.type { json["type"] = type.asJSON() @@ -465,7 +465,7 @@ public class SpecimenContainer: BackboneElement { json["description"] = description_fhir.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let specimenQuantity = self.specimenQuantity { json["specimenQuantity"] = specimenQuantity.asJSON() @@ -542,7 +542,7 @@ public class SpecimenTreatment: BackboneElement { var json = super.asJSON() if let additive = self.additive { - json["additive"] = Reference.asJSONArray(additive) + json["additive"] = additive.map() { $0.asJSON() } } if let description_fhir = self.description_fhir { json["description"] = description_fhir.asJSON() diff --git a/Sources/Models/StructureDefinition.swift b/Sources/Models/StructureDefinition.swift index 7a6d218b..4ce671c1 100644 --- a/Sources/Models/StructureDefinition.swift +++ b/Sources/Models/StructureDefinition.swift @@ -368,13 +368,13 @@ public class StructureDefinition: DomainResource { json["base"] = base.asJSON() } if let code = self.code { - json["code"] = Coding.asJSONArray(code) + json["code"] = code.map() { $0.asJSON() } } if let constrainedType = self.constrainedType { json["constrainedType"] = constrainedType.asJSON() } if let contact = self.contact { - json["contact"] = StructureDefinitionContact.asJSONArray(contact) + json["contact"] = contact.map() { $0.asJSON() } } if let context = self.context { var arr = [Any]() @@ -408,13 +408,13 @@ public class StructureDefinition: DomainResource { json["fhirVersion"] = fhirVersion.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let kind = self.kind { json["kind"] = kind.asJSON() } if let mapping = self.mapping { - json["mapping"] = StructureDefinitionMapping.asJSONArray(mapping) + json["mapping"] = mapping.map() { $0.asJSON() } } if let name = self.name { json["name"] = name.asJSON() @@ -435,7 +435,7 @@ public class StructureDefinition: DomainResource { json["url"] = url.asJSON() } if let useContext = self.useContext { - json["useContext"] = CodeableConcept.asJSONArray(useContext) + json["useContext"] = useContext.map() { $0.asJSON() } } if let version = self.version { json["version"] = version.asJSON() @@ -500,7 +500,7 @@ public class StructureDefinitionContact: BackboneElement { json["name"] = name.asJSON() } if let telecom = self.telecom { - json["telecom"] = ContactPoint.asJSONArray(telecom) + json["telecom"] = telecom.map() { $0.asJSON() } } return json @@ -557,7 +557,7 @@ public class StructureDefinitionDifferential: BackboneElement { var json = super.asJSON() if let element = self.element { - json["element"] = ElementDefinition.asJSONArray(element) + json["element"] = element.map() { $0.asJSON() } } return json @@ -715,7 +715,7 @@ public class StructureDefinitionSnapshot: BackboneElement { var json = super.asJSON() if let element = self.element { - json["element"] = ElementDefinition.asJSONArray(element) + json["element"] = element.map() { $0.asJSON() } } return json diff --git a/Sources/Models/Subscription.swift b/Sources/Models/Subscription.swift index d0f11828..f09e1b25 100644 --- a/Sources/Models/Subscription.swift +++ b/Sources/Models/Subscription.swift @@ -159,7 +159,7 @@ public class Subscription: DomainResource { json["channel"] = channel.asJSON() } if let contact = self.contact { - json["contact"] = ContactPoint.asJSONArray(contact) + json["contact"] = contact.map() { $0.asJSON() } } if let criteria = self.criteria { json["criteria"] = criteria.asJSON() @@ -177,7 +177,7 @@ public class Subscription: DomainResource { json["status"] = status.asJSON() } if let tag = self.tag { - json["tag"] = Coding.asJSONArray(tag) + json["tag"] = tag.map() { $0.asJSON() } } return json diff --git a/Sources/Models/Substance.swift b/Sources/Models/Substance.swift index 50756c6a..43f9640d 100644 --- a/Sources/Models/Substance.swift +++ b/Sources/Models/Substance.swift @@ -115,7 +115,7 @@ public class Substance: DomainResource { var json = super.asJSON() if let category = self.category { - json["category"] = CodeableConcept.asJSONArray(category) + json["category"] = category.map() { $0.asJSON() } } if let code = self.code { json["code"] = code.asJSON() @@ -124,13 +124,13 @@ public class Substance: DomainResource { json["description"] = description_fhir.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let ingredient = self.ingredient { - json["ingredient"] = SubstanceIngredient.asJSONArray(ingredient) + json["ingredient"] = ingredient.map() { $0.asJSON() } } if let instance = self.instance { - json["instance"] = SubstanceInstance.asJSONArray(instance) + json["instance"] = instance.map() { $0.asJSON() } } return json diff --git a/Sources/Models/SupplyDelivery.swift b/Sources/Models/SupplyDelivery.swift index 7d81cd44..210e1a3b 100644 --- a/Sources/Models/SupplyDelivery.swift +++ b/Sources/Models/SupplyDelivery.swift @@ -180,7 +180,7 @@ public class SupplyDelivery: DomainResource { json["quantity"] = quantity.asJSON() } if let receiver = self.receiver { - json["receiver"] = Reference.asJSONArray(receiver) + json["receiver"] = receiver.map() { $0.asJSON() } } if let status = self.status { json["status"] = status.asJSON() diff --git a/Sources/Models/SupplyRequest.swift b/Sources/Models/SupplyRequest.swift index dccfa1ce..5d59869b 100644 --- a/Sources/Models/SupplyRequest.swift +++ b/Sources/Models/SupplyRequest.swift @@ -195,7 +195,7 @@ public class SupplyRequest: DomainResource { json["status"] = status.asJSON() } if let supplier = self.supplier { - json["supplier"] = Reference.asJSONArray(supplier) + json["supplier"] = supplier.map() { $0.asJSON() } } if let when = self.when { json["when"] = when.asJSON() diff --git a/Sources/Models/TestScript.swift b/Sources/Models/TestScript.swift index fc3dafce..e82239ad 100644 --- a/Sources/Models/TestScript.swift +++ b/Sources/Models/TestScript.swift @@ -306,7 +306,7 @@ public class TestScript: DomainResource { var json = super.asJSON() if let contact = self.contact { - json["contact"] = TestScriptContact.asJSONArray(contact) + json["contact"] = contact.map() { $0.asJSON() } } if let copyright = self.copyright { json["copyright"] = copyright.asJSON() @@ -321,7 +321,7 @@ public class TestScript: DomainResource { json["experimental"] = experimental.asJSON() } if let fixture = self.fixture { - json["fixture"] = TestScriptFixture.asJSONArray(fixture) + json["fixture"] = fixture.map() { $0.asJSON() } } if let identifier = self.identifier { json["identifier"] = identifier.asJSON() @@ -336,7 +336,7 @@ public class TestScript: DomainResource { json["name"] = name.asJSON() } if let profile = self.profile { - json["profile"] = Reference.asJSONArray(profile) + json["profile"] = profile.map() { $0.asJSON() } } if let publisher = self.publisher { json["publisher"] = publisher.asJSON() @@ -354,16 +354,16 @@ public class TestScript: DomainResource { json["teardown"] = teardown.asJSON() } if let test = self.test { - json["test"] = TestScriptTest.asJSONArray(test) + json["test"] = test.map() { $0.asJSON() } } if let url = self.url { json["url"] = url.asJSON() } if let useContext = self.useContext { - json["useContext"] = CodeableConcept.asJSONArray(useContext) + json["useContext"] = useContext.map() { $0.asJSON() } } if let variable = self.variable { - json["variable"] = TestScriptVariable.asJSONArray(variable) + json["variable"] = variable.map() { $0.asJSON() } } if let version = self.version { json["version"] = version.asJSON() @@ -428,7 +428,7 @@ public class TestScriptContact: BackboneElement { json["name"] = name.asJSON() } if let telecom = self.telecom { - json["telecom"] = ContactPoint.asJSONArray(telecom) + json["telecom"] = telecom.map() { $0.asJSON() } } return json @@ -573,10 +573,10 @@ public class TestScriptMetadata: BackboneElement { var json = super.asJSON() if let capability = self.capability { - json["capability"] = TestScriptMetadataCapability.asJSONArray(capability) + json["capability"] = capability.map() { $0.asJSON() } } if let link = self.link { - json["link"] = TestScriptMetadataLink.asJSONArray(link) + json["link"] = link.map() { $0.asJSON() } } return json @@ -848,7 +848,7 @@ public class TestScriptSetup: BackboneElement { var json = super.asJSON() if let action = self.action { - json["action"] = TestScriptSetupAction.asJSONArray(action) + json["action"] = action.map() { $0.asJSON() } } if let metadata = self.metadata { json["metadata"] = metadata.asJSON() @@ -1439,7 +1439,7 @@ public class TestScriptSetupActionOperation: BackboneElement { json["params"] = params.asJSON() } if let requestHeader = self.requestHeader { - json["requestHeader"] = TestScriptSetupActionOperationRequestHeader.asJSONArray(requestHeader) + json["requestHeader"] = requestHeader.map() { $0.asJSON() } } if let resource = self.resource { json["resource"] = resource.asJSON() @@ -1588,7 +1588,7 @@ public class TestScriptTeardown: BackboneElement { var json = super.asJSON() if let action = self.action { - json["action"] = TestScriptTeardownAction.asJSONArray(action) + json["action"] = action.map() { $0.asJSON() } } return json @@ -1725,7 +1725,7 @@ public class TestScriptTest: BackboneElement { var json = super.asJSON() if let action = self.action { - json["action"] = TestScriptTestAction.asJSONArray(action) + json["action"] = action.map() { $0.asJSON() } } if let description_fhir = self.description_fhir { json["description"] = description_fhir.asJSON() diff --git a/Sources/Models/ValueSet.swift b/Sources/Models/ValueSet.swift index ec1efd04..08c8f501 100644 --- a/Sources/Models/ValueSet.swift +++ b/Sources/Models/ValueSet.swift @@ -279,7 +279,7 @@ public class ValueSet: DomainResource { json["compose"] = compose.asJSON() } if let contact = self.contact { - json["contact"] = ValueSetContact.asJSONArray(contact) + json["contact"] = contact.map() { $0.asJSON() } } if let copyright = self.copyright { json["copyright"] = copyright.asJSON() @@ -324,7 +324,7 @@ public class ValueSet: DomainResource { json["url"] = url.asJSON() } if let useContext = self.useContext { - json["useContext"] = CodeableConcept.asJSONArray(useContext) + json["useContext"] = useContext.map() { $0.asJSON() } } if let version = self.version { json["version"] = version.asJSON() @@ -427,7 +427,7 @@ public class ValueSetCodeSystem: BackboneElement { json["caseSensitive"] = caseSensitive.asJSON() } if let concept = self.concept { - json["concept"] = ValueSetCodeSystemConcept.asJSONArray(concept) + json["concept"] = concept.map() { $0.asJSON() } } if let system = self.system { json["system"] = system.asJSON() @@ -556,13 +556,13 @@ public class ValueSetCodeSystemConcept: BackboneElement { json["code"] = code.asJSON() } if let concept = self.concept { - json["concept"] = ValueSetCodeSystemConcept.asJSONArray(concept) + json["concept"] = concept.map() { $0.asJSON() } } if let definition = self.definition { json["definition"] = definition.asJSON() } if let designation = self.designation { - json["designation"] = ValueSetCodeSystemConceptDesignation.asJSONArray(designation) + json["designation"] = designation.map() { $0.asJSON() } } if let display = self.display { json["display"] = display.asJSON() @@ -724,7 +724,7 @@ public class ValueSetCompose: BackboneElement { var json = super.asJSON() if let exclude = self.exclude { - json["exclude"] = ValueSetComposeInclude.asJSONArray(exclude) + json["exclude"] = exclude.map() { $0.asJSON() } } if let import_fhir = self.import_fhir { var arr = [Any]() @@ -734,7 +734,7 @@ public class ValueSetCompose: BackboneElement { json["import"] = arr } if let include = self.include { - json["include"] = ValueSetComposeInclude.asJSONArray(include) + json["include"] = include.map() { $0.asJSON() } } return json @@ -824,10 +824,10 @@ public class ValueSetComposeInclude: BackboneElement { var json = super.asJSON() if let concept = self.concept { - json["concept"] = ValueSetComposeIncludeConcept.asJSONArray(concept) + json["concept"] = concept.map() { $0.asJSON() } } if let filter = self.filter { - json["filter"] = ValueSetComposeIncludeFilter.asJSONArray(filter) + json["filter"] = filter.map() { $0.asJSON() } } if let system = self.system { json["system"] = system.asJSON() @@ -916,7 +916,7 @@ public class ValueSetComposeIncludeConcept: BackboneElement { json["code"] = code.asJSON() } if let designation = self.designation { - json["designation"] = ValueSetCodeSystemConceptDesignation.asJSONArray(designation) + json["designation"] = designation.map() { $0.asJSON() } } if let display = self.display { json["display"] = display.asJSON() @@ -1076,7 +1076,7 @@ public class ValueSetContact: BackboneElement { json["name"] = name.asJSON() } if let telecom = self.telecom { - json["telecom"] = ContactPoint.asJSONArray(telecom) + json["telecom"] = telecom.map() { $0.asJSON() } } return json @@ -1197,7 +1197,7 @@ public class ValueSetExpansion: BackboneElement { var json = super.asJSON() if let contains = self.contains { - json["contains"] = ValueSetExpansionContains.asJSONArray(contains) + json["contains"] = contains.map() { $0.asJSON() } } if let identifier = self.identifier { json["identifier"] = identifier.asJSON() @@ -1206,7 +1206,7 @@ public class ValueSetExpansion: BackboneElement { json["offset"] = offset.asJSON() } if let parameter = self.parameter { - json["parameter"] = ValueSetExpansionParameter.asJSONArray(parameter) + json["parameter"] = parameter.map() { $0.asJSON() } } if let timestamp = self.timestamp { json["timestamp"] = timestamp.asJSON() @@ -1325,7 +1325,7 @@ public class ValueSetExpansionContains: BackboneElement { json["code"] = code.asJSON() } if let contains = self.contains { - json["contains"] = ValueSetExpansionContains.asJSONArray(contains) + json["contains"] = contains.map() { $0.asJSON() } } if let display = self.display { json["display"] = display.asJSON() diff --git a/Sources/Models/VisionPrescription.swift b/Sources/Models/VisionPrescription.swift index ddf46ce6..ae375559 100644 --- a/Sources/Models/VisionPrescription.swift +++ b/Sources/Models/VisionPrescription.swift @@ -135,13 +135,13 @@ public class VisionPrescription: DomainResource { json["dateWritten"] = dateWritten.asJSON() } if let dispense = self.dispense { - json["dispense"] = VisionPrescriptionDispense.asJSONArray(dispense) + json["dispense"] = dispense.map() { $0.asJSON() } } if let encounter = self.encounter { json["encounter"] = encounter.asJSON() } if let identifier = self.identifier { - json["identifier"] = Identifier.asJSONArray(identifier) + json["identifier"] = identifier.map() { $0.asJSON() } } if let patient = self.patient { json["patient"] = patient.asJSON() diff --git a/Tests/ResourceTests.swift b/Tests/ResourceTests.swift index 12b54369..9f24b120 100644 --- a/Tests/ResourceTests.swift +++ b/Tests/ResourceTests.swift @@ -204,10 +204,10 @@ class LocalPatientServer: FHIROpenServer { req.resource = pat try! req.prepareData() - callback(req.response(http, data: req.data)) + callback(req.response(with: http, data: req.data)) } else { - callback(handler.response(http)) + callback(handler.response(with: http)) } lastPostedResource = handler.resource @@ -222,7 +222,7 @@ class LocalPatientServer: FHIROpenServer { handler.resource = last try! handler.prepareData() - callback(handler.response(http, data: handler.data)) + callback(handler.response(with: http, data: handler.data)) } else { callback(handler.notSent("\(request.httpMethod) without preceding “POST” is not supported")) diff --git a/fhir-parser b/fhir-parser index 99a7fc99..7c79b9dc 160000 --- a/fhir-parser +++ b/fhir-parser @@ -1 +1 @@ -Subproject commit 99a7fc99c3c18e134d895e9bf3f15360206c55a9 +Subproject commit 7c79b9dcce3b6f015b3bb5c323f6b16296009b77