Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move measure build out of elm defs #712

Merged
merged 1 commit into from
Jan 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions Cql/Cql.Packaging/ResourcePackager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ void OnResourceCreated(FhirResource resource)
foreach (var elmLibrary in elmLibrarySet)
{
var elmFile = new FileInfo(Path.Combine(elmDirectory.FullName, $"{elmLibrary.GetVersionedIdentifier()}.json"));
var tags = new List<Tag>();
foreach (var def in elmLibrary.statements ?? [])
{
if (def.annotation == null)
continue;

var tags = new List<Tag>();
foreach (var a in def.annotation.OfType<Annotation>())
{
if (a.t == null)
Expand All @@ -114,18 +114,19 @@ void OnResourceCreated(FhirResource resource)
}
}

var measureAnnotation = tags.SingleOrDefault(t => t?.name == "measure");
var yearAnnotation = tags.SingleOrDefault(t => t?.name == "year");
if (measureAnnotation != null
&& !string.IsNullOrWhiteSpace(measureAnnotation.value)
&& yearAnnotation != null
&& !string.IsNullOrWhiteSpace(yearAnnotation.value)
&& int.TryParse(yearAnnotation.value, out var measureYear))
{
FhirMeasure measure = MeasurePackager.CreateMeasureResource(elmFile, resourceCanonicalRootUrl, measureAnnotation, measureYear, librariesByVersionedIdentifier, elmLibrary);
OnResourceCreated(measure);
}
}
var measureAnnotation = tags.SingleOrDefault(t => t?.name == "measure");
var yearAnnotation = tags.SingleOrDefault(t => t?.name == "year");
if (measureAnnotation != null
&& !string.IsNullOrWhiteSpace(measureAnnotation.value)
&& yearAnnotation != null
&& !string.IsNullOrWhiteSpace(yearAnnotation.value)
&& int.TryParse(yearAnnotation.value, out var measureYear))
{
FhirMeasure measure = MeasurePackager.CreateMeasureResource(elmFile, resourceCanonicalRootUrl, measureAnnotation, measureYear, librariesByVersionedIdentifier, elmLibrary);
OnResourceCreated(measure);
}

}

return resources;
Expand Down Expand Up @@ -619,7 +620,7 @@ private static void AddParameterCqlTypeExtension(CqlTypeToFhirMapping type, Para

// "Generic" display
(_, CqlPrimitiveType.Fhir) => $"{cqlType}<{cqlElementType}.{type.ElementType!.FhirType}>",
(_, { }) => $"{cqlType}<{cqlElementType}>",
(_, { }) => $"{cqlType}<{cqlElementType}>",

// Non-"Generic" display
_ => cqlType.ToString(),
Expand Down