Preventive Care Guidelines IG
1.0.0 - CI Build
Preventive Care Guidelines IG - Local Development build (v1.0.0). See the Directory of published versions
| depends-on | FHIR model information | http://fhir.org/guides/cqf/common/Library/FHIR-ModelInfo|4.0.1 |
| depends-on | Library FHIRHelpers | http://hl7.org/fhir/Library/FHIRHelpers|4.0.1 |
| depends-on | Library C3F | CDSConnectCommons (version 1.0.0) |
| depends-on | Library PCC | PreventiveCareConcepts (version 1.0.0) |
| depends-on | Library Data | PreventiveCareData (version 1.0.0) |
| Patient | out | 0 | 1 | Patient |
| PatientSummary | out | 0 | 1 | Any |
| Type: Patient (Patient) |
| Type: Patient (Patient) | |
| Filter | Value |
| url | One of these codes: [not stated] http://hl7.org/fhir/us/core/StructureDefinition/us-core-race: http://hl7.org/fhir/us/core/StructureDefinition/us-core-race |
text/cql
// # Introduction
// The Preventive Care logic library supports decision-making on preventive care screening.
library PreventiveCareSummary version '1.0.0'
// # Data model #
using FHIR version '4.0.1'
// # Referenced libraries #
// The FHIRHelpers library provides common functions for simplifying interaction w/ the FHIR R4 data model.
include FHIRHelpers version '4.0.1' called FHIRHelpers
// The CDS Connect Commons library provides functions representing commonly used CDS logic and patterns.
include CDSConnectCommons version '1.0.0' called C3F
// The PreventiveCareConcepts library provides terminology concepts used to identify data elements throughout the artifact.
include PreventiveCareConcepts version '1.0.0' called PCC
// The PreventiveCareData library provides common data retrieval logic for preventive care guidelines.
include PreventiveCareData version '1.0.0' called Data
// # CDS logic #
context Patient
define PatientSummary: {
givenName: Data."Patient Given Name",
fullName: Data."Patient Full Name",
gender: Patient.gender.value,
birthSex: Data."Patient birth sex",
age: AgeInYears(),
race: Data."Patient Race Text",
pcpName: Data."Patient PCP name"
}
/*
* Helper expressions and functions used by summaries.
*/
// Returns the first-found display text for a CodeableConcept, looking first at the `text` attribute, then the
// `display` on each `coding` until it finds a non-null value.
// @param c - a FHIR CodeableConcept to get text from
// @returns {System.String} the display text or null if none is found
define function ConceptText(c FHIR.CodeableConcept):
Coalesce(c.text.value, Coalesce((c.coding) c2 return c2.display.value), Coalesce((c.coding) c3 return c3.code.value))
// Returns a text representation of a Quantity with the Quantity's value and unit.
// If the unit is {score}, then omit it (as it is not useful to display)
// @param q - a FHIR Quantity to get text for
// @returns {System.String} the text representation of the Quantity
define function QuantityText(q FHIR.Quantity):
if (q is null) then null
else if (q.unit is not null and q.unit.value != '{score}') then ToString(q.value.value) + ' ' + q.unit.value
else if (q.code is not null and q.code.value != '{score}') then ToString(q.value.value) + ' ' + q.code.value
else ToString(q.value.value)
// Returns a list of observation view Tuples.
define function ReportObservations(ObsList List<Observation>):
ObsList o
return { // result decimal value
Date: ToString(C3F.FindDate(o)),
Name: ConceptText(o.code), // display nanme
Result: QuantityText(o.value as FHIR.Quantity), // result value with units
ResultValue: (o.value as FHIR.Quantity).value // result value as Decimal
}
sort by Date asc
define function ReportLabObservation(o FHIR.Observation):
if (o is null) then null
else
{
Date: ToString(C3F.FindDate(o)),
Name: ConceptText(o.code), // display nanme
ResultText: QuantityText(o.value as FHIR.Quantity), // result value with units
ResultValue: (o.value as FHIR.Quantity).value,
ResultUnits: (o.value as FHIR.Quantity).unit.value,
ReferenceRange: LabReferenceRange(o),
Interpretation: LabInterpretation(o),
Flag: LabReferenceRangeFlag(o) // true if value out of range, else false
}
define function LabReferenceRange(o FHIR.Observation):
if (o is null or o.referenceRange is null) then null
else
Coalesce(First(o.referenceRange.text),
ToString(LabReferenceRangeLow(o)) + ' - ' + ToString(LabReferenceRangeHigh(o))
)
define function LabReferenceRangeLow(o FHIR.Observation):
First(o.referenceRange).low.value
define function LabReferenceRangeHigh(o FHIR.Observation):
First(o.referenceRange).high.value
define function LabReferenceRangeFlag(o FHIR.Observation):
if (o.value.value < LabReferenceRangeLow(o)
or o.value.value > LabReferenceRangeHigh(o)) then true
else false
define function LabInterpretation(o FHIR.Observation):
if (o.interpretation is not null) then
Coalesce(First(o.interpretation.text), First(First(o.interpretation).coding.display))
else if o.referenceRange is not null then
// Derive interpretation from the reference range, return null if within normal range.
if o.value.value < LabReferenceRangeLow(o) then 'L'
else if o.value.value > LabReferenceRangeHigh(o) then 'H'
else null
else
null
Content not shown - (application/elm+xml, size = 95Kb)