From 6393b013a5fd9f8b52b02af5c134de784a11440d Mon Sep 17 00:00:00 2001 From: Ewout Kramer Date: Tue, 22 Oct 2024 15:26:04 +0200 Subject: [PATCH 1/2] Libraries will now also contain dataRequirements of their included libraries. --- Cql/CoreTests/CSharp/TestRetrieve-1.0.1.g.cs | 22 ++ .../CSharp/TestRetrieveInclude-1.0.1.g.cs | 9 + .../Elm/TestDataRequirementsAnalyzer.cs | 4 +- Cql/CoreTests/Input/ELM/HL7/TestRetrieve.cql | 18 +- Cql/CoreTests/Input/ELM/HL7/TestRetrieve.json | 92 ++++++++ .../Input/ELM/HL7/TestRetrieveInclude.cql | 4 + .../Input/ELM/HL7/TestRetrieveInclude.json | 45 +++- Cql/Cql.Compiler/LibrarySet.cs | 12 +- Cql/Cql.Compiler/PublicAPI.Unshipped.txt | 1 + Cql/Cql.Packaging/DataRequirementsAnalyzer.cs | 216 ++++++++++-------- Cql/Cql.Packaging/PublicAPI.Unshipped.txt | 3 - 11 files changed, 299 insertions(+), 127 deletions(-) diff --git a/Cql/CoreTests/CSharp/TestRetrieve-1.0.1.g.cs b/Cql/CoreTests/CSharp/TestRetrieve-1.0.1.g.cs index 6fcbdfe85..a7dc007c9 100644 --- a/Cql/CoreTests/CSharp/TestRetrieve-1.0.1.g.cs +++ b/Cql/CoreTests/CSharp/TestRetrieve-1.0.1.g.cs @@ -129,4 +129,26 @@ public Patient Patient(CqlContext context) return b_; } + + [CqlDeclaration("InDemographic")] + public IEnumerable InDemographic(CqlContext context) + { + IEnumerable a_ = context.Operators.Retrieve(new RetrieveParameters(default, default, default, "http://hl7.org/fhir/StructureDefinition/Patient")); + + return a_; + } + + + [CqlDeclaration("SexuallyActive")] + public bool? SexuallyActive(CqlContext context) + { + IEnumerable a_ = context.Operators.Retrieve(new RetrieveParameters(default, default, default, "http://hl7.org/fhir/StructureDefinition/Condition")); + bool? b_ = context.Operators.Exists(a_); + IEnumerable c_ = context.Operators.Retrieve(new RetrieveParameters(default, default, default, "http://hl7.org/fhir/StructureDefinition/ServiceRequest")); + bool? d_ = context.Operators.Exists(c_); + bool? e_ = context.Operators.Or(b_, d_); + + return e_; + } + } diff --git a/Cql/CoreTests/CSharp/TestRetrieveInclude-1.0.1.g.cs b/Cql/CoreTests/CSharp/TestRetrieveInclude-1.0.1.g.cs index f519ddb98..a7001d95c 100644 --- a/Cql/CoreTests/CSharp/TestRetrieveInclude-1.0.1.g.cs +++ b/Cql/CoreTests/CSharp/TestRetrieveInclude-1.0.1.g.cs @@ -61,4 +61,13 @@ public CqlValueSet Inflammatory_Diseases_of_Female_Reproductive_Organs(CqlContex public CqlValueSet Chlamydia(CqlContext context) => new CqlValueSet("2.16.840.1.113883.3.464.1003.112.12.1003", default); + + [CqlDeclaration("InDemographic")] + public IEnumerable InDemographic(CqlContext context) + { + IEnumerable a_ = context.Operators.Retrieve(new RetrieveParameters(default, default, default, "http://hl7.org/fhir/StructureDefinition/Observation")); + + return a_; + } + } diff --git a/Cql/CoreTests/Elm/TestDataRequirementsAnalyzer.cs b/Cql/CoreTests/Elm/TestDataRequirementsAnalyzer.cs index c4eda147a..252380fc7 100644 --- a/Cql/CoreTests/Elm/TestDataRequirementsAnalyzer.cs +++ b/Cql/CoreTests/Elm/TestDataRequirementsAnalyzer.cs @@ -33,6 +33,8 @@ public void ConvertRetrievesToDataRequirements() // Assert var actual = dataRequirements.Select(dr => dr.Type).Distinct().ToArray(); - actual.Should().BeEquivalentTo([FHIRAllTypes.Patient]); + + // Condition+Patient+ServiceRequest is from TestRetrieve, Observation is from TestRetrieveInclude + actual.Should().BeEquivalentTo([FHIRAllTypes.Patient, FHIRAllTypes.ServiceRequest, FHIRAllTypes.Condition, FHIRAllTypes.Observation]); } } \ No newline at end of file diff --git a/Cql/CoreTests/Input/ELM/HL7/TestRetrieve.cql b/Cql/CoreTests/Input/ELM/HL7/TestRetrieve.cql index f242f83ab..386b0e717 100644 --- a/Cql/CoreTests/Input/ELM/HL7/TestRetrieve.cql +++ b/Cql/CoreTests/Input/ELM/HL7/TestRetrieve.cql @@ -27,21 +27,7 @@ parameter MeasurementPeriod default Interval[DateTime(2013, 1, 1, 0, 0, 0, 0), D context Patient -define "InDemographic": - AgeInYearsAt(start of MeasurementPeriod) >= 16 and AgeInYearsAt(start of MeasurementPeriod) < 24 - and "Patient"."gender" in test."Female Administrative Sex" +define "InDemographic": ["Patient"] define "SexuallyActive": -exists (["Condition": test."Other Female Reproductive Conditions"] C where Interval[C.onset, C.abatement] overlaps MeasurementPeriod) - or exists (["Condition": test."Genital Herpes"] C where Interval[C.onset, C.abatement] overlaps MeasurementPeriod) - or exists (["Condition": onset = 'HIV'] C where Interval[C.onset, C.abatement] overlaps MeasurementPeriod) - or exists (["ServiceRequest": status in {'a','b'}] O where O.authoredOn during MeasurementPeriod) - -define "InInitialPopulation": - "InDemographic" and "SexuallyActive" - -define "InDenominator": - true - -define "InNumerator": -exists (["DiagnosticReport": "Chlamydia Screening"] R where R.effective during MeasurementPeriod and R."result" is not null) + exists (["Condition"]) or exists (["ServiceRequest"]) diff --git a/Cql/CoreTests/Input/ELM/HL7/TestRetrieve.json b/Cql/CoreTests/Input/ELM/HL7/TestRetrieve.json index 3cb30d291..5d6c37368 100644 --- a/Cql/CoreTests/Input/ELM/HL7/TestRetrieve.json +++ b/Cql/CoreTests/Input/ELM/HL7/TestRetrieve.json @@ -329,6 +329,98 @@ "type" : "Retrieve" } } + }, { + "locator" : "30:1-30:35", + "name" : "InDemographic", + "context" : "Patient", + "accessLevel" : "Public", + "resultTypeSpecifier" : { + "type" : "ListTypeSpecifier", + "elementType" : { + "name" : "{http://hl7.org/fhir}Patient", + "type" : "NamedTypeSpecifier" + } + }, + "expression" : { + "locator" : "30:25-30:35", + "dataType" : "{http://hl7.org/fhir}Patient", + "templateId" : "http://hl7.org/fhir/StructureDefinition/Patient", + "type" : "Retrieve", + "resultTypeSpecifier" : { + "type" : "ListTypeSpecifier", + "elementType" : { + "name" : "{http://hl7.org/fhir}Patient", + "type" : "NamedTypeSpecifier" + } + } + } + }, { + "locator" : "32:1-33:57", + "resultTypeName" : "{urn:hl7-org:elm-types:r1}Boolean", + "name" : "SexuallyActive", + "context" : "Patient", + "accessLevel" : "Public", + "expression" : { + "locator" : "33:5-33:57", + "resultTypeName" : "{urn:hl7-org:elm-types:r1}Boolean", + "type" : "Or", + "signature" : [ { + "name" : "{urn:hl7-org:elm-types:r1}Boolean", + "type" : "NamedTypeSpecifier" + }, { + "name" : "{urn:hl7-org:elm-types:r1}Boolean", + "type" : "NamedTypeSpecifier" + } ], + "operand" : [ { + "locator" : "33:5-33:26", + "resultTypeName" : "{urn:hl7-org:elm-types:r1}Boolean", + "type" : "Exists", + "signature" : [ { + "type" : "ListTypeSpecifier", + "elementType" : { + "name" : "{http://hl7.org/fhir}Condition", + "type" : "NamedTypeSpecifier" + } + } ], + "operand" : { + "locator" : "33:12-33:26", + "dataType" : "{http://hl7.org/fhir}Condition", + "templateId" : "http://hl7.org/fhir/StructureDefinition/Condition", + "type" : "Retrieve", + "resultTypeSpecifier" : { + "type" : "ListTypeSpecifier", + "elementType" : { + "name" : "{http://hl7.org/fhir}Condition", + "type" : "NamedTypeSpecifier" + } + } + } + }, { + "locator" : "33:31-33:57", + "resultTypeName" : "{urn:hl7-org:elm-types:r1}Boolean", + "type" : "Exists", + "signature" : [ { + "type" : "ListTypeSpecifier", + "elementType" : { + "name" : "{http://hl7.org/fhir}ServiceRequest", + "type" : "NamedTypeSpecifier" + } + } ], + "operand" : { + "locator" : "33:38-33:57", + "dataType" : "{http://hl7.org/fhir}ServiceRequest", + "templateId" : "http://hl7.org/fhir/StructureDefinition/ServiceRequest", + "type" : "Retrieve", + "resultTypeSpecifier" : { + "type" : "ListTypeSpecifier", + "elementType" : { + "name" : "{http://hl7.org/fhir}ServiceRequest", + "type" : "NamedTypeSpecifier" + } + } + } + } ] + } } ] } } diff --git a/Cql/CoreTests/Input/ELM/HL7/TestRetrieveInclude.cql b/Cql/CoreTests/Input/ELM/HL7/TestRetrieveInclude.cql index 7484c5f0d..56c6da1c2 100644 --- a/Cql/CoreTests/Input/ELM/HL7/TestRetrieveInclude.cql +++ b/Cql/CoreTests/Input/ELM/HL7/TestRetrieveInclude.cql @@ -1,8 +1,12 @@ library TestRetrieveInclude version '1.0.1' +using FHIR version '4.0.1' + valueset "Female Administrative Sex": '2.16.840.1.113883.3.560.100.2' valueset "Other Female Reproductive Conditions": '2.16.840.1.113883.3.464.1003.111.12.1006' valueset "Genital Herpes": '2.16.840.1.113883.3.464.1003.110.12.1049' valueset "Genococcal Infections and Venereal Diseases": '2.16.840.1.113883.3.464.1003.112.12.1001' valueset "Inflammatory Diseases of Female Reproductive Organs": '2.16.840.1.113883.3.464.1003.112.12.1004' valueset "Chlamydia": '2.16.840.1.113883.3.464.1003.112.12.1003' + +define "InDemographic": ["Observation"] diff --git a/Cql/CoreTests/Input/ELM/HL7/TestRetrieveInclude.json b/Cql/CoreTests/Input/ELM/HL7/TestRetrieveInclude.json index a070ed083..426786645 100644 --- a/Cql/CoreTests/Input/ELM/HL7/TestRetrieveInclude.json +++ b/Cql/CoreTests/Input/ELM/HL7/TestRetrieveInclude.json @@ -17,46 +17,79 @@ "def" : [ { "localIdentifier" : "System", "uri" : "urn:hl7-org:elm-types:r1" + }, { + "locator" : "3:1-3:26", + "localIdentifier" : "FHIR", + "uri" : "http://hl7.org/fhir", + "version" : "4.0.1" } ] }, "valueSets" : { "def" : [ { - "locator" : "3:1-3:69", + "locator" : "5:1-5:69", "resultTypeName" : "{urn:hl7-org:elm-types:r1}ValueSet", "name" : "Female Administrative Sex", "id" : "2.16.840.1.113883.3.560.100.2", "accessLevel" : "Public" }, { - "locator" : "4:1-4:91", + "locator" : "6:1-6:91", "resultTypeName" : "{urn:hl7-org:elm-types:r1}ValueSet", "name" : "Other Female Reproductive Conditions", "id" : "2.16.840.1.113883.3.464.1003.111.12.1006", "accessLevel" : "Public" }, { - "locator" : "5:1-5:69", + "locator" : "7:1-7:69", "resultTypeName" : "{urn:hl7-org:elm-types:r1}ValueSet", "name" : "Genital Herpes", "id" : "2.16.840.1.113883.3.464.1003.110.12.1049", "accessLevel" : "Public" }, { - "locator" : "6:1-6:98", + "locator" : "8:1-8:98", "resultTypeName" : "{urn:hl7-org:elm-types:r1}ValueSet", "name" : "Genococcal Infections and Venereal Diseases", "id" : "2.16.840.1.113883.3.464.1003.112.12.1001", "accessLevel" : "Public" }, { - "locator" : "7:1-7:106", + "locator" : "9:1-9:106", "resultTypeName" : "{urn:hl7-org:elm-types:r1}ValueSet", "name" : "Inflammatory Diseases of Female Reproductive Organs", "id" : "2.16.840.1.113883.3.464.1003.112.12.1004", "accessLevel" : "Public" }, { - "locator" : "8:1-8:64", + "locator" : "10:1-10:64", "resultTypeName" : "{urn:hl7-org:elm-types:r1}ValueSet", "name" : "Chlamydia", "id" : "2.16.840.1.113883.3.464.1003.112.12.1003", "accessLevel" : "Public" } ] + }, + "statements" : { + "def" : [ { + "locator" : "12:1-12:39", + "name" : "InDemographic", + "context" : "Patient", + "accessLevel" : "Public", + "resultTypeSpecifier" : { + "type" : "ListTypeSpecifier", + "elementType" : { + "name" : "{http://hl7.org/fhir}Observation", + "type" : "NamedTypeSpecifier" + } + }, + "expression" : { + "locator" : "12:25-12:39", + "dataType" : "{http://hl7.org/fhir}Observation", + "templateId" : "http://hl7.org/fhir/StructureDefinition/Observation", + "type" : "Retrieve", + "resultTypeSpecifier" : { + "type" : "ListTypeSpecifier", + "elementType" : { + "name" : "{http://hl7.org/fhir}Observation", + "type" : "NamedTypeSpecifier" + } + } + } + } ] } } } diff --git a/Cql/Cql.Compiler/LibrarySet.cs b/Cql/Cql.Compiler/LibrarySet.cs index 86a376c43..7d34f6153 100644 --- a/Cql/Cql.Compiler/LibrarySet.cs +++ b/Cql/Cql.Compiler/LibrarySet.cs @@ -33,7 +33,7 @@ public class LibrarySet : IReadOnlyCollection//, IReadOnlyDictionary public string Name { get; } - private readonly Dictionary _libraryInfosByVersionedIdentifier; + private readonly Dictionary _libraryInfosByVersionedIdentifier; private (IReadOnlySet RootLibraries, IReadOnlyCollection TopologicallySortedLibraries) _calculatedState; @@ -101,6 +101,16 @@ private bool TryGetLibraryInfoByVersionedIdentifier( public IReadOnlySet GetLibraryDependencies(string? versionedIdentifier, bool throwError = true) => TryGetLibraryInfoByVersionedIdentifier(versionedIdentifier, throwError, out var info) ? info.dependencies : EmptySet.Instance; + /// + /// Gets the dependencies of a library. + /// + /// The library to retrieve the dependencies for. + /// Indicates whether to throw an exception if the library is not found. + /// The dependencies of the parent library, or an empty list if the library is not part of this . + /// If the library is not part of the LibrarySet and if throwError is set to true. + public IReadOnlySet GetLibraryDependencies(Library parent, bool throwError = true) => + GetLibraryDependencies(parent.GetVersionedIdentifier(), throwError); + /// /// Loads the libraries from the specified collection of files. /// diff --git a/Cql/Cql.Compiler/PublicAPI.Unshipped.txt b/Cql/Cql.Compiler/PublicAPI.Unshipped.txt index 471b8b782..fb08e1890 100644 --- a/Cql/Cql.Compiler/PublicAPI.Unshipped.txt +++ b/Cql/Cql.Compiler/PublicAPI.Unshipped.txt @@ -4,6 +4,7 @@ Hl7.Cql.Compiler.LibrarySet.AddLibraries(System.Collections.Generic.IEnumerable< Hl7.Cql.Compiler.LibrarySet.Count.get -> int Hl7.Cql.Compiler.LibrarySet.GetEnumerator() -> System.Collections.Generic.IEnumerator! Hl7.Cql.Compiler.LibrarySet.GetLibrary(string! versionedIdentifier, bool throwError = true) -> Hl7.Cql.Elm.Library? +Hl7.Cql.Compiler.LibrarySet.GetLibraryDependencies(Hl7.Cql.Elm.Library! parent, bool throwError = true) -> System.Collections.Generic.IReadOnlySet! Hl7.Cql.Compiler.LibrarySet.GetLibraryDependencies(string? versionedIdentifier, bool throwError = true) -> System.Collections.Generic.IReadOnlySet! Hl7.Cql.Compiler.LibrarySet.LibrarySet(string! name = "", params Hl7.Cql.Elm.Library![]! libraries) -> void Hl7.Cql.Compiler.LibrarySet.LoadLibraries(System.Collections.Generic.IReadOnlyCollection! files) -> System.Collections.Generic.IReadOnlyCollection! diff --git a/Cql/Cql.Packaging/DataRequirementsAnalyzer.cs b/Cql/Cql.Packaging/DataRequirementsAnalyzer.cs index 4daeddf15..44a74fc0f 100644 --- a/Cql/Cql.Packaging/DataRequirementsAnalyzer.cs +++ b/Cql/Cql.Packaging/DataRequirementsAnalyzer.cs @@ -23,7 +23,7 @@ namespace Hl7.Cql.Packaging; /// Resources used by the retrieves. There's much more to it, as can be glanced /// from the public Java version here: https://github.com/cqframework/clinical_quality_language/blob/master/Src/java/elm-fhir/src/main/java/org/cqframework/cql/elm/requirements/fhir/DataRequirementsProcessor.java /// -public class DataRequirementsAnalyzer(LibrarySet librarySet, Elm.Library library) +internal class DataRequirementsAnalyzer(LibrarySet librarySet, Elm.Library focusLibrary) { /// /// Visits the ELM in the LibrarySet and extracts the DataRequirements from it. @@ -31,14 +31,25 @@ public class DataRequirementsAnalyzer(LibrarySet librarySet, Elm.Library library public IReadOnlyCollection Analyze() { var result = new List(); + Visit(focusLibrary, result); - var walker = new Elm.ElmTreeWalker(n => Visit(result, n)); + return result; + } + + private void Visit(Elm.Library library, List allRequirements) + { + var walker = new Elm.ElmTreeWalker(n => Visit(library, allRequirements, n)); walker.Start(library); - return result; + var dependencies = librarySet.GetLibraryDependencies(library); + foreach (var dependency in dependencies) + { + Visit(dependency, allRequirements); + } } private bool Visit( + Elm.Library library, List result, object node) { @@ -67,11 +78,13 @@ private bool Visit( // Collect must supports HashSet ps = []; + var codeFilterBuilder = new CodeFilterComponentBuilder(librarySet, library); + // Set code path if specified if (retrieve.codeProperty is { } codeProperty) { dr.CodeFilter.Add( - ToCodeFilterComponent(library, codeProperty, retrieve.codes)); + codeFilterBuilder.ToCodeFilterComponent(codeProperty, retrieve.codes)); ps.Add(codeProperty); } @@ -81,8 +94,8 @@ private bool Visit( { foreach (var cfe in retrieve.codeFilter) { - dr.CodeFilter - .Add(ToCodeFilterComponent(library, cfe.property, cfe.value)); + dr.CodeFilter.Add( + codeFilterBuilder.ToCodeFilterComponent(cfe.property, cfe.value)); } } @@ -97,121 +110,124 @@ private bool Visit( } private static string ToReference(Elm.ValueSetDef def) => def.id + (def.version is { } v ? $"|{v}" : null); - // private static string ToReference(Elm.CodeSystemDef def) => def.id + (def.version is { } v ? $"|{v}" : null); + // private static string ToReference(Elm.CodeSystemDef def) => def.id + (def.version is { } v ? $"|{v}" : null); + - private DataRequirement.CodeFilterComponent ToCodeFilterComponent( - Elm.Library context, - string property, - Elm.Expression value) + private class CodeFilterComponentBuilder(LibrarySet librarySet, Elm.Library contextLibrary) { - DataRequirement.CodeFilterComponent cfc = new() + public DataRequirement.CodeFilterComponent ToCodeFilterComponent( + string property, + Elm.Expression value) { - Path = property - }; + DataRequirement.CodeFilterComponent cfc = new() + { + Path = property + }; - // TODO: Support retrieval when the target is a CodeSystemRef - switch (value) - { - case Elm.ValueSetRef vsr: - if (librarySet.TryResolveDefinition(context, vsr, out var vsd)) - cfc.ValueSet = ToReference(vsd); - else - throw new UnresolvedReferenceError(context, vsr).ToException(); - break; - case Elm.ToList toList: - cfc.Code.AddRange(ResolveCodeFilterCodes(toList.operand)); - break; - case Elm.List codeList: - cfc.Code.AddRange(codeList.element.SelectMany(ResolveCodeFilterCodes)); - break; - case Elm.Literal l: - // TODO: no system??? - cfc.Code.Add(new Coding { Code = l.value }); - break; - default: - throw new NotSupportedException($"Unexpected Elm expression of type {value.GetType()} in code filter."); + // TODO: Support retrieval when the target is a CodeSystemRef + switch (value) + { + case Elm.ValueSetRef vsr: + if (librarySet.TryResolveDefinition(contextLibrary, vsr, out var vsd)) + cfc.ValueSet = ToReference(vsd); + else + throw new UnresolvedReferenceError(contextLibrary, vsr).ToException(); + break; + case Elm.ToList toList: + cfc.Code.AddRange(ResolveCodeFilterCodes(toList.operand)); + break; + case Elm.List codeList: + cfc.Code.AddRange(codeList.element.SelectMany(ResolveCodeFilterCodes)); + break; + case Elm.Literal l: + // TODO: no system??? + cfc.Code.Add(new Coding { Code = l.value }); + break; + default: + throw new NotSupportedException( + $"Unexpected Elm expression of type {value.GetType()} in code filter."); + } + + return cfc; } - return cfc; - } + private List ResolveCodeFilterCodes(Elm.Expression toListOperand) + { + return toListOperand switch + { + Elm.CodeRef codeRef => [BuildCoding(codeRef)], + Elm.Code code => [BuildCoding(code)], + Elm.ConceptRef conceptRef => BuildCodeableConcept(conceptRef).Coding, + Elm.Concept concept => BuildCodeableConcept(concept).Coding, + Elm.Literal literal => + // TODO: no system??? + [ + new Coding { Code = literal.value } + ], + _ => throw new NotSupportedException( + $"Unexpected Elm expression of type {toListOperand.GetType()} in code filter codes.") + }; + } - private List ResolveCodeFilterCodes( - Elm.Expression toListOperand) - { - return toListOperand switch + private CodeableConcept BuildCodeableConcept(Elm.ConceptRef conceptRef) { - Elm.CodeRef codeRef => [BuildCoding(codeRef)], - Elm.Code code => [BuildCoding(code)], - Elm.ConceptRef conceptRef => BuildCodeableConcept(conceptRef).Coding, - Elm.Concept concept => BuildCodeableConcept(concept).Coding, - Elm.Literal literal => - // TODO: no system??? - [ - new Coding { Code = literal.value } - ], - _ => throw new NotSupportedException( - $"Unexpected Elm expression of type {toListOperand.GetType()} in code filter codes.") - }; - } + if (librarySet.TryResolveDefinition(contextLibrary, conceptRef, out var cd)) + return BuildCodeableConcept(cd.display, cd.code); - private CodeableConcept BuildCodeableConcept(Elm.ConceptRef conceptRef) - { - if (librarySet.TryResolveDefinition(library, conceptRef, out var cd)) - return BuildCodeableConcept(cd.display, cd.code); + throw new UnresolvedReferenceError(contextLibrary, conceptRef).ToException(); + } - throw new UnresolvedReferenceError(library, conceptRef).ToException(); - } + private CodeableConcept BuildCodeableConcept(Elm.Concept concept) + => BuildCodeableConcept(concept.display, concept.code); - private CodeableConcept BuildCodeableConcept(Elm.Concept concept) - => BuildCodeableConcept(concept.display, concept.code); + private CodeableConcept BuildCodeableConcept(string display, Elm.CodeRef[] codes) + { + var codings = codes.Select(BuildCoding).ToList(); - private CodeableConcept BuildCodeableConcept(string display, Elm.CodeRef[] codes) - { - var codings = codes.Select(BuildCoding).ToList(); + return new CodeableConcept + { + Coding = codings, + Text = display + }; + } - return new CodeableConcept + private CodeableConcept BuildCodeableConcept(string display, Elm.Code[] codes) { - Coding = codings, - Text = display - }; - } + var codings = codes.Select(BuildCoding).ToList(); - private CodeableConcept BuildCodeableConcept(string display, Elm.Code[] codes) - { - var codings = codes.Select(BuildCoding).ToList(); + return new CodeableConcept + { + Coding = codings, + Text = display + }; + } - return new CodeableConcept + private Coding BuildCoding(Elm.CodeRef codeRef) { - Coding = codings, - Text = display - }; - } - - private Coding BuildCoding(Elm.CodeRef codeRef) - { - if (librarySet.TryResolveDefinition(library, codeRef, out var cd)) - return BuildCoding(cd.id, cd.codeSystem, cd.display); - else - throw new UnresolvedReferenceError(library, codeRef).ToException(); - } + if (librarySet.TryResolveDefinition(contextLibrary, codeRef, out var cd)) + return BuildCoding(cd.id, cd.codeSystem, cd.display); + else + throw new UnresolvedReferenceError(contextLibrary, codeRef).ToException(); + } - private Coding BuildCoding(Elm.Code code) => BuildCoding(code.code, code.system, code.display); + private Coding BuildCoding(Elm.Code code) => BuildCoding(code.code, code.system, code.display); - private Coding BuildCoding( - string code, - Elm.CodeSystemRef codeSystemRef, - string display) - { - if (librarySet.TryResolveDefinition(library, codeSystemRef, out var csd)) + private Coding BuildCoding( + string code, + Elm.CodeSystemRef codeSystemRef, + string display) { - return new Coding + if (librarySet.TryResolveDefinition(contextLibrary, codeSystemRef, out var csd)) { - Code = code, - System = csd.id, - Display = display - }; - } + return new Coding + { + Code = code, + System = csd.id, + Display = display + }; + } - throw new UnresolvedReferenceError(library, codeSystemRef).ToException(); + throw new UnresolvedReferenceError(contextLibrary, codeSystemRef).ToException(); + } } } \ No newline at end of file diff --git a/Cql/Cql.Packaging/PublicAPI.Unshipped.txt b/Cql/Cql.Packaging/PublicAPI.Unshipped.txt index cf6930619..cb0f2de93 100644 --- a/Cql/Cql.Packaging/PublicAPI.Unshipped.txt +++ b/Cql/Cql.Packaging/PublicAPI.Unshipped.txt @@ -19,9 +19,6 @@ Hl7.Cql.Packaging.CqlTypeToFhirTypeMapper.TypeEntryFor(Hl7.Cql.Primitives.CqlPri Hl7.Cql.Packaging.CqlTypeToFhirTypeMapper.TypeEntryFor(Hl7.Fhir.Model.FHIRAllTypes fhirType) -> Hl7.Cql.Packaging.CqlTypeToFhirMapping? Hl7.Cql.Packaging.CqlTypeToFhirTypeMapper.TypeEntryFor(string? name) -> Hl7.Cql.Packaging.CqlTypeToFhirMapping? Hl7.Cql.Packaging.CqlTypeToFhirTypeMapper.TypeEntryFor(System.Type! type) -> Hl7.Cql.Packaging.CqlTypeToFhirMapping? -Hl7.Cql.Packaging.DataRequirementsAnalyzer -Hl7.Cql.Packaging.DataRequirementsAnalyzer.Analyze() -> System.Collections.Generic.IReadOnlyCollection! -Hl7.Cql.Packaging.DataRequirementsAnalyzer.DataRequirementsAnalyzer(Hl7.Cql.Compiler.LibrarySet! librarySet, Hl7.Cql.Elm.Library! library) -> void Hl7.Cql.Packaging.PostProcessors.FhirResourceWriterOptions Hl7.Cql.Packaging.PostProcessors.FhirResourceWriterOptions.FhirResourceWriterOptions() -> void Hl7.Cql.Packaging.PostProcessors.FhirResourceWriterOptions.OutDirectory.get -> System.IO.DirectoryInfo? From 825502638affe4ffffdf754edc10eeabc9b02a8c Mon Sep 17 00:00:00 2001 From: Ewout Kramer Date: Tue, 22 Oct 2024 16:04:43 +0200 Subject: [PATCH 2/2] Trying to fix unit tests --- build/templates/build.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build/templates/build.yml b/build/templates/build.yml index e9bfaa197..7c0ab9466 100644 --- a/build/templates/build.yml +++ b/build/templates/build.yml @@ -61,7 +61,9 @@ jobs: displayName: 'dotnet test UnitTests' inputs: command: test - projects: '**/*Tests/*Tests.csproj;!**/Ncqa.HT.DeckTests.csproj' + projects: | + **/*Tests/*Tests.csproj + !**/Ncqa.HT.DeckTests.csproj arguments: '--configuration $(buildConfiguration) --no-build --no-restore' - task: DotNetCoreCLI@2