Clinical Practice Guidelines Example Implementation Guide - Chronic Kidney Disease
1.0.0 - ci-build International flag

Clinical Practice Guidelines Example Implementation Guide - Chronic Kidney Disease, published by HL7 International - Clinical Decision Support WG. This guide is not an authorized publication; it is the continuous build for version 1.0.0 built by the FHIR (HL7® FHIR® Standard) CI Build. This version is based on the current content of https://github.com/cqframework/cpg-example-ckd/ and changes regularly. See the Directory of published versions

: Chronic Kidney Disease (CKD) risk screening logic - XML Representation

Active as of 2024-11-18

Raw xml | Download


<Library xmlns="http://hl7.org/fhir">
  <id value="CKDRiskLogic"/>
  <text>
    <status value="generated"/>
    <div xmlns="http://www.w3.org/1999/xhtml"><p class="res-header-id"><b>Generated Narrative: Library CKDRiskLogic</b></p><a name="CKDRiskLogic"> </a><a name="hcCKDRiskLogic"> </a><a name="CKDRiskLogic-en-US"> </a><h2>Contents</h2><p><code>text/cql</code></p><pre><code class="language-sql">library CKDRiskLogic version '1.0'

using FHIR version '4.0.0'

include FHIRHelpers version '4.0.0' called FHIRHelpers

codesystem &quot;SNOMEDCT&quot;: 'http://snomed.info/sct'
codesystem &quot;LOINC&quot;: 'http://loinc.org'
codesystem &quot;RxNorm&quot;: 'http://www.nlm.nih.gov/research/umls/rxnorm'

valueset &quot;Chronic Kidney Disease&quot;: 'ckd-valueset-ckd'
valueset &quot;Diabetes mellitus&quot;: 'ckd-valueset-diabetes'

valueset &quot;eGFR Labs&quot;: 'ckd-valueset-egfr'
valueset &quot;UACR Labs&quot;: 'ckd-valueset-uacr'
valueset &quot;Creatinine Labs&quot;: 'ckd-valueset-creatinine'

code &quot;Blood pressure systolic and diastolic&quot;: '55284-4' from &quot;LOINC&quot;

context Patient

// Conditions
//
define &quot;Has CKD or Diabetes&quot;:
  &quot;Has CKD&quot; or &quot;Has Diabetes&quot;

define &quot;Has CKD&quot;:
  exists( &quot;Chronic Kidney Disease Dx&quot; )

define &quot;No CKD Dx&quot;:
  not exists( &quot;Chronic Kidney Disease Dx&quot; )

define &quot;Has Diabetes&quot;:
  exists( &quot;Diabetes Dx&quot; )

define &quot;CKD or Diabetes Dx&quot;:
  &quot;Chronic Kidney Disease Dx&quot; union &quot;Diabetes Dx&quot;

define &quot;Chronic Kidney Disease Dx&quot;:
  [Condition: code in &quot;Chronic Kidney Disease&quot;] condition
    where condition.clinicalStatus.value in { 'active', 'recurrence' }

define &quot;Diabetes Dx&quot;:
  [Condition: code in &quot;Diabetes mellitus&quot;] condition
    where condition.clinicalStatus.value in { 'active', 'recurrence' }

// Laboratory observations
//
define &quot;Has eGFR or UACR Lab&quot;:
  &quot;Last eGFR Lab Result&quot; is not null
	or &quot;Last UACR Lab Result&quot; is not null

define &quot;Last eGFR Lab Result&quot;:
  Last( [Observation: code in &quot;eGFR Labs&quot;] )

define &quot;Last eGFR Quantity&quot;:
  &quot;Last eGFR Lab Result&quot; Result
    return ToQuantity(Result.value as Quantity)

define &quot;Has Abnormal eGFR&quot;:
  &quot;Last eGFR Quantity&quot;.value &lt; 60

define &quot;Last UACR Lab Result&quot;:
  Last( [Observation: code in &quot;UACR Labs&quot;] )

define &quot;Last UACR Quantity&quot;:
  &quot;Last UACR Lab Result&quot; Result
    return ToQuantity(Result.value as Quantity)

define &quot;Has Abnormal UACR&quot;:
  &quot;Last UACR Quantity&quot; uacr
    return UACRtoMetric(uacr).value &gt; 30

define &quot;Last Creatinine Lab Result&quot;:
  Last( [Observation: code in &quot;Creatinine Labs&quot;] )

define &quot;Last Creatinine Quantity&quot;:
  &quot;Last Creatinine Lab Result&quot; Result
    return ToQuantity(Result.value as Quantity)

define &quot;Needs eGFR Lab&quot;:
	&quot;eGFR Lab is Overdue&quot;
		or (&quot;eGFR Lab Frequency&quot; is not null and &quot;Last eGFR Lab Result&quot; is null)

define &quot;eGFR Lab Frequency&quot;:
	case
		when &quot;CKD Stage&quot; &gt;= 4
			then 3 months
		when &quot;CKD Stage&quot; &gt;= 3
			then 6 months
		when &quot;Has CKD or Diabetes&quot;
			then 12 months
		else null
	end

define &quot;eGFR Lab is Overdue&quot;:
  &quot;Last eGFR Lab Result&quot; Result
    return
      case
        when Result.effective is null
          then true
        when Result.effective is dateTime
          then (Result.effective.value + &quot;eGFR Lab Frequency&quot;) &lt; Today()
        when Result.effective is Period
          then (end of PeriodToInterval(Result.effective) + &quot;eGFR Lab Frequency&quot;) &lt; Today()
        else false
      end

define NeedsGFRSummary: 'Order Renal Lab Panel'

define NeedsGFRDetail:
	case
		when &quot;CKD Stage&quot; &gt;= 1
			then 'eGFR lab recommended every ' + ToString(&quot;eGFR Lab Frequency&quot;) + ' for Stage ' + ToString(&quot;CKD Stage&quot;) + ' CKD.'
		when &quot;Has CKD or Diabetes&quot;
			then 'eGFR lab recommended every ' + ToString(&quot;eGFR Lab Frequency&quot;) + ' for CKD or Diabetes.'
		else null
	end

define NeedsGFRSeverity: 'info'

define &quot;CKD Stage&quot;:
  &quot;Last eGFR Quantity&quot; egfr
  	return case
      when egfr.value &lt; 15
    		then 5
    	when egfr.value &lt; 30
    		then 4
    	when egfr.value &lt; 60
    		then 3
    	when egfr.value &lt; 90
    		then 2
    	when egfr.value &gt;= 90
        // TODO this does not parse
        //case  when UACRtoMetric(&quot;Get UACR Quantity&quot;).value &gt; 20
  		  //  then 1
        //else 0
        //end
        then 0
      else 0
  	end

// Referrals
//
define &quot;Recommend Nephrology Referral&quot;:
	&quot;5-Year Risk Level&quot; = 'High'

define NephrologyReferralDetail: 'Referral to a nephrologist is recommended when 5-year risk is High'

define NephrologyReferralSeverity: 'info'

//
// Tangri CKD risk model
//
// 4 variable
// 1 – 0.9750 ^ exp (-0.2201 × (age/10 – 7.036) + 0.2467 × (male – 0.5642) – 0.5567 × (eGFR/5 – 7.222) + 0.4510 × (logACR – 5.137))
// 5 year factor =  0.9240
//
// 8 variable
// 1 – 0.9780 ^ exp (-0.1992 × (age/10 – 7.036) + 0.1602 × (male – 0.5642) – 0.4919 × (eGFR/5 – 7.222) + 0.3364 × (logACR – 5.137)
//		– 0.3441 × (albumin – 3.997) + 0.2604 × (phosphorous – 3.916) – 0.07354 × (bicarbonate – 25.57) – 0.2228 × (calcium – 9.355))
// 5 year factor = 0.9301

define &quot;2-YearRiskDetail&quot;:
	'2-year kidney failure risk of ' + ToString(&quot;2-Year CKD Risk Percent&quot;) + '% is considered to be ' + &quot;2-Year Risk Level&quot; + ' risk.'

define &quot;5-YearRiskDetail&quot;:
	'5-year kidney failure risk of ' + ToString(&quot;5-Year CKD Risk Percent&quot;) + '% is considered to be ' + &quot;5-Year Risk Level&quot; + ' risk.'

define &quot;2-YearRiskSeverity&quot;: if &quot;2-Year Risk Level&quot; = 'High' then 'warning' else 'info'

define &quot;5-YearRiskSeverity&quot;: if &quot;5-Year Risk Level&quot; = 'High' then 'warning' else 'info'

define &quot;2-Year CKD Risk Percent&quot;:
  &quot;2-Year CKD Risk&quot; risk
    return Round(risk * 100, 2)

define &quot;5-Year CKD Risk Percent&quot;:
  &quot;5-Year CKD Risk&quot; risk
    return Round(risk * 100, 2)

define &quot;2-Year CKD Risk&quot;:
  &quot;Last eGFR Quantity&quot; egfr
    return calculateCkdRisk(0.9750, 0, AgeInYears(), egfr, UACRtoMetric(&quot;Last UACR Quantity&quot;))

define &quot;5-Year CKD Risk&quot;:
  &quot;Last eGFR Quantity&quot; egfr
    return calculateCkdRisk(0.9240, 0, AgeInYears(), egfr, UACRtoMetric(&quot;Last UACR Quantity&quot;))

// The ckdFactor is a variable determined by (Non-) North American location and whether calculation is 2 or 5 year prediction
define function calculateCkdRisk(ckdFactor Decimal, sex Integer, age Integer, egfr System.Quantity, acr System.Quantity):
  1.0 - Power(ckdFactor, Exp(-0.2201 * (age / 10 - 7.036) + 0.2467 * (sex - 0.5642) - 0.5567 * (egfr.value / 5 - 7.222) + 0.4510 * (Ln(acr.value) - 5.137)))

define &quot;2-Year Risk Level&quot;:
  &quot;2-Year CKD Risk Percent&quot; riskPercent
  	return case
      when riskPercent &lt; 5
    		then 'Low'
    	when riskPercent &lt; 15
    		then 'Intermediate'
    	when riskPercent &gt; 15
    		then 'High'
      else null
  	end

define &quot;5-Year Risk Level&quot;:
  &quot;5-Year CKD Risk Percent&quot; riskPercent
  	return case
      when riskPercent &lt; 5
    		then 'Low'
    	when riskPercent &lt; 15
    		then 'Intermediate'
    	when riskPercent &gt; 15
    		then 'High'
      else null
  	end

// Conversion functions

define function PeriodToInterval(value FHIR.Period):
	Interval[value.&quot;start&quot;.value, value.&quot;end&quot;.value]

define function CodingToCode(coding FHIR.Coding):
	System.Code {
		code: coding.code.value,
		system: coding.system.value,
		version: coding.version.value,
		display: coding.display.value
	}

define function ToConcept(concept FHIR.CodeableConcept):
    System.Concept {
        codes: concept.coding C return CodingToCode(C),
        display: concept.text.value
    }

define function ToQuantity(quantity FHIR.Quantity):
    System.Quantity {
        value: quantity.value.value,
        unit: quantity.unit.value
    }

define function UACRtoMetric(qty System.Quantity):
	case when qty.unit = 'mg/mmol creatinine' then
		System.Quantity { value: qty.value * 8.84, unit: 'mg/g' }
	when qty.unit = 'mg/g' then
    qty
	else
    // unknown units, ignore this quantity in calculation
		null
	end

define function ToMetric(qty System.Quantity):
	case when qty.unit = 'lb' then
		System.Quantity { value: qty.value * 0.454, unit: 'kg' }
	when qty.unit = 'in' then
		System.Quantity { value: qty.value * 0.0254, unit: 'm' }
	else
		qty
	end
</code></pre><p><code>No Content</code> (<code>application/elm+xml</code>)</p></div>
  </text>
  <extension
             url="http://hl7.org/fhir/StructureDefinition/cqf-knowledgeCapability">
    <valueCode value="shareable"/>
  </extension>
  <extension
             url="http://hl7.org/fhir/StructureDefinition/cqf-knowledgeCapability">
    <valueCode value="computable"/>
  </extension>
  <extension
             url="http://hl7.org/fhir/StructureDefinition/cqf-knowledgeCapability">
    <valueCode value="publishable"/>
  </extension>
  <extension
             url="http://hl7.org/fhir/StructureDefinition/cqf-knowledgeRepresentationLevel">
    <valueCode value="structured"/>
  </extension>
  <url value="http://cqframework.org/cpg-example-ckd/Library/CKDRiskLogic"/>
  <version value="1.0.0"/>
  <name value="CKDRiskLogic"/>
  <title value="Chronic Kidney Disease (CKD) risk screening logic"/>
  <status value="active"/>
  <experimental value="true"/>
  <type>
    <coding>
      <system value="http://terminology.hl7.org/CodeSystem/library-type"/>
      <code value="logic-library"/>
    </coding>
  </type>
  <date value="2024-11-18T18:20:09+00:00"/>
  <publisher value="HL7 International - Clinical Decision Support WG"/>
  <contact>
    <name value="HL7 International - Clinical Decision Support WG"/>
    <telecom>
      <system value="url"/>
      <value value="http://www.hl7.org/Special/committees/dss/index.cfm"/>
    </telecom>
  </contact>
  <description value="Chronic Kidney Disease (CKD) risk screening logic"/>
  <jurisdiction>
    <coding>
      <system value="http://unstats.un.org/unsd/methods/m49/m49.htm"/>
      <code value="001"/>
      <display value="World"/>
    </coding>
  </jurisdiction>
  <content>
    <contentType value="text/cql"/>
    <data
          value="bGlicmFyeSBDS0RSaXNrTG9naWMgdmVyc2lvbiAnMS4wJwoKdXNpbmcgRkhJUiB2ZXJzaW9uICc0LjAuMCcKCmluY2x1ZGUgRkhJUkhlbHBlcnMgdmVyc2lvbiAnNC4wLjAnIGNhbGxlZCBGSElSSGVscGVycwoKY29kZXN5c3RlbSAiU05PTUVEQ1QiOiAnaHR0cDovL3Nub21lZC5pbmZvL3NjdCcKY29kZXN5c3RlbSAiTE9JTkMiOiAnaHR0cDovL2xvaW5jLm9yZycKY29kZXN5c3RlbSAiUnhOb3JtIjogJ2h0dHA6Ly93d3cubmxtLm5paC5nb3YvcmVzZWFyY2gvdW1scy9yeG5vcm0nCgp2YWx1ZXNldCAiQ2hyb25pYyBLaWRuZXkgRGlzZWFzZSI6ICdja2QtdmFsdWVzZXQtY2tkJwp2YWx1ZXNldCAiRGlhYmV0ZXMgbWVsbGl0dXMiOiAnY2tkLXZhbHVlc2V0LWRpYWJldGVzJwoKdmFsdWVzZXQgImVHRlIgTGFicyI6ICdja2QtdmFsdWVzZXQtZWdmcicKdmFsdWVzZXQgIlVBQ1IgTGFicyI6ICdja2QtdmFsdWVzZXQtdWFjcicKdmFsdW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ewogICAgICAgIHZhbHVlOiBxdWFudGl0eS52YWx1ZS52YWx1ZSwKICAgICAgICB1bml0OiBxdWFudGl0eS51bml0LnZhbHVlCiAgICB9CgpkZWZpbmUgZnVuY3Rpb24gVUFDUnRvTWV0cmljKHF0eSBTeXN0ZW0uUXVhbnRpdHkpOgoJY2FzZSB3aGVuIHF0eS51bml0ID0gJ21nL21tb2wgY3JlYXRpbmluZScgdGhlbgoJCVN5c3RlbS5RdWFudGl0eSB7IHZhbHVlOiBxdHkudmFsdWUgKiA4Ljg0LCB1bml0OiAnbWcvZycgfQoJd2hlbiBxdHkudW5pdCA9ICdtZy9nJyB0aGVuCiAgICBxdHkKCWVsc2UKICAgIC8vIHVua25vd24gdW5pdHMsIGlnbm9yZSB0aGlzIHF1YW50aXR5IGluIGNhbGN1bGF0aW9uCgkJbnVsbAoJZW5kCgpkZWZpbmUgZnVuY3Rpb24gVG9NZXRyaWMocXR5IFN5c3RlbS5RdWFudGl0eSk6CgljYXNlIHdoZW4gcXR5LnVuaXQgPSAnbGInIHRoZW4KCQlTeXN0ZW0uUXVhbnRpdHkgeyB2YWx1ZTogcXR5LnZhbHVlICogMC40NTQsIHVuaXQ6ICdrZycgfQoJd2hlbiBxdHkudW5pdCA9ICdpbicgdGhlbgoJCVN5c3RlbS5RdWFudGl0eSB7IHZhbHVlOiBxdHkudmFsdWUgKiAwLjAyNTQsIHVuaXQ6ICdtJyB9CgllbHNlCgkJcXR5CgllbmQK"/>
  </content>
  <content>
    <contentType value="application/elm+xml"/>
  </content>
</Library>