Skip to content

Commit

Permalink
Update to FHIR v4.0.0 and Swift 4.2 (#21) (#23)
Browse files Browse the repository at this point in the history
* Update to FHIR R4 v4.0.0

* Update to FHIR R4 v4.0.0

* Update fhir-parser and regenerate

* Update to FHIR R4, Swift 4.2
  • Loading branch information
drdavec authored and xmlmodeling committed Mar 7, 2019
1 parent f383716 commit f95b737
Show file tree
Hide file tree
Showing 401 changed files with 47,565 additions and 22,022 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0
4.2
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
=========

## 4.0

- Update to FHIR `R4` (v4.0.0-a53ec6ee1b)


## 3.0

- Update to FHIR `STU-3` (v3.0.0.11832)
Expand Down
4 changes: 2 additions & 2 deletions FHIR.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

Pod::Spec.new do |s|
s.name = "FHIR"
s.version = "3.0.0"
s.version = "4.0.0"
s.summary = "Swift 🔥FHIR data model classes, with some goodies."
s.description = <<-DESC
Swift 🔥FHIR data model classes, generated from spec. Uses custom Date/Time structs to facilitate
Expand All @@ -20,7 +20,7 @@ Pod::Spec.new do |s|
s.author = { "Pascal Pfiffner" => "[email protected]" }
s.source = { :git => "https://github.com/smart-on-fhir/Swift-FHIR.git", :tag => "#{s.version}" }

s.ios.deployment_target = "8.0"
s.ios.deployment_target = "11.0"
s.osx.deployment_target = "10.10"
s.requires_arc = true
s.pod_target_xcconfig = { 'OTHER_SWIFT_FLAGS' => '-DNO_MODEL_IMPORT' }
Expand Down
4 changes: 2 additions & 2 deletions Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>3.0</string>
<string>4.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>3.0.0.0</string>
<string>4.0.0.0</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2014 CHIP. All rights reserved.</string>
<key>NSPrincipalClass</key>
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FHIR Swift Classes
==================

These are [Swift][] classes representing data models of [🔥 FHIR][fhir] elements and resources, compatible with **iOS 8** and **OS X 10.9** and later.
These are [Swift][] classes representing data models of [🔥 FHIR][fhir] elements and resources, compatible with **iOS 11** and **OS X 10.13** and later.

This work is [Apache licensed](LICENSE.txt).
FHIR® is the registered trademark of [HL7][] and is used with the permission of HL7.
Expand All @@ -19,6 +19,7 @@ See [tags/releases](https://github.com/smart-on-fhir/Swift-FHIR/releases).

Version | Swift | FHIR | &nbsp;
---------|-----------|---------------|-----------------------------
**4.0**| 4.2 | `4.0.0-a53ec6ee1b` | R4
**3.1**| 3.2 | `3.0.0.11832` | STU 3
**3.0** | 3.0 | `3.0.0.11832` | STU 3
**2.10** | 3.0 | `1.8.0.10521` | STU 3 Freeze, Jan 2017
Expand Down
8 changes: 4 additions & 4 deletions Sources/Client/Element+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public extension FHIRPrimitive {
- parameter forURI: The URI defining the extension on the receiver
*/
public func extensions(forURI uri: String) -> [Extension]? {
return extension_fhir?.filter() { return $0.url?.absoluteString == uri }
return extension_fhir?.filter() { return $0.url?.string == uri }
}
}

Expand All @@ -33,7 +33,7 @@ public extension Element {
- parameter forURI: The URI defining the extension on the receiver
*/
public final func extensions(forURI uri: String) -> [Extension]? {
return extension_fhir?.filter() { return $0.url?.absoluteString == uri }
return extension_fhir?.filter() { return $0.url?.string == uri }
}
}

Expand All @@ -46,7 +46,7 @@ public extension DomainResource {
- parameter forURI: The URI defining the extension on the receiver
*/
public final func extensions(forURI uri: String) -> [Extension]? {
return extension_fhir?.filter() { return $0.url?.absoluteString == uri }
return extension_fhir?.filter() { return $0.url?.string == uri }
}

/**
Expand All @@ -55,7 +55,7 @@ public extension DomainResource {
- parameter forURI: The URI defining the modifier extension on the receiver
*/
public final func modifierExtensions(forURI uri: String) -> [Extension]? {
return modifierExtension?.filter() { return $0.url?.absoluteString == uri }
return modifierExtension?.filter() { return $0.url?.string == uri }
}
}

4 changes: 2 additions & 2 deletions Sources/Client/FHIRBaseRequestHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Base implementation of `FHIRRequestHandler`.
open class FHIRBaseRequestHandler: FHIRRequestHandler {

/// The HTTP method of the request.
open let method: FHIRRequestMethod
public let method: FHIRRequestMethod

/// Headers to be used on the request.
open var headers = FHIRRequestHeaders()
Expand Down Expand Up @@ -168,7 +168,7 @@ If you use this as PUT/POST, you are responsible for setting the `data` property
*/
open class FHIRDataRequestHandler: FHIRBaseRequestHandler {

open let contentType: String
public let contentType: String

init(_ method: FHIRRequestMethod, contentType: String) {
self.contentType = contentType
Expand Down
7 changes: 5 additions & 2 deletions Sources/Client/FHIROpenServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ open class FHIROpenServer: FHIRMinimalServer {
var operations: [String: OperationDefinition]?

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

/** Find operation with given name. */
func cababilityOperation(_ name: String) -> CapabilityStatementRestOperation? {
func cababilityOperation(_ name: String) -> CapabilityStatementRestResourceOperation? {
if let defs = cababilityOperations {
for def in defs {
if name == def.name?.string {
Expand All @@ -117,6 +117,8 @@ open class FHIROpenServer: FHIRMinimalServer {
if let op = operations?[name] {
callback(op)
}
// TODO resolve a 'canonical' reference
/*
else if let def = cababilityOperation(name) {
def.definition?.resolve(OperationDefinition.self) { optop in
if let op = optop {
Expand All @@ -130,6 +132,7 @@ open class FHIROpenServer: FHIRMinimalServer {
callback(optop)
}
}
*/
else {
callback(nil)
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/Client/FHIROperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ open class FHIROperation: CustomStringConvertible {
var instance: Resource? {
didSet {
if let inst = instance {
type = type(of: inst)
type = Swift.type(of: inst)
context = .instance
}
}
Expand Down Expand Up @@ -87,7 +87,7 @@ open class FHIROperation: CustomStringConvertible {
guard definition.type?.bool ?? false else {
throw FHIRError.operationConfigurationError("Operation \(self) cannot be executed in type context")
}
guard let resources = definition.resource, let typ = type, resources.contains(FHIRString(typ.resourceType)) else {
guard let resources = definition.resource, let typ = type, let resType = ResourceType(rawValue: typ.resourceType), resources.contains(resType) else {
throw FHIRError.operationConfigurationError("Operation \(self) cannot be executed against \(String(describing: type)) type")
}
case .instance:
Expand Down Expand Up @@ -181,5 +181,5 @@ open class FHIROperation: CustomStringConvertible {


/// Alias to `FHIROperation` for neat operation usage.
public typealias $ = FHIROperation
public typealias `$` = FHIROperation

10 changes: 5 additions & 5 deletions Sources/Client/FHIRServerDataResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ extension FHIRServerResponse {
// inspect ETag header
if var etag = headers["ETag"] {
if etag.hasPrefix("W/") {
etag = etag[etag.index(etag.startIndex, offsetBy: 2)..<etag.endIndex]
etag = String(etag[etag.index(etag.startIndex, offsetBy: 2)..<etag.endIndex])
}
if etag.hasPrefix("\"") {
etag = etag[etag.index(etag.startIndex, offsetBy: 1)..<etag.endIndex]
etag = String(etag[etag.index(etag.startIndex, offsetBy: 1)..<etag.endIndex])
}
if etag.hasSuffix("\"") {
etag = etag[etag.startIndex..<etag.index(etag.endIndex, offsetBy: -1)]
etag = String(etag[etag.startIndex..<etag.index(etag.endIndex, offsetBy: -1)])
}
resource.meta = resource.meta ?? Meta()
resource.meta!.versionId = FHIRString(etag)
Expand Down Expand Up @@ -93,10 +93,10 @@ open class FHIRServerDataResponse: FHIRServerResponse {
public internal(set) var handler: FHIRRequestHandler?

/// The HTTP status code.
open let status: Int
public let status: Int

/// Response headers.
open let headers: [String: String]
public let headers: [String: String]

/// The response body data.
open var body: Data?
Expand Down
2 changes: 1 addition & 1 deletion Sources/Client/Reference+Resolving.swift
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ extension Reference {
/** Strips the leading hash "#" symbol, if it's there, in order to perform a contained resource lookup. */
func processedReferenceIdentifier() -> String? {
if let ref = reference?.string, "#" == ref[ref.startIndex] {
return ref[ref.index(ref.startIndex, offsetBy: 1)..<ref.endIndex]
return String(ref[ref.index(ref.startIndex, offsetBy: 1)..<ref.endIndex])
}
return reference?.string
}
Expand Down
58 changes: 33 additions & 25 deletions Sources/Models/Account.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Account.swift
// SwiftFHIR
//
// Generated from FHIR 3.0.0.11832 (http://hl7.org/fhir/StructureDefinition/Account) on 2017-03-22.
// 2017, SMART Health IT.
// Generated from FHIR 4.0.0-a53ec6ee1b (http://hl7.org/fhir/StructureDefinition/Account) on 2019-03-01.
// 2019, SMART Health IT.
//

import Foundation
Expand All @@ -20,20 +20,14 @@ open class Account: DomainResource {
get { return "Account" }
}

/// Time window that transactions may be posted to this account.
public var active: Period?

/// How much is in account?.
public var balance: Money?

/// The party(s) that are responsible for covering the payment of this account, and what order should they be
/// applied to the account.
public var coverage: [AccountCoverage]?

/// Explanation of purpose/use.
public var description_fhir: FHIRString?

/// Responsible for the account.
/// The parties ultimately responsible for balancing the Account.
public var guarantor: [AccountGuarantor]?

/// Account number.
Expand All @@ -42,53 +36,67 @@ open class Account: DomainResource {
/// Human-readable label.
public var name: FHIRString?

/// Who is responsible?.
/// Entity managing the Account.
public var owner: Reference?

/// Reference to a parent Account.
public var partOf: Reference?

/// Transaction window.
public var period: Period?
public var servicePeriod: Period?

/// Indicates whether the account is presently used/usable or not.
public var status: AccountStatus?

/// What is account tied to?.
public var subject: Reference?
/// The entity that caused the expenses.
public var subject: [Reference]?

/// E.g. patient, expense, depreciation.
public var type: CodeableConcept?


/** Convenience initializer, taking all required properties as arguments. */
public convenience init(status: AccountStatus) {
self.init()
self.status = status
}


override open func populate(from json: FHIRJSON, context instCtx: inout FHIRInstantiationContext) {
super.populate(from: json, context: &instCtx)

active = createInstance(type: Period.self, for: "active", in: json, context: &instCtx, owner: self) ?? active
balance = createInstance(type: Money.self, for: "balance", in: json, context: &instCtx, owner: self) ?? balance
coverage = createInstances(of: AccountCoverage.self, for: "coverage", in: json, context: &instCtx, owner: self) ?? coverage
description_fhir = createInstance(type: FHIRString.self, for: "description", in: json, context: &instCtx, owner: self) ?? description_fhir
guarantor = createInstances(of: AccountGuarantor.self, for: "guarantor", in: json, context: &instCtx, owner: self) ?? guarantor
identifier = createInstances(of: Identifier.self, for: "identifier", in: json, context: &instCtx, owner: self) ?? identifier
name = createInstance(type: FHIRString.self, for: "name", in: json, context: &instCtx, owner: self) ?? name
owner = createInstance(type: Reference.self, for: "owner", in: json, context: &instCtx, owner: self) ?? owner
period = createInstance(type: Period.self, for: "period", in: json, context: &instCtx, owner: self) ?? period
partOf = createInstance(type: Reference.self, for: "partOf", in: json, context: &instCtx, owner: self) ?? partOf
servicePeriod = createInstance(type: Period.self, for: "servicePeriod", in: json, context: &instCtx, owner: self) ?? servicePeriod
status = createEnum(type: AccountStatus.self, for: "status", in: json, context: &instCtx) ?? status
subject = createInstance(type: Reference.self, for: "subject", in: json, context: &instCtx, owner: self) ?? subject
if nil == status && !instCtx.containsKey("status") {
instCtx.addError(FHIRValidationError(missing: "status"))
}
subject = createInstances(of: Reference.self, for: "subject", in: json, context: &instCtx, owner: self) ?? subject
type = createInstance(type: CodeableConcept.self, for: "type", in: json, context: &instCtx, owner: self) ?? type
}

override open func decorate(json: inout FHIRJSON, errors: inout [FHIRValidationError]) {
super.decorate(json: &json, errors: &errors)

self.active?.decorate(json: &json, withKey: "active", errors: &errors)
self.balance?.decorate(json: &json, withKey: "balance", errors: &errors)
arrayDecorate(json: &json, withKey: "coverage", using: self.coverage, errors: &errors)
self.description_fhir?.decorate(json: &json, withKey: "description", errors: &errors)
arrayDecorate(json: &json, withKey: "guarantor", using: self.guarantor, errors: &errors)
arrayDecorate(json: &json, withKey: "identifier", using: self.identifier, errors: &errors)
self.name?.decorate(json: &json, withKey: "name", errors: &errors)
self.owner?.decorate(json: &json, withKey: "owner", errors: &errors)
self.period?.decorate(json: &json, withKey: "period", errors: &errors)
self.partOf?.decorate(json: &json, withKey: "partOf", errors: &errors)
self.servicePeriod?.decorate(json: &json, withKey: "servicePeriod", errors: &errors)
self.status?.decorate(json: &json, withKey: "status", errors: &errors)
self.subject?.decorate(json: &json, withKey: "subject", errors: &errors)
if nil == self.status {
errors.append(FHIRValidationError(missing: "status"))
}
arrayDecorate(json: &json, withKey: "subject", using: self.subject, errors: &errors)
self.type?.decorate(json: &json, withKey: "type", errors: &errors)
}
}
Expand All @@ -103,7 +111,7 @@ open class AccountCoverage: BackboneElement {
get { return "AccountCoverage" }
}

/// The party(s) that are responsible for covering the payment of this account.
/// The party(s), such as insurances, that may contribute to the payment of this account.
public var coverage: Reference?

/// The priority of the coverage in the context of this account.
Expand Down Expand Up @@ -140,9 +148,9 @@ open class AccountCoverage: BackboneElement {


/**
Responsible for the account.
The parties ultimately responsible for balancing the Account.

Parties financially responsible for the account.
The parties responsible for balancing the account if other payment options fall short.
*/
open class AccountGuarantor: BackboneElement {
override open class var resourceType: String {
Expand All @@ -155,7 +163,7 @@ open class AccountGuarantor: BackboneElement {
/// Responsible entity.
public var party: Reference?

/// Guarrantee account during.
/// Guarantee account during.
public var period: Period?


Expand Down
Loading

0 comments on commit f95b737

Please sign in to comment.