8
8
9
9
using CLI . Helpers ;
10
10
using Dumpify ;
11
- using Hl7 . Cql . Abstractions ;
12
11
using Hl7 . Cql . CodeGeneration . NET ;
13
12
using Hl7 . Cql . Fhir ;
14
- using Hl7 . Cql . Fhir . Serialization . Extensions ;
15
13
using Hl7 . Cql . Invocation . Toolkit ;
16
14
using Hl7 . Cql . Invocation . Toolkit . Extensions ;
17
- using Hl7 . Cql . Primitives ;
18
15
using Hl7 . Cql . Runtime ;
19
16
using Hl7 . Cql . ValueSets ;
20
17
using Hl7 . Fhir . Model ;
@@ -53,10 +50,6 @@ public void RunWithResources()
53
50
//run using Library Resource files - production scenario, no debugging inline with measures project
54
51
Console . WriteLine ( $ "Loading resources for Library: { _opts . Library } ") ;
55
52
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
60
53
using var librarySetInvoker = new InvocationToolkit ( )
61
54
. AddAssemblyBinariesInFhirLibrariesFromDirectory ( new ( _opts . ResourcesDirectory ) )
62
55
. CreateLibrarySetInvoker ( libraryIdentifier ) ;
@@ -66,52 +59,14 @@ public void RunWithResources()
66
59
private void RunShared ( CommandLineOptions opt , LibrarySetInvoker librarySetInvoker )
67
60
{
68
61
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 ) ) ;
72
63
73
64
Console . WriteLine ( "Loading test case files" ) ;
74
65
var testDataDir = Path . Join ( opt . DataDirectory , ( string ) opt . LibraryIdentifier . Identifier ) ;
75
66
var patientList = ProcessTestPatients ( testDataDir , librarySetInvoker , valueSets ) ;
76
67
//optionally use patientList Dictionary
77
68
}
78
69
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
-
115
70
#region Processing Patients
116
71
private Dictionary < string , Dictionary < string , object > > ProcessTestPatients (
117
72
string testDataDir ,
@@ -285,22 +240,3 @@ private void WritePatientResults(Dictionary<string, object> patientResults)
285
240
#endregion Writing Output
286
241
}
287
242
}
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
- }
0 commit comments