-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsql-result
85 lines (82 loc) · 1.7 KB
/
sql-result
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
----------- Result ------------
----
with recursive r AS (
select attr.key as path, attr.value as val
from observation p,
jsonb_each(resource) attr
UNION
(
WITH prev AS (
select * from r
), obj AS (
select path || '.' || attr.key as path, attr.value as val
from prev, jsonb_each(val) attr
where jsonb_typeof(val) = 'object'
), arr AS (
select path as path, attr as val
from prev, jsonb_array_elements(val) attr
where jsonb_typeof(val) = 'array'
)
select * from obj union select * from arr
)
)
select path, count(*)
from r
group by path
order by path;
----
----------- End ------------
path
--------------------------------------
category
category.coding
category.coding.code
category.coding.display
category.coding.system
code
code.coding
code.coding.code
code.coding.display
code.coding.system
code.text
component
component.code
component.code.coding
component.code.coding.code
component.code.coding.display
component.code.coding.system
component.code.text
component.value
component.value.Quantity
component.value.Quantity.code
component.value.Quantity.system
component.value.Quantity.unit
component.value.Quantity.value
context
context.id
context.type
effective
effective.dateTime
id
issued
meta
meta.profile
resourceType
status
subject
subject.id
subject.type
value
value.CodeableConcept
value.CodeableConcept.coding
value.CodeableConcept.coding.code
value.CodeableConcept.coding.display
value.CodeableConcept.coding.system
value.CodeableConcept.text
value.Quantity
value.Quantity.code
value.Quantity.system
value.Quantity.unit
value.Quantity.value
value.string
(51 rows)