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

## Measure: EXM Measure (Experimental) 

 
An example FHIR-based measure 

* Metadata: Title
  * ?: EXM Measure
* Metadata: Version
  * ?: 2.0.0
* Metadata: Identifier
  * ?: EXM
* Metadata: Identifier
  * ?: urn:oid:2.16.840.1.113883.4.642.40.61.29.9
* 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 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
  * ?: Continuous Variable
* Metadata: Measure Scoring Precision
  * ?: 2
* Metadata: Improvement Notation
  * ?: Increased 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: Risk Adjustment
  * ?: Risk adjustment for this measure is performed by...
* Metadata: Rate Aggregation
  * ?: Rate aggregation for this measure is performed by...
* Metadata: Rationale
  * ?: The purpose of this measure is to show how all the elements of a FHIR-based quality measure are represented.
* Metadata: Clinical Recommendation Statement
  * ?: The clinical recommendation statement for this measure is...
* Metadata: Guidance (Usage)
  * ?: Users of this measure should be aware that this is intentionally simplified to show specific aspects of a measure.
* Metadata: Measure Group (Rate) (ID: primary)
* Metadata: Stratifier
  * ?: **ID**: stratifier-1**Code**:Stratifier 1
* Metadata: Stratifier
  * ?: **ID**: stratifier-2**Code**:Stratifier 2
* Metadata: Stratifier
  * ?: **ID**: stratifier-3**Code**:Stratifier 3
* Metadata: Stratifier
  * ?: **ID**: stratifier-4**Code**:Stratifier 4
* Metadata: Supplemental Data Elements
* Metadata: Supplemental Data Element
  * ?: **ID**: sde-ethnicity**Usage Code**:Supplemental Data**Description**: No description provided**Logic Definition**:[SDE Ethnicity](#exmlogic-sde-ethnicity)
* Metadata: Supplemental Data Element
  * ?: **ID**: sde-race**Usage Code**:Supplemental Data**Description**: No description provided**Logic Definition**:[SDE Race](#exmlogic-sde-race)
* Metadata: Supplemental Data Element
  * ?: **ID**: sde-payer**Usage Code**:Supplemental Data**Description**: No description provided**Logic Definition**:[SDE Payer](#exmlogic-sde-payer)
* Metadata: Supplemental Data Element
  * ?: **ID**: sde-sex**Usage Code**:Supplemental Data**Description**: No description provided**Logic Definition**:[SDE Sex](#exmlogic-sde-sex)
* Metadata: Measure Logic
* Metadata: Primary Library
  * ?: [Example Logic Library](Library-EXMLogic.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: Stratifier
* Metadata: ````define "Stratifier 1" : "Inpatient Encounter" Encounter where not (PrincipalDiagnosis(Encounter).code in "Psychiatric/Mental Health Patient")````[**Definition**](#exmlogic-stratifier-1)
* Metadata: Stratifier
* Metadata: ````define "Stratifier 2" : "Inpatient Encounter" Encounter where PrincipalDiagnosis(Encounter).code in "Psychiatric/Mental Health Patient"````[**Definition**](#exmlogic-stratifier-2)
* Metadata: Stratifier
* Metadata: ````define "Stratifier 3" : "Inpatient Encounter" Encounter where PrincipalDiagnosis(Encounter) is null````[**Definition**](#exmlogic-stratifier-3)
* Metadata: Stratifier
* Metadata: ````define "Stratifier 4" : "Inpatient Encounter" Encounter where PrincipalDiagnosis(Encounter) is null````[**Definition**](#exmlogic-stratifier-4)
* Metadata:  Logic Definitions
* Metadata: Logic Definition
  * ?: **Library Name:**EXMLogic
* Metadata:  ````define "SDE Sex": case when Patient.gender = 'male' then Code { code: 'M', system: 'http://hl7.org/fhir/v3/AdministrativeGender', display: 'Male' } when Patient.gender = 'female' then Code { code: 'F', system: 'http://hl7.org/fhir/v3/AdministrativeGender', display: 'Female' } else null end````
* Metadata: Logic Definition
  * ?: **Library Name:**EXMLogic
* Metadata:  ````define "Inpatient Encounter" : ["Encounter"] Encounter where LengthInDays(Encounter.period) <= 120 and Encounter.period ends during "Measurement Period"````
* Metadata: Logic Definition
  * ?: **Library Name:**EXMLogic
* Metadata:  ````define "Stratifier 3" : "Inpatient Encounter" Encounter where PrincipalDiagnosis(Encounter) is null````
* Metadata: Logic Definition
  * ?: **Library Name:**EXMLogic
* Metadata:  ````define "Stratifier 4" : "Inpatient Encounter" Encounter where PrincipalDiagnosis(Encounter) is null````
* Metadata: Logic Definition
  * ?: **Library Name:**EXMLogic
* Metadata:  ````define "SDE Payer": [Coverage: type in "Payer"] Payer return { code: Payer.type, period: Payer.period }````
* Metadata: Logic Definition
  * ?: **Library Name:**EXMLogic
* Metadata:  ````define "Initial Population" : "Inpatient Encounter" Encounter````
* Metadata: Logic Definition
  * ?: **Library Name:**EXMLogic
* Metadata:  ````define "SDE Ethnicity": (flatten ( Patient.extension Extension where Extension.url = 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity' return Extension.extension )) E where E.url = 'ombCategory' or E.url = 'detailed' return E.value as Coding````
* Metadata: Logic Definition
  * ?: **Library Name:**EXMLogic
* Metadata:  ````define "SDE Race": (flatten ( Patient.extension Extension where Extension.url = 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-race' return Extension.extension )) E where E.url = 'ombCategory' or E.url = 'detailed' return E.value as Coding````
* Metadata: Logic Definition
  * ?: **Library Name:**EXMLogic
* Metadata:  ````define "Measure Population" : "Initial Population"````
* Metadata: Logic Definition
  * ?: **Library Name:**EXMLogic
* Metadata:  ````define "Stratifier 1" : "Inpatient Encounter" Encounter where not (PrincipalDiagnosis(Encounter).code in "Psychiatric/Mental Health Patient")````
* Metadata: Logic Definition
  * ?: **Library Name:**EXMLogic
* Metadata:  ````define "Stratifier 2" : "Inpatient Encounter" Encounter where PrincipalDiagnosis(Encounter).code in "Psychiatric/Mental Health Patient"````
* Metadata: Logic Definition
  * ?: **Library Name:**EXMLogic
* Metadata:  ````define function "LengthInDays"(Value Interval<DateTime>): difference in days between start of Value and end of Value````
* Metadata: Logic Definition
  * ?: **Library Name:**EXMLogic
* Metadata:  ````define function "PrincipalDiagnosis"(Encounter Encounter): (singleton from (Encounter.diagnosis D where D.use ~ ToConcept("Billing") and D.rank.value = 1)) PD return singleton from ([Condition: id in "GetId"(PD.condition.reference)])````
* Metadata: Logic Definition
  * ?: **Library Name:**EXMLogic
* Metadata:  ````define function "GetId"(uri String): Last(Split(uri, '/'))````
* Metadata: Logic Definition
  * ?: **Library Name:**EXMLogic
* Metadata:  ````define function "Measure Observation" (Encounter "Encounter" ) : duration in minutes of "Related ED Visit"(Encounter).period````
* Metadata: Logic Definition
  * ?: **Library Name:**EXMLogic
* Metadata:  ````//Measure Observation define function "Related ED Visit" (Encounter "Encounter" ) : Last(["Encounter" : "Emergency Department Visit"] ED where ED.status = 'finished' and ED.period ends 1 hour or less before start of Encounter.period sort by start of period )````
* Metadata: Logic Definition
  * ?: **Library Name:**FHIRHelpers
* Metadata:  ````define function ToString(value AdministrativeGender): 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:  ````/* @description: Converts the given FHIR [CodeableConcept](https://hl7.org/fhir/datatypes.html#CodeableConcept) value to a CQL Concept. */ define function ToConcept(concept FHIR.CodeableConcept): if concept is null then null else System.Concept { codes: concept.coding C return ToCode(C), display: concept.text.value }````
* Metadata: Logic Definition
  * ?: **Library Name:**FHIRHelpers
* Metadata:  ````/* @description: Converts the given FHIR [Coding](https://hl7.org/fhir/datatypes.html#Coding) value to a CQL Code. */ define function ToCode(coding FHIR.Coding): if coding is null then null else System.Code { code: coding.code.value, system: coding.system.value, version: coding.version.value, display: coding.display.value }````
* Metadata: Logic Definition
  * ?: **Library Name:**FHIRHelpers
* Metadata:  ````define function ToString(value string): value.value````
* Metadata: Logic Definition
  * ?: **Library Name:**FHIRHelpers
* Metadata:  ````define function ToString(value uri): value.value````
* Metadata: Logic Definition
  * ?: **Library Name:**FHIRHelpers
* Metadata:  ````define function ToString(value EncounterStatus): value.value````
* Metadata:  Terminology
* Metadata: Code System
  * ?: **Description**: Code system Diagnosis Role**Resource**:[Diagnosis Role](http://terminology.hl7.org/7.1.0/CodeSystem-diagnosis-role.html)**Canonical URL**:http://terminology.hl7.org/CodeSystem/diagnosis-role
* Metadata: Value Set
  * ?: **Description**: Value set Payer**Resource**:[Payer Type](https://vsac.nlm.nih.gov/valueset/2.16.840.1.114222.4.11.3591/expansion)**Canonical URL**:http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591
* 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 Psychiatric/Mental Health Patient**Resource**:[Psychiatric/Mental Health Diagnosis](https://vsac.nlm.nih.gov/valueset/2.16.840.1.113883.3.117.1.7.1.299/expansion)**Canonical URL**:http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.299
* Metadata: Direct Reference Code
  * ?: **Display**: Billing**Code**: billing**System**:http://terminology.hl7.org/CodeSystem/diagnosis-role
* 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 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**: Patient**Profile(s)**:[Patient](http://hl7.org/fhir/R4/patient.html)**Must Support Elements**: url, extension, value
* Metadata: Data Requirement
  * ?: **Type**: Encounter**Profile(s)**:[Encounter](http://hl7.org/fhir/R4/encounter.html)**Must Support Elements**: type, status, period, use, rank, rank.value, condition, condition.reference**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**: period, use, rank, rank.value, condition, condition.reference
* Metadata: Data Requirement
  * ?: **Type**: Condition**Profile(s)**:[Condition](http://hl7.org/fhir/R4/condition.html)**Must Support Elements**: id**Code Filter(s)**:**Path**: id
* Metadata: Data Requirement
  * ?: **Type**: Coverage**Profile(s)**:[Coverage](http://hl7.org/fhir/R4/coverage.html)**Must Support Elements**: type, period**Code Filter(s)**:**Path**: type**ValueSet**:[Payer Type](https://vsac.nlm.nih.gov/valueset/2.16.840.1.114222.4.11.3591/expansion)
* Metadata:  Parameters
* Metadata: 
  * ?: 
| | | | | |
| :--- | :--- | :--- | :--- | :--- |
| **Name** | **Use** | **Card.** | **Type** | **Documentation** |
| Measurement Period | In | 0..1 | Period |  |
| SDE Sex | Out | 0..1 | Coding |  |
| Stratifier 3 | Out | 0..* | Encounter |  |
| Stratifier 4 | Out | 0..* | Encounter |  |
| SDE Payer | Out | 0..* | Resource |  |
| Initial Population | Out | 0..* | Encounter |  |
| SDE Ethnicity | Out | 0..* | Coding |  |
| SDE Race | Out | 0..* | Coding |  |
| Measure Population | Out | 0..* | Encounter |  |
| Stratifier 1 | Out | 0..* | Encounter |  |
| Stratifier 2 | Out | 0..* | Encounter |  |

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



## Resource Content

```json
{
  "resourceType" : "Measure",
  "id" : "EXMLogic-FHIR",
  "meta" : {
    "profile" : ["http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-cvmeasure",
    "http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-computablemeasure",
    "http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-executablemeasure",
    "http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-cqlmeasure",
    "http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-elmmeasure",
    "http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-computablemeasure"]
  },
  "contained" : [{
    "resourceType" : "Library",
    "id" : "effective-data-requirements",
    "extension" : [{
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode",
      "valueCoding" : {
        "system" : "http://terminology.hl7.org/CodeSystem/diagnosis-role",
        "code" : "billing",
        "display" : "Billing"
      }
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "EXMLogic"
      },
      {
        "url" : "name",
        "valueString" : "SDE Sex"
      },
      {
        "url" : "statement",
        "valueString" : "define \"SDE Sex\":\n  case\n    when Patient.gender = 'male' then Code { code: 'M', system: 'http://hl7.org/fhir/v3/AdministrativeGender', display: 'Male' }\n    when Patient.gender = 'female' then Code { code: 'F', system: 'http://hl7.org/fhir/v3/AdministrativeGender', display: 'Female' }\n    else null\n  end"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 0
      }],
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "EXMLogic"
      },
      {
        "url" : "name",
        "valueString" : "Inpatient Encounter"
      },
      {
        "url" : "statement",
        "valueString" : "define \"Inpatient Encounter\" :\n  [\"Encounter\"] Encounter\n    where LengthInDays(Encounter.period) <= 120\n      and Encounter.period ends during \"Measurement Period\""
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 1
      }],
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "EXMLogic"
      },
      {
        "url" : "name",
        "valueString" : "Stratifier 3"
      },
      {
        "url" : "statement",
        "valueString" : "define \"Stratifier 3\" :\n  \"Inpatient Encounter\" Encounter\n    where PrincipalDiagnosis(Encounter) is null"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 2
      }],
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "EXMLogic"
      },
      {
        "url" : "name",
        "valueString" : "Stratifier 4"
      },
      {
        "url" : "statement",
        "valueString" : "define \"Stratifier 4\" :\n  \"Inpatient Encounter\" Encounter\n    where PrincipalDiagnosis(Encounter) is null"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 3
      }],
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "EXMLogic"
      },
      {
        "url" : "name",
        "valueString" : "SDE Payer"
      },
      {
        "url" : "statement",
        "valueString" : "define \"SDE Payer\":\n    [Coverage: type in \"Payer\"] Payer\n      return {\n        code: Payer.type,\n        period: Payer.period\n      }"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 4
      }],
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "EXMLogic"
      },
      {
        "url" : "name",
        "valueString" : "Initial Population"
      },
      {
        "url" : "statement",
        "valueString" : "define \"Initial Population\" :\n  \"Inpatient Encounter\" Encounter"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 5
      }],
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "EXMLogic"
      },
      {
        "url" : "name",
        "valueString" : "SDE Ethnicity"
      },
      {
        "url" : "statement",
        "valueString" : "define \"SDE Ethnicity\":\n  (flatten (\n    Patient.extension Extension\n      where Extension.url = 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity'\n        return Extension.extension\n  )) E\n    where E.url = 'ombCategory'\n      or E.url = 'detailed'\n    return E.value as Coding"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 6
      }],
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "EXMLogic"
      },
      {
        "url" : "name",
        "valueString" : "SDE Race"
      },
      {
        "url" : "statement",
        "valueString" : "define \"SDE Race\":\n  (flatten (\n    Patient.extension Extension\n      where Extension.url = 'http://hl7.org/fhir/us/core/StructureDefinition/us-core-race'\n        return Extension.extension\n  )) E\n    where E.url = 'ombCategory'\n      or E.url = 'detailed'\n    return E.value as Coding"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 7
      }],
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "EXMLogic"
      },
      {
        "url" : "name",
        "valueString" : "Measure Population"
      },
      {
        "url" : "statement",
        "valueString" : "define \"Measure Population\" :\n  \"Initial Population\""
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 8
      }],
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "EXMLogic"
      },
      {
        "url" : "name",
        "valueString" : "Stratifier 1"
      },
      {
        "url" : "statement",
        "valueString" : "define \"Stratifier 1\" :\n  \"Inpatient Encounter\" Encounter\n    where not (PrincipalDiagnosis(Encounter).code in \"Psychiatric/Mental Health Patient\")"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 9
      }],
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "EXMLogic"
      },
      {
        "url" : "name",
        "valueString" : "Stratifier 2"
      },
      {
        "url" : "statement",
        "valueString" : "define \"Stratifier 2\" :\n  \"Inpatient Encounter\" Encounter\n    where PrincipalDiagnosis(Encounter).code in \"Psychiatric/Mental Health Patient\""
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 10
      }],
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "FHIRHelpers"
      },
      {
        "url" : "name",
        "valueString" : "ToString"
      },
      {
        "url" : "statement",
        "valueString" : "define function ToString(value AdministrativeGender): value.value"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 11
      }],
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "EXMLogic"
      },
      {
        "url" : "name",
        "valueString" : "LengthInDays"
      },
      {
        "url" : "statement",
        "valueString" : "define function \"LengthInDays\"(Value Interval<DateTime>):\n\tdifference in days between start of Value and end of Value"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 12
      }],
      "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" : 13
      }],
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "EXMLogic"
      },
      {
        "url" : "name",
        "valueString" : "PrincipalDiagnosis"
      },
      {
        "url" : "statement",
        "valueString" : "define function \"PrincipalDiagnosis\"(Encounter Encounter):\n\t(singleton from (Encounter.diagnosis D where D.use ~ ToConcept(\"Billing\") and D.rank.value = 1)) PD\n\t\treturn singleton from ([Condition: id in \"GetId\"(PD.condition.reference)])"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 14
      }],
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "FHIRHelpers"
      },
      {
        "url" : "name",
        "valueString" : "ToConcept"
      },
      {
        "url" : "statement",
        "valueString" : "/*\n@description: Converts the given FHIR [CodeableConcept](https://hl7.org/fhir/datatypes.html#CodeableConcept) value to a CQL Concept.\n*/\ndefine function ToConcept(concept FHIR.CodeableConcept):\n    if concept is null then\n        null\n    else\n        System.Concept {\n            codes: concept.coding C return ToCode(C),\n            display: concept.text.value\n        }"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 15
      }],
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "FHIRHelpers"
      },
      {
        "url" : "name",
        "valueString" : "ToCode"
      },
      {
        "url" : "statement",
        "valueString" : "/*\n@description: Converts the given FHIR [Coding](https://hl7.org/fhir/datatypes.html#Coding) value to a CQL Code.\n*/\ndefine function ToCode(coding FHIR.Coding):\n    if coding is null then\n        null\n    else\n        System.Code {\n          code: coding.code.value,\n          system: coding.system.value,\n          version: coding.version.value,\n          display: coding.display.value\n        }"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 16
      }],
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "EXMLogic"
      },
      {
        "url" : "name",
        "valueString" : "GetId"
      },
      {
        "url" : "statement",
        "valueString" : "define function \"GetId\"(uri String):\n\tLast(Split(uri, '/'))"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 17
      }],
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "FHIRHelpers"
      },
      {
        "url" : "name",
        "valueString" : "ToString"
      },
      {
        "url" : "statement",
        "valueString" : "define function ToString(value string): value.value"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 18
      }],
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "FHIRHelpers"
      },
      {
        "url" : "name",
        "valueString" : "ToString"
      },
      {
        "url" : "statement",
        "valueString" : "define function ToString(value uri): value.value"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 19
      }],
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "EXMLogic"
      },
      {
        "url" : "name",
        "valueString" : "Measure Observation"
      },
      {
        "url" : "statement",
        "valueString" : "define function \"Measure Observation\" (Encounter \"Encounter\" ) :\n  duration in minutes of \"Related ED Visit\"(Encounter).period"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 20
      }],
      "url" : "http://hl7.org/fhir/StructureDefinition/cqf-logicDefinition"
    },
    {
      "extension" : [{
        "url" : "libraryName",
        "valueString" : "EXMLogic"
      },
      {
        "url" : "name",
        "valueString" : "Related ED Visit"
      },
      {
        "url" : "statement",
        "valueString" : "//Measure Observation\ndefine function \"Related ED Visit\" (Encounter \"Encounter\" ) :\n  Last([\"Encounter\" : \"Emergency Department Visit\"] ED\n    where ED.status = 'finished'\n      and ED.period ends 1 hour or less before start of Encounter.period\n    sort by start of period )"
      },
      {
        "url" : "displaySequence",
        "valueInteger" : 21
      }],
      "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" : 22
      }],
      "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 FHIRHelpers",
      "resource" : "http://hl7.org/fhir/uv/cql/Library/FHIRHelpers|4.0.1"
    },
    {
      "type" : "depends-on",
      "display" : "Code system Diagnosis Role",
      "resource" : "http://terminology.hl7.org/CodeSystem/diagnosis-role"
    },
    {
      "type" : "depends-on",
      "display" : "Value set Payer",
      "resource" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591"
    },
    {
      "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 Psychiatric/Mental Health Patient",
      "resource" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.113883.3.117.1.7.1.299"
    }],
    "parameter" : [{
      "name" : "Measurement Period",
      "use" : "in",
      "min" : 0,
      "max" : "1",
      "type" : "Period"
    },
    {
      "name" : "SDE Sex",
      "use" : "out",
      "min" : 0,
      "max" : "1",
      "type" : "Coding"
    },
    {
      "name" : "Stratifier 3",
      "use" : "out",
      "min" : 0,
      "max" : "*",
      "type" : "Encounter"
    },
    {
      "name" : "Stratifier 4",
      "use" : "out",
      "min" : 0,
      "max" : "*",
      "type" : "Encounter"
    },
    {
      "name" : "SDE Payer",
      "use" : "out",
      "min" : 0,
      "max" : "*",
      "type" : "Resource"
    },
    {
      "name" : "Initial Population",
      "use" : "out",
      "min" : 0,
      "max" : "*",
      "type" : "Encounter"
    },
    {
      "name" : "SDE Ethnicity",
      "use" : "out",
      "min" : 0,
      "max" : "*",
      "type" : "Coding"
    },
    {
      "name" : "SDE Race",
      "use" : "out",
      "min" : 0,
      "max" : "*",
      "type" : "Coding"
    },
    {
      "name" : "Measure Population",
      "use" : "out",
      "min" : 0,
      "max" : "*",
      "type" : "Encounter"
    },
    {
      "name" : "Stratifier 1",
      "use" : "out",
      "min" : 0,
      "max" : "*",
      "type" : "Encounter"
    },
    {
      "name" : "Stratifier 2",
      "use" : "out",
      "min" : 0,
      "max" : "*",
      "type" : "Encounter"
    }],
    "dataRequirement" : [{
      "type" : "Patient",
      "profile" : ["http://hl7.org/fhir/StructureDefinition/Patient"],
      "mustSupport" : ["url", "extension", "value"]
    },
    {
      "type" : "Encounter",
      "profile" : ["http://hl7.org/fhir/StructureDefinition/Encounter"],
      "mustSupport" : ["type",
      "status",
      "period",
      "use",
      "rank",
      "rank.value",
      "condition",
      "condition.reference"],
      "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" : ["period",
      "use",
      "rank",
      "rank.value",
      "condition",
      "condition.reference"]
    },
    {
      "type" : "Condition",
      "profile" : ["http://hl7.org/fhir/StructureDefinition/Condition"],
      "mustSupport" : ["id"],
      "codeFilter" : [{
        "path" : "id"
      }]
    },
    {
      "type" : "Coverage",
      "profile" : ["http://hl7.org/fhir/StructureDefinition/Coverage"],
      "mustSupport" : ["type", "period"],
      "codeFilter" : [{
        "path" : "type",
        "valueSet" : "http://cts.nlm.nih.gov/fhir/ValueSet/2.16.840.1.114222.4.11.3591"
      }]
    }]
  }],
  "extension" : [{
    "extension" : [{
      "url" : "type",
      "valueCode" : "documentation"
    },
    {
      "url" : "text",
      "valueMarkdown" : "This illustrates an example comment"
    }],
    "url" : "http://hl7.org/fhir/StructureDefinition/cqf-artifactComment"
  },
  {
    "url" : "http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-populationBasis",
    "valueCode" : "Encounter"
  },
  {
    "url" : "http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-softwaresystem",
    "valueReference" : {
      "reference" : "Device/software-system-example"
    }
  },
  {
    "url" : "http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-scoringPrecision",
    "valuePositiveInt" : 2
  },
  {
    "url" : "http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-effectiveDataRequirements",
    "valueCanonical" : "#effective-data-requirements"
  }],
  "url" : "http://hl7.org/fhir/uv/cqm/Measure/EXMLogic-FHIR",
  "identifier" : [{
    "system" : "http://example.org/fhir/cqi/ecqm/Measure/Identifier/exm",
    "value" : "EXM"
  },
  {
    "system" : "urn:ietf:rfc:3986",
    "value" : "urn:oid:2.16.840.1.113883.4.642.40.61.29.9"
  }],
  "version" : "2.0.0",
  "name" : "MeasureEXM",
  "title" : "EXM 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 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 that this is intentionally simplified to show specific aspects of a measure.",
  "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/EXMLogic"],
  "disclaimer" : "Example disclaimer",
  "scoring" : {
    "coding" : [{
      "system" : "http://terminology.hl7.org/CodeSystem/measure-scoring",
      "code" : "continuous-variable",
      "display" : "Continuous Variable"
    }]
  },
  "type" : [{
    "coding" : [{
      "system" : "http://terminology.hl7.org/CodeSystem/measure-type",
      "code" : "process"
    }]
  }],
  "riskAdjustment" : "Risk adjustment for this measure is performed by...",
  "rateAggregation" : "Rate aggregation for this measure is performed by...",
  "rationale" : "The purpose of this measure is to show how all the elements of a FHIR-based quality measure are represented.",
  "clinicalRecommendationStatement" : "The clinical recommendation statement for this measure is...",
  "improvementNotation" : {
    "coding" : [{
      "system" : "http://terminology.hl7.org/CodeSystem/measure-improvement-notation",
      "code" : "increase",
      "display" : "Increased score indicates improvement"
    }]
  },
  "guidance" : "Additional guidance provided to help communicate the intent of the measure",
  "group" : [{
    "id" : "group-1",
    "extension" : [{
      "url" : "http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.group.linkId",
      "valueString" : "primary"
    }],
    "code" : {
      "coding" : [{
        "system" : "http://example.org/group",
        "code" : "group",
        "display" : "group-1"
      }]
    },
    "population" : [{
      "id" : "initial-population-1",
      "extension" : [{
        "url" : "http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.group.population.linkId",
        "valueString" : "primary-exmlogic-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" : "measure-population",
      "extension" : [{
        "url" : "http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.group.population.linkId",
        "valueString" : "primary-exmlogic-measure-population"
      }],
      "code" : {
        "coding" : [{
          "system" : "http://terminology.hl7.org/CodeSystem/measure-population",
          "code" : "measure-population",
          "display" : "Measure Population"
        }]
      },
      "criteria" : {
        "language" : "text/cql-identifier",
        "expression" : "Measure Population"
      }
    },
    {
      "id" : "measure-observation",
      "extension" : [{
        "url" : "http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.group.population.linkId",
        "valueString" : "primary-exmlogic-measure-observation"
      },
      {
        "url" : "http://hl7.org/fhir/StructureDefinition/cqf-criteriaReference",
        "valueString" : "measure-population"
      },
      {
        "url" : "http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-aggregateMethod",
        "valueCode" : "median"
      }],
      "code" : {
        "coding" : [{
          "system" : "http://terminology.hl7.org/CodeSystem/measure-population",
          "code" : "measure-observation",
          "display" : "Measure Observation"
        }]
      },
      "criteria" : {
        "language" : "text/cql-identifier",
        "expression" : "Measure Observation"
      }
    }],
    "stratifier" : [{
      "id" : "stratifier-1",
      "extension" : [{
        "url" : "http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.group.stratifier.linkId",
        "valueString" : "primary-exmlogic-stratification-1"
      },
      {
        "url" : "http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-appliesTo",
        "valueCodeableConcept" : {
          "coding" : [{
            "system" : "http://terminology.hl7.org/CodeSystem/measure-population",
            "code" : "initial-population",
            "display" : "Initial Population"
          }],
          "text" : "initial-population"
        }
      }],
      "code" : {
        "text" : "Stratifier 1"
      },
      "criteria" : {
        "language" : "text/cql-identifier",
        "expression" : "Stratifier 1"
      }
    },
    {
      "id" : "stratifier-2",
      "extension" : [{
        "url" : "http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.group.stratifier.linkId",
        "valueString" : "primary-exmlogic-stratification-2"
      },
      {
        "url" : "http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-appliesTo",
        "valueCodeableConcept" : {
          "coding" : [{
            "system" : "http://terminology.hl7.org/CodeSystem/measure-population",
            "code" : "initial-population",
            "display" : "Initial Population"
          }],
          "text" : "initial-population"
        }
      }],
      "code" : {
        "text" : "Stratifier 2"
      },
      "criteria" : {
        "language" : "text/cql-identifier",
        "expression" : "Stratifier 2"
      }
    },
    {
      "id" : "stratifier-3",
      "extension" : [{
        "url" : "http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.group.stratifier.linkId",
        "valueString" : "primary-exmlogic-stratification-3"
      },
      {
        "url" : "http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-appliesTo",
        "valueCodeableConcept" : {
          "coding" : [{
            "system" : "http://terminology.hl7.org/CodeSystem/measure-population",
            "code" : "initial-population",
            "display" : "Initial Population"
          }],
          "text" : "initial-population"
        }
      }],
      "code" : {
        "text" : "Stratifier 3"
      },
      "criteria" : {
        "language" : "text/cql-identifier",
        "expression" : "Stratifier 3"
      }
    },
    {
      "id" : "stratifier-4",
      "extension" : [{
        "url" : "http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.group.stratifier.linkId",
        "valueString" : "primary-exmlogic-stratification-4"
      },
      {
        "url" : "http://hl7.org/fhir/uv/cqm/StructureDefinition/cqm-appliesTo",
        "valueCodeableConcept" : {
          "coding" : [{
            "system" : "http://terminology.hl7.org/CodeSystem/measure-population",
            "code" : "initial-population",
            "display" : "Initial Population"
          }],
          "text" : "initial-population"
        }
      }],
      "code" : {
        "text" : "Stratifier 4"
      },
      "criteria" : {
        "language" : "text/cql-identifier",
        "expression" : "Stratifier 4"
      }
    }]
  }],
  "supplementalData" : [{
    "id" : "sde-ethnicity",
    "extension" : [{
      "url" : "http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.supplementalData.linkId",
      "valueString" : "primary-sde-ethnicity"
    }],
    "usage" : [{
      "coding" : [{
        "system" : "http://terminology.hl7.org/CodeSystem/measure-data-usage",
        "code" : "supplemental-data"
      }]
    }],
    "criteria" : {
      "language" : "text/cql-identifier",
      "expression" : "SDE Ethnicity"
    }
  },
  {
    "id" : "sde-race",
    "extension" : [{
      "url" : "http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.supplementalData.linkId",
      "valueString" : "primary-sde-race"
    }],
    "usage" : [{
      "coding" : [{
        "system" : "http://terminology.hl7.org/CodeSystem/measure-data-usage",
        "code" : "supplemental-data"
      }]
    }],
    "criteria" : {
      "language" : "text/cql-identifier",
      "expression" : "SDE Race"
    }
  },
  {
    "id" : "sde-payer",
    "extension" : [{
      "url" : "http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.supplementalData.linkId",
      "valueString" : "primary-sde-payer"
    }],
    "usage" : [{
      "coding" : [{
        "system" : "http://terminology.hl7.org/CodeSystem/measure-data-usage",
        "code" : "supplemental-data"
      }]
    }],
    "criteria" : {
      "language" : "text/cql-identifier",
      "expression" : "SDE Payer"
    }
  },
  {
    "id" : "sde-sex",
    "extension" : [{
      "url" : "http://hl7.org/fhir/5.0/StructureDefinition/extension-Measure.supplementalData.linkId",
      "valueString" : "primary-sde-sex"
    }],
    "usage" : [{
      "coding" : [{
        "system" : "http://terminology.hl7.org/CodeSystem/measure-data-usage",
        "code" : "supplemental-data"
      }]
    }],
    "criteria" : {
      "language" : "text/cql-identifier",
      "expression" : "SDE Sex"
    }
  }]
}

```
