Skip to content

Commit 08368fe

Browse files
committed
Remove LibraryExtensions and update project references
- Added `InternalsVisibleTo` entry for the `CLI` project in `Cql.Abstractions.csproj`. - Removed `LibraryExtensions.cs`, which contained methods for loading library dependencies. - Simplified `GetValueSetIds` method in `LibraryRunner.cs` and removed unnecessary using directives and comments. - Updated `Test.Measures.Demo.csproj` to remove reference to `LibraryExtensions.cs`.
1 parent 1ffd5dc commit 08368fe

File tree

4 files changed

+2
-163
lines changed

4 files changed

+2
-163
lines changed

Cql/Cql.Abstractions/Cql.Abstractions.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
<InternalsVisibleTo Include="Hl7.Cql.Invocation" Key="$(LibraryPKHash)" />
3737
<InternalsVisibleTo Include="Hl7.Cql.Packager" Key="$(LibraryPKHash)" />
3838
<InternalsVisibleTo Include="CqlSdkExamplesPreview" Key="$(LibraryPKHash)" />
39+
<InternalsVisibleTo Include="CLI" Key="$(LibraryPKHash)" />
3940
</ItemGroup>
4041

4142
<ItemGroup>

Demo/CLI/Helpers/LibraryExtensions.cs

Lines changed: 0 additions & 97 deletions
This file was deleted.

Demo/CLI/LibraryRunner.cs

Lines changed: 1 addition & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,10 @@
88

99
using CLI.Helpers;
1010
using Dumpify;
11-
using Hl7.Cql.Abstractions;
1211
using Hl7.Cql.CodeGeneration.NET;
1312
using Hl7.Cql.Fhir;
14-
using Hl7.Cql.Fhir.Serialization.Extensions;
1513
using Hl7.Cql.Invocation.Toolkit;
1614
using Hl7.Cql.Invocation.Toolkit.Extensions;
17-
using Hl7.Cql.Primitives;
1815
using Hl7.Cql.Runtime;
1916
using Hl7.Cql.ValueSets;
2017
using Hl7.Fhir.Model;
@@ -53,10 +50,6 @@ public void RunWithResources()
5350
//run using Library Resource files - production scenario, no debugging inline with measures project
5451
Console.WriteLine($"Loading resources for Library: {_opts.Library}");
5552
var libraryIdentifier = _opts.LibraryIdentifier;
56-
57-
// TODO: Not efficient to load all resources in the directory,
58-
// still have to add an extension to InvocationToolkit to load only the library resource
59-
// and its dependencies
6053
using var librarySetInvoker = new InvocationToolkit()
6154
.AddAssemblyBinariesInFhirLibrariesFromDirectory(new (_opts.ResourcesDirectory))
6255
.CreateLibrarySetInvoker(libraryIdentifier);
@@ -66,52 +59,14 @@ public void RunWithResources()
6659
private void RunShared(CommandLineOptions opt, LibrarySetInvoker librarySetInvoker)
6760
{
6861
Console.WriteLine("Loading value sets");
69-
var valueSetIds = GetValueSetIds(librarySetInvoker, opt.Library);
70-
IValueSetDictionary valueSets = ResourceHelper.LoadValueSets(
71-
new DirectoryInfo(opt.ValueSetsDirectory));
62+
IValueSetDictionary valueSets = ResourceHelper.LoadValueSets(new DirectoryInfo(opt.ValueSetsDirectory));
7263

7364
Console.WriteLine("Loading test case files");
7465
var testDataDir = Path.Join(opt.DataDirectory, (string)opt.LibraryIdentifier.Identifier);
7566
var patientList = ProcessTestPatients(testDataDir, librarySetInvoker, valueSets);
7667
//optionally use patientList Dictionary
7768
}
7869

79-
/// <summary>
80-
/// Retrieves a set of unique ValueSet IDs from the specified library and its dependencies.
81-
/// </summary>
82-
/// <param name="librarySetInvoker">
83-
/// An instance of <see cref="LibrarySetInvoker"/> used to access library invokers and their dependencies.
84-
/// </param>
85-
/// <param name="libraryName">
86-
/// The name of the library from which to retrieve ValueSet IDs. This should be a valid CQL library identifier.
87-
/// </param>
88-
/// <returns>
89-
/// A <see cref="HashSet{T}"/> containing the unique ValueSet IDs defined in the specified library and its dependencies.
90-
/// </returns>
91-
/// <exception cref="KeyNotFoundException">
92-
/// Thrown if the specified library name does not exist in the <paramref name="librarySetInvoker"/>.
93-
/// </exception>
94-
/// <exception cref="ArgumentException">
95-
/// Thrown if the <paramref name="libraryName"/> is not a valid CQL library identifier.
96-
/// </exception>
97-
private static List<string> GetValueSetIds(LibrarySetInvoker librarySetInvoker, string libraryName)
98-
{
99-
var libraryIdentifier = CqlVersionedLibraryIdentifier.Parse(libraryName);
100-
var libraryInvoker = librarySetInvoker.LibraryInvokers[libraryIdentifier];
101-
var libraryInvokerAndDependencies = libraryInvoker
102-
.SelectDependencyLibraries(includeSelf: true, recursive: true)
103-
.ToArray();
104-
var valueSetIds = libraryInvokerAndDependencies
105-
.SelectMany(li => li.Definitions.Values)
106-
.SelectWhere(d =>
107-
d.CqlDefinitionAttribute is CqlValueSetDefinitionAttribute vsda
108-
? (true, vsda)
109-
: default)
110-
.Select(vsda => vsda.ValueSetId)
111-
.ToList();
112-
return valueSetIds;
113-
}
114-
11570
#region Processing Patients
11671
private Dictionary<string, Dictionary<string, object>> ProcessTestPatients(
11772
string testDataDir,
@@ -285,22 +240,3 @@ private void WritePatientResults(Dictionary<string, object> patientResults)
285240
#endregion Writing Output
286241
}
287242
}
288-
289-
file static class EnumerableExtensions
290-
{
291-
/// <summary>
292-
/// Projects each element of a collection into a new form based on a selector function, and filters out elements based on a condition.
293-
/// </summary>
294-
/// <typeparam name="T">The type of elements in the source collection.</typeparam>
295-
/// <typeparam name="TR">The type of elements in the resulting collection.</typeparam>
296-
/// <param name="source">The source collection.</param>
297-
/// <param name="selector">A function to test each element for a condition and project the element into a new form.</param>
298-
/// <returns>An enumerable collection that contains the transformed elements that satisfy the condition.</returns>
299-
public static IEnumerable<TR> SelectWhere<T, TR>(this IEnumerable<T> source, Func<T, (bool include, TR resultOrDefault)> selector)
300-
{
301-
foreach (var item in source)
302-
if (selector(item) is (include: true, { } resultOrDefault))
303-
yield return resultOrDefault;
304-
}
305-
306-
}

Demo/Test.Measures.Demo/Test.Measures.Demo.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
<ItemGroup>
1212
<Compile Include="..\..\Cql\CoreTests\LibrarySetsDirs.cs" Link="LibrarySetsDirs.cs" />
13-
<Compile Include="..\CLI\Helpers\LibraryExtensions.cs" Link="LibraryExtensions.cs" />
1413
</ItemGroup>
1514

1615
<ItemGroup>

0 commit comments

Comments
 (0)