[e988c2]: / tests / spec / code_series_ops / test_containment.py

Download this file

66 lines (54 with data), 1.2 kB

 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
from ehrql.codes import SNOMEDCTCode, codelist_from_csv_lines
from ..tables import p
title = "Testing for containment using codes"
table_data = {
p: """
| c1
--+--------
1 | 123000
2 | 456000
3 | 789000
4 |
""",
}
def test_is_in(spec_test):
spec_test(
table_data,
p.c1.is_in([SNOMEDCTCode("123000"), SNOMEDCTCode("789000")]),
{
1: True,
2: False,
3: True,
4: None,
},
)
def test_is_not_in(spec_test):
spec_test(
table_data,
p.c1.is_not_in([SNOMEDCTCode("123000"), SNOMEDCTCode("789000")]),
{
1: False,
2: True,
3: False,
4: None,
},
)
def test_is_in_codelist_csv(spec_test):
codelist = codelist_from_csv_lines(
[
"code",
"123000",
"789000",
],
column="code",
)
spec_test(
table_data,
p.c1.is_in(codelist),
{
1: True,
2: False,
3: True,
4: None,
},
)