QI-Core Implementation Guide
4.1.0 - release

Publication Build: This will be filled in by the publication tooling

## : QICore Common - TTL Representation

Raw ttl | Download

    @prefix fhir: <http://hl7.org/fhir/> .
    @prefix owl: <http://www.w3.org/2002/07/owl#> .
    @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
    @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

    # - resource -------------------------------------------------------------------

     a fhir:Library;
      fhir:nodeRole fhir:treeRoot;
      fhir:Resource.id [ fhir:value "QICoreCommon"];
      fhir:DomainResource.text [
         fhir:Narrative.status [ fhir:value "extensions" ];
         fhir:Narrative.div "<div xmlns=\"http://www.w3.org/1999/xhtml\">\n    <table class=\"grid dict\">\n        \n        <tr>\n            <th scope=\"row\"><b>Id: </b></th>\n            <td style=\"padding-left: 4px;\">QICoreCommon</td>\n        </tr>\n        \n        \n        <tr>\n            <th scope=\"row\"><b>Url: </b></th>\n            <td style=\"padding-left: 4px;\">http://hl7.org/fhir/us/qicore/Library/QICoreCommon</td>\n        </tr>\n        \n        \n        <tr>\n            <th scope=\"row\"><b>Version: </b></th>\n            <td style=\"padding-left: 4px;\">4.1.0</td>\n        </tr>\n        \n        \n        \n        <tr>\n            <th scope=\"row\"><b>Name: </b></th>\n            <td style=\"padding-left: 4px;\">QICoreCommon</td>\n        </tr>\n        \n        \n        <tr>\n            <th scope=\"row\"><b>Title: </b></th>\n            <td style=\"padding-left: 4px;\">QICore Common</td>\n        </tr>\n        \n        \n        \n        <tr>\n            <th scope=\"row\"><b>Status: </b></th>\n            <td style=\"padding-left: 4px;\">active</td>\n        </tr>\n        \n        \n        <tr>\n            <th scope=\"row\"><b>Experimental: </b></th>\n            <td style=\"padding-left: 4px;\">false</td>\n        </tr>\n        \n        \n        <tr>\n            <th scope=\"row\"><b>Type: </b></th>\n            <td style=\"padding-left: 4px;\">\n                \n                    \n                        \n                        <p style=\"margin-bottom: 5px;\">\n                            <b>system: </b> <span>http://terminology.hl7.org/CodeSystem/library-type</span>\n                        </p>\n                        \n                        \n                        <p style=\"margin-bottom: 5px;\">\n                            <b>code: </b> <span>logic-library</span>\n                        </p>\n                        \n                        \n                    \n                \n                \n            </td>\n        </tr>\n        \n        \n        \n        <tr>\n            <th scope=\"row\"><b>Date: </b></th>\n            <td style=\"padding-left: 4px;\">2020-11-29T15:54:22-07:00</td>\n        </tr>\n        \n        \n        <tr>\n            <th scope=\"row\"><b>Publisher: </b></th>\n            <td style=\"padding-left: 4px;\">http://www.hl7.org/Special/committees/cqi/index.cfm</td>\n        </tr>\n        \n        \n        <tr>\n            <th scope=\"row\"><b>Description: </b></th>\n            <td style=\"padding-left: 4px;\">This library defines functions to expose extensions defined in QICore as fluent functions in CQL, as well as common terminology and functions used in writing CQL with FHIR and QICore profiles.</td>\n        </tr>\n        \n        \n        \n        \n        \n        <tr>\n            <th scope=\"row\"><b>Jurisdiction: </b></th>\n            <td style=\"padding-left: 4px;\">US</td>\n        </tr>\n        \n        \n        \n        \n        \n        <tr>\n            <th scope=\"row\"><b>Approval Date: </b></th>\n            <td style=\"padding-left: 4px;\">2021-11-06</td>\n        </tr>\n        \n        \n        <tr>\n            <th scope=\"row\"><b>Last Review Date: </b></th>\n            <td style=\"padding-left: 4px;\">2021-11-06</td>\n        </tr>\n        \n        \n        \n        <tr>\n          <th scope=\"row\"><b>Related Artifacts: </b></th>\n          <td style=\"padding-left: 4px;\">\n            \n            \n            \n            <p><b>Dependencies</b></p>\n            <ul>\n              \n                <li>http://loinc.org</li>\n              \n                <li>http://snomed.info/sct</li>\n              \n                <li>http://terminology.hl7.org/CodeSystem/v3-RoleCode</li>\n              \n                <li>http://terminology.hl7.org/CodeSystem/diagnosis-role</li>\n              \n                <li>http://terminology.hl7.org/CodeSystem/request-intent</li>\n              \n                <li>http://terminology.hl7.org/CodeSystem/medicationrequest-category</li>\n              \n                <li>http://terminology.hl7.org/CodeSystem/condition-clinical</li>\n              \n                <li>http://terminology.hl7.org/CodeSystem/condition-ver-status</li>\n              \n                <li>http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical</li>\n              \n                <li>http://terminology.hl7.org/CodeSystem/allergyintolerance-verification</li>\n              \n            </ul>\n            \n            \n            \n            \n            \n          </td>\n        </tr>\n        \n        \n        <tr>\n          <th scope=\"row\"><b>Parameters: </b></th>\n          <td style=\"padding-left: 4px;\">\n            <table class=\"grid-dict\">\n              <tr><th><b>Name</b></th><th><b>Type</b></th><th><b>Min</b></th><th><b>Max</b></th><th><b>In/Out</b></th></tr>\n              \n                <tr><th>Patient</th><th>Patient</th><th>0</th><th>1</th><th>out</th></tr>\n              \n            </table>\n          </td>\n        </tr>\n        \n        \n        <tr>\n          <th scope=\"row\"><b>Data Requirements:</b></th>\n          <td style=\"padding-left: 4px;\">\n            <table class=\"grid-dict\">\n              <tr><th><b>Type</b></th><th><b>Profile</b></th><th><b>MS</b></th><th><b>Code Filter</b></th></tr>\n              \n                <tr>\n                  <th>Patient</th>\n                  <th>http://hl7.org/fhir/StructureDefinition/Patient</th>\n                  <th></th>\n                  <th>\n                    \n                  </th>\n                </tr>\n              \n            </table>\n          </td>\n        </tr>\n        \n        \n        \n        <tr>\n          <td colspan=\"2\">\n            <table>\n              <tr><th><a id=\"cql-content\"><b>Content: </b></a> text/cql</th></tr>\n              <tr><td><pre><code class=\"language-cql\">/*\r\n@author: Bryn Rhodes\r\n@description: This library defines functions to expose extensions defined\r\nin QICore as fluent functions in CQL, as well as common terminology and functions\r\nused in writing CQL with FHIR and QICore profiles.\r\n*/\r\nlibrary QICoreCommon version '4.1.0'\r\n\r\nusing FHIR version '4.0.1'\r\n\r\ninclude FHIRHelpers version '4.0.1'\r\n\r\ncodesystem \"LOINC\": 'http://loinc.org'\r\ncodesystem \"SNOMEDCT\": 'http://snomed.info/sct'\r\ncodesystem \"RoleCode\": 'http://terminology.hl7.org/CodeSystem/v3-RoleCode'\r\ncodesystem \"Diagnosis Role\": 'http://terminology.hl7.org/CodeSystem/diagnosis-role'\r\ncodesystem \"RequestIntent\": 'http://terminology.hl7.org/CodeSystem/request-intent'\r\ncodesystem \"MedicationRequestCategory\": 'http://terminology.hl7.org/CodeSystem/medicationrequest-category'\r\ncodesystem \"ConditionClinicalStatusCodes\": 'http://terminology.hl7.org/CodeSystem/condition-clinical'\r\ncodesystem \"ConditionVerificationStatusCodes\": 'http://terminology.hl7.org/CodeSystem/condition-ver-status'\r\ncodesystem \"AllergyIntoleranceClinicalStatusCodes\": 'http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical'\r\ncodesystem \"AllergyIntoleranceVerificationStatusCodes\": 'http://terminology.hl7.org/CodeSystem/allergyintolerance-verification'\r\n\r\ncode \"Birthdate\": '21112-8' from \"LOINC\" display 'Birth date'\r\ncode \"Dead\": '419099009' from \"SNOMEDCT\" display 'Dead'\r\ncode \"ER\": 'ER' from \"RoleCode\" display 'Emergency room'\r\ncode \"ICU\": 'ICU' from \"RoleCode\" display 'Intensive care unit'\r\ncode \"Billing\": 'billing' from \"Diagnosis Role\" display 'Billing'\r\n\r\n// Condition Clinical Status Codes - Consider value sets for these\r\ncode \"active\": 'active' from \"ConditionClinicalStatusCodes\"\r\ncode \"recurrence\": 'recurrence' from \"ConditionClinicalStatusCodes\"\r\ncode \"relapse\": 'relapse' from \"ConditionClinicalStatusCodes\"\r\ncode \"inactive\": 'inactive' from \"ConditionClinicalStatusCodes\"\r\ncode \"remission\": 'remission' from \"ConditionClinicalStatusCodes\"\r\ncode \"resolved\": 'resolved' from \"ConditionClinicalStatusCodes\"\r\n\r\n// Condition Verification Status Codes - Consider value sets for these\r\ncode \"unconfirmed\": 'unconfirmed' from ConditionVerificationStatusCodes\r\ncode \"provisional\": 'provisional' from ConditionVerificationStatusCodes\r\ncode \"differential\": 'differential' from ConditionVerificationStatusCodes\r\ncode \"confirmed\": 'confirmed' from ConditionVerificationStatusCodes\r\ncode \"refuted\": 'refuted' from ConditionVerificationStatusCodes\r\ncode \"entered-in-error\": 'entered-in-error' from ConditionVerificationStatusCodes\r\n\r\ncode \"allergy-active\": 'active' from \"AllergyIntoleranceClinicalStatusCodes\"\r\ncode \"allergy-inactive\": 'inactive' from \"AllergyIntoleranceClinicalStatusCodes\"\r\ncode \"allergy-resolved\": 'resolved' from \"AllergyIntoleranceClinicalStatusCodes\"\r\n\r\n// Allergy/Intolerance Verification Status Codes - Consider value sets for these\r\ncode \"allergy-unconfirmed\": 'unconfirmed' from AllergyIntoleranceVerificationStatusCodes\r\ncode \"allergy-confirmed\": 'confirmed' from AllergyIntoleranceVerificationStatusCodes\r\ncode \"allergy-refuted\": 'refuted' from AllergyIntoleranceVerificationStatusCodes\r\n\r\n// MedicationRequest Category Codes\r\ncode \"Community\": 'community' from \"MedicationRequestCategory\" display 'Community'\r\ncode \"Discharge\": 'discharge' from \"MedicationRequestCategory\" display 'Discharge'\r\n\r\n// Diagnosis Role Codes\r\ncode \"AD\": 'AD' from \"Diagnosis Role\" display 'Admission diagnosis'\r\ncode \"DD\": 'DD' from \"Diagnosis Role\" display 'Discharge diagnosis'\r\ncode \"CC\": 'CC' from \"Diagnosis Role\" display 'Chief complaint'\r\ncode \"CM\": 'CM' from \"Diagnosis Role\" display 'Comorbidity diagnosis'\r\ncode \"pre-op\": 'pre-op' from \"Diagnosis Role\" display 'pre-op diagnosis'\r\ncode \"post-op\": 'post-op' from \"Diagnosis Role\" display 'post-op diagnosis'\r\ncode \"billing\": 'billing' from \"Diagnosis Role\" display 'billing diagnosis'\r\n\r\ncontext Patient\r\n\r\n/* Candidates for FHIRCommon */\r\n\r\n/*\r\n@description: Returns true if the given MedicationRequest has a category of Community\r\n*/\r\ndefine fluent function isCommunity(medicationRequest MedicationRequest):\r\n  exists (medicationRequest.category C\r\n    where C ~ Community\r\n  )\r\n\r\n/*\r\n@description: Returns true if the given MedicationRequest has a category of Discharge\r\n*/\r\ndefine fluent function isDischarge(medicationRequest MedicationRequest):\r\n  exists (medicationRequest.category C\r\n    where C ~ Discharge\r\n  )\r\n\r\n/*\r\n@description: Normalizes a value that is a choice of timing-valued types to an equivalent interval\r\n@comment: Normalizes a choice type of FHIR.dateTime, FHIR.Period, FHIR.Timing, FHIR.instance, FHIR.string, FHIR.Age, or FHIR.Range types\r\nto an equivalent interval. This selection of choice types is a superset of the majority of choice types that are used as possible\r\nrepresentations for timing-valued elements in FHIR, allowing this function to be used across any resource. NOTE: Due to the\r\ncomplexity of determining a single interval from a Timing or String type, this function will throw a run-time exception if it is used\r\nwith a Timing or String.\r\n*/\r\ndefine fluent function toInterval(choice Choice&lt;FHIR.dateTime, FHIR.Period, FHIR.Timing, FHIR.instant, FHIR.string, FHIR.Age, FHIR.Range&gt;):\r\n  case\r\n    when choice is FHIR.dateTime then\r\n      Interval[FHIRHelpers.ToDateTime(choice as FHIR.dateTime), FHIRHelpers.ToDateTime(choice as FHIR.dateTime)]\r\n    when choice is FHIR.Period then\r\n      FHIRHelpers.ToInterval(choice as FHIR.Period)\r\n    when choice is FHIR.instant then\r\n      Interval[FHIRHelpers.ToDateTime(choice as FHIR.instant), FHIRHelpers.ToDateTime(choice as FHIR.instant)]\r\n    when choice is FHIR.Age then\r\n      Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(choice as FHIR.Age),\r\n        FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(choice as FHIR.Age) + 1 year)\r\n    when choice is FHIR.Range then\r\n      Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((choice as FHIR.Range).low),\r\n        FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((choice as FHIR.Range).high) + 1 year)\r\n    when choice is FHIR.Timing then\r\n      Message(null as Interval&lt;DateTime&gt;, true, '1', 'Error', 'Cannot compute a single interval from a Timing type')\r\n    when choice is FHIR.string then\r\n      Message(null as Interval&lt;DateTime&gt;, true, '1', 'Error', 'Cannot compute an interval from a String value')\r\n    else\r\n      null as Interval&lt;DateTime&gt;\r\n  end\r\n\r\n/*\r\n@description: Returns an interval representing the normalized Abatement of a given Condition resource.\r\n@comment: NOTE: Due to the complexity of determining an interval from a String, this function will throw\r\na run-time exception if used with a Condition instance that has a String as the abatement value.\r\n*/\r\ndefine fluent function abatementInterval(condition Condition):\r\n  if condition.abatement is FHIR.dateTime then\r\n    Interval[FHIRHelpers.ToDateTime(condition.abatement as FHIR.dateTime), FHIRHelpers.ToDateTime(condition.abatement as FHIR.dateTime)]\r\n  else if condition.abatement is FHIR.Period then\r\n    FHIRHelpers.ToInterval(condition.abatement as FHIR.Period)\r\n  else if condition.abatement is FHIR.string then\r\n    Message(null as Interval&lt;DateTime&gt;, true, '1', 'Error', 'Cannot compute an interval from a String value')\r\n  else if condition.abatement is FHIR.Age then\r\n    Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(condition.abatement as FHIR.Age),\r\n      FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity(condition.abatement as FHIR.Age) + 1 year)\r\n  else if condition.abatement is FHIR.Range then\r\n    Interval[FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((condition.abatement as FHIR.Range).low),\r\n      FHIRHelpers.ToDate(Patient.birthDate) + FHIRHelpers.ToQuantity((condition.abatement as FHIR.Range).high) + 1 year)\r\n  else if condition.abatement is FHIR.boolean then\r\n    Interval[end of condition.onset.toInterval(), condition.recordedDate)\r\n  else null\r\n\r\n/*\r\n@description: Returns an interval representing the normalized prevalence period of a given Condition resource.\r\n@comment: Uses the ToInterval and ToAbatementInterval functions to determine the widest potential interval from\r\nonset to abatement as specified in the given Condition.\r\n*/\r\ndefine fluent function prevalenceInterval(condition Condition):\r\n  if condition.clinicalStatus ~ \"active\"\r\n    or condition.clinicalStatus ~ \"recurrence\"\r\n    or condition.clinicalStatus ~ \"relapse\" then\r\n    Interval[start of condition.onset.toInterval(), end of condition.abatementInterval()]\r\n  else\r\n    Interval[start of condition.onset.toInterval(), end of condition.abatementInterval())\r\n\r\n/*\r\n@description: Given an interval, return true if the interval has a starting boundary specified (i.e. the start of the interval is not null and not the minimum DateTime value)\r\n*/\r\ndefine fluent function hasStart(period Interval&lt;DateTime&gt;):\r\n  period.low is not null\r\n\r\n/*\r\n@description: Given an interval, return true if the interval has an ending boundary specified (i.e. the end of the interval is not null and not the maximum DateTime value)\r\n*/\r\ndefine fluent function hasEnd(period Interval&lt;DateTime&gt;):\r\n  period.high is not null\r\n\r\n/*\r\n@description: Given an interval, return the ending point if the interval has an ending boundary specified, otherwise, return the starting point\r\n*/\r\ndefine fluent function latest(choice Choice&lt;FHIR.dateTime, FHIR.Period, FHIR.Timing, FHIR.instant, FHIR.string, FHIR.Age, FHIR.Range&gt;):\r\n  (choice.toInterval()) period\r\n    return\r\n      if period.hasEnd() then\r\n        end of period\r\n      else\r\n        start of period\r\n\r\n/*\r\n@description: Given an interval, return the starting point if the interval has a starting boundary specified, otherwise, return the ending point\r\n*/\r\ndefine fluent function earliest(choice Choice&lt;FHIR.dateTime, FHIR.Period, FHIR.Timing, FHIR.instant, FHIR.string, FHIR.Age, FHIR.Range&gt;):\r\n  (choice.toInterval()) period\r\n    return\r\n      if period.hasStart() then\r\n        start of period\r\n      else\r\n        end of period\r\n\r\n/* FHIR Extensions */\r\n\r\n/*\r\n@description: Returns any extensions defined on the given resource with the specified url.\r\n@comment: NOTE: Extensions are not the preferred approach, but are used as a way to access\r\ncontent that is defined by extensions but not yet surfaced in the\r\nCQL model info.\r\n*/\r\ndefine fluent function extensions(domainResource DomainResource, url String):\r\n  domainResource.extension E\r\n	  where E.url = url\r\n		return E\r\n\r\n/*\r\n@description: Returns the single extension (if present) on the given resource with the specified url.\r\n@comment: This function uses singleton from to ensure that a run-time exception is thrown if there\r\nis more than one extension on the given resource with the specified url.\r\n*/\r\ndefine fluent function extension(domainResource DomainResource, url String):\r\n  singleton from domainResource.extensions(url)\r\n\r\n/*\r\n@description: Returns any extensions defined on the given element with the specified url.\r\n@comment: NOTE: Extensions are not the preferred approach, but are used as a way to access\r\ncontent that is defined by extensions but not yet surfaced in the CQL model info.\r\n*/\r\ndefine fluent function extensions(element Element, url String):\r\n  element.extension E\r\n	  where E.url = url\r\n		return E\r\n\r\n/*\r\n@description: Returns the single extension (if present) on the given element with the specified url.\r\n@comment: This function uses singleton from to ensure that a run-time exception is thrown if there\r\nis more than one extension on the given resource with the specified url.\r\n*/\r\ndefine fluent function extension(element Element, url String):\r\n  singleton from element.extensions(url)\r\n\r\n/*\r\n@description: Returns any modifier extensions defined on the given resource with the specified url.\r\n@comment: NOTE: Extensions are not the preferred approach, but are used as a way to access\r\ncontent that is defined by extensions but not yet surfaced in the\r\nCQL model info.\r\n*/\r\ndefine fluent function modifierExtensions(domainResource DomainResource, url String):\r\n  domainResource.modifierExtension E\r\n	  where E.url = url\r\n		return E\r\n\r\n/*\r\n@description: Returns the single modifier extension (if present) on the given resource with the specified url.\r\n@comment: This function uses singleton from to ensure that a run-time exception is thrown if there\r\nis more than one extension on the given resource with the specified url.\r\n*/\r\ndefine fluent function modifierExtension(domainResource DomainResource, url String):\r\n  singleton from domainResource.modifierExtensions(url)\r\n\r\n/*\r\n@description: Returns any modifier extensions defined on the given element with the specified url.\r\n@comment: NOTE: Extensions are not the preferred approach, but are used as a way to access\r\ncontent that is defined by extensions but not yet surfaced in the CQL model info.\r\n*/\r\ndefine fluent function modifierExtensions(element BackboneElement, url String):\r\n  element.modifierExtension E\r\n	  where E.url = url\r\n		return E\r\n\r\n/*\r\n@description: Returns the single modifier extension (if present) on the given element with the specified url.\r\n@comment: This function uses singleton from to ensure that a run-time exception is thrown if there\r\nis more than one extension on the given resource with the specified url.\r\n*/\r\ndefine fluent function modifierExtension(element BackboneElement, url String):\r\n  singleton from element.modifierExtensions(url)\r\n\r\n/*\r\n@description: Surfaces the [resolutionAge](http://hl7.org/fhir/StructureDefinition/allergyintolerance-resolutionAge)\r\nextension defined in FHIR.\r\n@comment: This function returns the value of the extension as an Age.\r\n@extension: http://hl7.org/fhir/StructureDefinition/allergyintolerance-resolutionAge\r\n*/\r\ndefine fluent function resolutionAge(allergyIntolerance AllergyIntolerance):\r\n  allergyIntolerance.extension('http://hl7.org/fhir/StructureDefinition/allergyintolerance-resolutionAge').value as Age\r\n\r\n/*\r\n@description: Surfaces the [reasonRefuted](http://hl7.org/fhir/StructureDefinition/allergyintolerance-reasonRefuted)\r\nextension defined in FHIR.\r\n@comment: This function returns the value of the extension as a CodeableConcept.\r\n@extension: http://hl7.org/fhir/StructureDefinition/allergyintolerance-reasonRefuted\r\n*/\r\ndefine fluent function reasonRefuted(allergyIntolerance AllergyIntolerance):\r\n  allergyIntolerance.extension('http://hl7.org/fhir/StructureDefinition/allergyintolerance-reasonRefuted').value as CodeableConcept\r\n\r\n/*\r\n@description: Surfaces the [duration](http://hl7.org/fhir/StructureDefinition/allergyintolerance-duration)\r\nextension defined in FHIR.\r\n@comment: This function returns the value of the extension as a Duration.\r\n@extension: http://hl7.org/fhir/StructureDefinition/allergyintolerance-duration\r\n*/\r\ndefine fluent function duration(allergyIntolerance BackboneElement):\r\n  allergyIntolerance.extension('http://hl7.org/fhir/StructureDefinition/allergyintolerance-duration').value as Duration\r\n\r\n/*\r\n@description: Surfaces the [dueTo](http://hl7.org/fhir/StructureDefinition/condition-dueTo)\r\nextension defined in FHIR.\r\n@comment: This function returns the value of the extension as a choice of CodeableConcept or Reference.\r\n@extension: http://hl7.org/fhir/StructureDefinition/condition-dueTo\r\n*/\r\ndefine fluent function dueTo(condition Condition):\r\n  condition.extension('http://hl7.org/fhir/StructureDefinition/condition-dueTo').value as Choice&lt;CodeableConcept, Reference&gt;\r\n\r\n/*\r\n@description: Surfaces the [occurredFollowing](http://hl7.org/fhir/StructureDefinition/condition-occurredFollowing)\r\nextension defined in FHIR.\r\n@comment: This function returns the value of the extension as a choice of CodeableConcept or Reference\r\n@extension: http://hl7.org/fhir/StructureDefinition/condition-occurredFollowing\r\n*/\r\ndefine fluent function occurredFollowing(condition Condition):\r\n  condition.extension('http://hl7.org/fhir/StructureDefinition/condition-occurredFollowing').value as Choice&lt;CodeableConcept, Reference&gt;\r\n\r\n/*\r\n@description: Surfaces the [doNotPerform](http://hl7.org/fhir/5.0/StructureDefinition/extension-DeviceRequest.doNotPerform)\r\nmodifier extension defined in FHIR.\r\n@comment: This function returns the value of the modifier extension as a boolean\r\n@extension: http://hl7.org/fhir/StructureDefinition/request-doNotPerform\r\n*/\r\ndefine fluent function doNotPerform(requestResource DomainResource):\r\n  requestResource.modifierExtension('http://hl7.org/fhir/5.0/StructureDefinition/extension-DeviceRequest.doNotPerform').value as boolean\r\n\r\n/*\r\n@description: Surfaces the [statusReason](http://hl7.org/fhir/StructureDefinition/request-statusReason)\r\nextension defined in FHIR.\r\n@comment: This function returns the value of the extension as a CodeableConcept\r\n@extension: http://hl7.org/fhir/StructureDefinition/request-statusReason\r\n*/\r\ndefine fluent function statusReason(requestResource DomainResource):\r\n  requestResource.extension('http://hl7.org/fhir/StructureDefinition/request-statusReason').value as CodeableConcept\r\n\r\n/*\r\n@description: Surfaces the [locationPerformed](http://hl7.org/fhir/StructureDefinition/diagnosticReport-locationPerformed)\r\nextension defined in FHIR.\r\n@comment: This function returns the value of the extension as a Reference\r\n@extension: http://hl7.org/fhir/StructureDefinition/diagnosticReport-locationPerformed\r\n*/\r\ndefine fluent function locationPerformed(diagnosticReport DiagnosticReport):\r\n  diagnosticReport.extension('http://hl7.org/fhir/StructureDefinition/diagnosticReport-locationPerformed').value as Reference\r\n\r\n/*\r\n@description: Surfaces the [abatement](http://hl7.org/fhir/StructureDefinition/familymemberhistory-abatement)\r\nextension defined in FHIR.\r\n@comment: This function returns the value of the extension as a choice of date, Age, or boolean\r\n@extension: http://hl7.org/fhir/StructureDefinition/familymemberhistory-abatement\r\n*/\r\ndefine fluent function abatement(familyMemberHistory FamilyMemberHistory):\r\n  familyMemberHistory.extension('http://hl7.org/fhir/StructureDefinition/familymemberhistory-abatement').value as Choice&lt;date, Age, boolean&gt;\r\n\r\n/*\r\n@description: Surfaces the [severity](http://hl7.org/fhir/StructureDefinition/familymemberhistory-severity)\r\nextension defined in FHIR.\r\n@comment: This function returns the value of the extension as a CodeableConcept\r\n@extension: http://hl7.org/fhir/StructureDefinition/familymemberhistory-severity\r\n*/\r\ndefine fluent function severity(familyMemberHistory FamilyMemberHistory):\r\n  familyMemberHistory.extension('http://hl7.org/fhir/StructureDefinition/familymemberhistory-severity').value as CodeableConcept\r\n\r\n/*\r\n@description: Surfaces the [reasonRejected](http://hl7.org/fhir/StructureDefinition/goal-reasonRejected)\r\nextension defined in FHIR.\r\n@comment: This function returns the value of the extension as a CodeableConcept\r\n@extension: http://hl7.org/fhir/StructureDefinition/goal-reasonRejected\r\n*/\r\ndefine fluent function reasonRejected(goal Goal):\r\n  goal.extension('http://hl7.org/fhir/StructureDefinition/goal-reasonRejected').value as CodeableConcept\r\n\r\n/*\r\n@description: Surfaces the [bodyPosition](http://hl7.org/fhir/StructureDefinition/observation-bodyPosition)\r\nextension defined in FHIR.\r\n@comment: This function returns the value of the extension as a CodeableConcept\r\n@extension: http://hl7.org/fhir/StructureDefinition/observation-bodyPosition\r\n*/\r\ndefine fluent function bodyPosition(observation Observation):\r\n  observation.extension('http://hl7.org/fhir/StructureDefinition/observation-bodyPosition').value as CodeableConcept\r\n\r\n/*\r\n@description: Surfaces the [delta](http://hl7.org/fhir/StructureDefinition/observation-delta)\r\nextension defined in FHIR.\r\n@comment: This function returns the value of the extension as a CodeableConcept\r\n@extension: http://hl7.org/fhir/StructureDefinition/observation-delta\r\n*/\r\ndefine fluent function delta(observation Observation):\r\n  observation.extension('http://hl7.org/fhir/StructureDefinition/observation-delta').value as CodeableConcept\r\n\r\n/*\r\n@description: Surfaces the [preferred](http://hl7.org/fhir/StructureDefinition/iso21090-preferred) extension defined in USCore.\r\n@comment: This function returns the value of the direct extension as a boolean\r\n@extension: http://hl7.org/fhir/StructureDefinition/iso21090-preferred\r\n*/\r\ndefine fluent function preferred(contactPoint ContactPoint):\r\n  contactPoint.extension('http://hl7.org/fhir/StructureDefinition/iso21090-preferred').value as boolean\r\n\r\n/*\r\n@description: Surfaces the [approachBodyStructure](http://hl7.org/fhir/StructureDefinition/procedure-approachBodyStructure)\r\nextension defined in FHIR.\r\n@comment: This function returns the value of the extension as a Reference\r\n@extension: http://hl7.org/fhir/StructureDefinition/procedure-approachBodyStructure\r\n*/\r\ndefine fluent function approachBodyStructure(procedure Procedure):\r\n  procedure.extension('http://hl7.org/fhir/StructureDefinition/procedure-approachBodyStructure').value as Reference\r\n\r\n/*\r\n@description: Surfaces the [incisionDateTime](http://hl7.org/fhir/StructureDefinition/procedure-incisionDateTime)\r\nextension defined in FHIR.\r\n@comment: This function returns the value of the extension as a dateTime\r\n@extension: http://hl7.org/fhir/StructureDefinition/procedure-incisionDateTime\r\n*/\r\ndefine fluent function incisionDateTime(procedure Procedure):\r\n  procedure.extension('http://hl7.org/fhir/StructureDefinition/procedure-incisionDateTime').value as dateTime\r\n\r\n/* USCore Extensions */\r\n/*\r\n@description: Surfaces the [ethnicity](http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity)\r\nextension defined in USCore.\r\n@comment: This function returns a tuple with elements for each subextension (ombCategory, detailed, and text).\r\n@extension: http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity\r\n*/\r\ndefine fluent function ethnicity(patient Patient):\r\n  patient P\r\n    let ethnicityEx: P.extension('http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity')\r\n    return\r\n      {\r\n        ombCategory: ethnicityEx.extension('ombCategory').value as Coding,\r\n        detailed:\r\n          (ethnicityEx.extensions('detailed')) E\r\n            return E.value as Coding,\r\n        text: ethnicityEx.extension('text').value as string\r\n      }\r\n\r\n/*\r\n@description: Surfaces the [race](http://hl7.org/fhir/us/core/StructureDefinition/us-core-race) extension defined in USCore.\r\n@comment: This function returns a tuple with elements for each subextension (ombCategory, detailed, and text).\r\n@extension: http://hl7.org/fhir/us/core/StructureDefinition/us-core-race\r\n*/\r\ndefine fluent function race(patient Patient):\r\n  patient P\r\n    let raceEx: P.extension('http://hl7.org/fhir/us/core/StructureDefinition/us-core-race')\r\n    return\r\n      {\r\n        ombCategory:\r\n          (raceEx.extensions('ombCategory')) E\r\n            return E.value as Coding,\r\n        detailed:\r\n          (raceEx.extensions('detailed')) E\r\n            return E.value as Coding,\r\n        text: raceEx.extension('text').value as string\r\n      }\r\n\r\n/*\r\n@description: Surfaces the [birthsex](http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex) extension defined in USCore.\r\n@comment: This function returns the value of the birthsex extension as a code\r\n@extension: http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex\r\n*/\r\ndefine fluent function birthsex(patient Patient):\r\n  patient.extension('http://hl7.org/fhir/us/core/StructureDefinition/us-core-birthsex').value as code\r\n\r\n/*\r\n@description: Surfaces the [direct](http://hl7.org/fhir/us/core/StructureDefinition/us-core-direct) extension defined in USCore.\r\n@comment: This function returns the value of the direct extension as a boolean\r\n@extension: http://hl7.org/fhir/us/core/StructureDefinition/us-core-direct\r\n*/\r\ndefine fluent function direct(contactPoint ContactPoint):\r\n  contactPoint.extension('http://hl7.org/fhir/us/core/StructureDefinition/us-core-direct').value as boolean\r\n\r\n/* QICore Extensions */\r\n\r\n/*\r\n@description: Surfaces the [isElective](http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-isElective)\r\nmodifier extension defined in QICore.\r\n@comment: This function returns the value of the isElective modifier extension as a boolean.\r\n@extension: http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-isElective\r\n*/\r\ndefine fluent function isElective(serviceRequest ServiceRequest):\r\n  serviceRequest.modifierExtension('http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-isElective').value as boolean\r\n\r\n/*\r\n@description: Surfaces the [procedure](http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter-procedure)\r\nextension defined in QICore.\r\n@comment: This function returns a tuple with elements for each subextension (type, rank, and procedure).\r\n@extension: http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter-procedure\r\n*/\r\ndefine fluent function procedure(encounter Encounter):\r\n  (encounter.extensions('http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter-procedure')) E\r\n    return {\r\n      type: E.extension('type').value as CodeableConcept,\r\n      rank: E.extension('rank').value as positiveInt,\r\n      procedure: E.extension('procedure').value as Reference\r\n    }\r\n\r\n/*\r\n@description: Surfaces the [doNotPerform](http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-doNotPerformReason)\r\nextension defined in QICore.\r\n@comment: This function returns the value of the extension as a CodeableConcept\r\n@extension: http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-doNotPerformReason\r\n*/\r\ndefine fluent function doNotPerformReason(requestResource DomainResource):\r\n  requestResource.extension('http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-doNotPerformReason').value as CodeableConcept\r\n\r\n/*\r\n@description: Surfaces the [recorded](http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-recorded)\r\nextension defined in QICore.\r\n@comment: This function returns the value of the extension as a dateTime\r\n@extension: http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-recorded\r\n*/\r\ndefine fluent function recorded(domainResource DomainResource):\r\n  domainResource.extension('http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-recorded').value as dateTime\r\n\r\n/*\r\n@description: Surfaces the [notDone](http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-notDone)\r\nmodifier extension defined in QICore.\r\n@comment: This function returns the value of the modifier extension as a boolean\r\n@extension: http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-notDone\r\n*/\r\ndefine fluent function notDone(eventResource DomainResource):\r\n  eventResource.modifierExtension('http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-notDone').value as boolean\r\n\r\n/*\r\n@description: Surfaces the [notDoneReason](http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-notDoneReason)\r\nextension defined in QICore.\r\n@comment: This function returns the value of the extension as a CodeableConcept\r\n@extension: http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-notDoneReason\r\n*/\r\ndefine fluent function notDoneReason(eventResource DomainResource):\r\n  eventResource.extension('http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-notDoneReason').value as CodeableConcept\r\n\r\n/*\r\n@description: Surfaces the [notDoneValueSet](http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-notDoneValueSet)\r\nextension defined in QICore.\r\n@comment: This function returns the value of the extension as a canonical\r\n@extension: http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-notDoneValueSet\r\n*/\r\ndefine fluent function notDoneValueSet(concept CodeableConcept):\r\n  concept.extension('http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-notDoneValueSet').value as canonical\r\n\r\n/*\r\n@description: Surfaces the [presentOnAdmission](http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter-diagnosisPresentOnAdmission)\r\nextension defined in QICore.\r\n@comment: This function returns the value of the extension as a CodeableConcept\r\n@extension: http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter-diagnosisPresentOnAdmission\r\n*/\r\ndefine fluent function presentOnAdmission(element Element):\r\n  element.extension('http://hl7.org/fhir/us/qicore/StructureDefinition/qicore-encounter-diagnosisPresentOnAdmission').value as CodeableConcept\r\n</code></pre></td></tr>\n            </table>\n          </td>\n        </tr>\n        \n        \n        \n        \n        \n        <tr>\n          <td colspan=\"2\">\n            <table>\n              <tr><th><b>Content: </b> application/elm+xml</th></tr>\n              <tr><td><pre><code>Encoded data (444756 characters)</code></pre></td></tr>\n            </table>\n          </td>\n        </tr>\n        \n        \n        \n        \n        <tr>\n          <td colspan=\"2\">\n            <table>\n              <tr><th><b>Content: </b> application/elm+json</th></tr>\n              <tr><td><pre><code>Encoded data (822604 characters)</code></pre></td></tr>\n            </table>\n          </td>\n        </tr>\n        \n        \n    </table>\n</div>"
      ];
      fhir:Library.url [ fhir:value "http://hl7.org/fhir/us/qicore/Library/QICoreCommon"];
      fhir:Library.version [ fhir:value "4.1.0"];
      fhir:Library.name [ fhir:value "QICoreCommon"];
      fhir:Library.title [ fhir:value "QICore Common"];
      fhir:Library.status [ fhir:value "active"];
      fhir:Library.experimental [ fhir:value "false"^^xsd:boolean];
      fhir:Library.type [
         fhir:CodeableConcept.coding [
           fhir:index 0;
           fhir:Coding.system [ fhir:value "http://terminology.hl7.org/CodeSystem/library-type" ];
           fhir:Coding.code [ fhir:value "logic-library" ]     ]
      ];
      fhir:Library.date [ fhir:value "2020-11-29T15:54:22-07:00"^^xsd:dateTime];
      fhir:Library.publisher [ fhir:value "http://www.hl7.org/Special/committees/cqi/index.cfm"];
      fhir:Library.contact [
         fhir:index 0;
         fhir:ContactDetail.name [ fhir:value "Clinical Quality Information WG" ];
         fhir:ContactDetail.telecom [
           fhir:index 0;
           fhir:ContactPoint.system [ fhir:value "url" ];
           fhir:ContactPoint.value [ fhir:value "http://www.hl7.org/Special/committees/cqi" ]     ]
      ];
      fhir:Library.description [ fhir:value "This library defines functions to expose extensions defined in QICore as fluent functions in CQL, as well as common terminology and functions used in writing CQL with FHIR and QICore profiles."];
      fhir:Library.jurisdiction [
         fhir:index 0;
         fhir:CodeableConcept.coding [
           fhir:index 0;
           fhir:Coding.system [ fhir:value "urn:iso:std:iso:3166" ];
           fhir:Coding.code [ fhir:value "US" ]     ]
      ];
      fhir:Library.approvalDate [ fhir:value "2021-11-06"^^xsd:date];
      fhir:Library.lastReviewDate [ fhir:value "2021-11-06"^^xsd:date];
      fhir:Library.topic [
         fhir:index 0;
         fhir:CodeableConcept.text [ fhir:value "FHIR" ]
      ], [
         fhir:index 1;
         fhir:CodeableConcept.text [ fhir:value "CQL" ]
      ], [
         fhir:index 2;
         fhir:CodeableConcept.text [ fhir:value "QICore" ]
      ];
      fhir:Library.relatedArtifact [
         fhir:index 0;
         fhir:RelatedArtifact.type [ fhir:value "depends-on" ];
         fhir:RelatedArtifact.display [ fhir:value "Code system LOINC" ];
         fhir:RelatedArtifact.resource [
           fhir:value "http://loinc.org";
           fhir:link <http://loinc.org>     ]
      ], [
         fhir:index 1;
         fhir:RelatedArtifact.type [ fhir:value "depends-on" ];
         fhir:RelatedArtifact.display [ fhir:value "Code system SNOMEDCT" ];
         fhir:RelatedArtifact.resource [
           fhir:value "http://snomed.info/sct";
           fhir:link <http://snomed.info/sct>     ]
      ], [
         fhir:index 2;
         fhir:RelatedArtifact.type [ fhir:value "depends-on" ];
         fhir:RelatedArtifact.display [ fhir:value "Code system RoleCode" ];
         fhir:RelatedArtifact.resource [
           fhir:value "http://terminology.hl7.org/CodeSystem/v3-RoleCode";
           fhir:link <http://terminology.hl7.org/CodeSystem/v3-RoleCode>     ]
      ], [
         fhir:index 3;
         fhir:RelatedArtifact.type [ fhir:value "depends-on" ];
         fhir:RelatedArtifact.display [ fhir:value "Code system Diagnosis Role" ];
         fhir:RelatedArtifact.resource [
           fhir:value "http://terminology.hl7.org/CodeSystem/diagnosis-role";
           fhir:link <http://terminology.hl7.org/CodeSystem/diagnosis-role>     ]
      ], [
         fhir:index 4;
         fhir:RelatedArtifact.type [ fhir:value "depends-on" ];
         fhir:RelatedArtifact.display [ fhir:value "Code system RequestIntent" ];
         fhir:RelatedArtifact.resource [
           fhir:value "http://terminology.hl7.org/CodeSystem/request-intent";
           fhir:link <http://terminology.hl7.org/CodeSystem/request-intent>     ]
      ], [
         fhir:index 5;
         fhir:RelatedArtifact.type [ fhir:value "depends-on" ];
         fhir:RelatedArtifact.display [ fhir:value "Code system MedicationRequestCategory" ];
         fhir:RelatedArtifact.resource [
           fhir:value "http://terminology.hl7.org/CodeSystem/medicationrequest-category";
           fhir:link <http://terminology.hl7.org/CodeSystem/medicationrequest-category>     ]
      ], [
         fhir:index 6;
         fhir:RelatedArtifact.type [ fhir:value "depends-on" ];
         fhir:RelatedArtifact.display [ fhir:value "Code system ConditionClinicalStatusCodes" ];
         fhir:RelatedArtifact.resource [
           fhir:value "http://terminology.hl7.org/CodeSystem/condition-clinical";
           fhir:link <http://terminology.hl7.org/CodeSystem/condition-clinical>     ]
      ], [
         fhir:index 7;
         fhir:RelatedArtifact.type [ fhir:value "depends-on" ];
         fhir:RelatedArtifact.display [ fhir:value "Code system ConditionVerificationStatusCodes" ];
         fhir:RelatedArtifact.resource [
           fhir:value "http://terminology.hl7.org/CodeSystem/condition-ver-status";
           fhir:link <http://terminology.hl7.org/CodeSystem/condition-ver-status>     ]
      ], [
         fhir:index 8;
         fhir:RelatedArtifact.type [ fhir:value "depends-on" ];
         fhir:RelatedArtifact.display [ fhir:value "Code system AllergyIntoleranceClinicalStatusCodes" ];
         fhir:RelatedArtifact.resource [
           fhir:value "http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical";
           fhir:link <http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical>     ]
      ], [
         fhir:index 9;
         fhir:RelatedArtifact.type [ fhir:value "depends-on" ];
         fhir:RelatedArtifact.display [ fhir:value "Code system AllergyIntoleranceVerificationStatusCodes" ];
         fhir:RelatedArtifact.resource [
           fhir:value "http://terminology.hl7.org/CodeSystem/allergyintolerance-verification";
           fhir:link <http://terminology.hl7.org/CodeSystem/allergyintolerance-verification>     ]
      ];
      fhir:Library.parameter [
         fhir:index 0;
         fhir:ParameterDefinition.name [ fhir:value "Patient" ];
         fhir:ParameterDefinition.use [ fhir:value "out" ];
         fhir:ParameterDefinition.min [ fhir:value "0"^^xsd:integer ];
         fhir:ParameterDefinition.max [ fhir:value "1" ];
         fhir:ParameterDefinition.type [ fhir:value "Patient" ]
      ];
      fhir:Library.dataRequirement [
         fhir:index 0;
         fhir:DataRequirement.type [ fhir:value "Patient" ];
         fhir:DataRequirement.profile [
           fhir:value "http://hl7.org/fhir/StructureDefinition/Patient";
           fhir:index 0;
           fhir:link <http://hl7.org/fhir/StructureDefinition/Patient>     ]
      ];
      fhir:Library.content [
         fhir:index 0;
         fhir:Attachment.contentType [ fhir:value "text/cql" ];
         fhir:Attachment.data [ fhir:value "[encoded data, 37832 characters]"^^xsd:base64Binary ]
      ], [
         fhir:index 1;
         fhir:Attachment.contentType [ fhir:value "application/elm+xml" ];
         fhir:Attachment.data [ fhir:value "[encoded data, 444756 characters]"^^xsd:base64Binary ]
      ], [
         fhir:index 2;
         fhir:Attachment.contentType [ fhir:value "application/elm+json" ];
         fhir:Attachment.data [ fhir:value "[encoded data, 822604 characters]"^^xsd:base64Binary ]
      ].

    # - ontology header ------------------------------------------------------------

     a owl:Ontology;
      owl:imports fhir:fhir.ttl.