Clinical Practice Guidelines Example Implementation Guide - Chronic Kidney Disease
1.0.0 - ci-build
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
Active as of 2024-11-18 |
{
"resourceType" : "Library",
"id" : "CKDRiskLogic",
"text" : {
"status" : "generated",
"div" : "<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'\n\nusing FHIR version '4.0.0'\n\ninclude FHIRHelpers version '4.0.0' called FHIRHelpers\n\ncodesystem "SNOMEDCT": 'http://snomed.info/sct'\ncodesystem "LOINC": 'http://loinc.org'\ncodesystem "RxNorm": 'http://www.nlm.nih.gov/research/umls/rxnorm'\n\nvalueset "Chronic Kidney Disease": 'ckd-valueset-ckd'\nvalueset "Diabetes mellitus": 'ckd-valueset-diabetes'\n\nvalueset "eGFR Labs": 'ckd-valueset-egfr'\nvalueset "UACR Labs": 'ckd-valueset-uacr'\nvalueset "Creatinine Labs": 'ckd-valueset-creatinine'\n\ncode "Blood pressure systolic and diastolic": '55284-4' from "LOINC"\n\ncontext Patient\n\n// Conditions\n//\ndefine "Has CKD or Diabetes":\n "Has CKD" or "Has Diabetes"\n\ndefine "Has CKD":\n exists( "Chronic Kidney Disease Dx" )\n\ndefine "No CKD Dx":\n not exists( "Chronic Kidney Disease Dx" )\n\ndefine "Has Diabetes":\n exists( "Diabetes Dx" )\n\ndefine "CKD or Diabetes Dx":\n "Chronic Kidney Disease Dx" union "Diabetes Dx"\n\ndefine "Chronic Kidney Disease Dx":\n [Condition: code in "Chronic Kidney Disease"] condition\n where condition.clinicalStatus.value in { 'active', 'recurrence' }\n\ndefine "Diabetes Dx":\n [Condition: code in "Diabetes mellitus"] condition\n where condition.clinicalStatus.value in { 'active', 'recurrence' }\n\n// Laboratory observations\n//\ndefine "Has eGFR or UACR Lab":\n "Last eGFR Lab Result" is not null\n\tor "Last UACR Lab Result" is not null\n\ndefine "Last eGFR Lab Result":\n Last( [Observation: code in "eGFR Labs"] )\n\ndefine "Last eGFR Quantity":\n "Last eGFR Lab Result" Result\n return ToQuantity(Result.value as Quantity)\n\ndefine "Has Abnormal eGFR":\n "Last eGFR Quantity".value < 60\n\ndefine "Last UACR Lab Result":\n Last( [Observation: code in "UACR Labs"] )\n\ndefine "Last UACR Quantity":\n "Last UACR Lab Result" Result\n return ToQuantity(Result.value as Quantity)\n\ndefine "Has Abnormal UACR":\n "Last UACR Quantity" uacr\n return UACRtoMetric(uacr).value > 30\n\ndefine "Last Creatinine Lab Result":\n Last( [Observation: code in "Creatinine Labs"] )\n\ndefine "Last Creatinine Quantity":\n "Last Creatinine Lab Result" Result\n return ToQuantity(Result.value as Quantity)\n\ndefine "Needs eGFR Lab":\n\t"eGFR Lab is Overdue"\n\t\tor ("eGFR Lab Frequency" is not null and "Last eGFR Lab Result" is null)\n\ndefine "eGFR Lab Frequency":\n\tcase\n\t\twhen "CKD Stage" >= 4\n\t\t\tthen 3 months\n\t\twhen "CKD Stage" >= 3\n\t\t\tthen 6 months\n\t\twhen "Has CKD or Diabetes"\n\t\t\tthen 12 months\n\t\telse null\n\tend\n\ndefine "eGFR Lab is Overdue":\n "Last eGFR Lab Result" Result\n return\n case\n when Result.effective is null\n then true\n when Result.effective is dateTime\n then (Result.effective.value + "eGFR Lab Frequency") < Today()\n when Result.effective is Period\n then (end of PeriodToInterval(Result.effective) + "eGFR Lab Frequency") < Today()\n else false\n end\n\ndefine NeedsGFRSummary: 'Order Renal Lab Panel'\n\ndefine NeedsGFRDetail:\n\tcase\n\t\twhen "CKD Stage" >= 1\n\t\t\tthen 'eGFR lab recommended every ' + ToString("eGFR Lab Frequency") + ' for Stage ' + ToString("CKD Stage") + ' CKD.'\n\t\twhen "Has CKD or Diabetes"\n\t\t\tthen 'eGFR lab recommended every ' + ToString("eGFR Lab Frequency") + ' for CKD or Diabetes.'\n\t\telse null\n\tend\n\ndefine NeedsGFRSeverity: 'info'\n\ndefine "CKD Stage":\n "Last eGFR Quantity" egfr\n \treturn case\n when egfr.value < 15\n \t\tthen 5\n \twhen egfr.value < 30\n \t\tthen 4\n \twhen egfr.value < 60\n \t\tthen 3\n \twhen egfr.value < 90\n \t\tthen 2\n \twhen egfr.value >= 90\n // TODO this does not parse\n //case when UACRtoMetric("Get UACR Quantity").value > 20\n \t\t // then 1\n //else 0\n //end\n then 0\n else 0\n \tend\n\n// Referrals\n//\ndefine "Recommend Nephrology Referral":\n\t"5-Year Risk Level" = 'High'\n\ndefine NephrologyReferralDetail: 'Referral to a nephrologist is recommended when 5-year risk is High'\n\ndefine NephrologyReferralSeverity: 'info'\n\n//\n// Tangri CKD risk model\n//\n// 4 variable\n// 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))\n// 5 year factor = 0.9240\n//\n// 8 variable\n// 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)\n//\t\t– 0.3441 × (albumin – 3.997) + 0.2604 × (phosphorous – 3.916) – 0.07354 × (bicarbonate – 25.57) – 0.2228 × (calcium – 9.355))\n// 5 year factor = 0.9301\n\ndefine "2-YearRiskDetail":\n\t'2-year kidney failure risk of ' + ToString("2-Year CKD Risk Percent") + '% is considered to be ' + "2-Year Risk Level" + ' risk.'\n\ndefine "5-YearRiskDetail":\n\t'5-year kidney failure risk of ' + ToString("5-Year CKD Risk Percent") + '% is considered to be ' + "5-Year Risk Level" + ' risk.'\n\ndefine "2-YearRiskSeverity": if "2-Year Risk Level" = 'High' then 'warning' else 'info'\n\ndefine "5-YearRiskSeverity": if "5-Year Risk Level" = 'High' then 'warning' else 'info'\n\ndefine "2-Year CKD Risk Percent":\n "2-Year CKD Risk" risk\n return Round(risk * 100, 2)\n\ndefine "5-Year CKD Risk Percent":\n "5-Year CKD Risk" risk\n return Round(risk * 100, 2)\n\ndefine "2-Year CKD Risk":\n "Last eGFR Quantity" egfr\n return calculateCkdRisk(0.9750, 0, AgeInYears(), egfr, UACRtoMetric("Last UACR Quantity"))\n\ndefine "5-Year CKD Risk":\n "Last eGFR Quantity" egfr\n return calculateCkdRisk(0.9240, 0, AgeInYears(), egfr, UACRtoMetric("Last UACR Quantity"))\n\n// The ckdFactor is a variable determined by (Non-) North American location and whether calculation is 2 or 5 year prediction\ndefine function calculateCkdRisk(ckdFactor Decimal, sex Integer, age Integer, egfr System.Quantity, acr System.Quantity):\n 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)))\n\ndefine "2-Year Risk Level":\n "2-Year CKD Risk Percent" riskPercent\n \treturn case\n when riskPercent < 5\n \t\tthen 'Low'\n \twhen riskPercent < 15\n \t\tthen 'Intermediate'\n \twhen riskPercent > 15\n \t\tthen 'High'\n else null\n \tend\n\ndefine "5-Year Risk Level":\n "5-Year CKD Risk Percent" riskPercent\n \treturn case\n when riskPercent < 5\n \t\tthen 'Low'\n \twhen riskPercent < 15\n \t\tthen 'Intermediate'\n \twhen riskPercent > 15\n \t\tthen 'High'\n else null\n \tend\n\n// Conversion functions\n\ndefine function PeriodToInterval(value FHIR.Period):\n\tInterval[value."start".value, value."end".value]\n\ndefine function CodingToCode(coding FHIR.Coding):\n\tSystem.Code {\n\t\tcode: coding.code.value,\n\t\tsystem: coding.system.value,\n\t\tversion: coding.version.value,\n\t\tdisplay: coding.display.value\n\t}\n\ndefine function ToConcept(concept FHIR.CodeableConcept):\n System.Concept {\n codes: concept.coding C return CodingToCode(C),\n display: concept.text.value\n }\n\ndefine function ToQuantity(quantity FHIR.Quantity):\n System.Quantity {\n value: quantity.value.value,\n unit: quantity.unit.value\n }\n\ndefine function UACRtoMetric(qty System.Quantity):\n\tcase when qty.unit = 'mg/mmol creatinine' then\n\t\tSystem.Quantity { value: qty.value * 8.84, unit: 'mg/g' }\n\twhen qty.unit = 'mg/g' then\n qty\n\telse\n // unknown units, ignore this quantity in calculation\n\t\tnull\n\tend\n\ndefine function ToMetric(qty System.Quantity):\n\tcase when qty.unit = 'lb' then\n\t\tSystem.Quantity { value: qty.value * 0.454, unit: 'kg' }\n\twhen qty.unit = 'in' then\n\t\tSystem.Quantity { value: qty.value * 0.0254, unit: 'm' }\n\telse\n\t\tqty\n\tend\n</code></pre><p><code>No Content</code> (<code>application/elm+xml</code>)</p></div>"
},
"extension" : [
{
"url" : "http://hl7.org/fhir/StructureDefinition/cqf-knowledgeCapability",
"valueCode" : "shareable"
},
{
"url" : "http://hl7.org/fhir/StructureDefinition/cqf-knowledgeCapability",
"valueCode" : "computable"
},
{
"url" : "http://hl7.org/fhir/StructureDefinition/cqf-knowledgeCapability",
"valueCode" : "publishable"
},
{
"url" : "http://hl7.org/fhir/StructureDefinition/cqf-knowledgeRepresentationLevel",
"valueCode" : "structured"
}
],
"url" : "http://cqframework.org/cpg-example-ckd/Library/CKDRiskLogic",
"version" : "1.0.0",
"name" : "CKDRiskLogic",
"title" : "Chronic Kidney Disease (CKD) risk screening logic",
"status" : "active",
"experimental" : true,
"type" : {
"coding" : [
{
"system" : "http://terminology.hl7.org/CodeSystem/library-type",
"code" : "logic-library"
}
]
},
"date" : "2024-11-18T18:20:09+00:00",
"publisher" : "HL7 International - Clinical Decision Support WG",
"contact" : [
{
"name" : "HL7 International - Clinical Decision Support WG",
"telecom" : [
{
"system" : "url",
"value" : "http://www.hl7.org/Special/committees/dss/index.cfm"
}
]
}
],
"description" : "Chronic Kidney Disease (CKD) risk screening logic",
"jurisdiction" : [
{
"coding" : [
{
"system" : "http://unstats.un.org/unsd/methods/m49/m49.htm",
"code" : "001",
"display" : "World"
}
]
}
],
"content" : [
{
"contentType" : "text/cql",
"data" : "bGlicmFyeSBDS0RSaXNrTG9naWMgdmVyc2lvbiAnMS4wJwoKdXNpbmcgRkhJUiB2ZXJzaW9uICc0LjAuMCcKCmluY2x1ZGUgRkhJUkhlbHBlcnMgdmVyc2lvbiAnNC4wLjAnIGNhbGxlZCBGSElSSGVscGVycwoKY29kZXN5c3RlbSAiU05PTUVEQ1QiOiAnaHR0cDovL3Nub21lZC5pbmZvL3NjdCcKY29kZXN5c3RlbSAiTE9JTkMiOiAnaHR0cDovL2xvaW5jLm9yZycKY29kZXN5c3RlbSAiUnhOb3JtIjogJ2h0dHA6Ly93d3cubmxtLm5paC5nb3YvcmVzZWFyY2gvdW1scy9yeG5vcm0nCgp2YWx1ZXNldCAiQ2hyb25pYyBLaWRuZXkgRGlzZWFzZSI6ICdja2QtdmFsdWVzZXQtY2tkJwp2YWx1ZXNldCAiRGlhYmV0ZXMgbWVsbGl0dXMiOiAnY2tkLXZhbHVlc2V0LWRpYWJldGVzJwoKdmFsdWVzZXQgImVHRlIgTGFicyI6ICdja2QtdmFsdWVzZXQtZWdmcicKdmFsdWVzZXQgIlVBQ1IgTGFicyI6ICdja2QtdmFsdWVzZXQtdWFjcicKdmFsdWVzZXQgIkNyZWF0aW5pbmUgTGFicyI6ICdja2QtdmFsdWVzZXQtY3JlYXRpbmluZScKCmNvZGUgIkJsb29kIHByZXNzdXJlIHN5c3RvbGljIGFuZCBkaWFzdG9saWMiOiAnNTUyODQtNCcgZnJvbSAiTE9JTkMiCgpjb250ZXh0IFBhdGllbnQKCi8vIENvbmRpdGlvbnMKLy8KZGVmaW5lICJIYXMgQ0tEIG9yIERpYWJldGVzIjoKICAiSGFzIENLRCI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