-
Notifications
You must be signed in to change notification settings - Fork 24
/
112_QDMandCQLTimingRedux.cql
85 lines (62 loc) · 3.05 KB
/
112_QDMandCQLTimingRedux.cql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
library QDMAndCQLTimingRedux
/*
There are numerous uses of the timing phrase "ends 1 hour or less on or before start of"
to identify an emergency department visit immediately prior to an inpatient encounter.
One such example is from CMS111 - Median Admit Decision Time to ED Departure Time for Admitted Patients
*/
using QDM version '5.4'
context Patient
define "Inpatient Encounter":
["Encounter, Performed"]
define "ED Visit with Admit Order":
["Encounter, Performed"]
/*
// CQL (CMS111v8)
*/
define "Initial Population":
/*Emergency Department visit with a Decision to Admit inpatient followed by an Inpatient encounter within or at an hour of the ED Visit*/
"Inpatient Encounter" Encounter
with "ED Visit with Admit Order" EDAdmitOrder
such that EDAdmitOrder.relevantPeriod ends 1 hour or less before or on start of Encounter.relevantPeriod
/*
QDM (CMS111v6)
AND:
"Occurrence A of Encounter, Performed: Emergency Department Visit"
<= 1 hour(s) ends before or concurrent with start of Occurrence A of $EncounterInpatient
*/
/*
In QDM, this comparison is performed by calculating the difference between the end of the
emergency department visit and the start of the inpatient encounter, and comparing that
to the quantity in the timing phrase. Since the duration calculation rounds, this results in
durations of 1 hour and 59 minutes still being considered "1 hour".
*/
/*
In CQL, the timing phrase "ends 1 hour or less before or on start of" is evaluated using
an interval calculation:
relevantPeriod.end in Interval[start - 1 hour, start]
So the comparison occurs at the millisecond, rather than at the hour as in QDM.
You can still achieve the same behavior in CQL by specifying the comparison precision:
"ends 1 hour or less before or on hour of start of"
*/
define "Initial Population 2":
/*Emergency Department visit with a Decision to Admit inpatient followed by an Inpatient encounter within or at an hour of the ED Visit*/
"Inpatient Encounter" Encounter
with "ED Visit with Admit Order" EDAdmitOrder
such that EDAdmitOrder.relevantPeriod ends 1 hour or less before or on hour of start of Encounter.relevantPeriod
/*
This "hour of" says that not only is the quantity an hour, but the comparison should be performed
at the "hour" precision. This will produce the same behavior as QDM, allowing anything up to
an hour and 59 minutes to be considered "1 hour"
Basically, QDM used the precision of the quantity to do the comparison, whereas CQL
supports identifying both the precision of the quantity
*/
/*
There is a general discussion of using timing relationships in CQL from an author's perspective here:
https://cql.hl7.org/02-authorsguide.html#timing-relationships
The detailed specification for how timing phrases are interpreted is part of the
CQL specification here:
https://cql.hl7.org/05-languagesemantics.html#timing-phrases
There is an exhaustive set of examples for calculating durations here:
https://cql.hl7.org/15-h-timeintervalcalculations.html
Would it be useful to have a worked out set of examples like this for timing phrases specifically?
*/