Skip to content

Commit c2074e0

Browse files
authored
Merge pull request #943 from FirelyTeam/copilot/fix-883
883 Fix Demo CLI to use modern LibrarySetInvoker APIs
2 parents 27a4cfb + 5f0ea85 commit c2074e0

File tree

8 files changed

+195
-350
lines changed

8 files changed

+195
-350
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/CommandLineOptions.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@
88

99
using CommandLine;
1010
using Dumpify;
11+
using Hl7.Cql.Runtime;
12+
using Hl7.Cql.Runtime.Parsing;
1113

1214
namespace CLI.Helpers
1315
{
1416
internal class CommandLineOptions
1517
{
1618
[Option('l', "library", Required = true, HelpText = "The name of a measure Library resource, which contains name and version.")]
1719
public string Library { get; set; } = "";
18-
public string LibraryName => Library.Split('-')[1];
19-
public string LibraryVersion => Library.Split('-')[2];
20+
21+
public CqlVersionedLibraryIdentifier LibraryIdentifier => CqlVersionedLibraryIdentifier.Parse(Library);
2022

2123
[Option('d', "data", HelpText = "The folder for test data.")]
2224
public string DataDirectory { get; set; } = "";
@@ -45,10 +47,10 @@ internal class CommandLineOptions
4547
public static void EnsureValidOptions(CommandLineOptions options)
4648
{
4749
// Validate the library name format
48-
if (options.Library.Count(c => c == '-') != 2
49-
&& !options.Library.StartsWith("Library-", StringComparison.OrdinalIgnoreCase))
50+
CqlParseError? cqlParseError = null;
51+
if (!CqlVersionedLibraryIdentifier.TryParse(options.Library, out _, err => cqlParseError = err))
5052
{
51-
throw new InvalidOperationException($"The name of the Library resource '{options.Library}' should be written as 'Library-<name>-<version>'.");
53+
throw new InvalidOperationException($"The name of the Library resource '{options.Library}' did not parse as a valid identifier ({cqlParseError}).");
5254
}
5355

5456
// Check if the data directory is set

Demo/CLI/Helpers/LibraryExtensions.cs

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

Demo/CLI/Helpers/ResourceHelper.cs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ public static Bundle LoadBundle(string bundleFile)
4242
return bundle;
4343
}
4444

45-
public static IValueSetDictionary LoadValueSets(DirectoryInfo directory)
45+
public static IValueSetDictionary LoadValueSets(
46+
DirectoryInfo directory)
4647
{
4748
var valueSets = new List<ValueSet>();
4849
foreach (var file in directory.GetFiles("*.json", SearchOption.AllDirectories))
@@ -59,19 +60,6 @@ public static IValueSetDictionary LoadValueSets(DirectoryInfo directory)
5960
return vsd;
6061
}
6162

62-
// public static LibrarySetInvoker CreateRuntimeScopeFromFhirLibraryFile(
63-
// DirectoryInfo dir,
64-
// string lib,
65-
// string version)
66-
// {
67-
// var libFile = new FileInfo(Path.Combine(dir.FullName, $"Library-{lib}-{version}.json"));
68-
// using var fs = libFile.OpenRead();
69-
// var library = fs.DeserializeJsonToFhir<Library>();
70-
// var deps = library.GetDependenciesAndSelf(dir);
71-
// return deps.ToLibrarySetInvoker();
72-
// }
73-
74-
7563
public static Bundle CreateBundle(string[] files)
7664
{
7765
var bundle = new Bundle();

0 commit comments

Comments
 (0)