tricc-oo 1.5.22__py3-none-any.whl → 1.5.24__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. tests/build.py +17 -23
  2. tests/test_cql.py +37 -108
  3. tests/to_ocl.py +15 -17
  4. tricc_oo/__init__.py +0 -6
  5. tricc_oo/converters/codesystem_to_ocl.py +51 -40
  6. tricc_oo/converters/cql/cqlLexer.py +1 -0
  7. tricc_oo/converters/cql/cqlListener.py +1 -0
  8. tricc_oo/converters/cql/cqlParser.py +1 -0
  9. tricc_oo/converters/cql/cqlVisitor.py +1 -0
  10. tricc_oo/converters/cql_to_operation.py +125 -123
  11. tricc_oo/converters/datadictionnary.py +45 -54
  12. tricc_oo/converters/drawio_type_map.py +143 -61
  13. tricc_oo/converters/tricc_to_xls_form.py +14 -24
  14. tricc_oo/converters/utils.py +3 -3
  15. tricc_oo/converters/xml_to_tricc.py +286 -231
  16. tricc_oo/models/__init__.py +2 -1
  17. tricc_oo/models/base.py +300 -308
  18. tricc_oo/models/calculate.py +63 -49
  19. tricc_oo/models/lang.py +26 -27
  20. tricc_oo/models/ocl.py +146 -161
  21. tricc_oo/models/ordered_set.py +15 -19
  22. tricc_oo/models/tricc.py +145 -89
  23. tricc_oo/parsers/xml.py +15 -30
  24. tricc_oo/serializers/planuml.py +4 -6
  25. tricc_oo/serializers/xls_form.py +81 -135
  26. tricc_oo/strategies/input/base_input_strategy.py +28 -32
  27. tricc_oo/strategies/input/drawio.py +59 -71
  28. tricc_oo/strategies/output/base_output_strategy.py +142 -67
  29. tricc_oo/strategies/output/fhir_form.py +377 -0
  30. tricc_oo/strategies/output/html_form.py +224 -0
  31. tricc_oo/strategies/output/openmrs_form.py +647 -0
  32. tricc_oo/strategies/output/spice.py +106 -127
  33. tricc_oo/strategies/output/xls_form.py +263 -222
  34. tricc_oo/strategies/output/xlsform_cdss.py +623 -142
  35. tricc_oo/strategies/output/xlsform_cht.py +108 -115
  36. tricc_oo/strategies/output/xlsform_cht_hf.py +13 -24
  37. tricc_oo/visitors/tricc.py +1297 -1016
  38. tricc_oo/visitors/utils.py +16 -16
  39. tricc_oo/visitors/xform_pd.py +91 -89
  40. {tricc_oo-1.5.22.dist-info → tricc_oo-1.5.24.dist-info}/METADATA +127 -84
  41. tricc_oo-1.5.24.dist-info/RECORD +50 -0
  42. tricc_oo-1.5.24.dist-info/licenses/LICENSE +373 -0
  43. tricc_oo-1.5.22.dist-info/RECORD +0 -46
  44. {tricc_oo-1.5.22.dist-info → tricc_oo-1.5.24.dist-info}/WHEEL +0 -0
  45. {tricc_oo-1.5.22.dist-info → tricc_oo-1.5.24.dist-info}/top_level.txt +0 -0
@@ -1,38 +1,67 @@
1
- from strenum import StrEnum
2
- from tricc_oo.models.base import *
3
- from tricc_oo.models.calculate import *
1
+ from tricc_oo.models.base import (
2
+ TriccNodeType
3
+ )
4
4
 
5
+ from tricc_oo.models.calculate import (
6
+ TriccNodeBridge,
7
+ TriccNodeActivityEnd,
8
+ TriccNodeActivityStart,
9
+ TriccNodeEnd,
10
+ TriccNodeAdd,
11
+ TriccNodeCount,
12
+ TriccNodeWait,
13
+ TriccNodeCalculate,
14
+ TriccNodeRhombus,
15
+ TriccNodeExclusive,
16
+ TriccNodeProposedDiagnosis,
17
+ TriccNodeDiagnosis,
18
+ TriccNodeInput,
19
+ )
5
20
 
21
+ from tricc_oo.models.tricc import (
22
+ TriccNodeMainStart,
23
+ TriccNodeLinkIn,
24
+ TriccNodeGoTo,
25
+ TriccNodeSelectMultiple,
26
+ TriccNodeSelectNotAvailable,
27
+ TriccNodeText,
28
+ TriccNodeDecimal,
29
+ TriccNodeInteger,
30
+ TriccNodeDate,
31
+ TriccNodeSelectOne,
32
+ TriccNodeSelectYesNo,
33
+ TriccNodeNote,
34
+ )
6
35
  TYPE_MAP = {
7
36
  TriccNodeType.start: {
8
37
  "objects": ["UserObject", "object"],
9
- "attributes": ['process', 'parent', 'form_id','relevance',"priority"],
38
+ "attributes": ["process", "parent", "form_id", "relevance", "priority"],
10
39
  "mandatory_attributes": ["label"],
11
- "model": TriccNodeMainStart
40
+ "model": TriccNodeMainStart,
12
41
  },
13
42
  TriccNodeType.activity_start: {
14
43
  "objects": ["UserObject", "object"],
15
- "attributes": ['parent', 'parent', 'instance', 'relevance',"priority"],
44
+ "attributes": ["parent", "parent", "instance", "relevance", "priority"],
16
45
  "mandatory_attributes": ["label", "name"],
17
- "model": TriccNodeActivityStart
46
+ "model": TriccNodeActivityStart,
18
47
  },
19
48
  TriccNodeType.note: {
20
49
  "objects": ["UserObject", "object"],
21
- "attributes": ['relevance',"priority"],
50
+ "attributes": ["relevance", "priority", "context_type"],
22
51
  "mandatory_attributes": ["label", "name"],
23
- "model": TriccNodeNote
52
+ "model": TriccNodeNote,
24
53
  },
25
54
  TriccNodeType.hint: {
26
55
  "objects": ["UserObject", "object"],
27
56
  "attributes": [],
28
57
  "mandatory_attributes": ["label"],
29
- "model": None
58
+ "model": None,
30
59
  },
31
60
  TriccNodeType.help: {
32
61
  "objects": ["UserObject", "object"],
33
62
  "attributes": [],
34
63
  "mandatory_attributes": ["label"],
35
- "model": None
64
+ "model": None,
36
65
  },
37
66
  TriccNodeType.select_one: {
38
67
  "has_options": True,
@@ -44,10 +73,13 @@ TYPE_MAP = {
44
73
  "constraint",
45
74
  "constraint_message",
46
75
  "relevance",
47
- "priority", "trigger", "default"
76
+ "priority",
77
+ "trigger",
78
+ "default",
79
+ "context_type",
48
80
  ],
49
81
  "mandatory_attributes": ["label", "name", "list_name"],
50
- "model": TriccNodeSelectOne
82
+ "model": TriccNodeSelectOne,
51
83
  },
52
84
  TriccNodeType.select_multiple: {
53
85
  "has_options": True,
@@ -59,10 +91,13 @@ TYPE_MAP = {
59
91
  "constraint",
60
92
  "constraint_message",
61
93
  "relevance",
62
- "priority", "trigger", "default"
94
+ "priority",
95
+ "trigger",
96
+ "default",
97
+ "context_type",
63
98
  ],
64
99
  "mandatory_attributes": ["label", "name", "list_name"],
65
- "model": TriccNodeSelectMultiple
100
+ "model": TriccNodeSelectMultiple,
66
101
  },
67
102
  TriccNodeType.decimal: {
68
103
  "objects": ["UserObject", "object"],
@@ -74,10 +109,13 @@ TYPE_MAP = {
74
109
  "constraint_message",
75
110
  "required",
76
111
  "relevance",
77
- "priority", "trigger", "default"
112
+ "priority",
113
+ "trigger",
114
+ "default",
115
+ "context_type",
78
116
  ],
79
117
  "mandatory_attributes": ["label", "name"],
80
- "model": TriccNodeDecimal
118
+ "model": TriccNodeDecimal,
81
119
  },
82
120
  TriccNodeType.integer: {
83
121
  "objects": ["UserObject", "object"],
@@ -89,66 +127,99 @@ TYPE_MAP = {
89
127
  "constraint_message",
90
128
  "required",
91
129
  "relevance",
92
- "priority", "trigger", "default"
93
-
130
+ "priority",
131
+ "trigger",
132
+ "default",
133
+ "context_type",
94
134
  ],
95
135
  "mandatory_attributes": ["label", "name"],
96
- "model": TriccNodeInteger
136
+ "model": TriccNodeInteger,
97
137
  },
98
-
99
138
  TriccNodeType.text: {
100
139
  "objects": ["UserObject", "object"],
101
- "attributes": ["save", "relevance","priority", "trigger", "default", "constraint", "constraint_message"],
102
- "mandatory_attributes": ["label", 'name'],
103
- "model": TriccNodeText
140
+ "attributes": [
141
+ "save",
142
+ "relevance",
143
+ "priority",
144
+ "trigger",
145
+ "default",
146
+ "constraint",
147
+ "constraint_message",
148
+ "context_type",
149
+ ],
150
+ "mandatory_attributes": ["label", "name"],
151
+ "model": TriccNodeText,
104
152
  },
105
153
  TriccNodeType.date: {
106
154
  "objects": ["UserObject", "object"],
107
- "attributes": ["save", "relevance","priority", "trigger", "default", "constraint", "constraint_message"],
155
+ "attributes": [
156
+ "save",
157
+ "relevance",
158
+ "priority",
159
+ "trigger",
160
+ "default",
161
+ "constraint",
162
+ "constraint_message",
163
+ "context_type",
164
+ ],
108
165
  "mandatory_attributes": ["label", "name"],
109
- "model": TriccNodeDate
166
+ "model": TriccNodeDate,
110
167
  },
111
168
  TriccNodeType.add: {
112
169
  "objects": ["UserObject", "object"],
113
170
  "attributes": ["save", "expression", "trigger"],
114
- "mandatory_attributes": ['label', "name"],
115
- "model": TriccNodeAdd
171
+ "mandatory_attributes": ["label", "name"],
172
+ "model": TriccNodeAdd,
116
173
  },
117
174
  TriccNodeType.count: {
118
175
  "objects": ["UserObject", "object"],
119
176
  "attributes": ["save", "expression", "trigger"],
120
- "mandatory_attributes": ['label', "name"],
121
- "model": TriccNodeCount
177
+ "mandatory_attributes": ["label", "name"],
178
+ "model": TriccNodeCount,
122
179
  },
123
180
  TriccNodeType.calculate: {
124
181
  "objects": ["UserObject", "object"],
125
- "attributes": ["save", "reference", "trigger"],
126
- "mandatory_attributes": [ "name", 'label'],
127
- "model": TriccNodeCalculate
182
+ "attributes": [
183
+ "save",
184
+ "reference",
185
+ "trigger",
186
+ "context_type",
187
+ "remote_reference",
188
+ ],
189
+ "mandatory_attributes": ["name", "label"],
190
+ "model": TriccNodeCalculate,
128
191
  },
192
+ # TODO: Make either reference or remote_reference mandatory
129
193
  TriccNodeType.rhombus: {
130
194
  "objects": ["UserObject", "object"],
131
- "attributes": ["save", "expression", 'label','priority', "trigger"],
195
+ "attributes": [
196
+ "save",
197
+ "expression",
198
+ "remote_reference",
199
+ "label",
200
+ "priority",
201
+ "trigger",
202
+ ],
132
203
  "mandatory_attributes": ["reference"],
133
- "model": TriccNodeRhombus
204
+ "model": TriccNodeRhombus,
134
205
  },
135
206
  TriccNodeType.wait: {
136
207
  "objects": ["UserObject", "object"],
137
208
  "attributes": ["save", "expression", "trigger"],
138
- "mandatory_attributes": ["reference", "name", 'label'],
139
- "model": TriccNodeWait
209
+ "mandatory_attributes": ["reference", "name", "label"],
210
+ "model": TriccNodeWait,
140
211
  },
141
212
  TriccNodeType.exclusive: {
142
213
  "objects": ["UserObject", "object"],
143
214
  "attributes": [],
144
215
  "mandatory_attributes": [],
145
- "model": TriccNodeExclusive
216
+ "model": TriccNodeExclusive,
146
217
  },
147
218
  TriccNodeType.not_available: {
148
219
  "objects": ["UserObject", "object"],
149
- "attributes": [],
220
+ "attributes": ["context_type"],
150
221
  "mandatory_attributes": ["label", "name", "list_name"],
151
- "model": TriccNodeSelectNotAvailable
222
+ "model": TriccNodeSelectNotAvailable,
152
223
  },
153
224
  TriccNodeType.select_yesno: {
154
225
  "objects": ["UserObject", "object"],
@@ -158,66 +229,77 @@ TYPE_MAP = {
158
229
  "filter",
159
230
  "constraint",
160
231
  "constraint_message",
161
- "relevance","priority", "trigger", "default"
232
+ "relevance",
233
+ "priority",
234
+ "trigger",
235
+ "default",
236
+ "context_type",
162
237
  ],
163
238
  "mandatory_attributes": ["label", "name", "list_name"],
164
- "model": TriccNodeSelectYesNo
239
+ "model": TriccNodeSelectYesNo,
165
240
  },
166
241
  TriccNodeType.link_out: {
167
242
  "objects": ["UserObject", "object"],
168
243
  "attributes": [],
169
244
  "mandatory_attributes": ["reference", "label", "name"],
170
- "model": TriccNodeNote
245
+ "model": TriccNodeNote,
171
246
  },
172
247
  TriccNodeType.link_in: {
173
248
  "objects": ["UserObject", "object"],
174
249
  "attributes": [],
175
250
  "mandatory_attributes": ["label", "name"],
176
- "model": TriccNodeLinkIn
251
+ "model": TriccNodeLinkIn,
177
252
  },
178
253
  TriccNodeType.goto: {
179
254
  "objects": ["UserObject", "object"],
180
- "attributes": ["instance","priority"],
255
+ "attributes": ["instance", "priority"],
181
256
  "mandatory_attributes": ["link", "label", "name"],
182
- "model": TriccNodeGoTo
257
+ "model": TriccNodeGoTo,
183
258
  },
184
259
  TriccNodeType.end: {
185
260
  "objects": ["UserObject", "object"],
186
- "attributes": ['process', 'name', 'label', 'hint'],
187
- "mandatory_attributes": ['label'],
188
- "model": TriccNodeEnd
261
+ "attributes": ["process", "name", "label", "hint"],
262
+ "mandatory_attributes": ["label"],
263
+ "model": TriccNodeEnd,
189
264
  },
190
265
  TriccNodeType.activity_end: {
191
266
  "objects": ["UserObject", "object"],
192
267
  "attributes": [],
193
268
  "mandatory_attributes": [],
194
- "model": TriccNodeActivityEnd
269
+ "model": TriccNodeActivityEnd,
195
270
  },
196
271
  TriccNodeType.bridge: {
197
272
  "objects": ["UserObject", "object"],
198
- "attributes": ["label","priority"],
273
+ "attributes": ["label", "priority"],
199
274
  "mandatory_attributes": [],
200
- "model": TriccNodeBridge
275
+ "model": TriccNodeBridge,
201
276
  },
202
277
  TriccNodeType.diagnosis: {
203
278
  "objects": ["UserObject", "object"],
204
279
  "attributes": ["save", "reference", "priority"],
205
- "mandatory_attributes": [ "name", 'label'],
206
- "model": TriccNodeDiagnosis
280
+ "mandatory_attributes": ["name", "label"],
281
+ "model": TriccNodeDiagnosis,
207
282
  },
208
283
  TriccNodeType.proposed_diagnosis: {
209
284
  "objects": ["UserObject", "object"],
210
- "attributes": ["save", "reference", "severity", "priority", "trigger"],
211
- "mandatory_attributes": [ "name", 'label'],
212
- "model": TriccNodeProposedDiagnosis
285
+ "attributes": [
286
+ "save",
287
+ "remote_reference",
288
+ "reference",
289
+ "severity",
290
+ "priority",
291
+ "trigger",
292
+ ],
293
+ "mandatory_attributes": ["name", "label"],
294
+ "model": TriccNodeProposedDiagnosis,
213
295
  },
214
296
  TriccNodeType.input: {
215
297
  "objects": ["UserObject", "object"],
216
- "attributes": ["save", "reference","datatype"],
217
- "mandatory_attributes": [ "name", 'label'],
218
- "model": TriccNodeInput
298
+ "attributes": ["save", "reference", "datatype", "context_type"],
299
+ "mandatory_attributes": ["name", "label"],
300
+ "model": TriccNodeInput,
219
301
  },
220
- # TriccNodeType.number: {
302
+ # TriccNodeType.number: {
221
303
  # "objects": ["UserObject", "object"],
222
304
  # "attributes": ["constraint", "save", "constraint_message", "required"],
223
305
  # "mandatory_attributes": [],
@@ -1,10 +1,8 @@
1
- from operator import attrgetter
2
- import re
3
-
4
- from tricc_oo.converters.utils import clean_str,clean_name
5
- from tricc_oo.models import *
6
- from tricc_oo.visitors.tricc import clean_or_list, negate_term
7
-
1
+ import logging
2
+ from tricc_oo.converters.utils import clean_name
3
+ from tricc_oo.models.tricc import TriccNodeSelectOption
4
+ from tricc_oo.models.calculate import TriccNodeInput
5
+ from tricc_oo.models.base import TriccNodeBaseModel
8
6
  # from babel import _
9
7
 
10
8
  # TRICC_SELECT_MULTIPLE_CALC_EXPRESSION = "count-selected(${{{0}}}) - number(selected(${{{0}}},'opt_none'))"
@@ -18,10 +16,9 @@ from tricc_oo.visitors.tricc import clean_or_list, negate_term
18
16
  TRICC_NEGATE = "not({})"
19
17
  # TRICC_NUMBER = "number({})"
20
18
  # TRICC_AND_EXPRESSION = '{0} and {1}'
21
- VERSION_SEPARATOR = '_Vv_'
19
+ VERSION_SEPARATOR = "_Vv_"
22
20
  INSTANCE_SEPARATOR = "_Ii_"
23
21
 
24
- import logging
25
22
 
26
23
  logger = logging.getLogger("default")
27
24
 
@@ -34,25 +31,18 @@ def get_export_name(node, replace_dots=True):
34
31
  if node.export_name is None:
35
32
  node.gen_name()
36
33
  if isinstance(node, TriccNodeSelectOption):
37
- node.export_name = node.name
38
- elif node.last == False:
39
- node.export_name = clean_name(node.name + VERSION_SEPARATOR + str(node.version), replace_dots=replace_dots)
40
- # elif node.activity.instance>1:
41
- # if node.version:
42
- # node.export_name = clean_name(node.name + VERSION_SEPARATOR + str(node.version), replace_dots=replace_dots)
43
- # else:
44
- # node.export_name = clean_name(node.name + INSTANCE_SEPARATOR + str(node.activity.instance), replace_dots=replace_dots)
45
-
34
+ node.export_name = node.name
35
+ elif node.last is False:
36
+ node.export_name = clean_name(
37
+ node.name + VERSION_SEPARATOR + str(node.version),
38
+ replace_dots=replace_dots,
39
+ )
46
40
  elif isinstance(node, TriccNodeInput):
47
- node.export_name = clean_name('load.' +node.name, replace_dots=replace_dots)
41
+ node.export_name = clean_name("load." + node.name, replace_dots=replace_dots)
48
42
  else:
49
43
  node.export_name = clean_name(node.name, replace_dots=replace_dots)
50
-
51
- return node.export_name
52
-
53
-
54
-
55
44
 
45
+ return node.export_name
56
46
 
57
47
 
58
48
  def get_list_names(list):
@@ -1,11 +1,11 @@
1
1
  import logging
2
- import re
3
2
  import random
4
3
  import string
5
4
  import hashlib
6
5
  from markdownify import markdownify as md
7
6
  import warnings
8
7
  from bs4 import MarkupResemblesLocatorWarning
8
+
9
9
  warnings.filterwarnings("ignore", category=MarkupResemblesLocatorWarning)
10
10
  logger = logging.getLogger("default")
11
11
 
@@ -50,8 +50,8 @@ def get_rand_name(name=None, length=8):
50
50
 
51
51
  # the soup.text strips off the html formatting also
52
52
  def remove_html(string):
53
-
54
- if ' ' in string:
53
+
54
+ if " " in string:
55
55
  text = md(
56
56
  string,
57
57
  strip=["img", "table", "a"],