Skip to content

Commit 5f0ea85

Browse files
committed
Refactor FHIR resource loading and update tests
Updated `LibraryRunner.cs` to add a comment about re-adding FHIR resource loading functionality and introduced a `libraryIdentifier` variable. In `MeasuresTest.cs`, removed the import for `Hl7.Cql.Fhir.Serialization.Extensions` and modified the `BCSEHEDIS2022_Numerator_FromResource_Passed` test method to use `InvocationToolkit` for creating runtime scopes. The method `CreateRuntimeScopeFromFhirResourceFile` was removed, reflecting a new approach to runtime scope creation in tests.
1 parent 08368fe commit 5f0ea85

File tree

2 files changed

+10
-18
lines changed

2 files changed

+10
-18
lines changed

Demo/CLI/LibraryRunner.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ public void RunWithResources()
5050
//run using Library Resource files - production scenario, no debugging inline with measures project
5151
Console.WriteLine($"Loading resources for Library: {_opts.Library}");
5252
var libraryIdentifier = _opts.LibraryIdentifier;
53+
54+
// The functionality to load a FHIR resource and its dependencies will be added back in issue:
55+
// https://github.com/FirelyTeam/firely-cql-sdk/issues/949
5356
using var librarySetInvoker = new InvocationToolkit()
5457
.AddAssemblyBinariesInFhirLibrariesFromDirectory(new (_opts.ResourcesDirectory))
5558
.CreateLibrarySetInvoker(libraryIdentifier);

Demo/Test.Measures.Demo/MeasuresTest.cs

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
using Hl7.Cql.Invocation.Toolkit;
1919
using Hl7.Cql.Invocation.Toolkit.Extensions;
2020
using Hl7.Cql.Fhir.Serialization;
21-
using Hl7.Cql.Fhir.Serialization.Extensions;
2221

2322
namespace Test
2423
{
@@ -51,17 +50,20 @@ public void BCSEHEDIS2022_Numerator()
5150
[TestMethod]
5251
public void BCSEHEDIS2022_Numerator_FromResource_Passed()
5352
{
54-
var lib = "BCSEHEDISMY2022";
55-
var version = "1.0.0";
53+
// The functionality to load a FHIR resource and its dependencies will be added back in issue:
54+
// https://github.com/FirelyTeam/firely-cql-sdk/issues/949
55+
var libraryIdentifier = CqlVersionedLibraryIdentifier.ParseFromIdentifierAndVersion("BCSEHEDISMY2022", "1.0.0");
5656
var dir = LibrarySetsDirs.Demo.ResourcesDir;
57-
var scope = CreateRuntimeScopeFromFhirResourceFile(dir, lib, version);
57+
using var scope = new InvocationToolkit()
58+
.AddAssemblyBinariesInFhirLibrariesFromDirectory(dir)
59+
.CreateLibrarySetInvoker(libraryIdentifier);
5860

5961
var patientEverything = new Bundle(); // Add data
6062
var valueSets = Enumerable.Empty<ValueSet>().ToValueSetDictionary(); // Add valuesets
6163
var ctx = FhirCqlContext.ForBundle(patientEverything, MY2023, valueSets);
6264

6365
var results = scope
64-
.SelectExpressionsForLibrary(CqlVersionedLibraryIdentifier.ParseFromIdentifierAndVersion(lib, version))
66+
.SelectExpressionsForLibrary(libraryIdentifier)
6567
.SelectResults(ctx)
6668
.ToDictionary(t => t.definitionInvoker.DefinitionName, t => t.invocationResult);
6769

@@ -124,19 +126,6 @@ public void BCSEHEDIS2022_Numerator_FromElm()
124126
.ToDictionary(t => t.definitionInvoker.DefinitionName, t => t.invocationResult);
125127
}
126128

127-
private static LibrarySetInvoker CreateRuntimeScopeFromFhirResourceFile(
128-
DirectoryInfo dir,
129-
string lib,
130-
string version)
131-
{
132-
var libFile = new FileInfo(Path.Combine(dir.FullName, $"Library-{lib}-{version}.json")); // Library-BCSEHEDISMY2022-1.0.0
133-
using var fs = libFile.OpenRead();
134-
var library = fs.DeserializeJsonToFhir<Library>();
135-
var allLibs = library.GetDependenciesAndSelf(dir);
136-
//Runtime
137-
return allLibs.ToLibrarySetInvoker();
138-
}
139-
140129
private static LibrarySetInvoker CreateRuntimeScopeFromElmLibraryFile(
141130
DirectoryInfo elmDirectory,
142131
string lib,

0 commit comments

Comments
 (0)