Skip to content

Commit

Permalink
Trials Loading, Keyword Search Generation, and Trials Matching (#22)
Browse files Browse the repository at this point in the history
# Trials Loading, Keyword Search Generation, and Trials Matching

## ⚙️ Release Notes 
- Loads FHIR resources into an LLM to determine keywords.
- Uses keywords to query the NIC API.
- Match NCI results with local FHIR resources to provide
recommendations.


### Code of Conduct & Contributing Guidelines 

By submitting creating this pull request, you agree to follow our [Code
of
Conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md):
- [x] I agree to follow the [Code of
Conduct](https://github.com/StanfordBDHG/.github/blob/main/CODE_OF_CONDUCT.md)
and [Contributing
Guidelines](https://github.com/StanfordBDHG/.github/blob/main/CONTRIBUTING.md).
  • Loading branch information
PSchmiedmayer authored May 15, 2024
1 parent 24a3063 commit 9a7b43c
Show file tree
Hide file tree
Showing 22 changed files with 1,535 additions and 198 deletions.
86 changes: 81 additions & 5 deletions OwnYourData.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
2F42E9E12B91BB2500D88DB7 /* PDFListRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F42E9DA2B91BB2500D88DB7 /* PDFListRow.swift */; };
2F42E9E22B91BB2500D88DB7 /* DocumentScanner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F42E9DB2B91BB2500D88DB7 /* DocumentScanner.swift */; };
2F42E9E72B91BB8300D88DB7 /* WebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F42E9E52B91BB8300D88DB7 /* WebView.swift */; };
2F42E9E82B91BB8300D88DB7 /* ClinicalTrialsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F42E9E62B91BB8300D88DB7 /* ClinicalTrialsView.swift */; };
2F42E9E82B91BB8300D88DB7 /* ViewClinicalTrialsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F42E9E62B91BB8300D88DB7 /* ViewClinicalTrialsView.swift */; };
2F42E9F22B91BBF300D88DB7 /* HowItWorks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F42E9EB2B91BBF300D88DB7 /* HowItWorks.swift */; };
2F42E9F32B91BBF300D88DB7 /* AddRecordInstructView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F42E9EC2B91BBF300D88DB7 /* AddRecordInstructView.swift */; };
2F42E9F42B91BBF300D88DB7 /* Instructions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F42E9ED2B91BBF300D88DB7 /* Instructions.swift */; };
Expand All @@ -50,6 +50,17 @@
2FB099B12A875DF100B20952 /* FirebaseFirestore in Frameworks */ = {isa = PBXBuildFile; productRef = 2FB099B02A875DF100B20952 /* FirebaseFirestore */; };
2FB099B32A875DF100B20952 /* FirebaseFirestoreSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 2FB099B22A875DF100B20952 /* FirebaseFirestoreSwift */; };
2FB099B62A875E2B00B20952 /* HealthKitOnFHIR in Frameworks */ = {isa = PBXBuildFile; productRef = 2FB099B52A875E2B00B20952 /* HealthKitOnFHIR */; };
2FB4DBB82BF4781D00E68AD9 /* MatchingModule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FB4DBB72BF4781D00E68AD9 /* MatchingModule.swift */; };
2FB4DBBB2BF479E600E68AD9 /* GetFHIRResourceLLMFunction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FB4DBBA2BF479E600E68AD9 /* GetFHIRResourceLLMFunction.swift */; };
2FB4DBC12BF47ABA00E68AD9 /* FHIRResource+Identifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FB4DBC02BF47ABA00E68AD9 /* FHIRResource+Identifier.swift */; };
2FB4DBC62BF48E4F00E68AD9 /* GetTrialsLLMFunction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FB4DBC52BF48E4F00E68AD9 /* GetTrialsLLMFunction.swift */; };
2FB4DBC92BF48E7400E68AD9 /* FHIRPrompt+OwnYourData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FB4DBC82BF48E7400E68AD9 /* FHIRPrompt+OwnYourData.swift */; };
2FB4DBCD2BF4915900E68AD9 /* NCITrialsModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FB4DBCC2BF4915900E68AD9 /* NCITrialsModel.swift */; };
2FB4DBD52BF4946E00E68AD9 /* MatchingState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FB4DBD42BF4946E00E68AD9 /* MatchingState.swift */; };
2FB4DBD72BF4948700E68AD9 /* MatchingStateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FB4DBD62BF4948700E68AD9 /* MatchingStateView.swift */; };
2FB4DBDB2BF4A08000E68AD9 /* MatchingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FB4DBDA2BF4A08000E68AD9 /* MatchingView.swift */; };
2FB4DBDE2BF4A62100E68AD9 /* TrialDetail+LLMIndentifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FB4DBDD2BF4A62100E68AD9 /* TrialDetail+LLMIndentifier.swift */; };
2FB4DBE42BF4AEF200E68AD9 /* BreastCancerExample.json in Resources */ = {isa = PBXBuildFile; fileRef = 2FB4DBE22BF4AE4200E68AD9 /* BreastCancerExample.json */; };
2FC3439229EE634B002D773C /* ConsentDocument.md in Resources */ = {isa = PBXBuildFile; fileRef = 2FE5DC2C29EDD78E004B9AB4 /* ConsentDocument.md */; };
2FC975A82978F11A00BA99FE /* Home.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2FC975A72978F11A00BA99FE /* Home.swift */; };
2FCDFF7C2BF33E5400158BDE /* SpeziLocation in Frameworks */ = {isa = PBXBuildFile; productRef = 2FCDFF7B2BF33E5400158BDE /* SpeziLocation */; };
Expand Down Expand Up @@ -128,7 +139,7 @@
2F42E9DA2B91BB2500D88DB7 /* PDFListRow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PDFListRow.swift; sourceTree = "<group>"; };
2F42E9DB2B91BB2500D88DB7 /* DocumentScanner.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DocumentScanner.swift; sourceTree = "<group>"; };
2F42E9E52B91BB8300D88DB7 /* WebView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WebView.swift; sourceTree = "<group>"; };
2F42E9E62B91BB8300D88DB7 /* ClinicalTrialsView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ClinicalTrialsView.swift; sourceTree = "<group>"; };
2F42E9E62B91BB8300D88DB7 /* ViewClinicalTrialsView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewClinicalTrialsView.swift; sourceTree = "<group>"; };
2F42E9EB2B91BBF300D88DB7 /* HowItWorks.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HowItWorks.swift; sourceTree = "<group>"; };
2F42E9EC2B91BBF300D88DB7 /* AddRecordInstructView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AddRecordInstructView.swift; sourceTree = "<group>"; };
2F42E9ED2B91BBF300D88DB7 /* Instructions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Instructions.swift; sourceTree = "<group>"; };
Expand All @@ -147,6 +158,17 @@
2F6025CA29BBE70F0045459E /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
2FA0BFEC2ACC977500E0EF83 /* Localizable.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; path = Localizable.xcstrings; sourceTree = "<group>"; };
2FAEC07F297F583900C11C42 /* OwnYourData.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = OwnYourData.entitlements; sourceTree = "<group>"; };
2FB4DBB72BF4781D00E68AD9 /* MatchingModule.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MatchingModule.swift; sourceTree = "<group>"; };
2FB4DBBA2BF479E600E68AD9 /* GetFHIRResourceLLMFunction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GetFHIRResourceLLMFunction.swift; sourceTree = "<group>"; };
2FB4DBC02BF47ABA00E68AD9 /* FHIRResource+Identifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FHIRResource+Identifier.swift"; sourceTree = "<group>"; };
2FB4DBC52BF48E4F00E68AD9 /* GetTrialsLLMFunction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GetTrialsLLMFunction.swift; sourceTree = "<group>"; };
2FB4DBC82BF48E7400E68AD9 /* FHIRPrompt+OwnYourData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "FHIRPrompt+OwnYourData.swift"; sourceTree = "<group>"; };
2FB4DBCC2BF4915900E68AD9 /* NCITrialsModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCITrialsModel.swift; sourceTree = "<group>"; };
2FB4DBD42BF4946E00E68AD9 /* MatchingState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MatchingState.swift; sourceTree = "<group>"; };
2FB4DBD62BF4948700E68AD9 /* MatchingStateView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MatchingStateView.swift; sourceTree = "<group>"; };
2FB4DBDA2BF4A08000E68AD9 /* MatchingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MatchingView.swift; sourceTree = "<group>"; };
2FB4DBDD2BF4A62100E68AD9 /* TrialDetail+LLMIndentifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TrialDetail+LLMIndentifier.swift"; sourceTree = "<group>"; };
2FB4DBE22BF4AE4200E68AD9 /* BreastCancerExample.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = BreastCancerExample.json; sourceTree = "<group>"; };
2FC94CD4298B0A1D009C8209 /* OwnYourData.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = OwnYourData.xctestplan; sourceTree = "<group>"; };
2FC975A72978F11A00BA99FE /* Home.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Home.swift; sourceTree = "<group>"; };
2FCDFF7E2BF33ED800158BDE /* LocationPermissions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationPermissions.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -261,7 +283,8 @@
2F42E9E32B91BB7000D88DB7 /* ClinicalTrials */ = {
isa = PBXGroup;
children = (
2F42E9E62B91BB8300D88DB7 /* ClinicalTrialsView.swift */,
2FB4DBCC2BF4915900E68AD9 /* NCITrialsModel.swift */,
2F42E9E62B91BB8300D88DB7 /* ViewClinicalTrialsView.swift */,
2FCDFF812BF3417300158BDE /* TrialView.swift */,
2F42E9E52B91BB8300D88DB7 /* WebView.swift */,
2F38F39F2BE805090002E7D5 /* NICTrialsAPIDateFormatter.swift */,
Expand Down Expand Up @@ -295,6 +318,46 @@
path = FHIR;
sourceTree = "<group>";
};
2FB4DBB92BF479CF00E68AD9 /* TrialsMatching */ = {
isa = PBXGroup;
children = (
2FB4DBD22BF4946100E68AD9 /* Helpers */,
2FB4DBCF2BF492F600E68AD9 /* LLMFunctions */,
2FB4DBD42BF4946E00E68AD9 /* MatchingState.swift */,
2FB4DBB72BF4781D00E68AD9 /* MatchingModule.swift */,
2FB4DBD62BF4948700E68AD9 /* MatchingStateView.swift */,
2FB4DBDA2BF4A08000E68AD9 /* MatchingView.swift */,
);
path = TrialsMatching;
sourceTree = "<group>";
};
2FB4DBCF2BF492F600E68AD9 /* LLMFunctions */ = {
isa = PBXGroup;
children = (
2FB4DBBA2BF479E600E68AD9 /* GetFHIRResourceLLMFunction.swift */,
2FB4DBC52BF48E4F00E68AD9 /* GetTrialsLLMFunction.swift */,
);
path = LLMFunctions;
sourceTree = "<group>";
};
2FB4DBD22BF4946100E68AD9 /* Helpers */ = {
isa = PBXGroup;
children = (
2FB4DBC02BF47ABA00E68AD9 /* FHIRResource+Identifier.swift */,
2FB4DBC82BF48E7400E68AD9 /* FHIRPrompt+OwnYourData.swift */,
2FB4DBDD2BF4A62100E68AD9 /* TrialDetail+LLMIndentifier.swift */,
);
path = Helpers;
sourceTree = "<group>";
};
2FB4DBE12BF4AE2500E68AD9 /* ExamplePatients */ = {
isa = PBXGroup;
children = (
2FB4DBE22BF4AE4200E68AD9 /* BreastCancerExample.json */,
);
path = ExamplePatients;
sourceTree = "<group>";
};
2FC9759D2978E30800BA99FE /* Supporting Files */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -322,6 +385,7 @@
2FE5DC2D29EDD792004B9AB4 /* Resources */ = {
isa = PBXGroup;
children = (
2FB4DBE12BF4AE2500E68AD9 /* ExamplePatients */,
653A255428338800005D4D48 /* Assets.xcassets */,
2FA0BFEC2ACC977500E0EF83 /* Localizable.xcstrings */,
2FE5DC2C29EDD78E004B9AB4 /* ConsentDocument.md */,
Expand Down Expand Up @@ -395,6 +459,7 @@
2FE5DC2829EDD398004B9AB4 /* Onboarding */,
56F6F29E2AB441640022FE5A /* Contributions */,
2F42E9D32B91BB1800D88DB7 /* Documents */,
2FB4DBB92BF479CF00E68AD9 /* TrialsMatching */,
2F42E9E32B91BB7000D88DB7 /* ClinicalTrials */,
2F42E9E92B91BBDD00D88DB7 /* Instructions */,
2FE5DC3C29EDD7DA004B9AB4 /* SharedContext */,
Expand Down Expand Up @@ -603,6 +668,7 @@
653A255528338800005D4D48 /* Assets.xcassets in Resources */,
2FA0BFED2ACC977500E0EF83 /* Localizable.xcstrings in Resources */,
2F6025CB29BBE70F0045459E /* GoogleService-Info.plist in Resources */,
2FB4DBE42BF4AEF200E68AD9 /* BreastCancerExample.json in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -651,10 +717,12 @@
2FE5DC4129EDD7EE004B9AB4 /* StorageKeys.swift in Sources */,
2F42E9F72B91BBF300D88DB7 /* ViewRecordsView.swift in Sources */,
2F42E9E22B91BB2500D88DB7 /* DocumentScanner.swift in Sources */,
2FB4DBD72BF4948700E68AD9 /* MatchingStateView.swift in Sources */,
2FE5DCB129EE6107004B9AB4 /* AccountOnboarding.swift in Sources */,
2F42E9F22B91BBF300D88DB7 /* HowItWorks.swift in Sources */,
2FE5DC3A29EDD7CA004B9AB4 /* Welcome.swift in Sources */,
2F42E9DE2B91BB2500D88DB7 /* PDFView.swift in Sources */,
2FB4DBBB2BF479E600E68AD9 /* GetFHIRResourceLLMFunction.swift in Sources */,
2F38F3A02BE805090002E7D5 /* NICTrialsAPIDateFormatter.swift in Sources */,
2F42E9F42B91BBF300D88DB7 /* Instructions.swift in Sources */,
2FCDFF7F2BF33ED800158BDE /* LocationPermissions.swift in Sources */,
Expand All @@ -671,6 +739,8 @@
A9DFE8A92ABE551400428242 /* AccountButton.swift in Sources */,
2FE5DC3729EDD7CA004B9AB4 /* OnboardingFlow.swift in Sources */,
2F42E9D12B91BAB900D88DB7 /* LogoView.swift in Sources */,
2FB4DBC12BF47ABA00E68AD9 /* FHIRResource+Identifier.swift in Sources */,
2FB4DBDE2BF4A62100E68AD9 /* TrialDetail+LLMIndentifier.swift in Sources */,
2F42EA072B91C24700D88DB7 /* URL+Zip.swift in Sources */,
2FF53D8D2A8729D600042B76 /* OwnYourDataStandard.swift in Sources */,
2FE5DC4729EDD7F2004B9AB4 /* CodableArray+RawRepresentable.swift in Sources */,
Expand All @@ -680,15 +750,20 @@
2F42E9DD2B91BB2500D88DB7 /* DocumentGallery.swift in Sources */,
2F42E9DF2B91BB2500D88DB7 /* PDFDocument+Transferable.swift in Sources */,
2F42E9F52B91BBF300D88DB7 /* InstructionsStep.swift in Sources */,
2FB4DBC92BF48E7400E68AD9 /* FHIRPrompt+OwnYourData.swift in Sources */,
2FB4DBC62BF48E4F00E68AD9 /* GetTrialsLLMFunction.swift in Sources */,
2F4E23832989D51F0013F3D9 /* OwnYourDataTestingSetup.swift in Sources */,
2FB4DBCD2BF4915900E68AD9 /* NCITrialsModel.swift in Sources */,
2F42E9DC2B91BB2500D88DB7 /* DocumentManager.swift in Sources */,
2F42E9E02B91BB2500D88DB7 /* PDFListDetailView.swift in Sources */,
2FCDFF822BF3417300158BDE /* TrialView.swift in Sources */,
2F38F3A52BE8BC890002E7D5 /* TrialDetail+Identifiable.swift in Sources */,
2FB4DBDB2BF4A08000E68AD9 /* MatchingView.swift in Sources */,
2FB4DBD52BF4946E00E68AD9 /* MatchingState.swift in Sources */,
2F42E9FA2B91BDD300D88DB7 /* InstructionsView.swift in Sources */,
56F6F2A02AB441930022FE5A /* ContributionsList.swift in Sources */,
2F42E9D22B91BAB900D88DB7 /* OwnYourDataButton.swift in Sources */,
2F42E9E82B91BB8300D88DB7 /* ClinicalTrialsView.swift in Sources */,
2F42E9E82B91BB8300D88DB7 /* ViewClinicalTrialsView.swift in Sources */,
566155292AB8447C00209B80 /* Package+LicenseType.swift in Sources */,
5680DD392AB8983D004E6D4A /* PackageCell.swift in Sources */,
2F5E32BD297E05EA003432F8 /* OwnYourDataDelegate.swift in Sources */,
Expand All @@ -697,6 +772,7 @@
653A2551283387FE005D4D48 /* OwnYourData.swift in Sources */,
2F42EA0E2B91CD7100D88DB7 /* OpenAIAPIKey.swift in Sources */,
2FE5DC3629EDD7CA004B9AB4 /* HealthKitPermissions.swift in Sources */,
2FB4DBB82BF4781D00E68AD9 /* MatchingModule.swift in Sources */,
5661552E2AB854C000209B80 /* PackageHelper.swift in Sources */,
2F42E9FF2B91BE3100D88DB7 /* FHIRStore+Extensions.swift in Sources */,
);
Expand Down Expand Up @@ -1231,7 +1307,7 @@
repositoryURL = "https://github.com/StanfordSpezi/SpeziLLM.git";
requirement = {
kind = upToNextMinorVersion;
minimumVersion = 0.8.1;
minimumVersion = 0.8.2;
};
};
2F42E9BE2B91B70F00D88DB7 /* XCRemoteSwiftPackageReference "SpeziFHIR" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@
"repositoryURL": "https://github.com/StanfordBDHG/llama.cpp",
"state": {
"branch": null,
"revision": "7bfd6d4b5bbc9fd47bd023bdbb35f96c827977f3",
"version": "0.2.1"
"revision": "6839853a321778906e210a33ee2c6aec52f34c97",
"version": "0.3.3"
}
},
{
Expand Down Expand Up @@ -249,8 +249,8 @@
"repositoryURL": "https://github.com/StanfordSpezi/SpeziLLM.git",
"state": {
"branch": null,
"revision": "cbaf20496e600c985dea2358f35a497fe4964116",
"version": "0.8.1"
"revision": "94f14f6a1d0fb4c7bb54efa6b6241f18dfc5004d",
"version": "0.8.2"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
<CommandLineArguments>
<CommandLineArgument
argument = "--disableFirebase"
isEnabled = "YES">
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "--showOnboarding"
Expand Down
49 changes: 43 additions & 6 deletions OwnYourData/Account/ResourceSelection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,50 @@ struct ResourceSelection: View {
private var mockPatients: [ModelsR4.Bundle] {
get async {
await [
.allen322Ferry570,
.beatris270Bogan287,
.edythe31Morar593,
.gonzalo160Duenas839,
.jacklyn830Veum823,
.milton509Ortiz186
.breastCancerExample
]
}
}
}


extension ModelsR4.Bundle {
private static var _breastCancerExample: ModelsR4.Bundle?
/// Example FHIR resources packed into a bundle to represent the simulated patient named Jamison785 Denesik803.
public static var breastCancerExample: ModelsR4.Bundle {
get async {
if let breastCancerExample = _breastCancerExample {
return breastCancerExample
}

let breastCancerExample = await Foundation.Bundle.main.improvedLoadFHIRBundle(
withName: "BreastCancerExample"
)
ModelsR4.Bundle._breastCancerExample = breastCancerExample
return breastCancerExample
}
}
}


extension Foundation.Bundle {
/// Loads a FHIR `Bundle` from a Foundation `Bundle`.
/// - Parameter name: Name of the JSON file in the Foundation `Bundle`
/// - Returns: The FHIR `Bundle`
public func improvedLoadFHIRBundle(withName name: String) async -> ModelsR4.Bundle {
guard let resourceURL = self.url(forResource: name, withExtension: "json") else {
fatalError("Could not find the resource \"\(name)\".json in the SpeziFHIRMockPatients Resources folder.")
}

let loadingTask = _Concurrency.Task {
let resourceData = try Data(contentsOf: resourceURL)
return try JSONDecoder().decode(Bundle.self, from: resourceData)
}

do {
return try await loadingTask.value
} catch {
fatalError("Could not decode the FHIR bundle named \"\(name).json\": \(error)")
}
}
}
Loading

0 comments on commit 9a7b43c

Please sign in to comment.