# EXM Ratio Measure - Quality Measure Implementation Guide v2.0.0-ballot

## Measure: EXM Ratio Measure (Experimental) 

 
An example FHIR-based publishable measure 

* Metadata: Title
  * ?: EXM Ratio Measure
* Metadata: Version
  * ?: 2.0.0
* Metadata: Identifier
  * ?: EXMRatio-FHIR
* Metadata: Identifier
  * ?: urn:oid:2.16.840.1.113883.4.642.40.61.29.10
* Metadata: Effective Period
  * ?: 2018-01-01 + 1 year(s)
* Metadata: Approval Date
  * ?: 2019-02-17
* Metadata: Last Review Date
  * ?: 2019-02-17
* Metadata: Experimental
  * ?: true
* Metadata: Use Context
  * ?: Clinical Venue = EC
* Metadata: Jurisdiction
  * ?: 001 from[http://unstats.un.org/unsd/methods/m49/m49.htm](http://unstats.un.org/unsd/methods/m49/m49.htm)
* Metadata: Topic
  * ?: Health Quality Measure Document
* Metadata: Steward (Publisher)
  * ?: HL7 International / Clinical Quality Information
* Metadata: Developer
  * ?: Example Measure Content Developer
* Metadata: Description
  * ?: An example FHIR-based publishable measure
* Metadata: Purpose
  * ?: This measure has been developed to support improvement in clinical care.
* Metadata: Copyright
  * ?: Example Copyright Statement
* Metadata: Disclaimer
  * ?: Example disclaimer
* Metadata: Measure Basis
  * ?: Encounter
* Metadata: Measure Scoring
  * ?: Ratio
* Metadata: Measure Scoring Unit
  * ?: /1000.d from[http://unitsofmeasure.org](http://terminology.hl7.org/6.5.0/CodeSystem-v3-ucum.html)
* Metadata: Improvement Notation
  * ?: Decreased score indicates improvement
* Metadata: Measure Type
  * ?: process from[http://terminology.hl7.org/CodeSystem/measure-type](http://terminology.hl7.org/7.1.0/CodeSystem-measure-type.html)
* Metadata: Rationale
  * ?: The rationale of this measure is...
* Metadata: Guidance (Usage)
  * ?: Users of this measure should be aware of...
* Metadata: Measure Group (Rate) (ID: primary)
* Metadata: Measure Logic
* Metadata: Primary Library
  * ?: [EXMRatio - Example Ratio Measure Library](Library-EXMRatio.md)
* Metadata: Contents
  * ?: **[Population Criteria](#population-criteria)****[Logic Definitions](#definitions)****[Terminology](#terminology)****[Dependencies](#dependencies)****[Data Requirements](#data-requirements)****[Parameters](#parameters)**
* Metadata:  Population Criteria
* Metadata: Measure Group (Rate) (ID: primary)
* Metadata:  Logic Definitions
* Metadata: Logic Definition
  * ?: **Library Name:**EXMRatio
* Metadata:  ````define "Qualifying Encounters": ["Encounter": "Inpatient"]````
* Metadata: Logic Definition
  * ?: **Library Name:**EXMRatio
* Metadata:  ````define "Initial Population": "Qualifying Encounters"````
* Metadata: Logic Definition
  * ?: **Library Name:**EXMRatio
* Metadata:  ````define "Numerator": "Initial Population"````
* Metadata: Logic Definition
  * ?: **Library Name:**EXMRatio
* Metadata:  ````define "Denominator": "Initial Population"````
* Metadata: Logic Definition
  * ?: **Library Name:**EXMRatio
* Metadata:  ````define "Falls with Major Injury": ["Observation": "Fall"]````
* Metadata: Logic Definition
  * ?: **Library Name:**EXMRatio
* Metadata:  ````define function "Denominator Observation"(Encounter "Encounter"): duration in hours of Global.Hospitalization(Encounter) / 24````
* Metadata: Logic Definition
  * ?: **Library Name:**EXMRatio
* Metadata:  ````define function "Numerator Observation"(Encounter "Encounter"): Count( "Falls with Major Injury" Falls where Global."Normalize Interval"(Falls.effective) during Encounter.period )````
* Metadata: Logic Definition
  * ?: **Library Name:**MATGlobalCommonFunctions
* Metadata:  ````define function "Hospitalization"(TheEncounter FHIR.Encounter): ( "ED Visit"(TheEncounter) ) X return if X is null then TheEncounter.period else Interval[start of FHIRHelpers.ToInterval(X.period), end of FHIRHelpers.ToInterval(TheEncounter.period)]````
* Metadata: Logic Definition
  * ?: **Library Name:**MATGlobalCommonFunctions
* Metadata:  ````define function "ED Visit"(TheEncounter FHIR.Encounter): singleton from ( [Encounter: "Emergency Department Visit"] EDVisit where EDVisit.status = 'finished' and EDVisit.period ends 1 hour or less on or before start of FHIRHelpers.ToInterval(TheEncounter.period) )````
* Metadata: Logic Definition
  * ?: **Library Name:**MATGlobalCommonFunctions
* Metadata:  ````/* * * CQFMeasures Common Logic * */ define function "Normalize Interval"(choice Choice<FHIR.dateTime, FHIR.Period, FHIR.Timing, FHIR.instant, FHIR.string, FHIR.Age, FHIR.Range>): case when choice is FHIR.dateTime then Interval[FHIRHelpers.ToDateTime(choice as FHIR.dateTime), FHIRHelpers.ToDateTime(choice as FHIR.dateTime)] when choice is FHIR.Period then FHIRHelpers.ToInterval(choice as FHIR.Period) when choice is FHIR.instant then Interval[FHIRHelpers.ToDateTime(choice as FHIR.instant), FHIRHelpers.ToDateTime(choice as FHIR.instant)] when choice is FHIR.Age then Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(choice as FHIR.Age), FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(choice as FHIR.Age) + 1 year) when choice is FHIR.Range then Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((choice as FHIR.Range).low), FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((choice as FHIR.Range).high) + 1 year) when choice is FHIR.Timing then Message(null as Interval<DateTime>, true, '1', 'Error', 'Cannot compute a single interval from a Timing type') when choice is FHIR.string then Message(null as Interval<DateTime>, true, '1', 'Error', 'Cannot compute an interval from a String value') else null as Interval<DateTime> end````
* Metadata: Logic Definition
  * ?: **Library Name:**FHIRHelpers
* Metadata:  ````define function ToString(value EncounterStatus): value.value````
* Metadata: Logic Definition
  * ?: **Library Name:**FHIRHelpers
* Metadata:  ````/* @description: Converts the given [Period](https://hl7.org/fhir/datatypes.html#Period) value to a CQL DateTime Interval @comment: If the start value of the given period is unspecified, the starting boundary of the resulting interval will be open (meaning the start of the interval is unknown, as opposed to interpreted as the beginning of time). */ define function ToInterval(period FHIR.Period): if period is null then null else if period."start" is null then Interval(period."start".value, period."end".value] else Interval[period."start".value, period."end".value]````
* Metadata: Logic Definition
  * ?: **Library Name:**FHIRHelpers
* Metadata:  ````define function ToDateTime(value dateTime): value.value````
* Metadata: Logic Definition
  * ?: **Library Name:**FHIRHelpers
* Metadata:  ````define function ToDateTime(value instant): value.value````
* Metadata: Logic Definition
  * ?: **Library Name:**FHIRHelpers
* Metadata:  ````define function ToDate(value date): value.value````
* Metadata: Logic Definition
  * ?: **Library Name:**FHIRHelpers
* Metadata:  ````/* @description: Converts the given FHIR [Quantity](https://hl7.org/fhir/datatypes.html#Quantity) value to a CQL Quantity @comment: If the given quantity has a comparator specified, a runtime error is raised. If the given quantity has a system other than UCUM (i.e. `http://unitsofmeasure.org`) or CQL calendar units (i.e. `http://hl7.org/fhirpath/CodeSystem/calendar-units`) an error is raised. For UCUM to calendar units, the `ToCalendarUnit` function is used. @seealso: ToCalendarUnit */ define function ToQuantity(quantity FHIR.Quantity): case when quantity is null then null when quantity.value is null then null when quantity.comparator is not null then Message(null, true, 'FHIRHelpers.ToQuantity.ComparatorQuantityNotSupported', 'Error', 'FHIR Quantity value has a comparator and cannot be converted to a System.Quantity value.') when quantity.system is null or quantity.system.value = 'http://unitsofmeasure.org' or quantity.system.value = 'http://hl7.org/fhirpath/CodeSystem/calendar-units' then System.Quantity { value: quantity.value.value, unit: ToCalendarUnit(Coalesce(quantity.code.value, quantity.unit.value, '1')) } else Message(null, true, 'FHIRHelpers.ToQuantity.InvalidFHIRQuantity', 'Error', 'Invalid FHIR Quantity code: ' & quantity.unit.value & ' (' & quantity.system.value & '|' & quantity.code.value & ')') end````
* Metadata: Logic Definition
  * ?: **Library Name:**FHIRHelpers
* Metadata:  ````/* @description: Converts a UCUM definite duration unit to a CQL calendar duration unit using conversions specified in the [quantities](https://cql.hl7.org/02-authorsguide.html#quantities) topic of the CQL specification. @comment: Note that for durations above days (or weeks), the conversion is understood to be approximate */ define function ToCalendarUnit(unit System.String): case unit when 'ms' then 'millisecond' when 's' then 'second' when 'min' then 'minute' when 'h' then 'hour' when 'd' then 'day' when 'wk' then 'week' when 'mo' then 'month' when 'a' then 'year' else unit end````
* Metadata:  Terminology
* Metadata: Value Set
  * ?: **Description**: Value set Inpatient**Resource**:`http://example.org/fhir/ValueSet/inpatient`**Canonical URL**:http://example.org/fhir/ValueSet/inpatient
* Metadata: Value Set
  * ?: **Description**: Value set Emergency Department Visit**Resource**:[Emergency Department Visit](https://vsac.nlm.nih.gov/valueset/2.16.840.1.113883.3.117.1.7.1.292/expansion)**Canonical URL**:http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292
* Metadata: Value Set
  * ?: **Description**: Value set Fall**Resource**:`http://example.org/fhir/ValueSet/fall`**Canonical URL**:http://example.org/fhir/ValueSet/fall
* Metadata:  Dependencies
* Metadata: Dependency
  * ?: **Description**: FHIR model information**Resource**:[http://hl7.org/fhir/uv/cql/Library/FHIR-ModelInfo|4.0.1](http://hl7.org/fhir/uv/cql/STU2/Library-FHIR-ModelInfo.html)**Canonical URL**:http://hl7.org/fhir/uv/cql/Library/FHIR-ModelInfo|4.0.1
* Metadata: Dependency
  * ?: **Description**: Library Global**Resource**:[MAT Global Common Functions FHIR Libraryversion: null5.0.000)](Library-MATGlobalCommonFunctions.md)**Canonical URL**:http://hl7.org/fhir/uv/cqm/Library/MATGlobalCommonFunctions|5.0.000
* Metadata: Dependency
  * ?: **Description**: Library FHIRHelpers**Resource**:[http://hl7.org/fhir/uv/cql/Library/FHIRHelpers|4.0.1](http://hl7.org/fhir/uv/cql/STU2/Library-FHIRHelpers.html)**Canonical URL**:http://hl7.org/fhir/uv/cql/Library/FHIRHelpers|4.0.1
* Metadata:  Data Requirements
* Metadata: Data Requirement
  * ?: **Type**: Encounter**Profile(s)**:[Encounter](http://hl7.org/fhir/R4/encounter.html)**Must Support Elements**: type, status, period**Code Filter(s)**:**Path**: type**ValueSet**:[Emergency Department Visit](https://vsac.nlm.nih.gov/valueset/2.16.840.1.113883.3.117.1.7.1.292/expansion)
* Metadata: Data Requirement
  * ?: **Type**: Encounter**Profile(s)**:[Encounter](http://hl7.org/fhir/R4/encounter.html)**Must Support Elements**: type, period**Code Filter(s)**:**Path**: type**ValueSet**:`http://example.org/fhir/ValueSet/inpatient`
* Metadata: Data Requirement
  * ?: **Type**: Observation**Profile(s)**:[Observation](http://hl7.org/fhir/R4/observation.html)**Must Support Elements**: code, effective**Code Filter(s)**:**Path**: code**ValueSet**:`http://example.org/fhir/ValueSet/fall`
* Metadata: Data Requirement
  * ?: **Type**: Patient**Profile(s)**:[Patient](http://hl7.org/fhir/R4/patient.html)
* Metadata:  Parameters
* Metadata: 
  * ?: 
| | | | | |
| :--- | :--- | :--- | :--- | :--- |
| **Name** | **Use** | **Card.** | **Type** | **Documentation** |
| Numerator | Out | 0..* | Encounter |  |
| Denominator | Out | 0..* | Encounter |  |
| Initial Population | Out | 0..* | Encounter |  |

* Metadata: Generated using version 0.5.4 of the sample-content-ig Liquid templates



## Resource Content

```json
{
  "resourceType" : "Measure",
  "id" : "EXMRatio-FHIR",
  "meta" : {
    "profile" : ["http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-ratiomeasure",
    "http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-computablemeasure",
    "http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-cqlmeasure",
    "http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-computablemeasure"]
  },
  "contained" : [{
    "resourceType" : "Library",
    "id" : "effective-data-requirements",
    "extension" : [{
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "EXMRatio"
      },
      {
        "url" : "name",
        "valueString" : "Qualifying Encounters"
      },
      {
        "url" : "statement",
        "valueString" : "define \"Qualifying Encounters\":\n  [\"Encounter\": \"Inpatient\"]"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 0
      }],
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "EXMRatio"
      },
      {
        "url" : "name",
        "valueString" : "Initial Population"
      },
      {
        "url" : "statement",
        "valueString" : "define \"Initial Population\":\n  \"Qualifying Encounters\""
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 1
      }],
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "EXMRatio"
      },
      {
        "url" : "name",
        "valueString" : "Numerator"
      },
      {
        "url" : "statement",
        "valueString" : "define \"Numerator\":\n  \"Initial Population\""
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 2
      }],
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "EXMRatio"
      },
      {
        "url" : "name",
        "valueString" : "Denominator"
      },
      {
        "url" : "statement",
        "valueString" : "define \"Denominator\":\n  \"Initial Population\""
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 3
      }],
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "EXMRatio"
      },
      {
        "url" : "name",
        "valueString" : "Falls with Major Injury"
      },
      {
        "url" : "statement",
        "valueString" : "define \"Falls with Major Injury\":\n  [\"Observation\": \"Fall\"]"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 4
      }],
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "EXMRatio"
      },
      {
        "url" : "name",
        "valueString" : "Denominator Observation"
      },
      {
        "url" : "statement",
        "valueString" : "define function \"Denominator Observation\"(Encounter \"Encounter\"):\n  duration in hours of Global.Hospitalization(Encounter) / 24"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 5
      }],
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "MATGlobalCommonFunctions"
      },
      {
        "url" : "name",
        "valueString" : "Hospitalization"
      },
      {
        "url" : "statement",
        "valueString" : "define function \"Hospitalization\"(TheEncounter FHIR.Encounter):\n\t( \"ED Visit\"(TheEncounter) ) X\n    return\n        if X is null then TheEncounter.period\n        else Interval[start of FHIRHelpers.ToInterval(X.period), end of FHIRHelpers.ToInterval(TheEncounter.period)]"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 6
      }],
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "MATGlobalCommonFunctions"
      },
      {
        "url" : "name",
        "valueString" : "ED Visit"
      },
      {
        "url" : "statement",
        "valueString" : "define function \"ED Visit\"(TheEncounter FHIR.Encounter):\n    singleton from (\n        [Encounter: \"Emergency Department Visit\"] EDVisit\n            where EDVisit.status = 'finished'\n                and EDVisit.period ends 1 hour or less on or before start of FHIRHelpers.ToInterval(TheEncounter.period)\n    )"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 7
      }],
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "FHIRHelpers"
      },
      {
        "url" : "name",
        "valueString" : "ToString"
      },
      {
        "url" : "statement",
        "valueString" : "define function ToString(value EncounterStatus): value.value"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 8
      }],
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "FHIRHelpers"
      },
      {
        "url" : "name",
        "valueString" : "ToInterval"
      },
      {
        "url" : "statement",
        "valueString" : "/*\n@description: Converts the given [Period](https://hl7.org/fhir/datatypes.html#Period)\nvalue to a CQL DateTime Interval\n@comment: If the start value of the given period is unspecified, the starting\nboundary of the resulting interval will be open (meaning the start of the interval\nis unknown, as opposed to interpreted as the beginning of time).\n*/\ndefine function ToInterval(period FHIR.Period):\n    if period is null then\n        null\n    else\n        if period.\"start\" is null then\n            Interval(period.\"start\".value, period.\"end\".value]\n        else\n            Interval[period.\"start\".value, period.\"end\".value]"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 9
      }],
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "EXMRatio"
      },
      {
        "url" : "name",
        "valueString" : "Numerator Observation"
      },
      {
        "url" : "statement",
        "valueString" : "define function \"Numerator Observation\"(Encounter \"Encounter\"):\n  Count(\n    \"Falls with Major Injury\" Falls\n      where Global.\"Normalize Interval\"(Falls.effective) during Encounter.period\n  )"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 10
      }],
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "MATGlobalCommonFunctions"
      },
      {
        "url" : "name",
        "valueString" : "Normalize Interval"
      },
      {
        "url" : "statement",
        "valueString" : "/*\n*\n*    CQFMeasures Common Logic\n*\n*/\n\ndefine function \"Normalize Interval\"(choice Choice<FHIR.dateTime, FHIR.Period, FHIR.Timing, FHIR.instant, FHIR.string, FHIR.Age, FHIR.Range>):\n  case\n\t  when choice is FHIR.dateTime then\n    \tInterval[FHIRHelpers.ToDateTime(choice as FHIR.dateTime), FHIRHelpers.ToDateTime(choice as FHIR.dateTime)]\n\t\twhen choice is FHIR.Period then\n  \t\tFHIRHelpers.ToInterval(choice as FHIR.Period)\n\t\twhen choice is FHIR.instant then\n\t\t\tInterval[FHIRHelpers.ToDateTime(choice as FHIR.instant), FHIRHelpers.ToDateTime(choice as FHIR.instant)]\n\t\twhen choice is FHIR.Age then\n\t\t  Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(choice as FHIR.Age),\n\t\t\t  FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(choice as FHIR.Age) + 1 year)\n\t\twhen choice is FHIR.Range then\n\t\t  Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((choice as FHIR.Range).low),\n\t\t\t  FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((choice as FHIR.Range).high) + 1 year)\n\t\twhen choice is FHIR.Timing then\n\t\t  Message(null as Interval<DateTime>, true, '1', 'Error', 'Cannot compute a single interval from a Timing type')\n    when choice is FHIR.string then\n      Message(null as Interval<DateTime>, true, '1', 'Error', 'Cannot compute an interval from a String value')\n\t\telse\n\t\t\tnull as Interval<DateTime>\n\tend"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 11
      }],
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "FHIRHelpers"
      },
      {
        "url" : "name",
        "valueString" : "ToDateTime"
      },
      {
        "url" : "statement",
        "valueString" : "define function ToDateTime(value dateTime): value.value"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 12
      }],
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "FHIRHelpers"
      },
      {
        "url" : "name",
        "valueString" : "ToDateTime"
      },
      {
        "url" : "statement",
        "valueString" : "define function ToDateTime(value instant): value.value"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 13
      }],
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "FHIRHelpers"
      },
      {
        "url" : "name",
        "valueString" : "ToDate"
      },
      {
        "url" : "statement",
        "valueString" : "define function ToDate(value date): value.value"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 14
      }],
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "FHIRHelpers"
      },
      {
        "url" : "name",
        "valueString" : "ToQuantity"
      },
      {
        "url" : "statement",
        "valueString" : "/*\n@description: Converts the given FHIR [Quantity](https://hl7.org/fhir/datatypes.html#Quantity) \nvalue to a CQL Quantity\n@comment: If the given quantity has a comparator specified, a runtime error is raised. If the given quantity\nhas a system other than UCUM (i.e. `http://unitsofmeasure.org`) or CQL calendar units (i.e. `http://hl7.org/fhirpath/CodeSystem/calendar-units`)\nan error is raised. For UCUM to calendar units, the `ToCalendarUnit` function is used.\n@seealso: ToCalendarUnit\n*/\ndefine function ToQuantity(quantity FHIR.Quantity):\n    case\n        when quantity is null then null\n        when quantity.value is null then null\n        when quantity.comparator is not null then\n            Message(null, true, 'FHIRHelpers.ToQuantity.ComparatorQuantityNotSupported', 'Error', 'FHIR Quantity value has a comparator and cannot be converted to a System.Quantity value.')\n        when quantity.system is null or quantity.system.value = 'http://unitsofmeasure.org'\n              or quantity.system.value = 'http://hl7.org/fhirpath/CodeSystem/calendar-units' then\n            System.Quantity { value: quantity.value.value, unit: ToCalendarUnit(Coalesce(quantity.code.value, quantity.unit.value, '1')) }\n        else\n            Message(null, true, 'FHIRHelpers.ToQuantity.InvalidFHIRQuantity', 'Error', 'Invalid FHIR Quantity code: ' & quantity.unit.value & ' (' & quantity.system.value & '|' & quantity.code.value & ')')\n    end"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 15
      }],
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "FHIRHelpers"
      },
      {
        "url" : "name",
        "valueString" : "ToCalendarUnit"
      },
      {
        "url" : "statement",
        "valueString" : "/*\n@description: Converts a UCUM definite duration unit to a CQL calendar duration\nunit using conversions specified in the [quantities](https://cql.hl7.org/02-authorsguide.html#quantities) \ntopic of the CQL specification.\n@comment: Note that for durations above days (or weeks), the conversion is understood to be approximate\n*/\ndefine function ToCalendarUnit(unit System.String):\n    case unit\n        when 'ms' then 'millisecond'\n        when 's' then 'second'\n        when 'min' then 'minute'\n        when 'h' then 'hour'\n        when 'd' then 'day'\n        when 'wk' then 'week'\n        when 'mo' then 'month'\n        when 'a' then 'year'\n        else unit\n    end"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 16
      }],
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
    }],
    "name" : "EffectiveDataRequirements",
    "status" : "active",
    "type" : {
      "coding" : [{
        "system" : "http://terminology.hl7.org/CodeSystem/library-type",
        "code" : "module-definition"
      }]
    },
    "relatedArtifact" : [{
      "type" : "depends-on",
      "display" : "FHIR model information",
      "resource" : "http://hl7.org/fhir/uv/cql/Library/FHIR-ModelInfo|4.0.1"
    },
    {
      "type" : "depends-on",
      "display" : "Library Global",
      "resource" : "http://hl7.org/fhir/uv/cqm/Library/MATGlobalCommonFunctions|5.0.000"
    },
    {
      "type" : "depends-on",
      "display" : "Library FHIRHelpers",
      "resource" : "http://hl7.org/fhir/uv/cql/Library/FHIRHelpers|4.0.1"
    },
    {
      "type" : "depends-on",
      "display" : "Value set Inpatient",
      "resource" : "http://example.org/fhir/ValueSet/inpatient"
    },
    {
      "type" : "depends-on",
      "display" : "Value set Emergency Department Visit",
      "resource" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292"
    },
    {
      "type" : "depends-on",
      "display" : "Value set Fall",
      "resource" : "http://example.org/fhir/ValueSet/fall"
    }],
    "parameter" : [{
      "name" : "Numerator",
      "use" : "out",
      "min" : 0,
      "max" : "*",
      "type" : "Encounter"
    },
    {
      "name" : "Denominator",
      "use" : "out",
      "min" : 0,
      "max" : "*",
      "type" : "Encounter"
    },
    {
      "name" : "Initial Population",
      "use" : "out",
      "min" : 0,
      "max" : "*",
      "type" : "Encounter"
    }],
    "dataRequirement" : [{
      "type" : "Encounter",
      "profile" : ["http://hl7.org/fhir/StructureDefinition/Encounter"],
      "mustSupport" : ["type", "status", "period"],
      "codeFilter" : [{
        "path" : "type",
        "valueSet" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.292"
      }]
    },
    {
      "type" : "Encounter",
      "profile" : ["http://hl7.org/fhir/StructureDefinition/Encounter"],
      "mustSupport" : ["type", "period"],
      "codeFilter" : [{
        "path" : "type",
        "valueSet" : "http://example.org/fhir/ValueSet/inpatient"
      }]
    },
    {
      "type" : "Observation",
      "profile" : ["http://hl7.org/fhir/StructureDefinition/Observation"],
      "mustSupport" : ["code", "effective"],
      "codeFilter" : [{
        "path" : "code",
        "valueSet" : "http://example.org/fhir/ValueSet/fall"
      }]
    },
    {
      "type" : "Patient",
      "profile" : ["http://hl7.org/fhir/StructureDefinition/Patient"]
    }]
  }],
  "extension" : [{
    "url" : "http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-populationBasis",
    "valueCode" : "Encounter"
  },
  {
    "url" : "http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-scoringUnit",
    "valueCodeableConcept" : {
      "coding" : [{
        "system" : "http://unitsofmeasure.org",
        "code" : "/1000.d"
      }]
    }
  },
  {
    "url" : "http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-softwaresystem",
    "valueReference" : {
      "reference" : "Device/software-system-example"
    }
  },
  {
    "url" : "http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-effectiveDataRequirements",
    "valueCanonical" : "#effective-data-requirements"
  }],
  "url" : "http://example.org/fhir/measures/measure-ratio-exm",
  "identifier" : [{
    "system" : "http://example.org/fhir/cqi/ecqm/Measure/Identifier/exm",
    "value" : "EXMRatio-FHIR"
  },
  {
    "system" : "urn:ietf:rfc:3986",
    "value" : "urn:oid:2.16.840.1.113883.4.642.40.61.29.10"
  }],
  "version" : "2.0.0",
  "name" : "EXMRatioMeasure",
  "title" : "EXM Ratio Measure",
  "status" : "active",
  "experimental" : true,
  "date" : "2025-08-13",
  "publisher" : "HL7 International / Clinical Quality Information",
  "contact" : [{
    "telecom" : [{
      "system" : "url",
      "value" : "http://www.hl7.org/Special/committees/cqi"
    }]
  }],
  "description" : "An example FHIR-based publishable measure",
  "useContext" : [{
    "code" : {
      "system" : "http://terminology.hl7.org/CodeSystem/usage-context-type",
      "code" : "venue",
      "display" : "Clinical Venue"
    },
    "valueCodeableConcept" : {
      "coding" : [{
        "system" : "http://hl7.org/fhir/uv/cqm/CodeSystem/intended-venue-codes",
        "code" : "ec",
        "display" : "EC"
      }]
    }
  }],
  "jurisdiction" : [{
    "coding" : [{
      "system" : "http://unstats.un.org/unsd/methods/m49/m49.htm",
      "code" : "001"
    }]
  }],
  "purpose" : "This measure has been developed to support improvement in clinical care.",
  "usage" : "Users of this measure should be aware of...",
  "copyright" : "Example Copyright Statement",
  "approvalDate" : "2019-02-17",
  "lastReviewDate" : "2019-02-17",
  "effectivePeriod" : {
    "extension" : [{
      "url" : "http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-effectivePeriodAnchor",
      "valueDateTime" : "2018-01-01"
    },
    {
      "url" : "http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-effectivePeriodDuration",
      "valueDuration" : {
        "value" : 1,
        "system" : "http://unitsofmeasure.org",
        "code" : "a"
      }
    }],
    "start" : "2018-01-01",
    "end" : "2018-12-31"
  },
  "topic" : [{
    "coding" : [{
      "system" : "http://loinc.org",
      "code" : "57024-2"
    }],
    "text" : "Health Quality Measure Document"
  }],
  "author" : [{
    "name" : "Example Measure Content Developer"
  }],
  "library" : ["http://hl7.org/fhir/uv/cqm/Library/EXMRatio"],
  "disclaimer" : "Example disclaimer",
  "scoring" : {
    "coding" : [{
      "system" : "http://terminology.hl7.org/CodeSystem/measure-scoring",
      "code" : "ratio",
      "display" : "Ratio"
    }]
  },
  "type" : [{
    "coding" : [{
      "system" : "http://terminology.hl7.org/CodeSystem/measure-type",
      "code" : "process"
    }]
  }],
  "rationale" : "The rationale of this measure is...",
  "improvementNotation" : {
    "coding" : [{
      "system" : "http://terminology.hl7.org/CodeSystem/measure-improvement-notation",
      "code" : "decrease",
      "display" : "Decreased score indicates improvement"
    }]
  },
  "group" : [{
    "id" : "group-1",
    "extension" : [{
      "url" : "http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.group.linkId",
      "valueString" : "primary"
    }],
    "population" : [{
      "id" : "initial-population",
      "extension" : [{
        "url" : "http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.group.population.linkId",
        "valueString" : "primary-exmratio-initial-population"
      }],
      "code" : {
        "coding" : [{
          "system" : "http://terminology.hl7.org/CodeSystem/measure-population",
          "code" : "initial-population",
          "display" : "Initial Population"
        }]
      },
      "criteria" : {
        "language" : "text/cql-identifier",
        "expression" : "Initial Population"
      }
    },
    {
      "id" : "numerator",
      "extension" : [{
        "url" : "http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.group.population.linkId",
        "valueString" : "primary-exmratio-numerator"
      }],
      "code" : {
        "coding" : [{
          "system" : "http://terminology.hl7.org/CodeSystem/measure-population",
          "code" : "numerator",
          "display" : "Numerator"
        }]
      },
      "criteria" : {
        "language" : "text/cql-identifier",
        "expression" : "Numerator"
      }
    },
    {
      "id" : "denominator",
      "extension" : [{
        "url" : "http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.group.population.linkId",
        "valueString" : "primary-exmratio-denominator"
      }],
      "code" : {
        "coding" : [{
          "system" : "http://terminology.hl7.org/CodeSystem/measure-population",
          "code" : "denominator",
          "display" : "Denominator"
        }]
      },
      "criteria" : {
        "language" : "text/cql-identifier",
        "expression" : "Denominator"
      }
    },
    {
      "id" : "denominator-observation",
      "extension" : [{
        "url" : "http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.group.population.linkId",
        "valueString" : "primary-exmratio-denominator-observation"
      },
      {
        "url" : "http://hl7.org/fhir/StructureDefinition/cqf-criteriaReference",
        "valueString" : "denominator"
      },
      {
        "url" : "http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-aggregateMethod",
        "valueCode" : "sum"
      }],
      "code" : {
        "coding" : [{
          "system" : "http://terminology.hl7.org/CodeSystem/measure-population",
          "code" : "measure-observation",
          "display" : "Measure Observation"
        }]
      },
      "criteria" : {
        "language" : "text/cql-identifier",
        "expression" : "Denominator Observation"
      }
    },
    {
      "id" : "numerator-observation",
      "extension" : [{
        "url" : "http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.group.population.linkId",
        "valueString" : "primary-exmratio-numerator-observation"
      },
      {
        "url" : "http://hl7.org/fhir/StructureDefinition/cqf-criteriaReference",
        "valueString" : "numerator"
      },
      {
        "url" : "http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-aggregateMethod",
        "valueCode" : "sum"
      }],
      "code" : {
        "coding" : [{
          "system" : "http://terminology.hl7.org/CodeSystem/measure-population",
          "code" : "measure-observation",
          "display" : "Measure Observation"
        }]
      },
      "criteria" : {
        "language" : "text/cql-identifier",
        "expression" : "Numerator Observation"
      }
    }]
  }]
}

```
