Update to FHIRModels 0.9 - #4
Conversation
FHIRModels 0.9 turned all model types into structs and made Element, BackboneElement, and DomainResource protocols. Port the helpers to value semantics: mutating resource helpers, inout extension builders, keypath helpers on FHIRType, and generated FHIRTypeWithExtensions conformances for all R4 types that carry extensions.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
API breaking changes
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4 +/- ##
==========================================
+ Coverage 38.22% 39.25% +1.03%
==========================================
Files 23 23
Lines 471 474 +3
==========================================
+ Hits 180 186 +6
+ Misses 291 288 -3
Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
Make FHIRExtensionBuilderProtocol refine Sendable, declare the FMCore product dependency explicitly, include FHIRPrimitive in the generated FHIRTypeWithExtensions conformances so extensions on primitive elements are covered, and add a static-analysis job that regenerates the conformance file and fails if the committed copy is stale.
♻️ Current situation & Problem
FHIRModels 0.9.0 is a breaking release: every model type is now a
Sendablestruct,Element,BackboneElement, andDomainResourceare protocols, andFHIRAbstractResourceno longer exists. #3 pinned this package to0.8.0..<0.9.0as a stopgap, which now also blocks downstream packages such as HealthKitOnFHIR from moving to 0.9.This PR ports the package to FHIRModels 0.9.3 with the smallest API change that works with value semantics. Helper names are unchanged.
⚙️ Release Notes
.upToNextMinor(from: "0.9.3"), and theFMCoreproduct is declared explicitly.mutating. This affects theObservationappend helpers,setEffective(startDate:endDate:timeZone:),setIssued(on:),encodeAbsoluteTimeRangeIntoExtension(), and theappendExtension(s)/removeFirstExtension/removeAllExtensionshelpers. Call them on avar.FHIRExtensionBuilderclosures and allapplyoverloads receive theObservationasinout.FHIRExtensionBuilderProtocolnow refinesSendable, so erased builders can be stored inSendabletypes and passed across isolation boundaries.FHIRResourceMutationExtensionsis removed. The keypath helpers (appendElement(s),removeFirstElement,removeAllElements) are now available on everyFHIRType, usingWritableKeyPath.FHIRTypeWithExtensionsno longer requiresAnyObject. Since a protocol cannot be conformed to another protocol, the conformances are now declared per concrete type in the generatedFHIRTypeWithExtensions+Conformances.swift: all 650 R4 elements, backbone elements, domain resources, andFHIRPrimitive, so extensions on primitive elements are covered too.Scripts/generate_extension_conformances.pyregenerates the file from the resolved FHIRModels checkout, and a new static-analysis job fails if the committed file is out of date.nilproperty now leaves itnilinstead of creating an empty array, matching FHIR's rule that arrays are never empty.nonisolated(unsafe)annotations on the extension URL constants are removed;FHIRPrimitiveisSendablenow.📚 Documentation
.linkspector.ymlignores the Zenodo and Swift Package Index badge targets, which answer automated requests with 403 or time out and were failing the required link check onmainas well.✅ Testing
FHIRExtensionBuilderTestscover typed and type-erased builder application, value-semantics isolation,setEffective/setIssued, the absolute time range extension (including the replace-on-reencode and unsupported-effective paths), extension helpers on nested extensions, backbone elements, non-observation resources, and primitives, and the keypath helpers including their nil-when-empty behavior.var; the@MainActorworkaround for Bug report: FHIRModels is not concurrency safe, leading to crashes at runtime apple/FHIRModels#36 is no longer needed.swift teston macOS, andxcodebuild teston the iOS, watchOS, and tvOS simulators and as Mac Catalyst. SwiftLint reports no violations and the DocC build has no warnings in package sources.let→var/inoutchanges, and its full test suite passes on macOS and on the iOS and watchOS simulators.Code of Conduct & Contributing Guidelines
By creating and submitting this pull request, you agree to follow our Code of Conduct and Contributing Guidelines: