-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathExercises02Key.cql
187 lines (131 loc) · 3 KB
/
Exercises02Key.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
/*
Types and Values
Type Categories (Simple, Structured, Interval, List, Choice)
Simple Types (Boolean, Integer, Decimal, String, Date, DateTime, Time)
Clinical Structured Types (Quantities, Ratios, Codes, Concepts)
Structured Values and Classes
Missing Information
Conversions
Type Testing and Casting
Choice Types
*/
library Exercises02Key
define "Boolean True": true
define "Boolean False": false
/*
Fill in the blanks to make the expressions evaluate to true
*/
// # Boolean Values
define "Boolean Not":
(not true) is false
define "Boolean And":
(true and false) is false
define "Boolean Xor":
(true xor false) is true
// Translator issue [#617](https://github.com/cqframework/clinical_quality_language/issues/617)
define "Boolean Implies":
(false implies true) is true
// # String Values
define "Simple String":
'John Doe'
define "String Escapes":
'John O\'Mally'
define "String Equality":
('John Doe' = 'john doe') is false
define "String Comparisons":
('Deer' < 'Doe') is true
// # Numbers
define "Integer":
5
define "Decimal":
5.0
define "Implicit Decimal Conversion":
5 + 5.0
define "Decimal Comparison Ignores Precision":
5.0 = 5.00
define "Standard Arithmetic Precedence":
2 + 5 * 10
define "Use Parentheses to Force Precedence":
(2 + 5) * 10
define "Division Returns Decimal":
10 / 2
define "Use Truncated Divide (div) for Integer Division":
10 div 2
define "Mod returns remainder":
10 mod 2
// # Quantities
define "Mass Quantity":
25 'mg'
define "Length Quantity":
100 'cm2'
define "Respect the Units":
1 'm' = 100 'cm'
define "Calculate the Units":
10 'cm' * 10 'cm'
// # Date and Time Values
define "Date Value":
@2021-03-01
define "DateTime Value":
@2021-03-01T14:30:14.5
define "Time Value (at midnight)":
@T12:00:00.0
define "Time Value":
@T14:30:14.5
define "Partial Date (Year)":
@2014
define "Partial Date (Year-Month)":
@2014-01
define "Partial Time (Hour)":
@T14
define "Partial Time (Hour Minute)":
@T14:30
define "DateTime Function":
DateTime(2014, 7, 5)
define "Time Function":
Time(14, 30)
define "Date From":
date from @2014-01-25T14:30:14
define "Time From":
time from @2014-01-25T14:30:14
define "Component From (Year)":
year from @2014-01-25
define "Now Function":
Now()
define "Today Function":
Today()
define "TimeOfDay Function":
TimeOfDay()
// # Structured Values
define "Simple Info":
Tuple { name: 'Patrick', dob: @2014-01-01 }
define "Nested Info":
{
name: 'Patrick',
dob: @2014-01-01,
address: {
line1: '41 Spinning Ave',
city: 'Dayton',
state: 'OH'
},
phones: {
{
number: '202-413-1234',
use: 'home'
}
}
}
// # Missing Information
define "Null Comparison":
1 = null
define "Null Arithmetic":
1 + null
define "Null Predicate":
1 is null
define "Not Null Predicate":
1 is not null
define "3-Valued Logic And":
false and null
define "3-Valued Logic Or":
true or null
define "Coalesce Expression":
Coalesce(null, 1)