| 1.0.0 |
| Draft |
|
United States of America
|
| HL7 International / Patient Care |
| HL7 International / Patient Care |
Shared logic for Goal Attainment Scaling.
|
|
logic-library from http://terminology.hl7.org/CodeSystem/library-type
|
Description: FHIR model information
Resource: http://fhir.org/guides/cqf/common/Library/FHIR-ModelInfo|4.0.1
Canonical URL: http://fhir.org/guides/cqf/common/Library/FHIR-ModelInfo|4.0.1
|
Description: Library FHIRCommon
Resource: http://hl7.org/fhir/uv/cql/Library/FHIRCommon|2.0.0
Canonical URL: http://hl7.org/fhir/uv/cql/Library/FHIRCommon|2.0.0
|
Description: Library FHIRHelpers
Resource: http://hl7.org/fhir/uv/cql/Library/FHIRHelpers|4.0.1
Canonical URL: http://hl7.org/fhir/uv/cql/Library/FHIRHelpers|4.0.1
|
Description: Library PC
Resource: http://hl7.org/fhir/us/pco/Library/PCOCommon|0.1.0
Canonical URL: http://hl7.org/fhir/us/pco/Library/PCOCommon|0.1.0
|
Description: Library WM
Resource: http://hl7.org/fhir/us/pco/Library/WhatMattersLogic|0.1.0
Canonical URL: http://hl7.org/fhir/us/pco/Library/WhatMattersLogic|0.1.0
|
Description: Code system LOINC
Resource: Logical Observation Identifiers, Names and Codes (LOINC)
Canonical URL: http://loinc.org
|
Description: Value set PCO Goal Domain Categories
Resource: PCO Goal Domain Categories
Canonical URL: http://hl7.org/fhir/us/pco/ValueSet/pco-goal-domain-categories
|
Description: Value set Goal Attainment Scaling (GAS) Score
Resource: Goal Attainment Scaling (GAS) Score
Canonical URL: http://hl7.org/fhir/us/pco/ValueSet/goal-attainment-scaling-score
|
Description: Value set PROM Target Measures
Resource: PROM Target Measure Scores
Canonical URL: http://hl7.org/fhir/us/pco/ValueSet/prom-target-measures
|
Type: Patient
Profile(s):
Patient
|
Type: Observation
Profile(s):
Observation
Must Support Elements: code
Code Filter(s):
Path: code
ValueSet: Goal Attainment Scaling (GAS) Score
|
Type: Observation
Profile(s):
Observation
Must Support Elements: code
Code Filter(s):
Path: code
ValueSet: PROM Target Measure Scores
|
Type: Goal
Profile(s):
Goal
Must Support Elements: id, id.value, category, measure, start
|
Type: CarePlan
Profile(s):
CarePlan
Must Support Elements: id, id.value
|
| Name |
Use |
Card. |
Type |
Documentation |
| Measurement Period |
In |
0..1 |
Period |
|
| Follow-Up Interval |
In |
0..1 |
Range |
|
| Patient |
Out |
0..1 |
Patient |
|
| GAS Scores |
Out |
0..* |
Observation |
|
| GoalSummary |
Out |
0..* |
Resource |
|
| PCO Goals |
Out |
0..* |
Goal |
|
| CarPlanSummary |
Out |
0..* |
Resource |
|
| All Goals |
Out |
0..* |
Goal |
|
| GAS Goals |
Out |
0..* |
Goal |
|
| All Care Plans |
Out |
0..* |
CarePlan |
|
| PCO Care Plans |
Out |
0..* |
CarePlan |
|
| PCO Goals with GAS and Action Plan |
Out |
0..* |
Goal |
|
| PROM Scores |
Out |
0..* |
Observation |
|
| GAS Patient Scores |
Out |
0..* |
Observation |
|
| GAS Practitioner Scores |
Out |
0..* |
Observation |
|
| GAS Caregiver Scores |
Out |
0..* |
Observation |
|
| PCO Goals During Measurement Period |
Out |
0..* |
Goal |
|
| Baseline Scores Before Follow-Up Period |
Out |
0..* |
Observation |
|
| Follow-Up Scores During Measurement Period |
Out |
0..* |
Observation |
|
|
library GoalAttainmentLogic version '0.1.0'
using FHIR version '4.0.1'
include hl7.fhir.uv.cql.FHIRCommon version '2.0.0'
include hl7.fhir.uv.cql.FHIRHelpers version '4.0.1'
include PCOCommon version '0.1.0' called PC
include WhatMattersLogic version '0.1.0' called WM
codesystem "LOINC": 'http://loinc.org'
valueset "PCO Goal Domain Categories": 'http://hl7.org/fhir/us/pco/ValueSet/pco-goal-domain-categories'
valueset "Goal Attainment Scaling (GAS) Score": 'http://hl7.org/fhir/us/pco/ValueSet/goal-attainment-scaling-score'
valueset "PROM Target Measures": 'http://hl7.org/fhir/us/pco/ValueSet/prom-target-measures'
code "Goal attainment scale": '107332-9' from "LOINC" display 'Goal attainment scale'
code "Practitioner follow-up goal attainment scaling score": '107333-7' from "LOINC" display 'Practitioner follow-up goal attainment scaling score'
code "Patient follow-up goal attainment scaling score": '107334-5' from "LOINC" display 'Patient follow-up goal attainment scaling score'
code "Caregiver follow-up goal attainment scaling score": '107331-1' from "LOINC" display 'Caregiver follow-up goal attainment scaling score'
parameter "Measurement Period" Interval<DateTime>
default Interval[@2024-01-01T00:00:00.000Z, @2024-12-31T23:59:59.999Z]
parameter "Follow-Up Interval" Interval<System.Quantity>
default Interval[2 weeks, 26 weeks]
context Patient
// For debugging
define GoalSummary:
[Goal] goal
return {
id: goal.id.value,
dueDate: goal.dueDate(),
wellbeingCategory: goal.category in WM."Well-Being Categories",
goalDomainCategory: goal.category in "PCO Goal Domain Categories",
addressesWhatMatters: exists goal.whatMattersObservations(),
hasGAS: goal.hasGAS(),
hasPROM: goal.hasPROM(),
carePlans: goal.carePlans()
}
// For debugging
define CarPlanSummary:
[CarePlan] carePlan
return {
id: carePlan.id.value,
pcoGoals: carePlan.pcoGoals()
}
// All FHIR Goals for this patient. Useful while debugging to verify subset matched by "PCO Goals".
define "All Goals":
[Goal] goal
/*
A "PCO Goal" is any FHIR Goal that has a category in "What Matters Category" or "PCO Domain Categories"
or that addresses a What Matters observation
and has a start date.
*/
define "PCO Goals":
[Goal] goal
where (goal.category in WM."Well-Being Categories"
or goal.category in "PCO Goal Domain Categories"
or exists goal.whatMattersObservations())
and (goal.start as FHIR.date) is not null
// A "GAS Goal" is any PCO Goal that includes GAS extensions
define "GAS Goals":
"PCO Goals" goal
where goal.hasGAS()
// All FHIR CarePlan resources for this patient. Useful for verifying subset matched by "PCO Care Plans".
define "All Care Plans":
[CarePlan] carePlan
// A "PCO CarePlan" is any FHIR CarePlan that includes a PCO Goal
define "PCO Care Plans":
[CarePlan] carePlan
where exists carePlan.pcoGoals()
/*
@description: Returns a list of Goals with goal attainment scaling (GAS) extensions and an associated CarePlan.
*/
define "PCO Goals with GAS and Action Plan":
"GAS Goals" goal
where exists goal.carePlans()
// Observations containing a PROM score.
define "PROM Scores":
[Observation: "PROM Target Measures"]
// Observations containing a GAS score.
define "GAS Scores":
[Observation: "Goal Attainment Scaling (GAS) Score"]
// Returns a collection of Observations with a patient's GAS scores.
define "GAS Patient Scores":
"GAS Scores" obs
where obs.code = "Patient follow-up goal attainment scaling score"
// where exists obs.performer.resolvePatients()
// Returns a collection of Observations with a practitioner's GAS scores.
define "GAS Practitioner Scores":
"GAS Scores" obs
where obs.code = "Practitioner follow-up goal attainment scaling score"
// where exists obs.performer.resolvePractitioners()
// Returns a collection of Observations with a caregiver's GAS scores.
define "GAS Caregiver Scores":
"GAS Scores" obs
where obs.code = "Caregiver follow-up goal attainment scaling score"
// where exists obs.performer.resolveRelatedPersons()
define fluent function hasGAS(goal Goal):
exists goal.exts('http://hl7.org/fhir/us/pco/StructureDefinition/pco-goal-attainment-scaling')
or exists (goal.target target
where target.measure = "Goal attainment scale"
)
or exists goal.gasScores()
/// Returns true if this Goal has a PROM code in its target.measure
define fluent function hasPROM(goal Goal):
exists (goal.target target
where target.measure in "PROM Target Measures"
)
// Returns a list of Observation including both GAS and PROM scores
define fluent function pcoScores(goal Goal):
goal.gasScores()
union goal.promScores()
// Returns a list of Observation including only GAS scores
define fluent function gasScores(goal Goal):
"GAS Scores" score
where score.focusGoals() contains goal
// Returns a list of Observation including only PROM scores
define fluent function promScores(goal Goal):
"PROM Scores" score
where score.focusGoals() contains goal
// Returns a list of PCO Goals that are included in this CarePlan.
define fluent function pcoGoals(carePlan CarePlan):
flatten( carePlan.goal goalRef
return [Goal] goal
where goalRef.references(goal.id)
and "PCO Goals" contains goal
)
// Returns a list of Goal where focus includes the given Observation.
define fluent function focusGoals(obs Observation):
obs.focus.resolveGoals()
// PCO Goals whose startDate falls within the Measurement Period
define "PCO Goals During Measurement Period":
"PCO Goals" goal
where (ToDateTime(goal.start as FHIR.date) during "Measurement Period")
and (goal.hasGAS() or goal.hasPROM())
and exists goal.carePlans()
/*
Baseline Scares are PCO score observations taken during the Measurement Period,
but before the follow-up period for its Goal. Default follow-up period is
2 weeks to 6 months following the goal startDate.
*/
define "Baseline Scores Before Follow-Up Period":
flatten( "PCO Goals During Measurement Period" goal
let pcoScores: goal.pcoScores()
return pcoScores score
let scoreDate: score.effective as FHIR.dateTime
where (scoreDate during "Measurement Period")
and (scoreDate before start of "Follow-Up Interval For"(goal))
)
/*
Follow-Up Scares are PCO score observations taken during the Measurement Period,
and during the follow-up period for its Goal. Default follow-up period is
2 weeks to 6 months following the goal startDate.
*/
define "Follow-Up Scores During Measurement Period":
flatten( "PCO Goals During Measurement Period" goal
let pcoScores: goal.pcoScores()
return pcoScores score
let scoreDate: score.effective as FHIR.dateTime
where scoreDate during "Measurement Period"
and scoreDate during "Follow-Up Interval For"(goal)
)
/*
Computes the follow-up interval for a Goal based on this measure's "Follow-Up Interval" parameter.
@return Interval<DateTime>
*/
define function "Follow-Up Interval For" (goal Goal):
goal goal
let startDate: ToDateTime(goal.start as FHIR.date)
return Interval(startDate + start of "Follow-Up Interval", startDate + end of "Follow-Up Interval")
|
Encoded data
|
Encoded data
|