diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 97a0672..aaa7b8a 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -1,5 +1,5 @@ # -# This source file is part of the TemplatePackage open source project +# This source file is part of the CardinalKit open-source project # # SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) # @@ -16,22 +16,24 @@ on: workflow_dispatch: jobs: - build_and_test-spm: + buildandtest: name: Build and Test Swift Package - uses: StanfordBDHG/.github/.github/workflows/build-and-test-xcodebuild-spm.yml@v1 + uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2 with: - scheme: TemplatePackage - build_and_test-uitests: - name: Build and Test UITest App - uses: StanfordBDHG/.github/.github/workflows/build-and-test-xcodebuild.yml@v1 + artifactname: CardinalKitFHIR-Package.xcresult + runsonlabels: '["macOS", "self-hosted"]' + scheme: CardinalKitFHIR-Package + buildandtestuitests: + name: Build and Test UI Tests + uses: StanfordBDHG/.github/.github/workflows/xcodebuild-or-fastlane.yml@v2 with: - xcodeprojname: Tests/UITests/UITests.xcodeproj + artifactname: TestApp.xcresult + runsonlabels: '["macOS", "self-hosted"]' + path: Tests/UITests scheme: TestApp - create-and-upload-coverage-report: - name: Create and Upload Coverage Report - needs: [build_and_test-spm, build_and_test-uitests] - uses: StanfordBDHG/.github/.github/workflows/create-and-upload-coverage-report.yml@v1 + uploadcoveragereport: + name: Upload Coverage Report + needs: [buildandtest, buildandtestuitests] + uses: StanfordBDHG/.github/.github/workflows/create-and-upload-coverage-report.yml@v2 with: - coveragereports: TemplatePackage.xcresult TemplatePackage.xcresult - secrets: - token: ${{ secrets.CODECOV_TOKEN }} + coveragereports: CardinalKitFHIR-Package.xcresult TestApp.xcresult diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index ce646a3..0c04e33 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -1,5 +1,5 @@ # -# This source file is part of the TemplatePackage open source project +# This source file is part of the CardinalKit open-source project # # SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) # @@ -15,7 +15,7 @@ on: jobs: reuse_action: name: REUSE Compliance Check - uses: StanfordBDHG/.github/.github/workflows/reuse.yml@v1 + uses: StanfordBDHG/.github/.github/workflows/reuse.yml@v2 swiftlint: name: SwiftLint - uses: StanfordBDHG/.github/.github/workflows/swiftlint.yml@v1 + uses: StanfordBDHG/.github/.github/workflows/swiftlint.yml@v2 diff --git a/.gitignore b/.gitignore index 5405129..9b2c26d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,17 +1,17 @@ # -# This source file is part of the TemplatePackage open source project +# This source file is part of the CardinalKit open-source project # # SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) # # SPDX-License-Identifier: MIT -# +# # Swift Package Manager -Package.resolved *.xcodeproj .swiftpm -.build/ -.xcodebuild/ +.build +.xcodebuild +.derivedData coverage.lcov *.xcresult diff --git a/.spi.yml b/.spi.yml index 504bb5a..ca3a331 100644 --- a/.spi.yml +++ b/.spi.yml @@ -1,14 +1,15 @@ # -# This source file is part of the TemplatePackage open source project +# This source file is part of the CardinalKit open-source project # # SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) # # SPDX-License-Identifier: MIT -# +# version: 1 builder: configs: - platform: ios documentation_targets: - - TemplatePackage + - CardinalKitFHIR + - CardinalKitFHIRMockDataStorageProvider diff --git a/.swiftlint.yml b/.swiftlint.yml index 49ed89f..9be25d7 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -1,11 +1,11 @@ # -# This source file is part of the TemplatePackage open source project +# This source file is part of the CardinalKit open-source project # # SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) # # SPDX-License-Identifier: MIT -# - +# + # The whitelist_rules configuration also includes rules that are enabled by default to provide a good overview of all rules. only_rules: # All Images that provide context should have an accessibility label. Purely decorative images can be hidden from accessibility. @@ -166,6 +166,8 @@ only_rules: - legacy_multiple # Struct extension properties and methods are preferred over legacy functions - legacy_nsgeometry_functions + # Prefer Swift value types to bridged Objective-C reference types + - legacy_objc_type # Prefer using type.random(in:) over legacy functions. - legacy_random # Lines should not span too many characters. diff --git a/CITATION.cff b/CITATION.cff index 3c4ad73..6e77214 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -1,10 +1,10 @@ # -# This source file is part of the TemplatePackage open source project +# This source file is part of the CardinalKit open-source project # # SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) # # SPDX-License-Identifier: MIT -# +# cff-version: 1.2.0 message: "If you use this software, please cite it as below." @@ -12,6 +12,5 @@ authors: - family-names: "Schmiedmayer" given-names: "Paul" orcid: "https://orcid.org/0000-0002-8607-9148" -title: "TemplatePackage" -doi: 10.5281/zenodo.7538165 -url: "https://github.com/StanfordBDHG/SwiftPackageTemplate" +title: "CardinalKitFHIR" +url: "https://github.com/StanfordBDHG/CardinalKitFHIR" diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 6951f13..4a26421 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -1,16 +1,14 @@ -TemplatePackage contributors +CardinalKitFHIR contributors ==================== * [Paul Schmiedmayer](https://github.com/PSchmiedmayer) diff --git a/Package.resolved b/Package.resolved new file mode 100644 index 0000000..d8cb691 --- /dev/null +++ b/Package.resolved @@ -0,0 +1,158 @@ +{ + "pins" : [ + { + "identity" : "abseil-cpp-swiftpm", + "kind" : "remoteSourceControl", + "location" : "https://github.com/firebase/abseil-cpp-SwiftPM.git", + "state" : { + "revision" : "583de9bd60f66b40e78d08599cc92036c2e7e4e1", + "version" : "0.20220203.2" + } + }, + { + "identity" : "boringssl-swiftpm", + "kind" : "remoteSourceControl", + "location" : "https://github.com/firebase/boringssl-SwiftPM.git", + "state" : { + "revision" : "dd3eda2b05a3f459fc3073695ad1b28659066eab", + "version" : "0.9.1" + } + }, + { + "identity" : "cardinalkit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/StanfordBDHG/CardinalKit", + "state" : { + "revision" : "6e90348e30709f4b739fc3473c2fa54fbcf77eec", + "version" : "0.3.3" + } + }, + { + "identity" : "fhirmodels", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/FHIRModels", + "state" : { + "revision" : "e115442fb3c5d44ffb1dc9b4e039b77fd143ad96", + "version" : "0.4.0" + } + }, + { + "identity" : "firebase-ios-sdk", + "kind" : "remoteSourceControl", + "location" : "https://github.com/firebase/firebase-ios-sdk", + "state" : { + "revision" : "60f9a33e7084482df67b48e16f315f4f7a6f5da9", + "version" : "10.6.0" + } + }, + { + "identity" : "googleappmeasurement", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/GoogleAppMeasurement.git", + "state" : { + "revision" : "04351180d4c757c6c16127cb57b685fff9ef260b", + "version" : "10.6.0" + } + }, + { + "identity" : "googledatatransport", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/GoogleDataTransport.git", + "state" : { + "revision" : "f6b558e3f801f2cac336b04f615ce111fa9ddaa0", + "version" : "9.2.1" + } + }, + { + "identity" : "googleutilities", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/GoogleUtilities.git", + "state" : { + "revision" : "0543562f85620b5b7c510c6bcbef75b562a5127b", + "version" : "7.11.0" + } + }, + { + "identity" : "grpc-ios", + "kind" : "remoteSourceControl", + "location" : "https://github.com/grpc/grpc-ios.git", + "state" : { + "revision" : "8440b914756e0d26d4f4d054a1c1581daedfc5b6", + "version" : "1.44.3-grpc" + } + }, + { + "identity" : "gtm-session-fetcher", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/gtm-session-fetcher.git", + "state" : { + "revision" : "96d7cc73a71ce950723aa3c50ce4fb275ae180b8", + "version" : "3.1.0" + } + }, + { + "identity" : "healthkitonfhir", + "kind" : "remoteSourceControl", + "location" : "https://github.com/StanfordBDHG/HealthKitOnFHIR", + "state" : { + "revision" : "1b7b7d71c30563f84d4c892421caf7f1c79ff09e", + "version" : "0.2.2" + } + }, + { + "identity" : "leveldb", + "kind" : "remoteSourceControl", + "location" : "https://github.com/firebase/leveldb.git", + "state" : { + "revision" : "0706abcc6b0bd9cedfbb015ba840e4a780b5159b", + "version" : "1.22.2" + } + }, + { + "identity" : "nanopb", + "kind" : "remoteSourceControl", + "location" : "https://github.com/firebase/nanopb.git", + "state" : { + "revision" : "819d0a2173aff699fb8c364b6fb906f7cdb1a692", + "version" : "2.30909.0" + } + }, + { + "identity" : "promises", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/promises.git", + "state" : { + "revision" : "ec957ccddbcc710ccc64c9dcbd4c7006fcf8b73a", + "version" : "2.2.0" + } + }, + { + "identity" : "researchkit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/StanfordBDHG/ResearchKit", + "state" : { + "revision" : "52a9bd8bcf2112b2f70479cd192f8c5fa9850c31", + "version" : "2.2.8" + } + }, + { + "identity" : "researchkitonfhir", + "kind" : "remoteSourceControl", + "location" : "https://github.com/StanfordBDHG/ResearchKitOnFHIR", + "state" : { + "revision" : "1bc7a15760916ade4c5058fa798a871e80c2955c", + "version" : "0.1.6" + } + }, + { + "identity" : "swift-protobuf", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-protobuf.git", + "state" : { + "revision" : "0af9125c4eae12a4973fb66574c53a54962a9e1e", + "version" : "1.21.0" + } + } + ], + "version" : 2 +} diff --git a/Package.resolved.license b/Package.resolved.license new file mode 100644 index 0000000..b15600d --- /dev/null +++ b/Package.resolved.license @@ -0,0 +1,5 @@ +This source file is part of the CardinalKit open-source project + +SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) + +SPDX-License-Identifier: MIT diff --git a/Package.swift b/Package.swift index 3942530..4b27952 100644 --- a/Package.swift +++ b/Package.swift @@ -1,10 +1,10 @@ // swift-tools-version:5.7 // -// This source file is part of the TemplatePackage open source project -// +// This source file is part of the CardinalKit open-source project +// // SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) -// +// // SPDX-License-Identifier: MIT // @@ -12,21 +12,42 @@ import PackageDescription let package = Package( - name: "TemplatePackage", + name: "CardinalKitFHIR", + defaultLocalization: "en", platforms: [ .iOS(.v16) ], products: [ - .library(name: "TemplatePackage", targets: ["TemplatePackage"]) + .library(name: "CardinalKitFHIR", targets: ["CardinalKitFHIR"]), + .library(name: "CardinalKitFHIRMockDataStorageProvider", targets: ["CardinalKitFHIRMockDataStorageProvider"]) + ], + dependencies: [ + .package(url: "https://github.com/apple/FHIRModels", .upToNextMinor(from: "0.4.0")), + .package(url: "https://github.com/StanfordBDHG/CardinalKit", .upToNextMinor(from: "0.3.3")) ], targets: [ .target( - name: "TemplatePackage" + name: "CardinalKitFHIR", + dependencies: [ + .product(name: "CardinalKit", package: "CardinalKit"), + .product(name: "ModelsR4", package: "FHIRModels") + ] ), .testTarget( - name: "TemplatePackageTests", + name: "CardinalKitFHIRTests", + dependencies: [ + .target(name: "CardinalKitFHIR") + ] + ), + .target( + name: "CardinalKitFHIRMockDataStorageProvider", dependencies: [ - .target(name: "TemplatePackage") + .target(name: "CardinalKitFHIR"), + .product(name: "CardinalKit", package: "CardinalKit"), + .product(name: "Views", package: "CardinalKit") + ], + resources: [ + .process("Resources") ] ) ] diff --git a/README.md b/README.md index 5bbacb9..5b0d6ba 100644 --- a/README.md +++ b/README.md @@ -1,49 +1,35 @@ -# TemplatePackage +# CardinalKit FHIR -[![Build and Test](https://github.com/StanfordBDHG/SwiftPackageTemplate/actions/workflows/build-and-test.yml/badge.svg)](https://github.com/StanfordBDHG/SwiftPackageTemplate/actions/workflows/build-and-test.yml) -[![codecov](https://codecov.io/gh/StanfordBDHG/SwiftPackageTemplate/branch/main/graph/badge.svg?token=X7BQYSUKOH)](https://codecov.io/gh/StanfordBDHG/SwiftPackageTemplate) -[![DOI](https://zenodo.org/badge/573230182.svg)](https://zenodo.org/badge/latestdoi/573230182) -[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FStanfordBDHG%2FSwiftPackageTemplate%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/StanfordBDHG/SwiftPackageTemplate) -[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FStanfordBDHG%2FSwiftPackageTemplate%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/StanfordBDHG/SwiftPackageTemplate) +[![Build and Test](https://github.com/StanfordBDHG/CardinalKitFHIR/actions/workflows/build-and-test.yml/badge.svg)](https://github.com/StanfordBDHG/CardinalKitFHIR/actions/workflows/build-and-test.yml) +The FHIR Standard and related modules build a code building block of standard-based mobile appications using CardinalKit. -## How To Use This Template +For more information, please refer to the [API documentation](https://swiftpackageindex.com/StanfordBDHG/CardinalKitFHIR/documentation). -The template repository contains a template Swift Package, including a continuous integration setup. Follow these steps to customize it to your needs: -1. Rename the Swift Package. Be sure that you update the name in the `build-and-test.yml` GitHub Action accordingly. If you have multiple targets in your Swift Package, you need to pass the name of the Swift Package followed by an `-Package` as the scheme to the GitHub Action, e.g., `StanfordProject-Package` if your Swift Package is named `StanfordProject`. -2. If your Swift Package does not provide any user interface or does not require an iOS application environment to function, you can remove the `UITests` application from the `Tests` folder. You need to update the `build-and-test.yml` GitHub Action accordingly by removing the GitHub Action that builds and tests the application, removing the dependency from the code coverage upload step, and removing the UI test `.xresult` input from the code coverage test. -3. You will either need to add the [CodeCov GitHub App](https://github.com/apps/codecov) or add a codecov.io token to your [GitHub Actions Secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-an-environment) following the instructions of the [Codecov GitHub Action](https://github.com/marketplace/actions/codecov#usage). The StanfordBDHG organization already has the [CodeCov GitHub App](https://github.com/apps/codecov) installed. If you do not want to cover test coverage data, you can remove the code coverage job in the `build-and-test.yml` GitHub Action. -4. Adjust this README to describe your project and adjust the badges at the top to point to the correct GitHub Action of your repository and Codecov badge. -5. The Swift Package template includes a Swift Package Index configuration file to automatically build the package and [host the documentation on the Swift Package Index website](https://blog.swiftpackageindex.com/posts/auto-generating-auto-hosting-and-auto-updating-docc-documentation/). Adjust the `.spi.yml` file to include all targets that you want to build documentation for. You can follow the [instructions of the Swift Package Index](https://swiftpackageindex.com/add-a-package) to include your Swift Package in the Swift Package Index. You can link to the [API documentation](https://swiftpackageindex.com/StanfordBDHG/SwiftPackageTemplate/documentation) from your README file. -6. Adjust the CITATION.cff file to admend information about the new Swift Package ([learn more about CITATION files on GitHub](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-citation-files)) and [register the Swift Package on Zenodo](https://docs.github.com/en/repositories/archiving-a-github-repository/referencing-and-citing-content). +## The CardinalKit Template Application -## Installation +The [CardinalKit Template Application](https://github.com/StanfordBDHG/CardinalKitTemplateApplication) provides a great starting point and example using the CardinalKit FHIR Standard. -The project can be added to your Xcode project or Swift Package using the [Swift Package Manager](https://github.com/apple/swift-package-manager). -**Xcode:** For an Xcode project, follow the instructions on [adding package dependencies to your app](https://developer.apple.com/documentation/xcode/adding-package-dependencies-to-your-app). +## Contributing -**Swift Package:** You can follow the [Swift Package Manager documentation about defining dependencies](https://github.com/apple/swift-package-manager/blob/main/Documentation/Usage.md#defining-dependencies) to add this project as a dependency to your Swift Package. +Contributions to this project are welcome. Please make sure to read the [contribution guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md) and the [contributor covenant code of conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md) first. ## License -This project is licensed under the MIT License. See [Licenses](https://github.com/StanfordBDHG/TemplatePackage/tree/main/LICENSES) for more information. - -## Contributors -This project is developed as part of the Stanford Byers Center for Biodesign at Stanford University. -See [CONTRIBUTORS.md](https://github.com/StanfordBDHG/TemplatePackage/tree/main/CONTRIBUTORS.md) for a full list of all TemplatePackage contributors. +This project is licensed under the MIT License. See [Licenses](https://github.com/StanfordBDHG/CardinalKitFHIR/tree/main/LICENSES) for more information. ![Stanford Byers Center for Biodesign Logo](https://raw.githubusercontent.com/StanfordBDHG/.github/main/assets/biodesign-footer-light.png#gh-light-mode-only) ![Stanford Byers Center for Biodesign Logo](https://raw.githubusercontent.com/StanfordBDHG/.github/main/assets/biodesign-footer-dark.png#gh-dark-mode-only) diff --git a/Sources/CardinalKitFHIR/Configuration+FHIR.swift b/Sources/CardinalKitFHIR/Configuration+FHIR.swift new file mode 100644 index 0000000..51de5f2 --- /dev/null +++ b/Sources/CardinalKitFHIR/Configuration+FHIR.swift @@ -0,0 +1,26 @@ +// +// This source file is part of the CardinalKit open-source project +// +// SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) +// +// SPDX-License-Identifier: MIT +// + +import CardinalKit + + +extension Configuration { + /// A FHIR-based ``Configuration``that defines ``Component``s that are used in a CardinalKit project. + /// + /// See ``Configuration`` for more detail about standard-independent configurations. + /// - Parameters: + /// - components: The ``Component``s used in the CardinalKit project. You can define the ``Component``s using the ``ComponentBuilder`` result builder. + public init( + @ComponentBuilder _ components: () -> (ComponentCollection) + ) { + self.init( + standard: FHIR(), + components + ) + } +} diff --git a/Sources/CardinalKitFHIR/FHIR+Identifiable.swift b/Sources/CardinalKitFHIR/FHIR+Identifiable.swift new file mode 100644 index 0000000..3eb9c22 --- /dev/null +++ b/Sources/CardinalKitFHIR/FHIR+Identifiable.swift @@ -0,0 +1,27 @@ +// +// This source file is part of the CardinalKit open-source project +// +// SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) +// +// SPDX-License-Identifier: MIT +// + +import ModelsR4 + + +extension Resource: Identifiable { + public typealias ID = FHIRPrimitive? +} + +extension FHIRPrimitive: Identifiable where PrimitiveType: Identifiable { } + +extension Optional: Identifiable where Wrapped == FHIRPrimitive { + public var id: FHIRPrimitive? { + switch self { + case let .some(value): + return value + case .none: + return nil + } + } +} diff --git a/Sources/CardinalKitFHIR/FHIR.swift b/Sources/CardinalKitFHIR/FHIR.swift new file mode 100644 index 0000000..af8617c --- /dev/null +++ b/Sources/CardinalKitFHIR/FHIR.swift @@ -0,0 +1,134 @@ +// +// This source file is part of the CardinalKit open-source project +// +// SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) +// +// SPDX-License-Identifier: MIT +// + +import CardinalKit +import Foundation +@_exported @preconcurrency import ModelsR4 +import XCTRuntimeAssertions + + +/// The ``FHIR/FHIR`` standard provides a CardinalKit `Standard` that utilizes HL7® FHIR® as the central standard for your CardinalKit application. +/// +/// +/// If you import the FHIR module using `import FHIR` you can specify all FHIR compatible components and modules in the configuration builder: +/// ```swift +/// import FHIR +/// import CardinalKit +/// +/// public class ExampleCardinalKitAppDelegate: CardinalKitAppDelegate { +/// override public var configuration: Configuration { +/// Configuration { +/// FHIRComponentExample() +/// } +/// } +/// } +/// ``` +/// +/// You can also manually specify the FHIR Standard by passing it into the `configuration` initializer: +/// ```swift +/// import FHIR +/// import CardinalKit +/// +/// public class ExampleCardinalKitAppDelegate: CardinalKitAppDelegate { +/// override public var configuration: Configuration { +/// Configuration(standard: FHIR()) { +/// FHIRComponentExample() +/// } +/// } +/// } +/// ``` +public actor FHIR: Standard, ObservableObject, ObservableObjectProvider { + /// The FHIR `Resource` type builds the `BaseType` of the ``FHIR/FHIR`` standard. + public typealias BaseType = Resource + /// The FHIR ``FHIRRemovalContext`` type builds the `RemovalContext` of the ``FHIR/FHIR`` standard. + public typealias RemovalContext = FHIRRemovalContext + + + /// Defines the nescessary context to process removals of a FHIR `Resource`. + public struct FHIRRemovalContext: Sendable, Identifiable { + /// The identifier of the FHIR `Resource`. + public let id: BaseType.ID + /// The string representation of the resource type of the FHIR `Resource`. + /// + /// You can obtain the resource type using a `ResourceProxy`: + /// ```swift + /// let resource: Resource = // ... + /// let resourceProxy = ResourceProxy(with: resource) + /// let resourceType = resourceProxy.resourceType + /// ``` + /// or shortly: + /// ```swift + /// let resourceType = ResourceProxy(with: resource).resourceType + /// ``` + public let resourceType: ResourceType + + + /// - Parameters: + /// - id: The identifier of the FHIR `Resource`. + /// - resourceType: The string representation of the resource type of the FHIR `Resource`. + /// + /// You can obtain the resource type using a `ResourceProxy`: + /// ```swift + /// let resourceType = ResourceProxy(with: resource).resourceType + /// ``` + public init(id: BaseType.ID, resourceType: ResourceType) { + self.id = id + self.resourceType = resourceType + } + } + + + private var resources: [Resource.ID: ResourceProxy] = [:] { + didSet { + _Concurrency.Task { @MainActor in + objectWillChange.send() + } + } + } + + @DataStorageProviders + var dataStorageProviders: [any DataStorageProvider] + + + public init() { } + + + public func registerDataSource(_ asyncSequence: some TypedAsyncSequence>) { + _Concurrency.Task { + for try await dateSourceElement in asyncSequence { + switch dateSourceElement { + case let .addition(resource): + guard let id = resource.id else { + continue + } + resources[id] = ResourceProxy(with: resource) + for dataStorageProvider in dataStorageProviders { + try await dataStorageProvider.process(.addition(resource)) + } + case let .removal(removalContext): + guard let id = removalContext.id else { + continue + } + resources[id] = nil + for dataStorageProvider in dataStorageProviders { + try await dataStorageProvider.process(.removal(removalContext)) + } + } + } + } + } + + + public func resource(withId id: Resource.ID) -> ResourceProxy? { + resources[id] + } + + public func resources(resourceType: R.Type = R.self) -> [R] { + resources.values.compactMap { $0.get(if: R.self) } + } +} diff --git a/Sources/CardinalKitFHIR/OptionalFHIRPrimitiveFHIRString+LosslessStringConvertible.swift b/Sources/CardinalKitFHIR/OptionalFHIRPrimitiveFHIRString+LosslessStringConvertible.swift new file mode 100644 index 0000000..4aaa3ae --- /dev/null +++ b/Sources/CardinalKitFHIR/OptionalFHIRPrimitiveFHIRString+LosslessStringConvertible.swift @@ -0,0 +1,26 @@ +// +// This source file is part of the CardinalKit open-source project +// +// SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) +// +// SPDX-License-Identifier: MIT +// + +import ModelsR4 + + +extension Optional: CustomStringConvertible, LosslessStringConvertible where Wrapped == FHIRPrimitive { + public var description: String { + switch self { + case .none: + return "" + case let .some(wrapped): + return wrapped.value?.string ?? "" + } + } + + + public init?(_ description: String) { + self = .some(FHIRPrimitive(stringLiteral: description)) + } +} diff --git a/Sources/CardinalKitFHIRMockDataStorageProvider/MockDataStorageProvider.swift b/Sources/CardinalKitFHIRMockDataStorageProvider/MockDataStorageProvider.swift new file mode 100644 index 0000000..4796363 --- /dev/null +++ b/Sources/CardinalKitFHIRMockDataStorageProvider/MockDataStorageProvider.swift @@ -0,0 +1,60 @@ +// +// This source file is part of the CardinalKit open-source project +// +// SPDX-FileCopyrightText: 2023 Stanford University +// +// SPDX-License-Identifier: MIT +// + +import CardinalKit +import CardinalKitFHIR +import Foundation + + +/// A data storage provider that collects all uploads and displays them in a user interface using the ``MockUploadList``. +public actor MockDataStorageProvider: DataStorageProvider, ObservableObjectProvider, ObservableObject { + public typealias ComponentStandard = FHIR + + + let encoder: JSONEncoder = { + let encoder = JSONEncoder() + encoder.outputFormatting = [.prettyPrinted, .sortedKeys, .withoutEscapingSlashes] + return encoder + }() + @MainActor @Published + private(set) var mockUploads: [MockUpload] = [] + + + public init() { } + + + public func process(_ element: DataChange) async throws { + switch element { + case let .addition(element): + let data = try encoder.encode(element) + let json = String(decoding: data, as: UTF8.self) + _Concurrency.Task { @MainActor in + mockUploads.insert( + MockUpload( + id: element.id.description, + type: .add, + path: ResourceProxy(with: element).resourceType.description, + body: json + ), + at: 0 + ) + } + case let .removal(removalContext): + _Concurrency.Task { @MainActor in + mockUploads.insert( + MockUpload( + id: removalContext.id.description, + type: .delete, + path: removalContext.resourceType.rawValue + ), + at: 0 + ) + } + } + } +} diff --git a/Sources/CardinalKitFHIRMockDataStorageProvider/MockUpload.swift b/Sources/CardinalKitFHIRMockDataStorageProvider/MockUpload.swift new file mode 100644 index 0000000..548c86d --- /dev/null +++ b/Sources/CardinalKitFHIRMockDataStorageProvider/MockUpload.swift @@ -0,0 +1,37 @@ +// +// This source file is part of the CardinalKit open-source project +// +// SPDX-FileCopyrightText: 2023 Stanford University +// +// SPDX-License-Identifier: MIT +// + +import Foundation + + +struct MockUpload: Identifiable, Hashable { + enum UploadType { + case add + case delete + } + + + let identifier: String + let date = Date() + let type: UploadType + let path: String + let body: String? + + + var id: String { + "\(type): \(path)/\(identifier) at \(date.debugDescription)" + } + + + init(id: String, type: UploadType, path: String, body: String? = nil) { + self.identifier = id + self.type = type + self.path = path + self.body = body + } +} diff --git a/Sources/CardinalKitFHIRMockDataStorageProvider/MockUploadDetailView.swift b/Sources/CardinalKitFHIRMockDataStorageProvider/MockUploadDetailView.swift new file mode 100644 index 0000000..ad3695f --- /dev/null +++ b/Sources/CardinalKitFHIRMockDataStorageProvider/MockUploadDetailView.swift @@ -0,0 +1,45 @@ +// +// This source file is part of the CardinalKit open-source project +// +// SPDX-FileCopyrightText: 2023 Stanford University +// +// SPDX-License-Identifier: MIT +// + +import SwiftUI +import Views + + +struct MockUploadDetailView: View { + let mockUpload: MockUpload + + + var body: some View { + List { + Section(String(localized: "MOCK_UPLOAD_DETAIL_HEADER", bundle: .module)) { + MockUploadHeader(mockUpload: mockUpload) + } + Section(String(localized: "MOCK_UPLOAD_DETAIL_BODY", bundle: .module)) { + LazyText(text: mockUpload.body ?? "") + } + } + .listStyle(.insetGrouped) + .navigationBarTitleDisplayMode(.inline) + } +} + + +#if DEBUG +struct MockUploadDetailView_Previews: PreviewProvider { + static var previews: some View { + MockUploadDetailView( + mockUpload: MockUpload( + id: UUID().uuidString, + type: .add, + path: "A Path", + body: "A Body ..." + ) + ) + } +} +#endif diff --git a/Sources/CardinalKitFHIRMockDataStorageProvider/MockUploadHeader.swift b/Sources/CardinalKitFHIRMockDataStorageProvider/MockUploadHeader.swift new file mode 100644 index 0000000..c19a9c5 --- /dev/null +++ b/Sources/CardinalKitFHIRMockDataStorageProvider/MockUploadHeader.swift @@ -0,0 +1,62 @@ +// +// This source file is part of the CardinalKit open-source project +// +// SPDX-FileCopyrightText: 2023 Stanford University +// +// SPDX-License-Identifier: MIT +// + +import SwiftUI + + +struct MockUploadHeader: View { + let mockUpload: MockUpload + + + var body: some View { + VStack(alignment: .leading, spacing: 4) { + HStack(alignment: .center, spacing: 12) { + switch mockUpload.type { + case .add: + Image(systemName: "arrow.up.doc.fill") + .foregroundColor(.green) + case .delete: + Image(systemName: "trash.fill") + .foregroundColor(.red) + } + Text("/\(mockUpload.path)/") + } + .font(.title3) + .bold() + .padding(.bottom, 12) + Text("On \(format(mockUpload.date))") + .font(.subheadline) + Text("\(mockUpload.identifier)") + .font(.footnote) + .foregroundColor(.gray) + } + } + + + private func format(_ date: Date) -> String { + let dateFormatter = DateFormatter() + dateFormatter.dateStyle = .long + dateFormatter.timeStyle = .long + return dateFormatter.string(from: date) + } +} + + +#if DEBUG +struct MockUploadHeader_Previews: PreviewProvider { + static var previews: some View { + MockUploadHeader( + mockUpload: MockUpload( + id: UUID().uuidString, + type: .add, + path: "A Path" + ) + ) + } +} +#endif diff --git a/Sources/CardinalKitFHIRMockDataStorageProvider/MockUploadList.swift b/Sources/CardinalKitFHIRMockDataStorageProvider/MockUploadList.swift new file mode 100644 index 0000000..f8b7d91 --- /dev/null +++ b/Sources/CardinalKitFHIRMockDataStorageProvider/MockUploadList.swift @@ -0,0 +1,63 @@ +// +// This source file is part of the CardinalKit open-source project +// +// SPDX-FileCopyrightText: 2023 Stanford University +// +// SPDX-License-Identifier: MIT +// + +import SwiftUI + + +/// Displays the recoded uploads collected by the ``MockDataStorageProvider``. +public struct MockUploadList: View { + @EnvironmentObject var mockDataStorageProvider: MockDataStorageProvider + + + public var body: some View { + Group { + if mockDataStorageProvider.mockUploads.isEmpty { + VStack(spacing: 32) { + Image(systemName: "server.rack") + .font(.system(size: 100)) + Text(String(localized: "MOCK_UPLOAD_LIST_PLACEHOLDER", bundle: .module)) + .multilineTextAlignment(.center) + } + .padding(32) + } else { + List(mockDataStorageProvider.mockUploads) { mockUpload in + NavigationLink(value: mockUpload) { + MockUploadHeader(mockUpload: mockUpload) + } + } + } + } + .navigationDestination(for: MockUpload.self) { mockUpload in + MockUploadDetailView(mockUpload: mockUpload) + } + .navigationTitle(String(localized: "MOCK_UPLOAD_LIST_TITLE", bundle: .module)) + } + + + public init() {} + + + private func format(_ date: Date) -> String { + let dateFormatter = DateFormatter() + dateFormatter.dateStyle = .long + dateFormatter.timeStyle = .long + return dateFormatter.string(from: date) + } +} + + +#if DEBUG +struct MockUploadsList_Previews: PreviewProvider { + static var previews: some View { + NavigationStack { + MockUploadList() + .environmentObject(MockDataStorageProvider()) + } + } +} +#endif diff --git a/Sources/CardinalKitFHIRMockDataStorageProvider/Resources/en.lproj/Localizable.strings b/Sources/CardinalKitFHIRMockDataStorageProvider/Resources/en.lproj/Localizable.strings new file mode 100644 index 0000000..e34de0c --- /dev/null +++ b/Sources/CardinalKitFHIRMockDataStorageProvider/Resources/en.lproj/Localizable.strings @@ -0,0 +1,13 @@ +// +// This source file is part of the CardinalKit open-source project +// +// SPDX-FileCopyrightText: 2023 Stanford University +// +// SPDX-License-Identifier: MIT +// + +// MARK: - Mock Upload Data Storage Provider +"MOCK_UPLOAD_LIST_PLACEHOLDER" = "The Mock Upload Data Storage Provider will display all uploads that would be triggered by the FHIR standard."; +"MOCK_UPLOAD_LIST_TITLE" = "Mock Upload"; +"MOCK_UPLOAD_DETAIL_HEADER" = "Upload Header"; +"MOCK_UPLOAD_DETAIL_BODY" = "Upload Body"; diff --git a/Sources/TemplatePackage/TemplatePackage.docc/TemplatePackage.md b/Sources/TemplatePackage/TemplatePackage.docc/TemplatePackage.md deleted file mode 100644 index 2417f3d..0000000 --- a/Sources/TemplatePackage/TemplatePackage.docc/TemplatePackage.md +++ /dev/null @@ -1,23 +0,0 @@ -# ``TemplatePackage`` - - - -The template repository contains a template Swift Package, including a continuous integration setup. - -## Overview - -Please follow the steps in the README.md file to customize the code to your needs. - -## Types - -### Template Package - -- ``TemplatePackage`` diff --git a/Sources/TemplatePackage/TemplatePackage.swift b/Sources/TemplatePackage/TemplatePackage.swift deleted file mode 100644 index be39395..0000000 --- a/Sources/TemplatePackage/TemplatePackage.swift +++ /dev/null @@ -1,19 +0,0 @@ -// -// This source file is part of the TemplatePackage open source project -// -// SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) -// -// SPDX-License-Identifier: MIT -// - -/// The main type of the Swift Package template. -public struct TemplatePackage { - /// The Swift Package template package is provided by Stanford University. - public var stanford: String { - "Stanford University" - } - - - /// The main type of the Swift Package template. - public init() {} -} diff --git a/Tests/CardinalKitFHIRTests/FHIRTests.swift b/Tests/CardinalKitFHIRTests/FHIRTests.swift new file mode 100644 index 0000000..34ec926 --- /dev/null +++ b/Tests/CardinalKitFHIRTests/FHIRTests.swift @@ -0,0 +1,155 @@ +// +// This source file is part of the CardinalKit open-source project +// +// SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) +// +// SPDX-License-Identifier: MIT +// + +@testable import CardinalKit +@testable import CardinalKitFHIR +import XCTest + + +final class DataStorageProviderTests: XCTestCase { + private enum MockUpload { + case post(String) + case delete(String) + + + func assertPost(is value: String) { + guard case let .post(test) = self else { + XCTFail("Expected a .post and got: \(self)") + return + } + XCTAssertEqual(test, value) + } + + func assertDelete(is value: String) { + guard case let .delete(test) = self else { + XCTFail("Expected a .delete and got: \(self)") + return + } + XCTAssertEqual(test, value) + } + } + + + private actor FHIRDataStorageExample: DataStorageProvider { + typealias ComponentStandard = FHIR + + + let mockUpload: (MockUpload) -> Void + + + init(mockUpload: @escaping (MockUpload) -> Void) { + self.mockUpload = mockUpload + } + + + func process(_ element: DataChange) async throws { + switch element { + case let .addition(element): + let data = try JSONEncoder().encode(element) + let string = String(decoding: data, as: UTF8.self) + mockUpload(.post(string)) + case let .removal(removalContext): + mockUpload(.delete(removalContext.id.description)) + } + } + } + + private class DataStorageProviderApplicationDelegate: CardinalKitAppDelegate { + let mockUpload: (MockUpload) -> Void + + + override var configuration: Configuration { + Configuration { + FHIRDataStorageExample(mockUpload: mockUpload) + } + } + + + init(mockUpload: @escaping (MockUpload) -> Void) { + self.mockUpload = mockUpload + } + } + + + @MainActor + func testDataStorageProviderTests() async throws { + let expectation = expectation(description: "Timeout Expection") + expectation.isInverted = true + + var count = 0 + let delegate = DataStorageProviderApplicationDelegate { mockUpload in + switch count { + case 0: + mockUpload.assertPost(is: #"{"status":"final","id":"1","code":{},"resourceType":"Observation"}"#) + case 1: + mockUpload.assertPost(is: #"{"status":"final","id":"2","code":{},"resourceType":"Observation"}"#) + case 2: + mockUpload.assertPost(is: #"{"status":"final","id":"3","code":{},"resourceType":"Observation"}"#) + case 3: + mockUpload.assertDelete(is: "1") + default: + XCTFail("Too many calls to the mock upload function.") + } + count += 1 + } + + let observation1 = Observation( + code: CodeableConcept(), + id: "1", + status: FHIRPrimitive(.final) + ) + let observation2 = Observation( + code: CodeableConcept(), + id: "2", + status: FHIRPrimitive(.final) + ) + let observation3 = Observation( + code: CodeableConcept(), + id: "3", + status: FHIRPrimitive(.final) + ) + let observationNilId = Observation( + code: CodeableConcept(), + status: FHIRPrimitive(.final) + ) + + + let cardinalKit = try XCTUnwrap(delegate.cardinalKit as? CardinalKit) + await cardinalKit.standard.registerDataSource( + asyncStream: AsyncStream { continuation in + continuation.yield(.addition(observation1)) + continuation.yield(.addition(observation2)) + continuation.yield(.addition(observation3)) + continuation.yield(.addition(observationNilId)) + continuation.yield(.removal(FHIR.RemovalContext(id: nil, resourceType: .observation))) + continuation.yield(.removal(FHIR.RemovalContext(id: "1", resourceType: .observation))) + } + ) + + wait(for: [expectation], timeout: 1) + XCTAssertEqual(count, 4) + } + + + func testFHIRIdentifiable() { + let contentFHIRString: FHIRPrimitive? = "42" + XCTAssertEqual(contentFHIRString.description, "42") + + let emptyFHIRString: FHIRPrimitive? = "" + XCTAssertEqual(emptyFHIRString.description, "") + + let nilFHIRString: FHIRPrimitive? = FHIRPrimitive(nil) + XCTAssertEqual(nilFHIRString.description, "") + + let nilFHIRPrimitive: FHIRPrimitive? = nil + XCTAssertEqual(nilFHIRPrimitive.description, "") + + let descriptionFHIRString = FHIRPrimitive?("43") + XCTAssertEqual(descriptionFHIRString, "43") + } +} diff --git a/Tests/TemplatePackageTests/TemplatePackageTests.swift b/Tests/TemplatePackageTests/TemplatePackageTests.swift deleted file mode 100644 index bc52b5f..0000000 --- a/Tests/TemplatePackageTests/TemplatePackageTests.swift +++ /dev/null @@ -1,18 +0,0 @@ -// -// This source file is part of the TemplatePackage open source project -// -// SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) -// -// SPDX-License-Identifier: MIT -// - -@testable import TemplatePackage -import XCTest - - -final class TemplatePackageTests: XCTestCase { - func testTemplatePackage() throws { - let templatePackage = TemplatePackage() - XCTAssertEqual(templatePackage.stanford, "Stanford University") - } -} diff --git a/Tests/UITests/TestApp/Assets.xcassets/AccentColor.colorset/Contents.json.license b/Tests/UITests/TestApp/Assets.xcassets/AccentColor.colorset/Contents.json.license index d77e33d..deee265 100644 --- a/Tests/UITests/TestApp/Assets.xcassets/AccentColor.colorset/Contents.json.license +++ b/Tests/UITests/TestApp/Assets.xcassets/AccentColor.colorset/Contents.json.license @@ -1,4 +1,4 @@ -This source file is part of the TemplatePackage open-source project +This source file is part of the CardinalKit open-source project SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) diff --git a/Tests/UITests/TestApp/Assets.xcassets/AppIcon.appiconset/Contents.json.license b/Tests/UITests/TestApp/Assets.xcassets/AppIcon.appiconset/Contents.json.license index d77e33d..deee265 100644 --- a/Tests/UITests/TestApp/Assets.xcassets/AppIcon.appiconset/Contents.json.license +++ b/Tests/UITests/TestApp/Assets.xcassets/AppIcon.appiconset/Contents.json.license @@ -1,4 +1,4 @@ -This source file is part of the TemplatePackage open-source project +This source file is part of the CardinalKit open-source project SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) diff --git a/Tests/UITests/TestApp/Assets.xcassets/Contents.json.license b/Tests/UITests/TestApp/Assets.xcassets/Contents.json.license index d77e33d..deee265 100644 --- a/Tests/UITests/TestApp/Assets.xcassets/Contents.json.license +++ b/Tests/UITests/TestApp/Assets.xcassets/Contents.json.license @@ -1,4 +1,4 @@ -This source file is part of the TemplatePackage open-source project +This source file is part of the CardinalKit open-source project SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) diff --git a/Tests/UITests/TestApp/FHIRMockDataStorageProviderTests/FHIRMockDataStorageProviderTestsView.swift b/Tests/UITests/TestApp/FHIRMockDataStorageProviderTests/FHIRMockDataStorageProviderTestsView.swift new file mode 100644 index 0000000..89321ec --- /dev/null +++ b/Tests/UITests/TestApp/FHIRMockDataStorageProviderTests/FHIRMockDataStorageProviderTestsView.swift @@ -0,0 +1,59 @@ +// +// This source file is part of the CardinalKit open-source project +// +// SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) +// +// SPDX-License-Identifier: MIT +// + +import CardinalKit +import CardinalKitFHIR +import CardinalKitFHIRMockDataStorageProvider +import SwiftUI + + +struct FHIRMockDataStorageProviderTestsView: View { + @EnvironmentObject var fhirStandard: FHIR + + + var body: some View { + MockUploadList() + .toolbar { + ToolbarItem(placement: .navigationBarTrailing) { + Button("Inject Observation") { + injectNewObservations() + } + } + } + } + + + private func injectNewObservations() { + let observations = [ + Observation( + code: .init(), + id: UUID().uuidString.asFHIRStringPrimitive(), + status: FHIRPrimitive(.final) + ) + ] + + _Concurrency.Task { + await fhirStandard.registerDataSource( + AsyncStream { continuation in + for observation in observations { + continuation.yield(.addition(observation)) + } + } + ) + } + } +} + + +#if DEBUG +struct FHIRMockDataStorageProviderTestsView_Previews: PreviewProvider { + static var previews: some View { + FHIRMockDataStorageProviderTestsView() + } +} +#endif diff --git a/Tests/UITests/TestApp/Info.plist b/Tests/UITests/TestApp/Info.plist new file mode 100644 index 0000000..816a149 --- /dev/null +++ b/Tests/UITests/TestApp/Info.plist @@ -0,0 +1,13 @@ + + + + + UIApplicationSceneManifest + + UIApplicationSupportsMultipleScenes + + UISceneConfigurations + + + + diff --git a/Tests/UITests/TestApp.xctestplan.license b/Tests/UITests/TestApp/Info.plist.license similarity index 64% rename from Tests/UITests/TestApp.xctestplan.license rename to Tests/UITests/TestApp/Info.plist.license index d77e33d..deee265 100644 --- a/Tests/UITests/TestApp.xctestplan.license +++ b/Tests/UITests/TestApp/Info.plist.license @@ -1,4 +1,4 @@ -This source file is part of the TemplatePackage open-source project +This source file is part of the CardinalKit open-source project SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) diff --git a/Tests/UITests/TestApp/TestApp.swift b/Tests/UITests/TestApp/TestApp.swift index 90fdb20..34d3ae8 100644 --- a/Tests/UITests/TestApp/TestApp.swift +++ b/Tests/UITests/TestApp/TestApp.swift @@ -1,5 +1,5 @@ // -// This source file is part of the TemplatePackage open-source project +// This source file is part of the CardinalKit open-source project // // SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) // @@ -7,14 +7,45 @@ // import SwiftUI -import TemplatePackage @main struct UITestsApp: App { + enum Tests: String, CaseIterable, Identifiable { + case fhirMockDataStorageProvider = "FHIRMockDataStorageProvider" + + + var id: RawValue { + self.rawValue + } + + @MainActor + @ViewBuilder + func view(withNavigationPath path: Binding) -> some View { + switch self { + case .fhirMockDataStorageProvider: + FHIRMockDataStorageProviderTestsView() + } + } + } + + + @UIApplicationDelegateAdaptor(TestAppDelegate.self) var appDelegate + @State private var path = NavigationPath() + + var body: some Scene { WindowGroup { - Text(TemplatePackage().stanford) + NavigationStack(path: $path) { + List(Tests.allCases) { test in + NavigationLink(test.rawValue, value: test) + } + .navigationDestination(for: Tests.self) { test in + test.view(withNavigationPath: $path) + } + .navigationTitle("UITest") + } + .cardinalKit(appDelegate) } } } diff --git a/Tests/UITests/TestApp/TestAppDelegate.swift b/Tests/UITests/TestApp/TestAppDelegate.swift new file mode 100644 index 0000000..eea83d8 --- /dev/null +++ b/Tests/UITests/TestApp/TestAppDelegate.swift @@ -0,0 +1,21 @@ +// +// This source file is part of the CardinalKit open-source project +// +// SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) +// +// SPDX-License-Identifier: MIT +// + +import CardinalKit +import CardinalKitFHIR +import CardinalKitFHIRMockDataStorageProvider +import SwiftUI + + +class TestAppDelegate: CardinalKitAppDelegate { + override var configuration: Configuration { + Configuration(standard: FHIR()) { + MockDataStorageProvider() + } + } +} diff --git a/Tests/UITests/TestAppUITests/FHIRMockDataStorageProviderTests.swift b/Tests/UITests/TestAppUITests/FHIRMockDataStorageProviderTests.swift new file mode 100644 index 0000000..3a25aa1 --- /dev/null +++ b/Tests/UITests/TestAppUITests/FHIRMockDataStorageProviderTests.swift @@ -0,0 +1,46 @@ +// +// This source file is part of the CardinalKit open-source project +// +// SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) +// +// SPDX-License-Identifier: MIT +// + +import XCTest +import XCTestExtensions +import XCTHealthKit + + +final class FHIRMockDataStorageProviderTests: XCTestCase { + func testFHIRMockDataStorageProviderTests() throws { + let app = XCUIApplication() + app.launch() + + app.buttons["FHIRMockDataStorageProvider"].tap() + + try assertObservationCellPresent(false) + + XCTAssert(app.buttons["Inject Observation"].waitForExistence(timeout: 2)) + app.buttons["Inject Observation"].tap() + + try assertObservationCellPresent(true, pressIfPresent: true) + try assertObservationCellPresent(true, pressIfPresent: false) + } + + + private func assertObservationCellPresent(_ shouldBePresent: Bool, pressIfPresent: Bool = true) throws { + let app = XCUIApplication() + + let observationText = "/Observation/" + let predicate = NSPredicate(format: "label CONTAINS[c] %@", observationText) + + if shouldBePresent { + XCTAssertTrue(app.staticTexts.containing(predicate).firstMatch.waitForExistence(timeout: 5)) + if pressIfPresent { + app.staticTexts.containing(predicate).firstMatch.tap() + } + } else { + XCTAssertFalse(app.staticTexts.containing(predicate).firstMatch.waitForExistence(timeout: 5)) + } + } +} diff --git a/Tests/UITests/TestAppUITests/Info.plist.license b/Tests/UITests/TestAppUITests/Info.plist.license new file mode 100644 index 0000000..deee265 --- /dev/null +++ b/Tests/UITests/TestAppUITests/Info.plist.license @@ -0,0 +1,5 @@ +This source file is part of the CardinalKit open-source project + +SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) + +SPDX-License-Identifier: MIT \ No newline at end of file diff --git a/Tests/UITests/TestAppUITests/TestAppUITests.swift b/Tests/UITests/TestAppUITests/TestAppUITests.swift deleted file mode 100644 index d422843..0000000 --- a/Tests/UITests/TestAppUITests/TestAppUITests.swift +++ /dev/null @@ -1,25 +0,0 @@ -// -// This source file is part of the TemplatePackage open-source project -// -// SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) -// -// SPDX-License-Identifier: MIT -// - -import XCTest - - -class TestAppUITests: XCTestCase { - override func setUpWithError() throws { - try super.setUpWithError() - - continueAfterFailure = false - } - - - func testTemplatePackage() throws { - let app = XCUIApplication() - app.launch() - XCTAssert(app.staticTexts["Stanford University"].waitForExistence(timeout: 0.1)) - } -} diff --git a/Tests/UITests/TestApp.xctestplan b/Tests/UITests/UITests.xcodeproj/TestApp.xctestplan similarity index 90% rename from Tests/UITests/TestApp.xctestplan rename to Tests/UITests/UITests.xcodeproj/TestApp.xctestplan index 3f6fca6..9fe1b8a 100644 --- a/Tests/UITests/TestApp.xctestplan +++ b/Tests/UITests/UITests.xcodeproj/TestApp.xctestplan @@ -1,7 +1,7 @@ { "configurations" : [ { - "id" : "074FA9C1-7635-4C64-BF5D-90402604CC46", + "id" : "A3A0543A-08F3-4356-97BF-88EC80ED0D0E", "name" : "Default", "options" : { diff --git a/Tests/UITests/UITests.xcodeproj/TestApp.xctestplan.license b/Tests/UITests/UITests.xcodeproj/TestApp.xctestplan.license new file mode 100644 index 0000000..b15600d --- /dev/null +++ b/Tests/UITests/UITests.xcodeproj/TestApp.xctestplan.license @@ -0,0 +1,5 @@ +This source file is part of the CardinalKit open-source project + +SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) + +SPDX-License-Identifier: MIT diff --git a/Tests/UITests/UITests.xcodeproj/project.pbxproj b/Tests/UITests/UITests.xcodeproj/project.pbxproj index 82771d7..37aa6f8 100644 --- a/Tests/UITests/UITests.xcodeproj/project.pbxproj +++ b/Tests/UITests/UITests.xcodeproj/project.pbxproj @@ -7,10 +7,17 @@ objects = { /* Begin PBXBuildFile section */ - 2F68C3C8292EA52000B3E12C /* TemplatePackage in Frameworks */ = {isa = PBXBuildFile; productRef = 2F68C3C7292EA52000B3E12C /* TemplatePackage */; }; + 2F36AD2F299DB11D00B1077C /* FHIRMockDataStorageProviderTestsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F36AD2E299DB11D00B1077C /* FHIRMockDataStorageProviderTestsView.swift */; }; + 2F36AD33299DB72400B1077C /* FHIRMockDataStorageProviderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F36AD32299DB72400B1077C /* FHIRMockDataStorageProviderTests.swift */; }; 2F6D139A28F5F386007C25D6 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2F6D139928F5F386007C25D6 /* Assets.xcassets */; }; - 2F8A431329130A8C005D2B8F /* TestAppUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F8A431229130A8C005D2B8F /* TestAppUITests.swift */; }; + 2F746D9F29962B2A00BF54FE /* XCTestExtensions in Frameworks */ = {isa = PBXBuildFile; productRef = 2F746D9E29962B2A00BF54FE /* XCTestExtensions */; }; 2FA7382C290ADFAA007ACEB9 /* TestApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FA7382B290ADFAA007ACEB9 /* TestApp.swift */; }; + 2FCF659129B5C9CF0041B496 /* Views in Frameworks */ = {isa = PBXBuildFile; productRef = 2FCF659029B5C9CF0041B496 /* Views */; }; + 2FCF659829B5CA630041B496 /* XCTHealthKit in Frameworks */ = {isa = PBXBuildFile; productRef = 2FCF659729B5CA630041B496 /* XCTHealthKit */; }; + 2FD021D6299E0E0B00E5B91B /* CardinalKitFHIR in Frameworks */ = {isa = PBXBuildFile; productRef = 2FD021D5299E0E0B00E5B91B /* CardinalKitFHIR */; }; + 2FD021D8299E0E0B00E5B91B /* CardinalKitFHIRMockDataStorageProvider in Frameworks */ = {isa = PBXBuildFile; productRef = 2FD021D7299E0E0B00E5B91B /* CardinalKitFHIRMockDataStorageProvider */; }; + 2FD021DB299E0E2F00E5B91B /* CardinalKit in Frameworks */ = {isa = PBXBuildFile; productRef = 2FD021DA299E0E2F00E5B91B /* CardinalKit */; }; + 2FD021DD299E0F2900E5B91B /* TestAppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FD021DC299E0F2900E5B91B /* TestAppDelegate.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -24,13 +31,16 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ - 2F68C3C6292E9F8F00B3E12C /* TemplatePackage */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = TemplatePackage; path = ../..; sourceTree = ""; }; + 2F01E8CE291493560089C46B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = ""; }; + 2F36AD2E299DB11D00B1077C /* FHIRMockDataStorageProviderTestsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FHIRMockDataStorageProviderTestsView.swift; sourceTree = ""; }; + 2F36AD32299DB72400B1077C /* FHIRMockDataStorageProviderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FHIRMockDataStorageProviderTests.swift; sourceTree = ""; }; 2F6D139228F5F384007C25D6 /* TestApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TestApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; 2F6D139928F5F386007C25D6 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 2F6D13AC28F5F386007C25D6 /* TestAppUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TestAppUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 2F8A431229130A8C005D2B8F /* TestAppUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestAppUITests.swift; sourceTree = ""; }; + 2F7B6CB4294C03C800FDC494 /* TestApp.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; name = TestApp.xctestplan; path = UITests.xcodeproj/TestApp.xctestplan; sourceTree = ""; }; 2FA7382B290ADFAA007ACEB9 /* TestApp.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestApp.swift; sourceTree = ""; }; - 2FB0758A299DDB9000C0B37F /* TestApp.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = TestApp.xctestplan; sourceTree = ""; }; + 2FC42FD7290ADD5E00B08F18 /* CardinalKitFHIR */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = CardinalKitFHIR; path = ../..; sourceTree = ""; }; + 2FD021DC299E0F2900E5B91B /* TestAppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestAppDelegate.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -38,7 +48,10 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 2F68C3C8292EA52000B3E12C /* TemplatePackage in Frameworks */, + 2FD021DB299E0E2F00E5B91B /* CardinalKit in Frameworks */, + 2FD021D6299E0E0B00E5B91B /* CardinalKitFHIR in Frameworks */, + 2FD021D8299E0E0B00E5B91B /* CardinalKitFHIRMockDataStorageProvider in Frameworks */, + 2FCF659129B5C9CF0041B496 /* Views in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -46,17 +59,27 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 2F746D9F29962B2A00BF54FE /* XCTestExtensions in Frameworks */, + 2FCF659829B5CA630041B496 /* XCTHealthKit in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 2F36AD2D299DB0FF00B1077C /* FHIRMockDataStorageProviderTests */ = { + isa = PBXGroup; + children = ( + 2F36AD2E299DB11D00B1077C /* FHIRMockDataStorageProviderTestsView.swift */, + ); + path = FHIRMockDataStorageProviderTests; + sourceTree = ""; + }; 2F6D138928F5F384007C25D6 = { isa = PBXGroup; children = ( - 2FB0758A299DDB9000C0B37F /* TestApp.xctestplan */, - 2F68C3C6292E9F8F00B3E12C /* TemplatePackage */, + 2F7B6CB4294C03C800FDC494 /* TestApp.xctestplan */, + 2FC42FD7290ADD5E00B08F18 /* CardinalKitFHIR */, 2F6D139428F5F384007C25D6 /* TestApp */, 2F6D13AF28F5F386007C25D6 /* TestAppUITests */, 2F6D139328F5F384007C25D6 /* Products */, @@ -77,7 +100,10 @@ isa = PBXGroup; children = ( 2FA7382B290ADFAA007ACEB9 /* TestApp.swift */, + 2FD021DC299E0F2900E5B91B /* TestAppDelegate.swift */, + 2F36AD2D299DB0FF00B1077C /* FHIRMockDataStorageProviderTests */, 2F6D139928F5F386007C25D6 /* Assets.xcassets */, + 2F01E8CE291493560089C46B /* Info.plist */, ); path = TestApp; sourceTree = ""; @@ -85,7 +111,7 @@ 2F6D13AF28F5F386007C25D6 /* TestAppUITests */ = { isa = PBXGroup; children = ( - 2F8A431229130A8C005D2B8F /* TestAppUITests.swift */, + 2F36AD32299DB72400B1077C /* FHIRMockDataStorageProviderTests.swift */, ); path = TestAppUITests; sourceTree = ""; @@ -114,7 +140,10 @@ ); name = TestApp; packageProductDependencies = ( - 2F68C3C7292EA52000B3E12C /* TemplatePackage */, + 2FD021D5299E0E0B00E5B91B /* CardinalKitFHIR */, + 2FD021D7299E0E0B00E5B91B /* CardinalKitFHIRMockDataStorageProvider */, + 2FD021DA299E0E2F00E5B91B /* CardinalKit */, + 2FCF659029B5C9CF0041B496 /* Views */, ); productName = Example; productReference = 2F6D139228F5F384007C25D6 /* TestApp.app */; @@ -134,6 +163,10 @@ 2F6D13AE28F5F386007C25D6 /* PBXTargetDependency */, ); name = TestAppUITests; + packageProductDependencies = ( + 2F746D9E29962B2A00BF54FE /* XCTestExtensions */, + 2FCF659729B5CA630041B496 /* XCTHealthKit */, + ); productName = ExampleUITests; productReference = 2F6D13AC28F5F386007C25D6 /* TestAppUITests.xctest */; productType = "com.apple.product-type.bundle.ui-testing"; @@ -166,6 +199,11 @@ Base, ); mainGroup = 2F6D138928F5F384007C25D6; + packageReferences = ( + 2F746D9D29962B2A00BF54FE /* XCRemoteSwiftPackageReference "XCTestExtensions" */, + 2FD021D9299E0E2F00E5B91B /* XCRemoteSwiftPackageReference "CardinalKit" */, + 2FCF659429B5CA400041B496 /* XCRemoteSwiftPackageReference "XCTHealthKit" */, + ); productRefGroup = 2F6D139328F5F384007C25D6 /* Products */; projectDirPath = ""; projectRoot = ""; @@ -199,7 +237,9 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 2F36AD2F299DB11D00B1077C /* FHIRMockDataStorageProviderTestsView.swift in Sources */, 2FA7382C290ADFAA007ACEB9 /* TestApp.swift in Sources */, + 2FD021DD299E0F2900E5B91B /* TestAppDelegate.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -207,7 +247,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 2F8A431329130A8C005D2B8F /* TestAppUITests.swift in Sources */, + 2F36AD33299DB72400B1077C /* FHIRMockDataStorageProviderTests.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -258,6 +298,7 @@ DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; + ENABLE_TESTING_SEARCH_PATHS = YES; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; @@ -318,6 +359,7 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTING_SEARCH_PATHS = YES; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; @@ -346,24 +388,28 @@ DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = 637867499T; ENABLE_PREVIEWS = YES; - ENABLE_TESTING_SEARCH_PATHS = YES; GENERATE_INFOPLIST_FILE = YES; - INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; + INFOPLIST_FILE = TestApp/Info.plist; + INFOPLIST_KEY_NSHealthShareUsageDescription = "The TestApp accesses your HealthKit data to run the tests."; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown"; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = edu.stanford.templatepackage.testapp; + PRODUCT_BUNDLE_IDENTIFIER = edu.stanford.cardinalkit.fhir.testapp; PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; + SUPPORTS_MACCATALYST = NO; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_STRICT_CONCURRENCY = complete; SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = 1; }; name = Debug; }; @@ -377,24 +423,28 @@ DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = 637867499T; ENABLE_PREVIEWS = YES; - ENABLE_TESTING_SEARCH_PATHS = YES; GENERATE_INFOPLIST_FILE = YES; - INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; + INFOPLIST_FILE = TestApp/Info.plist; + INFOPLIST_KEY_NSHealthShareUsageDescription = "The TestApp accesses your HealthKit data to run the tests."; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown"; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = edu.stanford.templatepackage.testapp; + PRODUCT_BUNDLE_IDENTIFIER = edu.stanford.cardinalkit.fhir.testapp; PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; + SUPPORTS_MACCATALYST = NO; + SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_STRICT_CONCURRENCY = complete; SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; + TARGETED_DEVICE_FAMILY = 1; }; name = Release; }; @@ -406,8 +456,9 @@ CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = 637867499T; GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_LSApplicationCategoryType = ""; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = edu.stanford.TemplatePackage.testappuitests; + PRODUCT_BUNDLE_IDENTIFIER = edu.stanford.cardinalkit.fhir.testappuitests; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; SWIFT_EMIT_LOC_STRINGS = NO; @@ -425,8 +476,9 @@ CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = 637867499T; GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_LSApplicationCategoryType = ""; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = edu.stanford.TemplatePackage.testappuitests; + PRODUCT_BUNDLE_IDENTIFIER = edu.stanford.cardinalkit.fhir.testappuitests; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; SWIFT_EMIT_LOC_STRINGS = NO; @@ -436,116 +488,6 @@ }; name = Release; }; - 2FB07587299DDB6000C0B37F /* Test */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 16.0; - MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - MTL_FAST_MATH = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = TEST; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - }; - name = Test; - }; - 2FB07588299DDB6000C0B37F /* Test */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; - CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_ASSET_PATHS = ""; - DEVELOPMENT_TEAM = 637867499T; - ENABLE_PREVIEWS = YES; - ENABLE_TESTING_SEARCH_PATHS = YES; - GENERATE_INFOPLIST_FILE = YES; - INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; - INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; - INFOPLIST_KEY_UILaunchScreen_Generation = YES; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); - MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = edu.stanford.templatepackage.testapp; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_EMIT_LOC_STRINGS = YES; - SWIFT_STRICT_CONCURRENCY = complete; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Test; - }; - 2FB07589299DDB6000C0B37F /* Test */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; - CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = 637867499T; - GENERATE_INFOPLIST_FILE = YES; - MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = edu.stanford.TemplatePackage.testappuitests; - PRODUCT_NAME = "$(TARGET_NAME)"; - PROVISIONING_PROFILE = ""; - SWIFT_EMIT_LOC_STRINGS = NO; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - TEST_TARGET_NAME = TestApp; - }; - name = Test; - }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -553,7 +495,6 @@ isa = XCConfigurationList; buildConfigurations = ( 2F6D13B428F5F386007C25D6 /* Debug */, - 2FB07587299DDB6000C0B37F /* Test */, 2F6D13B528F5F386007C25D6 /* Release */, ); defaultConfigurationIsVisible = 0; @@ -563,7 +504,6 @@ isa = XCConfigurationList; buildConfigurations = ( 2F6D13B728F5F386007C25D6 /* Debug */, - 2FB07588299DDB6000C0B37F /* Test */, 2F6D13B828F5F386007C25D6 /* Release */, ); defaultConfigurationIsVisible = 0; @@ -573,7 +513,6 @@ isa = XCConfigurationList; buildConfigurations = ( 2F6D13BD28F5F386007C25D6 /* Debug */, - 2FB07589299DDB6000C0B37F /* Test */, 2F6D13BE28F5F386007C25D6 /* Release */, ); defaultConfigurationIsVisible = 0; @@ -581,10 +520,61 @@ }; /* End XCConfigurationList section */ +/* Begin XCRemoteSwiftPackageReference section */ + 2F746D9D29962B2A00BF54FE /* XCRemoteSwiftPackageReference "XCTestExtensions" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/StanfordBDHG/XCTestExtensions"; + requirement = { + kind = upToNextMinorVersion; + minimumVersion = 0.3.0; + }; + }; + 2FCF659429B5CA400041B496 /* XCRemoteSwiftPackageReference "XCTHealthKit" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/StanfordBDHG/XCTHealthKit"; + requirement = { + kind = upToNextMinorVersion; + minimumVersion = 0.3.3; + }; + }; + 2FD021D9299E0E2F00E5B91B /* XCRemoteSwiftPackageReference "CardinalKit" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/StanfordBDHG/CardinalKit.git"; + requirement = { + kind = upToNextMinorVersion; + minimumVersion = 0.3.3; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + /* Begin XCSwiftPackageProductDependency section */ - 2F68C3C7292EA52000B3E12C /* TemplatePackage */ = { + 2F746D9E29962B2A00BF54FE /* XCTestExtensions */ = { + isa = XCSwiftPackageProductDependency; + package = 2F746D9D29962B2A00BF54FE /* XCRemoteSwiftPackageReference "XCTestExtensions" */; + productName = XCTestExtensions; + }; + 2FCF659029B5C9CF0041B496 /* Views */ = { + isa = XCSwiftPackageProductDependency; + package = 2FD021D9299E0E2F00E5B91B /* XCRemoteSwiftPackageReference "CardinalKit" */; + productName = Views; + }; + 2FCF659729B5CA630041B496 /* XCTHealthKit */ = { + isa = XCSwiftPackageProductDependency; + package = 2FCF659429B5CA400041B496 /* XCRemoteSwiftPackageReference "XCTHealthKit" */; + productName = XCTHealthKit; + }; + 2FD021D5299E0E0B00E5B91B /* CardinalKitFHIR */ = { + isa = XCSwiftPackageProductDependency; + productName = CardinalKitFHIR; + }; + 2FD021D7299E0E0B00E5B91B /* CardinalKitFHIRMockDataStorageProvider */ = { + isa = XCSwiftPackageProductDependency; + productName = CardinalKitFHIRMockDataStorageProvider; + }; + 2FD021DA299E0E2F00E5B91B /* CardinalKit */ = { isa = XCSwiftPackageProductDependency; - productName = TemplatePackage; + package = 2FD021D9299E0E2F00E5B91B /* XCRemoteSwiftPackageReference "CardinalKit" */; + productName = CardinalKit; }; /* End XCSwiftPackageProductDependency section */ }; diff --git a/Tests/UITests/UITests.xcodeproj/project.pbxproj.license b/Tests/UITests/UITests.xcodeproj/project.pbxproj.license index d77e33d..deee265 100644 --- a/Tests/UITests/UITests.xcodeproj/project.pbxproj.license +++ b/Tests/UITests/UITests.xcodeproj/project.pbxproj.license @@ -1,4 +1,4 @@ -This source file is part of the TemplatePackage open-source project +This source file is part of the CardinalKit open-source project SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) diff --git a/Tests/UITests/UITests.xcodeproj/project.xcworkspace/contents.xcworkspacedata.license b/Tests/UITests/UITests.xcodeproj/project.xcworkspace/contents.xcworkspacedata.license index d77e33d..deee265 100644 --- a/Tests/UITests/UITests.xcodeproj/project.xcworkspace/contents.xcworkspacedata.license +++ b/Tests/UITests/UITests.xcodeproj/project.xcworkspace/contents.xcworkspacedata.license @@ -1,4 +1,4 @@ -This source file is part of the TemplatePackage open-source project +This source file is part of the CardinalKit open-source project SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) diff --git a/Tests/UITests/UITests.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist.license b/Tests/UITests/UITests.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist.license index d77e33d..deee265 100644 --- a/Tests/UITests/UITests.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist.license +++ b/Tests/UITests/UITests.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist.license @@ -1,4 +1,4 @@ -This source file is part of the TemplatePackage open-source project +This source file is part of the CardinalKit open-source project SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) diff --git a/Tests/UITests/UITests.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Tests/UITests/UITests.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 0000000..9e7f5e6 --- /dev/null +++ b/Tests/UITests/UITests.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,176 @@ +{ + "pins" : [ + { + "identity" : "abseil-cpp-swiftpm", + "kind" : "remoteSourceControl", + "location" : "https://github.com/firebase/abseil-cpp-SwiftPM.git", + "state" : { + "revision" : "583de9bd60f66b40e78d08599cc92036c2e7e4e1", + "version" : "0.20220203.2" + } + }, + { + "identity" : "boringssl-swiftpm", + "kind" : "remoteSourceControl", + "location" : "https://github.com/firebase/boringssl-SwiftPM.git", + "state" : { + "revision" : "dd3eda2b05a3f459fc3073695ad1b28659066eab", + "version" : "0.9.1" + } + }, + { + "identity" : "cardinalkit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/StanfordBDHG/CardinalKit", + "state" : { + "revision" : "6e90348e30709f4b739fc3473c2fa54fbcf77eec", + "version" : "0.3.3" + } + }, + { + "identity" : "fhirmodels", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/FHIRModels", + "state" : { + "revision" : "e115442fb3c5d44ffb1dc9b4e039b77fd143ad96", + "version" : "0.4.0" + } + }, + { + "identity" : "firebase-ios-sdk", + "kind" : "remoteSourceControl", + "location" : "https://github.com/firebase/firebase-ios-sdk", + "state" : { + "revision" : "f567ed9a2b30e29159df258049a9c662c517688e", + "version" : "10.5.0" + } + }, + { + "identity" : "googleappmeasurement", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/GoogleAppMeasurement.git", + "state" : { + "revision" : "9a09ece724128e8d1e14c5133b87c0e236844ac0", + "version" : "10.4.0" + } + }, + { + "identity" : "googledatatransport", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/GoogleDataTransport.git", + "state" : { + "revision" : "f6b558e3f801f2cac336b04f615ce111fa9ddaa0", + "version" : "9.2.1" + } + }, + { + "identity" : "googleutilities", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/GoogleUtilities.git", + "state" : { + "revision" : "0543562f85620b5b7c510c6bcbef75b562a5127b", + "version" : "7.11.0" + } + }, + { + "identity" : "grpc-ios", + "kind" : "remoteSourceControl", + "location" : "https://github.com/grpc/grpc-ios.git", + "state" : { + "revision" : "8440b914756e0d26d4f4d054a1c1581daedfc5b6", + "version" : "1.44.3-grpc" + } + }, + { + "identity" : "gtm-session-fetcher", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/gtm-session-fetcher.git", + "state" : { + "revision" : "96d7cc73a71ce950723aa3c50ce4fb275ae180b8", + "version" : "3.1.0" + } + }, + { + "identity" : "healthkitonfhir", + "kind" : "remoteSourceControl", + "location" : "https://github.com/StanfordBDHG/HealthKitOnFHIR", + "state" : { + "revision" : "1b7b7d71c30563f84d4c892421caf7f1c79ff09e", + "version" : "0.2.2" + } + }, + { + "identity" : "leveldb", + "kind" : "remoteSourceControl", + "location" : "https://github.com/firebase/leveldb.git", + "state" : { + "revision" : "0706abcc6b0bd9cedfbb015ba840e4a780b5159b", + "version" : "1.22.2" + } + }, + { + "identity" : "nanopb", + "kind" : "remoteSourceControl", + "location" : "https://github.com/firebase/nanopb.git", + "state" : { + "revision" : "819d0a2173aff699fb8c364b6fb906f7cdb1a692", + "version" : "2.30909.0" + } + }, + { + "identity" : "promises", + "kind" : "remoteSourceControl", + "location" : "https://github.com/google/promises.git", + "state" : { + "revision" : "ec957ccddbcc710ccc64c9dcbd4c7006fcf8b73a", + "version" : "2.2.0" + } + }, + { + "identity" : "researchkit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/StanfordBDHG/ResearchKit", + "state" : { + "revision" : "52a9bd8bcf2112b2f70479cd192f8c5fa9850c31", + "version" : "2.2.8" + } + }, + { + "identity" : "researchkitonfhir", + "kind" : "remoteSourceControl", + "location" : "https://github.com/StanfordBDHG/ResearchKitOnFHIR", + "state" : { + "revision" : "1bc7a15760916ade4c5058fa798a871e80c2955c", + "version" : "0.1.6" + } + }, + { + "identity" : "swift-protobuf", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-protobuf.git", + "state" : { + "revision" : "ab3a58b7209a17d781c0d1dbb3e1ff3da306bae8", + "version" : "1.20.3" + } + }, + { + "identity" : "xctestextensions", + "kind" : "remoteSourceControl", + "location" : "https://github.com/StanfordBDHG/XCTestExtensions", + "state" : { + "revision" : "a96a1680557507a9746bbb0529043b9767c503db", + "version" : "0.3.0" + } + }, + { + "identity" : "xcthealthkit", + "kind" : "remoteSourceControl", + "location" : "https://github.com/StanfordBDHG/XCTHealthKit", + "state" : { + "revision" : "19395bbd14a2554e4c9d3fe5cf38aa626c807269", + "version" : "0.3.3" + } + } + ], + "version" : 2 +} diff --git a/Tests/UITests/UITests.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved.license b/Tests/UITests/UITests.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved.license new file mode 100644 index 0000000..deee265 --- /dev/null +++ b/Tests/UITests/UITests.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved.license @@ -0,0 +1,5 @@ +This source file is part of the CardinalKit open-source project + +SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md) + +SPDX-License-Identifier: MIT \ No newline at end of file diff --git a/Tests/UITests/UITests.xcodeproj/xcshareddata/xcschemes/TestApp.xcscheme b/Tests/UITests/UITests.xcodeproj/xcshareddata/xcschemes/TestApp.xcscheme deleted file mode 100644 index fa4eca3..0000000 --- a/Tests/UITests/UITests.xcodeproj/xcshareddata/xcschemes/TestApp.xcscheme +++ /dev/null @@ -1,104 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Tests/UITests/UITests.xcodeproj/xcshareddata/xcschemes/TestApp.xcscheme.license b/Tests/UITests/UITests.xcodeproj/xcshareddata/xcschemes/TestApp.xcscheme.license index d77e33d..deee265 100644 --- a/Tests/UITests/UITests.xcodeproj/xcshareddata/xcschemes/TestApp.xcscheme.license +++ b/Tests/UITests/UITests.xcodeproj/xcshareddata/xcschemes/TestApp.xcscheme.license @@ -1,4 +1,4 @@ -This source file is part of the TemplatePackage open-source project +This source file is part of the CardinalKit open-source project SPDX-FileCopyrightText: 2022 Stanford University and the project authors (see CONTRIBUTORS.md)