### Run Specific Example Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/Examples/CqlSdkExamplesPreview/README.md Execute a single example by its code. Navigate to the project directory and run the command, replacing `` with the example's identifier. ```bash cd Examples/CqlSdkExamplesPreview dotnet run ``` -------------------------------- ### Run All Examples Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/Examples/CqlSdkExamplesPreview/README.md Execute all available examples sequentially. Navigate to the project directory and run the command. ```bash cd Examples/CqlSdkExamplesPreview dotnet run 000 ``` -------------------------------- ### Example Template Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/Examples/CqlSdkExamplesPreview/README.md A template for creating new examples. It demonstrates setting the current directory and accessing internal APIs. Ensure your example code is placed within the designated area. ```csharp namespace CqlSdkExamplesPreview; partial class Program { void MyInternalFeatureExample() { SetCurrentDirectory(Path.Combine(InitialCurrentDirectory, "100 My Internal Feature")); // Your example code using internal APIs Console.WriteLine("Demonstrating internal feature..."); // Access internal types and members here } } ``` -------------------------------- ### CQL Library Versioning Example Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/03-developersguide.md Illustrates how to declare libraries with specific versions and how to reference them. This example shows two versions of library 'A' and how library 'B' and 'C' reference specific versions. ```cql library A version '1' library A version '2' library B includes library A version '1' library C includes library A version '2' ``` -------------------------------- ### Verify CQL Packager Installation Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/docs/cql-packager.md Checks the installed version and displays help information for the cql-package command-line tool. ```shell cql-package --version cql-package --help ``` -------------------------------- ### Before Operator Examples Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/09-b-cqlreference.md Demonstrates the 'before' operator for intervals and points in CQL. Examples cover scenarios where the condition is true, false, and results in null. ```cql define "BeforeIsTrue": 0 before Interval[1, 4] define "BeforeIsFalse": Interval[1, 4] before 0 define "BeforeIsNull": Interval[1, 4] before null ``` -------------------------------- ### During Interval (Inclusive) Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/15-h-timeintervalcalculations.md Examples demonstrating the 'during' keyword with an interval. These return true because 'during' is defined inclusively, meaning the start and end points of the interval are included. ```cql @2020-01-01T00:00:00.0 during Interval[@2020-01-01T00:00:00.0, @2020-01T10:30:00.00] ``` ```cql @2020-01-01T10:30:00.0 during Interval[@2020-01-01T00:00:00.0, @2020-01T10:30:00.00] ``` -------------------------------- ### Integer Between Example Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/09-b-cqlreference.md A simple example demonstrating the 'between' operator with integer values, resulting in true. ```cql define "IntegerBetweenIsTrue": 4 between 2 and 6 ``` -------------------------------- ### Install HL7 CQL Packager Tool Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/Cql/PackagerCLI/README.md Installs the HL7 CQL Packager tool globally. The `--prerelease` option is required as only prerelease versions are currently available. ```shell dotnet tool install Hl7.Cql.Packager --global --prerelease ``` -------------------------------- ### Example Content Type for CQL Version 1.4 Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/07-physicalrepresentation.md This example shows how to specify the CQL version using the content type header. This is a new feature in CQL 1.5 and is trial-use. ```text text/cql; version=1.4 ``` -------------------------------- ### Full CQL Query Structure Example Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/02-authorsguide.md This example illustrates the complete structure of a CQL query, including primary source, 'with' clause, 'where' clause, 'return' clause, and 'sort' clause in the correct order. ```cql [Encounter: "Inpatient"] E with [Condition: "Acute Pharyngitis"] P such that P.onsetDateTime during E.period and P.abatementDate after end of E.period where duration in days of E.period >= 120 return Tuple { id: E.id, lengthOfStay: duration in days of E.period } sort by lengthOfStay desc ``` -------------------------------- ### Start Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/Cql/Cql.Runtime/PublicAPI.Shipped.txt Retrieves the start value of an interval. ```APIDOC ## Start ### Description Returns the starting point of a given interval. ### Method `Start` ### Parameters - `argument` (CqlInterval?): The interval of decimal values. ### Method `Start` ### Parameters - `argument` (CqlInterval?): The interval of CqlDate values. ### Method `Start` ### Parameters - `argument` (CqlInterval?): The interval of CqlDateTime values. ### Method `Start` ### Parameters - `argument` (CqlInterval?): The interval of CqlQuantity values. ### Method `Start` ### Parameters - `argument` (CqlInterval?): The interval of CqlTime values. ### Method `Start` ### Parameters - `argument` (CqlInterval?): The interval of integer values. ### Method `Start` ### Parameters - `argument` (CqlInterval?): The interval of long values. ``` -------------------------------- ### ToInteger Operator Examples Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/09-b-cqlreference.md Provides examples of converting strings, booleans, and Long values to Integer using the ToInteger operator. Includes cases for valid and invalid string formats. ```cql define "IsValid": ToInteger('-1') define "IsNull": ToInteger('one') ``` -------------------------------- ### CQL Specification Examples Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/report/issue-06-medium-matches-operator-anchoring.md Examples demonstrating the expected behavior of the Matches operator according to the CQL specification, including partial matching. ```cql define "MatchesTrue": Matches('1,2three', '\d,\d\w+') define "MatchesFalse": Matches('1,2three', '\w+') define "MatchesTrue2": Matches('http://fhir.org/guides/cqf/common/Library/FHIR-ModelInfo|4.0.1', 'Library') ``` -------------------------------- ### Check .NET SDK Version Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/tools/XsdToCSharpConverter/testing-guide.md Verify that the correct .NET SDK version is installed on your system. ```bash dotnet --version ``` -------------------------------- ### List Indexing Example Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/02-authorsguide.md Illustrates zero-based indexing for accessing elements within a list of integers. ```cql { 6, 7, 8, 9, 10 } ``` -------------------------------- ### After Operator Examples Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/09-b-cqlreference.md Illustrates the behavior of the 'after' operator for intervals and points in CQL. Examples show cases where the condition is true, false, and results in null. ```cql define "AfterIsTrue": 5 after Interval[1, 4] define "AfterIsFalse": Interval[1, 4] after 5 define "AfterIsNull": Interval[1, 4] after null ``` -------------------------------- ### Start Operator Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/04-logicalspecification.md Returns the starting point of an interval. Handles open and closed boundaries, returning the successor for open boundaries or the low value for closed boundaries. ```cql Start : UnaryExpression ``` -------------------------------- ### Meets Operator Examples Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/09-b-cqlreference.md Demonstrates the usage of the 'meets' operator for intervals. The 'meets before' and 'meets after' variants are also shown. ```cql define "MeetsAtHours": Interval[@T03, @T04] meets Interval[@T05, @T06] ``` ```cql define "MeetsIsTrue": Interval[6, 10] meets Interval[0, 5] ``` ```cql define "MeetsBeforeIsTrue": Interval[-5, -1] meets before Interval[0, 5] ``` ```cql define "MeetsAfterIsFalse": Interval[6, 10] meets after Interval[0, 7] ``` ```cql define "MeetsIsNull": Interval[6, 10] meets (null as Interval) ``` -------------------------------- ### Extracting Interval Boundaries Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/02-authorsguide.md Get the starting or ending point of an interval. ```cql start of Interval[3, 5) end of Interval[3, 5) ``` -------------------------------- ### Example Workflow: Local Spec File Analysis Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/report/spec-content-guide.md Demonstrates the command-line steps to set up local spec files, commit them to a Git repository, and initiate agent analysis. ```bash # 1. You save spec files locally mkdir -p docs/spec # ... download spec pages ... # 2. Commit to repository git add docs/spec/ git commit -m "Add CQL specification for conformance analysis" # 3. Agent reads files # Agent: view docs/spec/09-b-cqlreference.html # 4. Enhanced analysis produced # - Verified deviations with exact quotes # - Additional issues discovered # - Clear fix guidance with spec support ``` -------------------------------- ### Get Interval Start Point Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/09-b-cqlreference.md Returns the starting point of an interval. Handles open and closed boundaries, and null values. Returns null if the input interval is null. ```cql define "StartOfInterval": start of Interval[1, 5] // 1 define "StartIsNull": start of (null as Interval) ``` -------------------------------- ### CQL Equal Operator Examples Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/09-b-cqlreference.md Demonstrates the 'equal' operator for intervals. Returns true if intervals have the same start and end points. ```cql define "EqualIsTrue": Interval[0, 5] = Interval[0, 5] define "EqualIsFalse": Interval[-1, 7] = Interval[0, 7] define "EqualIsNull": Interval[1, 5] = null ``` -------------------------------- ### Simple Query in CQL Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/14-g-formattingconventions.md A basic example of a single-line query construct in CQL. ```cql ["Encounter, Performed": "Inpatient"] Encounter where duration in days of Encounter.period >= 120 ``` -------------------------------- ### Hello World CQL Invocation Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/docs/getting-started.md Demonstrates a basic 'Hello World' example by compiling a CQL string and invoking a definition. Requires setting up a LoggerFactory and using CqlToolkit. ```csharp using Hl7.Cql.CqlToElm.Toolkit; using Hl7.Cql.CqlToElm.Toolkit.Extensions; using Hl7.Cql.Fhir; using Hl7.Cql.Invocation.Toolkit.Extensions; using Microsoft.Extensions.Logging; var loggerFactory = LoggerFactory.Create(b => b.AddConsole()); var cql = (CqlLibraryString) மாதிரிகள் library HelloWorldLib version '1.0.0' define "HelloWorld" : 'Hello from CQL!' """; using var invoker = new CqlToolkit(loggerFactory) .AddCqlLibraries(cql) .CreateLibrarySetInvoker(); var result = invoker.InvokeLibraryDefinition( FhirCqlContext.WithDataSource(), cql.LibraryIdentifier, "HelloWorld"); Console.WriteLine(result); // Hello from CQL! ``` -------------------------------- ### Invalid Unit Interval Example Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/02-authorsguide.md Demonstrates an invalid interval where the start is inclusive and the end is exclusive for the same point, leading to a conflict. ```cql Interval[1, 1) // Invalid interval, conflicting to say it both includes and excludes 1 ``` -------------------------------- ### Upper Operator Examples Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/09-b-cqlreference.md Demonstrates the usage of the Upper operator to convert strings to uppercase and handle null inputs. ```cql define "UpperCQL": Upper('abcde') // 'ABCDE' define "UpperIsNull": Upper(null) // null ``` -------------------------------- ### Invalid Interval Example Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/02-authorsguide.md Demonstrates an invalid interval where the ending boundary is less than the starting boundary, which will cause a run-time error. ```cql Interval[1, -1] // Invalid interval, this will result in an error ``` -------------------------------- ### CQL Equivalent Operator Examples Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/09-b-cqlreference.md Shows the 'equivalent' operator for intervals. Returns true if intervals have equivalent start and end points. ```cql define "EquivalentIsTrue": Interval[0, 5] ~ Interval[0, 5] define "EquivalentIsAlsoTrue": Interval[1, null] ~ Interval[1, null] define "EquivalentIsFalse": Interval[-1, 7] ~ Interval[0, 7] ``` -------------------------------- ### Build Entire Solution Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/build/README.md Command to build the entire solution, `Cql-Sdk.slnf`, for the Release configuration. ```bash # Build entire solution for both frameworks dotnet build Cql-Sdk.slnf --configuration Release ``` -------------------------------- ### Build Example: Full Pipeline Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/docs/build-pipeline.md Executes the full build pipeline: CQL to ELM (Java), ELM to C# + FHIR (PackagerCLI), and finally assembly compilation. Use for a complete build from source. ```bash # Full pipeline: CQL → ELM (Java) → C# + FHIR (PackagerCLI) → assembly ./build.sh --framework net10.0 --enable-cql-tooling --enable-elm-tooling ``` -------------------------------- ### Date/Time Interval Example (Full Precision) Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/02-authorsguide.md Defines an interval starting at midnight on January 1, 2014, and ending just before midnight on December 31, 2014. ```cql Interval[@2014-01-01T00:00:00.0, @2015-01-01T00:00:00.0) ``` -------------------------------- ### Mode Operator Examples Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/09-b-cqlreference.md Demonstrates the Mode operator with Decimal and Quantity types, including cases where the result is null. ```cql define "DecimalMode": Mode({ 2.0, 2.0, 8.0, 6.0, 8.0, 8.0 }) // 8.0 define "QuantityMode": Mode({ 1.0 'mg', 2.0 'mg', 3.0 'mg', 2.0 'mg' }) // 2.0 'mg' define "ModeIsNull": Mode({ null as Quantity, null as Quantity, null as Quantity }) define "ModeIsAlsoNull": Mode(null as List) ``` -------------------------------- ### NuGet Version Prefix and Suffix Example Source: https://github.com/firelyteam/firely-cql-sdk/wiki/Creating-Tags-and-Releases Demonstrates how to define version prefix and suffix in a .NET project file to construct the full NuGet version. This is useful for managing pre-release versions. ```xml 1.2.0 rc.1 ``` ```plaintext Version = 1.2.0-rc.1 ``` -------------------------------- ### CQL Date Interval with Mixed Precision Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/02-authorsguide.md An example of a date interval in CQL with mixed precision boundaries, specifying a year for the start and a specific date for the end. ```cql Interval[Date(2014), Date(2015, 1, 1)] ``` -------------------------------- ### Build the XSD to C# Converter Tool Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/tools/XsdToCSharpConverter/README.md Build the tool from the command line. Navigate to the tool's directory and run the dotnet build command. ```bash cd tools/XsdToCSharpConverter dotnet build ``` -------------------------------- ### Date Interval Example (Undefined Time) Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/02-authorsguide.md Defines a date interval starting on January 1, 2014, and ending on December 31, 2014, with undefined times. ```cql Interval[@2014-01-01, @2015-01-01) ``` -------------------------------- ### Library and Data Model Declaration Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/02-authorsguide.md This snippet shows the initial setup for a CQL library, including the library name, version, data model (QUICK), and code system declarations. It sets the context to Patient for subsequent definitions. ```cql library CMS153_CDS version '2' using QUICK codesystem "SNOMED": 'http://snomed.info/sct' valueset "Female Administrative Sex": 'urn:oid:2.16.840.1.113883.3.560.100.2' ... context Patient ``` -------------------------------- ### Maximum Operator Examples Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/09-b-cqlreference.md Demonstrates the behavior of the maximum operator for Integer, Long, DateTime, and Quantity types. Note that attempting to get the maximum of a Quantity results in an error. ```cql define "IntegerMaximum": maximum Integer // 2147483647 define "LongMaximum": maximum Long // 9223372036854775807 define "DateTimeMaximum": maximum DateTime // @9999-12-31T23:59:59.999 define "ErrorMaximum": maximum Quantity ``` -------------------------------- ### Get Help for CQL Packager Commands Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/Cql/PackagerCLI/README.md Displays help information for the command-line tool and its subcommands. Use these commands to understand available options and usage patterns. ```shell cql-package --help cql-package cql --help cql-package elm --help cql-package extract-library-attachments --help cql-package replace-library-attachments --help ``` -------------------------------- ### Minimum Operator Examples Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/09-b-cqlreference.md Illustrates the minimum operator's behavior for Integer, Long, DateTime, and Quantity types. Similar to maximum, attempting to get the minimum of a Quantity results in an error. ```cql define "IntegerMinimum": minimum Integer // -2147483648 define "LongMinimum": minimum Long // -9223372036854775808 define "DateTimeMinimum": minimum DateTime // @0001-01-01T00:00:00.000 define "ErrorMinimum": minimum Quantity ``` -------------------------------- ### Product Operator Examples Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/09-b-cqlreference.md Demonstrates the Product operator for Integer, Long, Decimal, and Quantity types, including null cases. ```cql define "DecimalProduct": Product({ 1.0, 2.0, 3.0, 4.0 }) // 24.0 define "QuantityProduct": Product({ 1.0 'mg', 2.0 'mg', 3.0 'mg', 4.0 'mg' }) // 24.0 'mg' define "ProductIsNull": Product({ null as Quantity, null as Quantity, null as Quantity }) define "ProductIsAlsoNull": Product(null as List) ``` -------------------------------- ### Build Example: No Code Generation Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/docs/build-pipeline.md Builds the project with no code generation, compiling only C# from committed sources. Use for the fastest build when no regeneration is needed. ```bash # Build with no code generation (fastest — only compiles C# from committed sources) ./build.sh --framework net10.0 --configuration Debug ``` -------------------------------- ### Calculate Factorial with Inferred Type Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/03-developersguide.md Shows an example of the aggregate clause where the starting clause is omitted, and the result type is inferred. Coalesce is used to provide a default value for the initial null result. ```cql define FactorialOfFive: ({ 1, 2, 3, 4, 5 }) Num aggregate Result: Coalesce(Result, 1) * Num ``` -------------------------------- ### CQL Except Operator Example Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/09-b-cqlreference.md Illustrates the 'except' operator for intervals, returning the portion of the first interval not overlapping with the second. Returns null if the second interval is properly contained within the first and does not start or end it. ```cql define "Except": Interval[0, 5] except Interval[3, 7] // Interval[0, 2] define "ExceptIsNull": null except Interval[-1, 7] ``` -------------------------------- ### Build All SDK Projects Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/docs/technical-readme.md Use this command to build all projects in the SDK, excluding submodules. It's the recommended approach for a full build. ```bash # Build all SDK projects (recommended - excludes submodules) dotnet build Cql-Sdk.slnf -c Debug ``` -------------------------------- ### Basic Interval Start Comparison Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/02-authorsguide.md Checks if the start of interval X is before the start of interval Y. ```cql X starts before start Y ``` -------------------------------- ### Interval Start Comparison with Duration Offset Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/02-authorsguide.md Checks if the start of interval X is equal to a specific duration before the start of interval Y. ```cql X starts 3 days before start Y ``` -------------------------------- ### Build Core SDK with Solution Filter Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/docs/getting-started.md Use this command to build the core SDK packages. This is the recommended approach for building the project. ```bash dotnet build Cql-Sdk.slnf ``` -------------------------------- ### Inclusive Interval Start Comparisons Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/02-authorsguide.md Demonstrates inclusive comparisons using 'or on' and 'on or' with 'before' and 'after' for precise boundary checks. ```cql X starts 3 days or less before or on start Y X starts less than 3 days on or after end Y ``` -------------------------------- ### Interval Start Comparison with 'within' Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/02-authorsguide.md Checks if the start of interval X falls within a specified duration range around the start of interval Y. ```cql X starts within 3 days of start Y ``` -------------------------------- ### Quick Start: Invoking CQL from .NET Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/README.md This snippet demonstrates how to compile and invoke a simple CQL definition ('HelloWorld') from .NET using the Invocation Toolkit. It shows defining inline CQL, creating a CqlToolkit instance, and executing the definition with a FHIR context. ```csharp using Hl7.Cql.CqlToElm.Toolkit; using Hl7.Cql.CqlToElm.Toolkit.Extensions; using Hl7.Cql.Fhir; using Hl7.Cql.Invocation.Toolkit.Extensions; using Microsoft.Extensions.Logging; var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole()); // Define inline CQL (or load from files/FHIR resources) var cql = (CqlLibraryString) மாதிரி" library HelloWorldLib version '1.0.0' define "HelloWorld" : 'Hello from CQL!' """; // Compile and create an invoker using var invoker = new CqlToolkit(loggerFactory) .AddCqlLibraries(cql) .CreateLibrarySetInvoker(); // Execute a CQL definition var context = FhirCqlContext.WithDataSource(); var result = invoker.InvokeLibraryDefinition(context, cql.LibraryIdentifier, "HelloWorld"); Console.WriteLine(result); // Hello from CQL! ``` -------------------------------- ### Before Operator Examples Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/09-b-cqlreference.md Demonstrates the functionality of the 'before' operator with various Date and DateTime inputs, showing outcomes for true, false, and null results. ```cql define "BeforeIsTrue": @2012-01-01 before month of @2012-02-01 define "BeforeIsFalse": @2012-01-01 before month of @2012-01-01 define "BeforeUncertainIsNull": @2012 before month of @2012-02-01 define "BeforeIsNull": @2012-01-01 before month of null ``` -------------------------------- ### Starts Operator Logic Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/04-logicalspecification.md The Starts operator checks if the first interval starts the second. It considers interval boundaries and precision for date/time comparisons. Returns null if either argument is null. ```cql Starts : BinaryExpression ¦ 0..1 --> precision ``` -------------------------------- ### Build Example: Regenerate ELM from CQL Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/docs/build-pipeline.md Regenerates ELM from CQL, requiring Java and Maven, then builds the project. Use when CQL source files have changed. ```bash # Regenerate ELM from CQL (requires Java + Maven), then build ./build.sh --framework net10.0 --enable-cql-tooling ``` -------------------------------- ### Starts Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/Cql/Cql.Runtime/PublicAPI.Shipped.txt Checks if one interval starts at the same point as another, with optional precision. ```APIDOC ## Starts ### Description Compares the starting points of two intervals to determine if they are the same, with an optional precision parameter for date/time comparisons. ### Method `Starts` ### Parameters - `starts` (CqlInterval?): The first interval. - `other` (CqlInterval?): The second interval. - `precision` (string?): The precision for comparison (e.g., 'year', 'month'). ``` -------------------------------- ### Build a Release Version of the Tool Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/tools/XsdToCSharpConverter/README.md Create a release build of the tool for optimized performance. Use the -c Release flag with the dotnet build command. ```bash dotnet build -c Release ``` -------------------------------- ### Decimal Between Example Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/09-b-cqlreference.md An example illustrating the 'between' operator with decimal values, where the condition is false. ```cql define "DecimalBetweenIsFalse": 3.5 between 3.6 and 4.8 ``` -------------------------------- ### StartsWith String Function Examples Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/09-b-cqlreference.md Demonstrates the StartsWith operator to check if a string begins with a specified prefix. Returns null if either argument is null. ```cql define "StartsWithIsTrue": StartsWith('ABCDE', 'ABC') // true define "StartsWithIsFalse": StartsWith('ABCDE', 'XYZ') // false define "StartsWithIsNull": StartsWith('ABCDE', null) // null ``` -------------------------------- ### Include and Use a CQL Library Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/03-developersguide.md Demonstrates how to include a previously defined library ('Global.Common') and use its functions. The 'include' statement makes the library's public components available under a local alias. ```cql library UsingCommon include Global.Common define function "Bar"(A Integer, B Integer): Common.Foo(A, B) ``` -------------------------------- ### Qualified Identifier Example Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/03-developersguide.md An example of a qualified identifier in CQL, formed by combining identifiers with the qualifier operator (.). ```cql Common.ConditionsIndicatingSexualActivity ``` -------------------------------- ### Build SDK for Specific Framework Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/docs/technical-readme.md Builds the SDK for a particular .NET framework version. Specify the target framework using the --framework flag. ```bash # Build for specific framework dotnet build Cql-Sdk.slnf -c Debug --framework net10.0 ``` -------------------------------- ### CQL Specification Examples Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/report/issue-02-high-endswith-bounds-check.md These examples demonstrate the expected behavior of the EndsWith operator according to the CQL specification. ```cql define "EndsWithIsTrue": EndsWith('ABC', 'C') // true define "EndsWithIsFalse": EndsWith('ABC', 'Z') // false define "EndsWithIsNull": EndsWith('ABC', null) // null ``` -------------------------------- ### Not Equivalent Operator Examples Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/09-b-cqlreference.md Shows examples of the 'not equivalent' (!~) operator for intervals. It returns true if the intervals are not equivalent. ```cql define "NotEquivalentIsFalse": Interval[0, 5] !~ Interval[0, 5] ``` ```cql define "NotEquivalentIsAlsoFalse": Interval[1, null] !~ Interval[1, null] ``` ```cql define "NotEquivalentIsTrue": Interval[-1, 7] !~ Interval[0, 7] ``` -------------------------------- ### static Hl7.Cql.Packaging.Toolkit.Extensions.ElmToolkitPackagingExtensions.CreatePackagingToolkit Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/Cql/Cql.Packaging/PublicAPI.Shipped.txt Creates a PackagingToolkit from an ElmToolkit and a CqlToolkit. ```APIDOC ## static Hl7.Cql.Packaging.Toolkit.Extensions.ElmToolkitPackagingExtensions.CreatePackagingToolkit ### Description Creates a PackagingToolkit from an ElmToolkit and a CqlToolkit. ### Method Hl7.Cql.Packaging.Toolkit.PackagingToolkit! ### Parameters #### Path Parameters - **elmToolkit** (Hl7.Cql.CodeGeneration.NET.Toolkit.ElmToolkit!) - Required - The ElmToolkit instance. - **cqlToolkit** (Hl7.Cql.CqlToElm.Toolkit.CqlToolkit!) - Required - The CqlToolkit instance. - **packagingToolkitConfig** (Hl7.Cql.Packaging.Toolkit.PackagingToolkitConfig?) - Optional - Configuration for the PackagingToolkit. ``` -------------------------------- ### DateTime Literal Examples Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/02-authorsguide.md Provides examples of DateTime literals in CQL, adhering to ISO-8601 format, with varying precision. ```cql @2014-01-25T14:30 @2014-01-25T14:30:14.559 ``` -------------------------------- ### static Hl7.Cql.Packaging.Toolkit.Extensions.CqlToolkitPackagingExtensions.CreatePackagingToolkit Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/Cql/Cql.Packaging/PublicAPI.Shipped.txt Creates a PackagingToolkit from a CqlToolkit. ```APIDOC ## static Hl7.Cql.Packaging.Toolkit.Extensions.CqlToolkitPackagingExtensions.CreatePackagingToolkit ### Description Creates a PackagingToolkit from a CqlToolkit. ### Method Hl7.Cql.Packaging.Toolkit.PackagingToolkit! ### Parameters #### Path Parameters - **cqlToolkit** (Hl7.Cql.CqlToElm.Toolkit.CqlToolkit!) - Required - The CqlToolkit instance. - **elmToolkitConfig** (Hl7.Cql.CodeGeneration.NET.Toolkit.ElmToolkitConfig?) - Optional - Configuration for the ElmToolkit. - **packagingToolkitConfig** (Hl7.Cql.Packaging.Toolkit.PackagingToolkitConfig?) - Optional - Configuration for the PackagingToolkit. ``` -------------------------------- ### Start New Feature Branch Source: https://github.com/firelyteam/firely-cql-sdk/wiki/Git-Branching-and-Workflow-Guidelines Use this command to create a new branch for feature development, starting from the 'develop' branch. ```bash git checkout develop git pull origin develop git checkout -b feature/your-feature-name ``` -------------------------------- ### Long Between Example Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/09-b-cqlreference.md An example showing the 'between' operator used with Long data types, which is a new feature in CQL 1.5. ```cql define "LongBetweenIsTrue": 4L between 2L and 6L ``` -------------------------------- ### Run Demo CLI Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/docs/demo-projects.md Execute the Demo CLI application to load FHIR Library resources and run CQL measures. Ensure you have built the console app first. ```bash dotnet run --project Demo/CLI -- --fhir LibrarySets/Demo/Resources ``` -------------------------------- ### Observation Data Model Example Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/05-languagesemantics.md Illustrates a data model for Observation and ObservationComponent, including their properties like id, code, value, and component. ```cql Observation { id: string, code: Concept, value: Quantity, component: List } ObservationComponent { code: Concept, value: Quantity } ``` -------------------------------- ### CQL Specification Example for Round Operator Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/report/issue-04-high-round-test-expectations.md This example from the CQL specification demonstrates the expected behavior of the Round operator with a negative half-value. ```cql define "RoundNegativePointFive": Round(-0.5) // -1 ``` -------------------------------- ### Substring Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/09-b-cqlreference.md Extracts a substring from a string, optionally specifying the length. Returns null if the string, start index is null, or the start index is out of range. ```APIDOC ## Substring ### Description The Substring operator returns the string within stringToSub, starting at the 0-based index startIndex, and consisting of length characters. If length is omitted, the substring returned starts at startIndex and continues to the end of stringToSub. If stringToSub or startIndex is null, or startIndex is out of range, the result is null. ### Signature ``` Substring(stringToSub String, startIndex Integer) String Substring(stringToSub String, startIndex Integer, length Integer) String ``` ### Examples ``` define "SubstringWithoutLength": Substring('ABCDE', 2) // 'CDE' define "SubstringWithLength": Substring('ABCDE', 2, 1) // 'C' define "SubstringIsNull": Substring('ABCDE', null) // null define "SubstringIsAlsoNull": Substring('ABCDE', 14) // null ``` ``` -------------------------------- ### CqlTime Static Methods and Properties Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/Cql/Cql.Abstractions/PublicAPI.Shipped.txt Provides documentation for static methods and properties related to CqlTime, including parsing and min/max values. ```APIDOC ## CqlTime Static Methods and Properties ### Description Provides documentation for static methods and properties related to CqlTime, including parsing and min/max values. ### Methods #### `TryParse(string! s, out CqlTime? time) -> bool` Attempts to parse a string into a CqlTime object. ### Properties #### `MaxValue -> CqlTime!` Gets the maximum value for CqlTime. #### `MinValue -> CqlTime!` Gets the minimum value for CqlTime. ``` -------------------------------- ### Generate Elm.g.cs and Build Solution Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/tools/XsdToCSharpConverter/testing-guide.md Generates the Elm.g.cs file and then builds the entire Cql-Sdk solution. This tests the integration of generated code into the build process. ```cmd cd Cql\Elm Elm.g.cs-Generate-xsd2cs.cmd cd ..\.. dotnet build Cql-Sdk.slnf ``` -------------------------------- ### Declare Parameter of Integer Type Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/03-developersguide.md This example declares a parameter named Threshold with the Integer type. This is a basic example of a named type specifier. ```cql parameter Threshold Integer ``` -------------------------------- ### Test All Projects on .NET 8 Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/build/README.md Command to test all projects in the solution on the .NET 8 framework, using the Release configuration and skipping the build step. ```bash # Test all projects on .NET 8 dotnet test Cql-Sdk.slnf --configuration Release --framework net8.0 --no-build ``` -------------------------------- ### CQL Specification Examples for Expand Operator Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/report/issue-07-low-unskip-expand-tests.md These examples from the CQL specification illustrate how the 'Expand' operator truncates interval boundaries to the specified precision. ```cql expand { Interval[@T10:00, @T12:30] } per hour expand { Interval[10.0, 12.5] } per 1 ``` ```cql { Interval[@T10, @T10], Interval[@T11, @T11], Interval[@T12, @T12] } ``` ```cql { Interval[10, 10], Interval[11, 11], Interval[12, 12] } ``` ```cql { Interval[@T10, @T10], Interval[@T11, @T11], Interval[@T12, @T12] } ``` -------------------------------- ### CqlDate Static Methods and Properties Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/Cql/Cql.Abstractions/PublicAPI.Shipped.txt Provides documentation for static methods and properties related to CqlDate, including parsing and min/max values. ```APIDOC ## CqlDate Static Methods and Properties ### Description Provides documentation for static methods and properties related to CqlDate, including parsing and min/max values. ### Methods #### `TryParse(string! s, out CqlDate? cqlDate) -> bool` Attempts to parse a string into a CqlDate object. ### Properties #### `MaxValue -> CqlDate!` Gets the maximum value for CqlDate. #### `MinValue -> CqlDate!` Gets the minimum value for CqlDate. ``` -------------------------------- ### ToLong Operator Examples Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/09-b-cqlreference.md Illustrates the conversion of strings and booleans to Long values using the ToLong operator. Shows examples for valid and invalid string inputs. ```cql define "IsValid": ToLong('-1') define "IsNull": ToLong('one') ``` -------------------------------- ### Same As Operator Examples Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/09-b-cqlreference.md Illustrates the behavior of the 'same *-precision- *as' operator for Date values, showing true, false, and null results based on precision and input values. ```cql define "SameAsTrue": @2012-01-01 same day as @2012-01-01 define "SameAsFalse": @2012-01-01 same day as @2012-01-02 define "UncertainSameAsIsNull": @2012-01-01 same day as @2012-01 define "SameAsIsNull": @2012-01-01 same day as null ``` -------------------------------- ### Cross-Context Expression Example Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/02-authorsguide.md This example illustrates how to define an expression in the Unfiltered context that references an expression from the Patient context. It counts patients meeting a specific age criterion. ```cql context Patient define "InInitialPopulation": AgeInYearsAt(@2013-01-01) >= 16 and AgeInYearsAt(@2013-01-01) < 24 context Unfiltered define "InitialPopulationCount": Count(InInitialPopulation IP where IP is true) ``` -------------------------------- ### Test All Projects on .NET 10 Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/build/README.md Command to test all projects in the solution on the .NET 10 framework, using the Release configuration and skipping the build step. ```bash # Test all projects on .NET 10 dotnet test Cql-Sdk.slnf --configuration Release --framework net10.0 --no-build ``` -------------------------------- ### Test CqlToElm Project on .NET 8 Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/build/README.md Command to run tests for the `CqlToElmTests.csproj` project targeting the .NET 8 framework. ```bash # Test CqlToElmTests on both frameworks dotnet test Cql/CqlToElmTests/CqlToElmTests.csproj --framework net8.0 ``` -------------------------------- ### Test CqlToElm Project on .NET 10 Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/build/README.md Command to run tests for the `CqlToElmTests.csproj` project targeting the .NET 10 framework. ```bash dotnet test Cql/CqlToElmTests/CqlToElmTests.csproj --framework net10.0 ``` -------------------------------- ### Hl7.Cql.Packaging.Toolkit.PackagingToolkitResultArtifacts.PackagingToolkitResultArtifacts Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/Cql/Cql.Packaging/PublicAPI.Shipped.txt Constructor for PackagingToolkitResultArtifacts. Initializes a new instance. ```APIDOC ## Hl7.Cql.Packaging.Toolkit.PackagingToolkitResultArtifacts.PackagingToolkitResultArtifacts ### Description Constructor for PackagingToolkitResultArtifacts. Initializes a new instance. ### Method void ### Parameters None ``` -------------------------------- ### CQL Message Operator Example Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/09-b-cqlreference.md This example demonstrates how to use the Message operator to generate a runtime error when the Denominator parameter is zero. The message includes a condition, code, severity, and a descriptive message. ```cql parameter Numerator Integer default 1 parameter Denominator Integer default 0 define "ErrorMessage": Message('Divide by zero error!', Denominator = 0, 'Undefined', 'Error', 'The Denominator parameter is zero') ``` -------------------------------- ### Clean and Rebuild Solution Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/tools/XsdToCSharpConverter/testing-guide.md Perform a clean build to resolve potential issues with cached artifacts or corrupted build outputs. ```bash dotnet clean && dotnet build ``` -------------------------------- ### Check if One Interval Starts Another Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/09-b-cqlreference.md Determines if the first interval starts at the same point as the second and ends at or before the second. Supports precision for date/time types. Returns null if either input interval is null. ```cql define "StartsIsTrue": Interval[0, 5] starts Interval[0, 7] define "StartsIsFalse": Interval[0, 7] starts Interval[0, 6] define "StartsIsNull": Interval[1, 5] starts null ``` -------------------------------- ### CQL to ELM and back to CQL Example Source: https://github.com/firelyteam/firely-cql-sdk/blob/develop/spec/condensed/06-translationsemantics.md Demonstrates a CQL expression, its ELM translation, and the resulting CQL when translated back. Note that the re-translated CQL may not be syntactically identical to the original. ```cql A starts within 3 days of start B ``` ```xml ``` ```cql days between start of A and start of B in [-3, 3] ```