Using CQL With FHIR
3.0.0-ballot - STU 3 Ballot

Using CQL With FHIR - Downloaded Version null See the Directory of published versions

## Library: FHIR HelpersTests (Experimental)

Official URL: http://hl7.org/fhir/uv/cql/Library/FHIRHelpersTests | Version: 3.0.0-ballot | Highlight text changes?
Standards status: Informative | Maturity Level: 4 | Computable Name: FHIRHelpersTests
Other Identifiers: OID:2.16.840.1.113883.4.642.40.37.28.13

This library defines test cases for FHIRHelpers functionality

Metadata
Title | FHIR HelpersTests
Version | 3.0.0-ballot
Identifier | urn:oid:2.16.840.1.113883.4.642.40.37.28.13
Approval Date | 2025-05-27
Last Review Date | 2025-05-27
Experimental | true
Jurisdiction | World
Topic | FHIR
Topic | CQL
Steward (Publisher) | HL7 International / Clinical Decision Support
Description | This library defines test cases for FHIRHelpers functionality
Type | logic-library from http://terminology.hl7.org/CodeSystem/library-type
Dependency | Description: Library FHIRHelpers Resource: FHIR Helpers version: 4.0.2-ballot Canonical URL: `http://hl7.org/fhir/uv/cql/Library/FHIRHelpers|4.0.2-ballot`
Parameters
Name | Use | Card. | Type | Documentation
TestInstant | Out | 0..1 | instant |
TestInstantConverts | Out | 0..1 | boolean |
TestTime | Out | 0..1 | time |
TestTimeConverts | Out | 0..1 | boolean |
TestHour | Out | 0..1 | time |
TestHourConverts | Out | 0..1 | boolean |
TestMinute | Out | 0..1 | time |
TestMinuteConverts | Out | 0..1 | boolean |
TestSecond | Out | 0..1 | time |
TestSecondConverts | Out | 0..1 | boolean |
TestDate | Out | 0..1 | date |
TestDateConverts | Out | 0..1 | boolean |
TestYear | Out | 0..1 | date |
TestYearConverts | Out | 0..1 | boolean |
TestMonth | Out | 0..1 | date |
TestMonthConverts | Out | 0..1 | boolean |
TestDateTime | Out | 0..1 | dateTime |
TestDateTimeConverts | Out | 0..1 | boolean |
TestYearDateTime | Out | 0..1 | dateTime |
TestYearDateTimeConverts | Out | 0..1 | boolean |
TestMonthDateTime | Out | 0..1 | dateTime |
TestMonthDateTimeConverts | Out | 0..1 | boolean |
TestDayDateTime | Out | 0..1 | dateTime |
TestDayDateTimeConverts | Out | 0..1 | boolean |
TestHourDateTime | Out | 0..1 | dateTime |
TestHourDateTimeConverts | Out | 0..1 | boolean |
TestMinuteDateTime | Out | 0..1 | dateTime |
TestMinuteDateTimeConverts | Out | 0..1 | boolean |
TestSecondDateTime | Out | 0..1 | dateTime |
TestSecondDateTimeConverts | Out | 0..1 | boolean |
TestBase64Binary | Out | 0..1 | base64Binary |
TestBase64BinaryConverts | Out | 0..1 | boolean |
TestDecimal | Out | 0..1 | decimal |
TestDecimalConverts | Out | 0..1 | boolean |
TestBoolean | Out | 0..1 | boolean |
TestBooleanConverts | Out | 0..1 | boolean |
TestUri | Out | 0..1 | uri |
TestUriConverts | Out | 0..1 | boolean |
TestUrl | Out | 0..1 | url |
TestUrlConverts | Out | 0..1 | boolean |
TestUrlSpecificallyConverts | Out | 0..1 | boolean |
TestCanonical | Out | 0..1 | canonical |
TestCanonicalConverts | Out | 0..1 | boolean |
TestCanonicalSpecificallyConverts | Out | 0..1 | boolean |
TestUuid | Out | 0..1 | uuid |
TestUuidConverts | Out | 0..1 | boolean |
TestUuidSpecificallyConverts | Out | 0..1 | boolean |
TestOid | Out | 0..1 | oid |
TestOidConverts | Out | 0..1 | boolean |
TestOidSpecificallyConverts | Out | 0..1 | boolean |
TestInteger | Out | 0..1 | integer |
TestIntegerConverts | Out | 0..1 | boolean |
TestIntegerSpecificallyConverts | Out | 0..1 | boolean |
TestUnsignedInt | Out | 0..1 | unsignedInt |
TestUnsignedIntConverts | Out | 0..1 | boolean |
TestUnsignedIntSpecificallyConverts | Out | 0..1 | boolean |
TestPositiveInt | Out | 0..1 | positiveInt |
TestPositiveIntConverts | Out | 0..1 | boolean |
TestPositiveIntSpecificallyConverts | Out | 0..1 | boolean |
TestString | Out | 0..1 | string |
TestStringConverts | Out | 0..1 | boolean |
TestCode | Out | 0..1 | code |
TestCodeConverts | Out | 0..1 | boolean |
TestCodeSpecificallyConverts | Out | 0..1 | boolean |
TestMarkdown | Out | 0..1 | markdown |
TestMarkdownConverts | Out | 0..1 | boolean |
TestMarkdownSpecificallyConverts | Out | 0..1 | boolean |
TestId | Out | 0..1 | id |
TestIdConverts | Out | 0..1 | boolean |
TestIdSpecificallyConverts | Out | 0..1 | boolean |
TestRatio | Out | 0..1 | Ratio |
TestRatioConverts | Out | 0..1 | boolean |
TestPeriod | Out | 0..1 | Period |
TestPeriodConverts | Out | 0..1 | boolean |
TestRange | Out | 0..1 | Range |
TestRangeConverts | Out | 0..1 | boolean |
TestCoding | Out | 0..1 | Coding |
TestCodingConverts | Out | 0..1 | boolean |
TestCodeableConcept | Out | 0..1 | CodeableConcept |
TestCodeableConceptConverts | Out | 0..1 | boolean |
TestQuantity | Out | 0..1 | Quantity |
TestQuantityConverts | Out | 0..1 | boolean |
TestAge | Out | 0..1 | Age |
TestAgeConverts | Out | 0..1 | boolean |
TestAgeSpecificallyConverts | Out | 0..1 | boolean |
TestDistance | Out | 0..1 | Distance |
TestDistanceConverts | Out | 0..1 | boolean |
TestDistanceSpecificallyConverts | Out | 0..1 | boolean |
TestDuration | Out | 0..1 | Duration |
TestDurationConverts | Out | 0..1 | boolean |
TestDurationSpecificallyConverts | Out | 0..1 | boolean |
TestCount | Out | 0..1 | Count |
TestCountConverts | Out | 0..1 | boolean |
TestCountSpecificallyConverts | Out | 0..1 | boolean |
TestSimpleQuantity | Out | 0..1 | Quantity |
TestSimpleQuantityConverts | Out | 0..1 | boolean |
TestSimpleQuantitySpecificallyConverts | Out | 0..1 | boolean |
TestQuantityWithoutComparator | Out | 0..1 | Quantity |
TestQuantityWithoutComparatorConverts | Out | 0..1 | boolean |
TestQuantityWithComparator1 | Out | 0..1 | Quantity |
TestQuantityWithComparator1Converts | Out | 0..1 | boolean |
TestQuantityWithComparator2 | Out | 0..1 | Quantity |
TestQuantityWithComparator2Converts | Out | 0..1 | boolean |
TestQuantityWithComparator3 | Out | 0..1 | Quantity |
TestQuantityWithComparator3Converts | Out | 0..1 | boolean |
TestQuantityWithComparator4 | Out | 0..1 | Quantity |
TestQuantityWithComparator4Converts | Out | 0..1 | boolean |
Library Content
CQL Content |
    library FHIRHelpersTests

    using FHIR version '4.0.1'

    include FHIRHelpers version '4.0.2-ballot'

    // Primitives
    // instant
    define TestInstant: instant { value: @2020-10-03T10:00:00.0 }
    define TestInstantConverts: TestInstant = @2020-10-03T10:00:00.0

    // time
    define TestTime: time { value: @T10:00:00.0 }
    define TestTimeConverts: TestTime = @T10:00:00.0
    define TestHour: time { value: @T10 }
    define TestHourConverts: TestHour = @T10
    define TestMinute: time { value: @T10:00 }
    define TestMinuteConverts: TestMinute = @T10:00
    define TestSecond: time { value: @T10:00:00 }
    define TestSecondConverts: TestSecond = @T10:00:00

    // date
    define TestDate: date { value: @2020-10-03 }
    define TestDateConverts: TestDate = @2020-10-03
    define TestYear: date { value: @2020 }
    define TestYearConverts: TestYear = @2020
    define TestMonth: date { value: @2020-10 }
    define TestMonthConverts: TestMonth = @2020-10

    // dateTime
    define TestDateTime: dateTime { value: @2020-10-03T10:00:00.0 }
    define TestDateTimeConverts: TestDateTime = @2020-10-03T10:00:00.0
    define TestYearDateTime: dateTime { value: @2020T }
    define TestYearDateTimeConverts: TestYearDateTime = @2020T
    define TestMonthDateTime: dateTime { value: @2020-10T }
    define TestMonthDateTimeConverts: TestMonthDateTime = @2020-10T
    define TestDayDateTime: dateTime { value: @2020-10-03T }
    define TestDayDateTimeConverts: TestDayDateTime = @2020-10-03T
    define TestHourDateTime: dateTime { value: @2020-10-03T10 }
    define TestHourDateTimeConverts: TestHourDateTime = @2020-10-03T10
    define TestMinuteDateTime: dateTime { value: @2020-10-03T10:00 }
    define TestMinuteDateTimeConverts: TestMinuteDateTime = @2020-10-03T10:00
    define TestSecondDateTime: dateTime { value: @2020-10-03T10:00:00 }
    define TestSecondDateTimeConverts: TestSecondDateTime = @2020-10-03T10:00:00

    // base64Binary
    define TestBase64Binary: base64Binary { value: 'Rm9vYmFy' }
    define TestBase64BinaryConverts: TestBase64Binary = 'Rm9vYmFy'

    // decimal
    define TestDecimal: decimal { value: 10.0 }
    define TestDecimalConverts: TestDecimal = 10.0

    // boolean
    define TestBoolean: boolean { value: true }
    define TestBooleanConverts: TestBoolean = true

    // uri
    define TestUri: uri { value: 'http://hl7.org/fhir' }
    define TestUriConverts: TestUri = 'http://hl7.org/fhir'
      // url
    define TestUrl: url { value: 'http://hl7.org/fhir' }
    define TestUrlConverts: TestUrl = 'http://hl7.org/fhir'
    define TestUrlSpecificallyConverts: FHIRHelpers.ToString(TestUrl) = 'http://hl7.org/fhir'
      // canonical
    define TestCanonical: canonical { value: 'http://hl7.org/fhir/CodeSystem/calendar-units' }
    define TestCanonicalConverts: TestCanonical = 'http://hl7.org/fhir/CodeSystem/calendar-units'
    define TestCanonicalSpecificallyConverts: FHIRHelpers.ToString(TestCanonical) = 'http://hl7.org/fhir/CodeSystem/calendar-units'
      // uuid
    define TestUuid: uuid { value: 'urn:uuid:c757873d-ec9a-4326-a141-556f43239520'}
    define TestUuidConverts: TestUuid = 'urn:uuid:c757873d-ec9a-4326-a141-556f43239520'
    define TestUuidSpecificallyConverts: FHIRHelpers.ToString(TestUuid) = 'urn:uuid:c757873d-ec9a-4326-a141-556f43239520'
      // oid
    define TestOid: oid { value: 'urn:oid:1.2.3.4.5' }
    define TestOidConverts: TestOid = 'urn:oid:1.2.3.4.5'
    define TestOidSpecificallyConverts: FHIRHelpers.ToString(TestOid) = 'urn:oid:1.2.3.4.5'

    // integer
    define TestInteger: integer { value: 1 }
    define TestIntegerConverts: TestInteger = 1
    define TestIntegerSpecificallyConverts: FHIRHelpers.ToInteger(TestInteger) = 1
      // unsignedInt
    define TestUnsignedInt: unsignedInt { value: 1 }
    define TestUnsignedIntConverts: TestUnsignedInt = 1
    define TestUnsignedIntSpecificallyConverts: FHIRHelpers.ToInteger(TestUnsignedInt) = 1
      // positiveInt
    define TestPositiveInt: positiveInt { value: 1 }
    define TestPositiveIntConverts: TestPositiveInt = 1
    define TestPositiveIntSpecificallyConverts: FHIRHelpers.ToInteger(TestPositiveInt) = 1

    // string
    define TestString: string { value: 'Foobar' }
    define TestStringConverts: TestString = 'Foobar'
      // code
    define TestCode: code { value: 'year' }
    define TestCodeConverts: TestCode = 'year'
    define TestCodeSpecificallyConverts: FHIRHelpers.ToString(TestCode) = 'year'
      // markdown
    define TestMarkdown: markdown { value: '#Markdown Content' }
    define TestMarkdownConverts: TestMarkdown = '#Markdown Content'
    define TestMarkdownSpecificallyConverts: FHIRHelpers.ToString(TestMarkdown) = '#Markdown Content'
      // id
    define TestId: id { value: 'calendar-units' }
    define TestIdConverts: TestId = 'calendar-units'
    define TestIdSpecificallyConverts: FHIRHelpers.ToString(TestId) = 'calendar-units'

    // Ratio
    define TestRatio: Ratio {
      numerator: Quantity { value: decimal { value: 10.0 }, unit: string { value: 'mg' } },
      denominator: Quantity { value: decimal { value: 100.0 }, unit: string { value: 'mg' } }
    }
    define TestRatioConverts: TestRatio = 10.0 'mg' : 100.0 'mg'

    // Period
    define TestPeriod: Period {
      start: dateTime { value: @2020-10-03T10:00:00 },
      end: dateTime { value: @2020-10-03T10:00:00 }
    }
    define TestPeriodConverts: TestPeriod = Interval[@2020-10-03T10:00:00, @2020-10-03T10:00:00]

    // Range
    define TestRange: Range {
      low: SimpleQuantity { value: decimal { value: 10.0 }, unit: string { value: 'mg' } },
      high: SimpleQuantity { value: decimal { value: 100.0 }, unit: string { value: 'mg' } }
    }
    define TestRangeConverts: TestRange = Interval[10.0 'mg', 100.0 'mg']

    // Coding
    define TestCoding: Coding {
      system: uri { value: 'http://hl7.org/fhir/CodeSystem/calendar-units' },
      code: code { value: 'year' },
      display: string { value: 'year' }
    }
    define TestCodingConverts: TestCoding = Code { code: 'year', system: 'http://hl7.org/fhir/CodeSystem/calendar-units', display: 'year' }

    // CodeableConcept
    define TestCodeableConcept: CodeableConcept {
      coding: {
        Coding {
          system: uri { value: 'http://hl7.org/fhir/CodeSystem/calendar-units' },
          code: code { value: 'year' },
          display: string { value: 'year' }
        }
      }
    }
    define TestCodeableConceptConverts: TestCodeableConcept = Concept { codes: { Code { code: 'year', system: 'http://hl7.org/fhir/CodeSystem/calendar-units', display: 'year' } } }

    // Money
    // Money implicit conversions are not supported

    // Quantity
    define TestQuantity: Quantity { value: decimal { value: 10.0 }, unit: string { value: 'mg' } }
    define TestQuantityConverts: TestQuantity = 10.0 'mg'
      // Age
    define TestAge: Age { value: decimal { value: 12.0 }, unit: string { value: 'a' }, system: uri { value: 'http://unitsofmeasure.org' }, code: code { value: 'a' } }
    define TestAgeConverts: TestAge = 12 years
    define TestAgeSpecificallyConverts: FHIRHelpers.ToQuantity(TestAge) = 12 years
      // Distance
    define TestDistance: Distance { value: decimal { value: 100 }, unit: string { value: 'km' }, system: uri { value: 'http://unitsofmeasure.org' }, code: code { value: 'km' } }
    define TestDistanceConverts: TestDistance = 100 'km'
    define TestDistanceSpecificallyConverts: FHIRHelpers.ToQuantity(TestDistance) = 100 'km'
      // Duration
    define TestDuration: Duration { value: decimal { value: 100 }, unit: string { value: 's' }, system: uri { value: 'http://unitsofmeasure.org' }, code: code { value: 's' } }
    define TestDurationConverts: TestDuration = 100 seconds
    define TestDurationSpecificallyConverts: FHIRHelpers.ToQuantity(TestDuration) = 100 seconds
      // Count
    define TestCount: Count { value: decimal { value: 100 }, unit: string { value: '1' }, system: uri { value: 'http://unitsofmeasure.org' }, code: code { value: '1' } }
    define TestCountConverts: TestCount = 100 '1'
    define TestCountSpecificallyConverts: FHIRHelpers.ToQuantity(TestCount) = 100 '1'
      // MoneyQuantity
      // MoneyQuantity implicit conversions would result in a runtime error
      // SimpleQuantity
    // NOTE: This expression cast as a Quantity because SimpleQuantity can't be represented in a FHIR DataRequirement in R5...
    define TestSimpleQuantity: (SimpleQuantity { value: decimal { value: 10 }, unit: string { value: 'g' }, system: uri { value: 'http://unitsofmeasure.org' }, code: code { value: 'g' } }) as Quantity
    define TestSimpleQuantityConverts: TestSimpleQuantity = 10 'g'
    define TestSimpleQuantitySpecificallyConverts: FHIRHelpers.ToQuantity(TestSimpleQuantity) = 10 'g'

    // Quantity with Comparator
    define TestQuantityWithoutComparator: Quantity { value: decimal { value: 10.0 }, unit: string { value: 'mg' } }
    define TestQuantityWithoutComparatorConverts: FHIRHelpers.ToInterval(TestQuantityWithoutComparator) = Interval[10.0 'mg', 10.0 'mg']
    define TestQuantityWithComparator1: Quantity { value: decimal { value: 10.0 }, unit: string { value: 'mg' }, comparator: FHIR.QuantityComparator { value: '<' } }
    define TestQuantityWithComparator1Converts: FHIRHelpers.ToInterval(TestQuantityWithComparator1) = Interval[null, 10 'mg')
    define TestQuantityWithComparator2: Quantity { value: decimal { value: 10.0 }, unit: string { value: 'mg' }, comparator: FHIR.QuantityComparator { value: '<=' } }
    define TestQuantityWithComparator2Converts: FHIRHelpers.ToInterval(TestQuantityWithComparator2) = Interval[null, 10 'mg']
    define TestQuantityWithComparator3: Quantity { value: decimal { value: 10.0 }, unit: string { value: 'mg' }, comparator: FHIR.QuantityComparator { value: '>=' } }
    define TestQuantityWithComparator3Converts: FHIRHelpers.ToInterval(TestQuantityWithComparator3) = Interval[10 'mg', null]
    define TestQuantityWithComparator4: Quantity { value: decimal { value: 10.0 }, unit: string { value: 'mg' }, comparator: FHIR.QuantityComparator { value: '>' } }
    define TestQuantityWithComparator4Converts: FHIRHelpers.ToInterval(TestQuantityWithComparator4) = Interval(10 'mg', null]
ELM JSON Content |
    Encoded data
Generated using version 0.5.6-cibuild of the sample-content-ig Liquid templates