generated from StanfordSpezi/SpeziTemplateApplication
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f711011
commit 4a87abd
Showing
43 changed files
with
414 additions
and
1,001 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
// | ||
// This source file is part of the Stanford LLM on FHIR project | ||
// | ||
// SPDX-FileCopyrightText: 2023 Stanford University | ||
// | ||
// SPDX-License-Identifier: MIT | ||
// | ||
|
||
import ModelsR4 | ||
import SpeziFHIR | ||
import SpeziFHIRMockPatients | ||
import SwiftUI | ||
|
||
|
||
struct ResourceSelection: View { | ||
@Environment(OwnYourDataStandard.self) private var standard | ||
@Environment(FHIRStore.self) private var store | ||
|
||
@State private var bundles: [ModelsR4.Bundle] = [] | ||
@State private var showBundleSelection = false | ||
|
||
@MainActor var useHealthKitResources: Binding<Bool> { | ||
Binding( | ||
get: { | ||
if FeatureFlags.mockPatients { | ||
showBundleSelection = true | ||
return false | ||
} | ||
return standard.useHealthKitResources | ||
}, | ||
set: { newValue in | ||
showBundleSelection = !newValue | ||
standard.useHealthKitResources = newValue | ||
} | ||
) | ||
} | ||
|
||
|
||
var body: some View { | ||
Form { | ||
Section { | ||
Toggle(isOn: useHealthKitResources) { | ||
Text("Use HealthKit Resources") | ||
} | ||
.onChange(of: useHealthKitResources.wrappedValue, initial: true) { | ||
if useHealthKitResources.wrappedValue { | ||
_Concurrency.Task { | ||
await standard.loadHealthKitResources() | ||
} | ||
} else { | ||
guard let firstMockPatient = bundles.first else { | ||
return | ||
} | ||
|
||
store.removeAllResources() | ||
store.load(bundle: firstMockPatient) | ||
} | ||
} | ||
} | ||
if showBundleSelection { | ||
Section { | ||
if bundles.isEmpty { | ||
HStack { | ||
Spacer() | ||
ProgressView() | ||
Spacer() | ||
} | ||
} else { | ||
FHIRBundleSelector(bundles: bundles) | ||
.pickerStyle(.inline) | ||
} | ||
} | ||
} | ||
} | ||
.task { | ||
self.bundles = await mockPatients | ||
} | ||
.onAppear { | ||
showBundleSelection = !standard.useHealthKitResources | ||
} | ||
.navigationTitle(Text("Resource Settings")) | ||
} | ||
|
||
private var mockPatients: [ModelsR4.Bundle] { | ||
get async { | ||
await [ | ||
.allen322Ferry570, | ||
.beatris270Bogan287, | ||
.edythe31Morar593, | ||
.gonzalo160Duenas839, | ||
.jacklyn830Veum823, | ||
.milton509Ortiz186 | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.