<Library xmlns="http://hl7.org/fhir">
   <id value="Status"></id>
   <meta>
      <profile value="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-shareablelibrary"></profile>
      <profile value="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-computablelibrary"></profile>
      <profile value="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-publishablelibrary"></profile>
      <profile value="http://hl7.org/fhir/uv/crmi/StructureDefinition/crmi-executablelibrary"></profile>
      <profile value="http://hl7.org/fhir/uv/cql/StructureDefinition/cql-library"></profile>
      <profile value="http://hl7.org/fhir/uv/cql/StructureDefinition/elm-json-library"></profile>
      <profile value="http://hl7.org/fhir/uv/cql/StructureDefinition/elm-xml-library"></profile>
   </meta>
   <language value="en"></language>
   <text>
      <status value="extensions"></status>
      <div xmlns="http://www.w3.org/1999/xhtml" class="col-12"> 
         <table class="narrative-table"> 
            <tbody> 
               <tr> 
                  <th colspan="2" scope="row" class="row-header">Metadata</th> 
               </tr> 
               <tr> 
                  <th scope="row" class="row-header">Title</th> 
                  <td class="content-container">Status</td> 
               </tr> 
               <tr> 
                  <th scope="row" class="row-header">Version</th> 
                  <td class="content-container">1.15.000</td> 
               </tr> 
               <tr> 
                  <th scope="row" class="row-header">Identifier</th> 
                  <td class="content-container">684c4d910d70b65363c69edf</td> 
               </tr> 
               <tr> 
                  <th scope="row" class="row-header">Steward (Publisher)</th> 
                  <td class="content-container">National Committee for Quality Assurance</td> 
               </tr> 
               <tr> 
                  <th scope="row" class="row-header">Description</th> 
                  <td class="content-container">This library contains functions used to constrain FHIR resource elements for measures authored by NCQA, based on QICore 6.0.0 resources including IG and authoring patterns. The functions may appear similar to some QICoreCommon functions but differ in that they have constraints that are relevant for measures authored by NCQA.</td> 
               </tr> 
               <tr> 
                  <th scope="row" class="row-header">Type</th> 
                  <td class="content-container">[http://terminology.hl7.org/CodeSystem/library-type#logic-library]</td> 
               </tr> 
               <tr> 
                  <th colspan="2" scope="row" class="row-header">Library Content</th> 
               </tr>  
               <tr> 
                  <th scope="row" class="row-header">CQL Content</th> 
                  <td> 
                     <pre style="border: none;" class="content-container highlight language-cql"><code class="language-cql">library Status version '1.15.000'

using QICore version '6.0.0'

include FHIRHelpers version '4.4.000' called FHIRHelpers

codesystem "ObservationCategoryCodes": 'http://terminology.hl7.org/CodeSystem/observation-category'
codesystem "ConditionVerificationStatusCodes": 'http://terminology.hl7.org/CodeSystem/condition-ver-status'

code "exam": 'exam' from "ObservationCategoryCodes" display 'exam'
code "imaging": 'imaging' from "ObservationCategoryCodes" display 'imaging'
code "confirmed": 'confirmed' from ConditionVerificationStatusCodes display 'confirmed'
code "unconfirmed": 'unconfirmed' from ConditionVerificationStatusCodes display 'unconfirmed'
code "provisional": 'provisional' from ConditionVerificationStatusCodes display 'provisional'
code "differential": 'differential' from ConditionVerificationStatusCodes display 'differential'

context Patient

//This library contains functions used to constrain FHIR resource elements for measures authored by NCQA, based on QICore 6.0.0 resources including IG and authoring patterns. The functions may appear similar to some QICoreCommon functions but differ in that they have constraints that are relevant for measures authored by NCQA.

//Condition
//Returns conditions in the given list that either have no verification status or have a verification status of confirmed, unconfirmed, provisional, or differential
define fluent function verified(conditions List&lt;Choice&lt;ConditionProblemsHealthConcerns, ConditionEncounterDiagnosis&gt;&gt;):
  conditions C
    where C.verificationStatus is not null implies
      (C.verificationStatus ~ "confirmed"
        or C.verificationStatus ~ "unconfirmed"
        or C.verificationStatus ~ "provisional"
        or C.verificationStatus ~ "differential"
      )

//Assessment, Performed
define fluent function isAssessmentPerformed(Obs List&lt;ObservationScreeningAssessment&gt;):
  Obs O
    where O.status in { 'final', 'amended', 'corrected' }

//Device, Order - Personal Use Devices
define fluent function isDeviceOrderPersonalUseDevices(DeviceRequest List&lt;DeviceRequest&gt;):
  DeviceRequest D
    where D.status in { 'active', 'completed' }
      and D.intent in {'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order'}

//Diagnostic Study, Order
define fluent function isDiagnosticStudyOrder(ServiceRequest List&lt;ServiceRequest&gt;):
  ServiceRequest S
    where S.status in { 'active', 'completed' }
      and S.intent in {'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order'}
      
//Intervention, Order
define fluent function isInterventionOrder(ServiceRequest List&lt;ServiceRequest&gt;):
  ServiceRequest S
    where S.status in { 'active', 'completed' }
      and S.intent in {'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order'}    

//Laboratory Test, Order
define fluent function isLaboratoryTestOrder(ServiceRequest List&lt;ServiceRequest&gt;):
  ServiceRequest S
    where S.status in { 'active', 'completed' }
      and S.intent in {'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order'}       

//Diagnostic Study, Performed
define fluent function isDiagnosticStudyPerformed(Obs List&lt;ObservationClinicalResult&gt;):
  Obs O
    where O.status in { 'final', 'amended', 'corrected' }
        and exists ( O.category ObservationCategory
        where ( ObservationCategory ) ~ "imaging"
    )
    
//Encounter, Performed
//General usage unless required otherwise by measure intent (e.g., follow-up encounters)
define fluent function isEncounterPerformed(Enc List&lt;Encounter&gt;):
  Enc E
    where E.status = 'finished'

//Immunization, Administered
define fluent function isImmunizationAdministered(Immunization List&lt;Immunization&gt;):
  Immunization I
    where I.status ~ 'completed'

//Intervention, Performed
define fluent function isInterventionPerformed(Proc List&lt;Procedure&gt;):
  Proc P
    where P.status ~ 'completed'

//Procedure, Performed
define fluent function isProcedurePerformed(Proc List&lt;Procedure&gt;):
  Proc P
    where P.status ~ 'completed'

//Laboratory Test, Performed
define fluent function isLaboratoryTestPerformed(Obs List&lt;LaboratoryResultObservation&gt;):
  Obs O
    where O.status in { 'final', 'amended', 'corrected' }

//Medication, Active
define fluent function isMedicationActive(MedicationRequest List&lt;MedicationRequest&gt;):
  MedicationRequest M
    where M.status = 'active'
      and M.intent in {'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order'}

//Medication, Dispensed
define fluent function isMedicationDispensed(Med List&lt;MedicationDispense&gt;):
  Med M
    where M.status in { 'completed', 'in-progress', 'on-hold' }

//Medication, Order
define fluent function isMedicationOrder(MedicationRequest List&lt;MedicationRequest&gt;):
  MedicationRequest M
    where M.status in { 'active', 'completed' }
    and M.intent in {'order', 'original-order', 'reflex-order', 'filler-order', 'instance-order'}

//Physical Exam, Performed
define fluent function isPhysicalExamPerformed(Obs List&lt;ObservationClinicalResult&gt;):
  Obs O
    where O.status in { 'final', 'amended', 'corrected' }
      and exists ( O.category ObservationCategory
          where ( ObservationCategory ) ~ "exam"
      )

//Observation Vital Signs
define fluent function isObservationBP(Obs List&lt;USCoreBloodPressureProfile&gt;):
  Obs O
    where O.status in { 'final', 'amended', 'corrected' }
      
define fluent function isObservationBodyHeight(Obs List&lt;USCoreBodyHeightProfile&gt;):
  Obs O
    where O.status in { 'final', 'amended', 'corrected' }
      
define fluent function isObservationBodyWeight(Obs List&lt;USCoreBodyWeightProfile&gt;):
  Obs O
    where O.status in { 'final', 'amended', 'corrected' }
      
define fluent function isObservationBMI(Obs List&lt;USCoreBMIProfile&gt;):
  Obs O
    where O.status in { 'final', 'amended', 'corrected' }
 
//Observation Pediatric BMI
define fluent function isObservationPediatricBMI(Obs List&lt;USCorePediatricBMIforAgeObservationProfile&gt;):
  Obs O
    where O.status in { 'final', 'amended', 'corrected' } 
   
//Observation Smoking Status
define fluent function isObservationSmokingStatus(Obs List&lt;USCoreSmokingStatusProfile&gt;):
  Obs O
    where O.status = 'final' 

//Symptom
define fluent function isSymptom(Obs List&lt;SimpleObservation&gt;):
  Obs O
    where O.status in { 'preliminary', 'final', 'amended', 'corrected' }</code></pre> 
                  </td> 
               </tr>   
               <tr> 
                  <th colspan="2" scope="row" class="row-header">Generated using version 0.4.8 of the sample-content-ig Liquid templates</th> 
               </tr> 
            </tbody> 
         </table> 
      </div>
   </text>
   <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
      <valueCoding>
         <system value="http://terminology.hl7.org/CodeSystem/observation-category"></system>
         <code value="exam"></code>
         <display value="exam"></display>
      </valueCoding>
   </extension>
   <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
      <valueCoding>
         <system value="http://terminology.hl7.org/CodeSystem/observation-category"></system>
         <code value="imaging"></code>
         <display value="imaging"></display>
      </valueCoding>
   </extension>
   <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
      <valueCoding>
         <system value="http://terminology.hl7.org/CodeSystem/condition-ver-status"></system>
         <code value="confirmed"></code>
         <display value="confirmed"></display>
      </valueCoding>
   </extension>
   <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
      <valueCoding>
         <system value="http://terminology.hl7.org/CodeSystem/condition-ver-status"></system>
         <code value="unconfirmed"></code>
         <display value="unconfirmed"></display>
      </valueCoding>
   </extension>
   <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
      <valueCoding>
         <system value="http://terminology.hl7.org/CodeSystem/condition-ver-status"></system>
         <code value="provisional"></code>
         <display value="provisional"></display>
      </valueCoding>
   </extension>
   <extension url="http://hl7.org/fhir/StructureDefinition/cqf-directReferenceCode">
      <valueCoding>
         <system value="http://terminology.hl7.org/CodeSystem/condition-ver-status"></system>
         <code value="differential"></code>
         <display value="differential"></display>
      </valueCoding>
   </extension>
   <url value="https://madie.cms.gov/Library/Status"></url>
   <identifier>
      <use value="official"></use>
      <system value="https://madie.cms.gov/login"></system>
      <value value="684c4d910d70b65363c69edf"></value>
   </identifier>
   <version value="1.15.000"></version>
   <name value="Status"></name>
   <title value="Status"></title>
   <status value="active"></status>
   <experimental value="false"></experimental>
   <type>
      <coding>
         <system value="http://terminology.hl7.org/CodeSystem/library-type"></system>
         <code value="logic-library"></code>
      </coding>
   </type>
   <date value="2025-08-20T20:34:33+00:00"></date>
   <publisher value="National Committee for Quality Assurance"></publisher>
   <description value="This library contains functions used to constrain FHIR resource elements for measures authored by NCQA, based on QICore 6.0.0 resources including IG and authoring patterns. The functions may appear similar to some QICoreCommon functions but differ in that they have constraints that are relevant for measures authored by NCQA."></description>
   <relatedArtifact>
      <type value="depends-on"></type>
      <display value="QICore model information"></display>
      <resource value="http://hl7.org/fhir/Library/QICore-ModelInfo"></resource>
   </relatedArtifact>
   <relatedArtifact>
      <type value="depends-on"></type>
      <display value="Library FHIRHelpers"></display>
      <resource value="https://madie.cms.gov/Library/FHIRHelpers|4.4.000"></resource>
   </relatedArtifact>
   <relatedArtifact>
      <type value="depends-on"></type>
      <display value="Code system ObservationCategoryCodes"></display>
      <resource value="http://terminology.hl7.org/CodeSystem/observation-category"></resource>
   </relatedArtifact>
   <relatedArtifact>
      <type value="depends-on"></type>
      <display value="Code system ConditionVerificationStatusCodes"></display>
      <resource value="http://terminology.hl7.org/CodeSystem/condition-ver-status"></resource>
   </relatedArtifact>
   <content>
      <contentType value="text/cql"></contentType>
      <data value="[encoded data, 8456 characters]"></data>
   </content>
   <content>
      <contentType value="application/elm+xml"></contentType>
      <data value="[encoded data, 208832 characters]"></data>
   </content>
   <content>
      <contentType value="application/elm+json"></contentType>
      <data value="[encoded data, 391068 characters]"></data>
   </content>
</Library>