Structured Data Capture
4.0.0-ballot - STU 4 ballot International flag

This page is part of the Structured Data Capture FHIR IG (v4.0.0-ballot: STU 4 Ballot 1) based on FHIR (HL7® FHIR® Standard) R4. The current version which supersedes this version is 3.0.0. For a full list of available versions, see the Directory of published versions

Library: Congestive Heart Failure Logic (Experimental)

Official URL: http://hl7.org/fhir/uv/sdc/Library/sdc-CHF Version: 4.0.0-ballot
Standards status: Informative Computable Name: CHF
Other Identifiers: OID:2.16.840.1.113883.4.642.40.17.28.1

Logic for an example congestive heart failure pathway

Title: Congestive Heart Failure Logic
Id: sdc-CHF
Version: 4.0.0-ballot
Url: Congestive Heart Failure Logic

urn:oid:2.16.840.1.113883.4.642.40.17.28.1

Experimental: true
Type:

system: http://terminology.hl7.org/CodeSystem/library-type

code: logic-library

display: Logic Library

Date: 2020-11-29 15:54:22-0700
Publisher: HL7 International / FHIR Infrastructure
Description:

Logic for an example congestive heart failure pathway

Jurisdiction: 001
Related Artifacts:

Dependencies

Parameters:
NameTypeMinMaxIn/Out
EncounterEncounter01In
PatientPatient01Out
Body WeightObservation0*Out
Body Weight Change AssertionObservation0*Out
Daily Body WeightResource0*Out
Daily Body Weight ChangeResource0*Out
Body Weight ChangeObservation0*Out
Current Body WeightObservation01Out
Previous Body WeightObservation01Out
Current Body Weight Changeinteger01Out
Urine OutputObservation0*Out
Current Urine OutputObservation01Out
Net Intake/OutputObservation0*Out
Current Net Intake/OutputObservation01Out
Jugular Venous PressureObservation0*Out
Oxygen SaturationObservation0*Out
PotassiumObservation0*Out
CreatinineObservation0*Out
eGFRObservation0*Out
Eligibility CriteriaCondition0*Out
Data Requirements:
TypeProfileMSCode Filter
Observation http://hl7.org/fhir/StructureDefinition/Observation code filter:
path: code

system: http://loinc.org

code: 29463-7

Observation http://hl7.org/fhir/StructureDefinition/Observation code filter:
path: code

system: http://example.org/CodeSystem/chf-codes

code: body-weight-change

Observation http://hl7.org/fhir/StructureDefinition/Observation code filter:
path: code

system: http://loinc.org

code: 9192-6

Observation http://hl7.org/fhir/StructureDefinition/Observation code filter:
path: code

system: http://example.org/CodeSystem/chf-codes

code: net-intake-output

Observation http://hl7.org/fhir/StructureDefinition/Observation code filter:
path: code

system: http://example.org/CodeSystem/chf-codes

code: jvp

Observation http://hl7.org/fhir/StructureDefinition/Observation code filter:
path: code

system: http://loinc.org

code: 2708-6

Observation http://hl7.org/fhir/StructureDefinition/Observation code filter:
path: code

system: http://loinc.org

code: 86919-8

display: Potassium goal [Moles/volume] Serum or Plasma

Observation http://hl7.org/fhir/StructureDefinition/Observation code filter:
path: code

system: http://loinc.org

code: 39802-4

display: Creatinine in dialysis fluid/Creatinine in serum or plasma

Observation http://hl7.org/fhir/StructureDefinition/Observation code filter:
path: code

system: http://example.org/CodeSystem/chf-codes

code: egfr

Condition http://hl7.org/fhir/StructureDefinition/Condition
Content: text/cql
library CHF version '1.0.0'

using FHIR version '4.0.1'

include FHIRHelpers version '4.0.1'

codesystem "SNOMED-CT": 'http://snomed.info/sct'
codesystem "LOINC": 'http://loinc.org'
codesystem "CHFCodes": 'http://hl7.org/fhir/uv/cpg/CodeSystem/chf-codes'
codesystem "Condition Clinical Status Code": 'http://terminology.hl7.org/CodeSystem/condition-clinical'
codesystem "Condition Verification Status Code": 'http://terminology.hl7.org/CodeSystem/condition-ver-status'

code "Congestive heart failure": '42343007' from "SNOMED-CT"

code "Body weight": '29463-7' from "LOINC"
code "Body weight change": 'body-weight-change' from "CHFCodes"
code "Urine output": '9192-6' from "LOINC"
code "Net intake/output": 'net-intake-output' from "CHFCodes"
code "Jugular venous pressure": 'jvp' from "CHFCodes"
code "Oxygen saturation": '2708-6' from "LOINC"
code "Potassium goal": '86919-8' from "LOINC" display 'Potassium goal [Moles/volume] Serum or Plasma' // meq/L
code "Creatinine in serum": '39802-4' from "LOINC" display 'Creatinine in serum or plasma' // NOTE: example shows mg/dL, but no LOINC code has those units?
code "eGFR result": 'egfr' from "CHFCodes" // NOTE: Too many to pick from, needs clinical/terminological SME input, in mol/mm/m2

code "Active condition": 'active' from "Condition Clinical Status Code"
code "Provisional condition": 'provisional' from "Condition Verification Status Code"
code "Confirmed condition": 'confirmed' from "Condition Verification Status Code"

parameter Encounter Encounter

context Patient

// Case Features
define "Body Weight":
  [Observation: "Body weight"] O
    where O.status = 'final'
      and references(O.encounter, Encounter)

define "Body Weight Change Assertion":
  [Observation: "Body weight change"] O
    where O.status = 'final'
      and references(O.encounter, Encounter)

define "Body Weight Change":
  "Daily Body Weight Change" WC
    return Observation {
      id: id { value: Encounter.id + '-bodyweight-change' + ToString(WC.date) },
      extension: {
        Extension {
          url: url { value: 'http://hl7.org/fhir/uv/cpg/StructureDefinition/cpg-instantiatesCaseFeature' },
          value: canonical { value: 'http://hl7.org/fhir/uv/cpg/StructureDefinition/chf-bodyweight-change' }
        },
        Extension {
          url: url { value: 'http://hl7.org/fhir/uv/cpg/StructureDefinition/cpg-caseFeatureType' },
          value: code { value: 'asserted' }
        }
      },
      status: ObservationStatus { value: 'final' },
      code: CodeableConcept {
        coding: {
          Coding {
            system: uri { value: 'http://hl7.org/fhir/uv/cpg/CodeSystem/chf-codes' },
            code: code { value: 'body-weight-change' }
          }
        }
      },
      effective: dateTime { value: WC.date },
      issued: instant { value: Now() },
      subject: referenceTo(Patient),
      encounter: referenceTo(Encounter),
      value: Quantity {
        value: decimal { value: WC.change.value },
        unit: string { value: WC.change.unit },
        system: uri { value: 'http://unitsofmeasure.org' },
        code: code { value: WC.change.unit }
      }
    }

define "Daily Body Weight":
  (expand Encounter.period per day) Date
    let maxWeight: Max("Body Weight" WT where WT.issued same day as Date return WT.value as FHIR.Quantity)
    return { date: Date, weight: maxWeight }

define "Daily Body Weight Change":
  "Daily Body Weight" WT
    let priorWeight: First("Daily Body Weight" PWT where PWT.date < WT.date sort by date descending).weight
    return { date: WT.date, weight: WT.weight, priorWeight: priorWeight, change: WT.weight - priorWeight}

define "Current Body Weight":
  First("Body Weight" WT where WT.issued same day as Today() sort by issued descending)

define "Previous Body Weight":
  First("Body Weight" WT where WT.issued 1 day before day of Today() sort by issued descending)

define "Current Body Weight Change":
  "Current Body Weight".value - "Previous Body Weight".value

define "Urine Output":
  [Observation: "Urine output"] O
    where O.status = 'final'
    and references(O.encounter, Encounter)

define "Current Urine Output":
  First("Urine Output" UO where UO.issued same day as Today() sort by issued descending)

define "Net Intake/Output":
  [Observation: "Net intake/output"] O
    where O.status = 'final'
      and references(O.encounter, Encounter)

define "Current Net Intake/Output":
  First("Net Intake/Output" IO where IO.issued same day as Today() sort by issued descending)

define "Jugular Venous Pressure":
  [Observation: "Jugular venous pressure"] O
    where O.status = 'final'
      and references(O.encounter, Encounter)

define "Oxygen Saturation":
  [Observation: "Oxygen saturation"] O
    where O.status = 'final'
      and references(O.encounter, Encounter)

define "Potassium":
  [Observation: "Potassium goal"] O
    where O.status = 'final'
      and references(O.encounter, Encounter)

define "Creatinine":
  [Observation: "Creatinine in serum"] O
    where O.status = 'final'
      and references(O.encounter, Encounter)

define "eGFR":
  [Observation: "eGFR result"] O
    where O.status = 'final'
      and references(O.encounter, Encounter)


// Eligibility Criteria
define "Eligibility Criteria":
  [Condition] C
    where C.code ~ "Congestive heart failure"
      and C.clinicalStatus ~ "Active condition"
      and C.verificationStatus ~ "Confirmed condition"

// TODO: Handle contained references
// TODO: Handle bundle references
// TODO: Handle remote references
define function references(reference Reference, encounter Encounter):
  EndsWith(reference.reference, '/' + encounter.id)

define function referenceTo(encounter Encounter):
  Reference { reference: string { value: 'Encounter/' + encounter.id } }

define function referenceTo(patient Patient):
  Reference { reference: string { value: 'Patient/' + patient.id } }