tricc-oo 1.0.1__py3-none-any.whl → 1.4.15__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 (66) hide show
  1. tests/build.py +213 -0
  2. tests/test_cql.py +197 -0
  3. tests/to_ocl.py +51 -0
  4. {tricc → tricc_oo}/__init__.py +3 -1
  5. tricc_oo/converters/codesystem_to_ocl.py +169 -0
  6. tricc_oo/converters/cql/cqlLexer.py +822 -0
  7. tricc_oo/converters/cql/cqlListener.py +1632 -0
  8. tricc_oo/converters/cql/cqlParser.py +11204 -0
  9. tricc_oo/converters/cql/cqlVisitor.py +913 -0
  10. tricc_oo/converters/cql_to_operation.py +402 -0
  11. tricc_oo/converters/datadictionnary.py +115 -0
  12. tricc_oo/converters/drawio_type_map.py +222 -0
  13. tricc_oo/converters/tricc_to_xls_form.py +61 -0
  14. tricc_oo/converters/utils.py +65 -0
  15. tricc_oo/converters/xml_to_tricc.py +1003 -0
  16. tricc_oo/models/__init__.py +4 -0
  17. tricc_oo/models/base.py +732 -0
  18. tricc_oo/models/calculate.py +216 -0
  19. tricc_oo/models/ocl.py +281 -0
  20. tricc_oo/models/ordered_set.py +125 -0
  21. tricc_oo/models/tricc.py +418 -0
  22. tricc_oo/parsers/xml.py +138 -0
  23. tricc_oo/serializers/__init__.py +0 -0
  24. tricc_oo/serializers/xls_form.py +745 -0
  25. tricc_oo/strategies/__init__.py +0 -0
  26. tricc_oo/strategies/input/__init__.py +0 -0
  27. tricc_oo/strategies/input/base_input_strategy.py +111 -0
  28. tricc_oo/strategies/input/drawio.py +317 -0
  29. tricc_oo/strategies/output/base_output_strategy.py +148 -0
  30. tricc_oo/strategies/output/spice.py +365 -0
  31. tricc_oo/strategies/output/xls_form.py +697 -0
  32. tricc_oo/strategies/output/xlsform_cdss.py +189 -0
  33. tricc_oo/strategies/output/xlsform_cht.py +200 -0
  34. tricc_oo/strategies/output/xlsform_cht_hf.py +334 -0
  35. tricc_oo/visitors/__init__.py +0 -0
  36. tricc_oo/visitors/tricc.py +2198 -0
  37. tricc_oo/visitors/utils.py +17 -0
  38. tricc_oo/visitors/xform_pd.py +264 -0
  39. tricc_oo-1.4.15.dist-info/METADATA +219 -0
  40. tricc_oo-1.4.15.dist-info/RECORD +46 -0
  41. {tricc_oo-1.0.1.dist-info → tricc_oo-1.4.15.dist-info}/WHEEL +1 -1
  42. tricc_oo-1.4.15.dist-info/top_level.txt +2 -0
  43. tricc/converters/mc_to_tricc.py +0 -542
  44. tricc/converters/tricc_to_xls_form.py +0 -553
  45. tricc/converters/utils.py +0 -44
  46. tricc/converters/xml_to_tricc.py +0 -740
  47. tricc/models/tricc.py +0 -1093
  48. tricc/parsers/xml.py +0 -81
  49. tricc/serializers/xls_form.py +0 -364
  50. tricc/strategies/input/base_input_strategy.py +0 -80
  51. tricc/strategies/input/drawio.py +0 -246
  52. tricc/strategies/input/medalcreator.py +0 -168
  53. tricc/strategies/output/base_output_strategy.py +0 -92
  54. tricc/strategies/output/xls_form.py +0 -194
  55. tricc/strategies/output/xlsform_cdss.py +0 -46
  56. tricc/strategies/output/xlsform_cht.py +0 -106
  57. tricc/visitors/tricc.py +0 -375
  58. tricc_oo-1.0.1.dist-info/LICENSE +0 -78
  59. tricc_oo-1.0.1.dist-info/METADATA +0 -229
  60. tricc_oo-1.0.1.dist-info/RECORD +0 -26
  61. tricc_oo-1.0.1.dist-info/top_level.txt +0 -2
  62. venv/bin/vba_extract.py +0 -78
  63. {tricc → tricc_oo}/converters/__init__.py +0 -0
  64. {tricc → tricc_oo}/models/lang.py +0 -0
  65. {tricc/serializers → tricc_oo/parsers}/__init__.py +0 -0
  66. {tricc → tricc_oo}/serializers/planuml.py +0 -0
@@ -0,0 +1,222 @@
1
+ from strenum import StrEnum
2
+ from tricc_oo.models.base import *
3
+ from tricc_oo.models.calculate import *
4
+
5
+
6
+ TYPE_MAP = {
7
+ TriccNodeType.start: {
8
+ "objects": ["UserObject", "object"],
9
+ "attributes": ['process', 'parent', 'form_id','relevance'],
10
+ "mandatory_attributes": ["label"],
11
+ "model": TriccNodeMainStart
12
+ },
13
+ TriccNodeType.activity_start: {
14
+ "objects": ["UserObject", "object"],
15
+ "attributes": ['parent', 'parent', 'instance', 'relevance'],
16
+ "mandatory_attributes": ["label", "name"],
17
+ "model": TriccNodeActivityStart
18
+ },
19
+ TriccNodeType.note: {
20
+ "objects": ["UserObject", "object"],
21
+ "attributes": ['relevance'],
22
+ "mandatory_attributes": ["label", "name"],
23
+ "model": TriccNodeNote
24
+ },
25
+ TriccNodeType.hint: {
26
+ "objects": ["UserObject", "object"],
27
+ "attributes": [],
28
+ "mandatory_attributes": ["label"],
29
+ "model": None
30
+ },
31
+ TriccNodeType.help: {
32
+ "objects": ["UserObject", "object"],
33
+ "attributes": [],
34
+ "mandatory_attributes": ["label"],
35
+ "model": None
36
+ },
37
+ TriccNodeType.select_one: {
38
+ "has_options": True,
39
+ "objects": ["UserObject", "object"],
40
+ "attributes": [
41
+ "required",
42
+ "save",
43
+ "filter",
44
+ "constraint",
45
+ "constraint_message",
46
+ "relevance",
47
+
48
+ ],
49
+ "mandatory_attributes": ["label", "name", "list_name"],
50
+ "model": TriccNodeSelectOne
51
+ },
52
+ TriccNodeType.select_multiple: {
53
+ "has_options": True,
54
+ "objects": ["UserObject", "object"],
55
+ "attributes": [
56
+ "required",
57
+ "save",
58
+ "filter",
59
+ "constraint",
60
+ "constraint_message",
61
+ "relevance",
62
+ ],
63
+ "mandatory_attributes": ["label", "name", "list_name"],
64
+ "model": TriccNodeSelectMultiple
65
+ },
66
+ TriccNodeType.decimal: {
67
+ "objects": ["UserObject", "object"],
68
+ "attributes": [
69
+ "min",
70
+ "max",
71
+ "constraint",
72
+ "save",
73
+ "constraint_message",
74
+ "required",
75
+ "relevance",
76
+ ],
77
+ "mandatory_attributes": ["label", "name"],
78
+ "model": TriccNodeDecimal
79
+ },
80
+ TriccNodeType.integer: {
81
+ "objects": ["UserObject", "object"],
82
+ "attributes": [
83
+ "min",
84
+ "max",
85
+ "constraint",
86
+ "save",
87
+ "constraint_message",
88
+ "required",
89
+ "relevance",
90
+ ],
91
+ "mandatory_attributes": ["label", "name"],
92
+ "model": TriccNodeInteger
93
+ },
94
+
95
+ TriccNodeType.text: {
96
+ "objects": ["UserObject", "object"],
97
+ "attributes": ["relevance"],
98
+ "mandatory_attributes": ["label", 'name'],
99
+ "model": TriccNodeText
100
+ },
101
+ TriccNodeType.date: {
102
+ "objects": ["UserObject", "object"],
103
+ "attributes": ["relevance"],
104
+ "mandatory_attributes": ["label", "name"],
105
+ "model": TriccNodeDate
106
+ },
107
+ TriccNodeType.add: {
108
+ "objects": ["UserObject", "object"],
109
+ "attributes": ["save", "expression"],
110
+ "mandatory_attributes": ['label', "name"],
111
+ "model": TriccNodeAdd
112
+ },
113
+ TriccNodeType.count: {
114
+ "objects": ["UserObject", "object"],
115
+ "attributes": ["save", "expression"],
116
+ "mandatory_attributes": ['label', "name"],
117
+ "model": TriccNodeCount
118
+ },
119
+ TriccNodeType.calculate: {
120
+ "objects": ["UserObject", "object"],
121
+ "attributes": ["save", "reference"],
122
+ "mandatory_attributes": [ "name", 'label'],
123
+ "model": TriccNodeCalculate
124
+ },
125
+ TriccNodeType.rhombus: {
126
+ "objects": ["UserObject", "object"],
127
+ "attributes": ["save", "expression", 'label'],
128
+ "mandatory_attributes": ["reference"],
129
+ "model": TriccNodeRhombus
130
+ },
131
+ TriccNodeType.wait: {
132
+ "objects": ["UserObject", "object"],
133
+ "attributes": ["save", "expression"],
134
+ "mandatory_attributes": ["reference", "name", 'label'],
135
+ "model": TriccNodeWait
136
+ },
137
+ TriccNodeType.exclusive: {
138
+ "objects": ["UserObject", "object"],
139
+ "attributes": [],
140
+ "mandatory_attributes": [],
141
+ "model": TriccNodeExclusive
142
+ },
143
+ TriccNodeType.not_available: {
144
+ "objects": ["UserObject", "object"],
145
+ "attributes": [],
146
+ "mandatory_attributes": ["label", "name", "list_name"],
147
+ "model": TriccNodeSelectNotAvailable
148
+ },
149
+ TriccNodeType.select_yesno: {
150
+ "objects": ["UserObject", "object"],
151
+ "attributes": [
152
+ "required",
153
+ "save",
154
+ "filter",
155
+ "constraint",
156
+ "constraint_message",
157
+ "relevance",
158
+ ],
159
+ "mandatory_attributes": ["label", "name", "list_name"],
160
+ "model": TriccNodeSelectYesNo
161
+ },
162
+ TriccNodeType.link_out: {
163
+ "objects": ["UserObject", "object"],
164
+ "attributes": [],
165
+ "mandatory_attributes": ["reference", "label", "name"],
166
+ "model": TriccNodeNote
167
+ },
168
+ TriccNodeType.link_in: {
169
+ "objects": ["UserObject", "object"],
170
+ "attributes": [],
171
+ "mandatory_attributes": ["label", "name"],
172
+ "model": TriccNodeLinkIn
173
+ },
174
+ TriccNodeType.goto: {
175
+ "objects": ["UserObject", "object"],
176
+ "attributes": ["instance"],
177
+ "mandatory_attributes": ["link", "label", "name"],
178
+ "model": TriccNodeGoTo
179
+ },
180
+ TriccNodeType.end: {
181
+ "objects": ["UserObject", "object"],
182
+ "attributes": ['process', 'name', 'label', 'hint'],
183
+ "mandatory_attributes": ['label'],
184
+ "model": TriccNodeEnd
185
+ },
186
+ TriccNodeType.activity_end: {
187
+ "objects": ["UserObject", "object"],
188
+ "attributes": [],
189
+ "mandatory_attributes": [],
190
+ "model": TriccNodeActivityEnd
191
+ },
192
+ TriccNodeType.bridge: {
193
+ "objects": ["UserObject", "object"],
194
+ "attributes": ["label"],
195
+ "mandatory_attributes": [],
196
+ "model": TriccNodeBridge
197
+ },
198
+ TriccNodeType.diagnosis: {
199
+ "objects": ["UserObject", "object"],
200
+ "attributes": ["save", "reference"],
201
+ "mandatory_attributes": [ "name", 'label'],
202
+ "model": TriccNodeDiagnosis
203
+ },
204
+ TriccNodeType.proposed_diagnosis: {
205
+ "objects": ["UserObject", "object"],
206
+ "attributes": ["save", "reference", "severity"],
207
+ "mandatory_attributes": [ "name", 'label'],
208
+ "model": TriccNodeProposedDiagnosis
209
+ },
210
+ TriccNodeType.input: {
211
+ "objects": ["UserObject", "object"],
212
+ "attributes": ["save", "reference","datatype"],
213
+ "mandatory_attributes": [ "name", 'label'],
214
+ "model": TriccNodeInput
215
+ },
216
+ # TriccNodeType.number: {
217
+ # "objects": ["UserObject", "object"],
218
+ # "attributes": ["constraint", "save", "constraint_message", "required"],
219
+ # "mandatory_attributes": [],
220
+ # "model": TriccNodeNumber
221
+ # },
222
+ }
@@ -0,0 +1,61 @@
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
+
8
+ # from babel import _
9
+
10
+ # TRICC_SELECT_MULTIPLE_CALC_EXPRESSION = "count-selected(${{{0}}}) - number(selected(${{{0}}},'opt_none'))"
11
+ # TRICC_SELECT_MULTIPLE_CALC_NONE_EXPRESSION = "selected(${{{0}}},'opt_none')"
12
+ # TRICC_CALC_EXPRESSION = "${{{0}}}>0"
13
+ # TRICC_CALC_NOT_EXPRESSION = "${{{0}}}=0"
14
+ # TRICC_EMPTY_EXPRESSION = "coalesce(${{{0}}},'') != ''"
15
+ # TRICC_SELECTED_EXPRESSION = 'selected(${{{0}}}, "{1}")'
16
+ # TRICC_SELECTED_NEGATE_EXPRESSION = 'count-selected(${{{0}}})>0 and not(selected(${{{0}}}, "{1}"))'
17
+ # TRICC_REF_EXPRESSION = "${{{0}}}"
18
+ TRICC_NEGATE = "not({})"
19
+ # TRICC_NUMBER = "number({})"
20
+ # TRICC_AND_EXPRESSION = '{0} and {1}'
21
+ VERSION_SEPARATOR = '_Vv_'
22
+ INSTANCE_SEPARATOR = "_Ii_"
23
+
24
+ import logging
25
+
26
+ logger = logging.getLogger("default")
27
+
28
+ # gettext language dict {'code':gettext}
29
+
30
+
31
+ def get_export_name(node, replace_dots=True):
32
+ if isinstance(node, str):
33
+ return clean_name(node, replace_dots=replace_dots)
34
+ if node.export_name is None:
35
+ node.gen_name()
36
+ if isinstance(node, TriccNodeSelectOption):
37
+ node.export_name = node.name
38
+ elif isinstance(node, TriccNodeActivityStart):
39
+ node.export_name = clean_name(node.name + INSTANCE_SEPARATOR + str(node.instance), replace_dots=replace_dots)
40
+ elif isinstance(node, TriccNodeInput):
41
+ node.export_name = clean_name('load.' +node.name, replace_dots=replace_dots)
42
+ elif node.last == False:
43
+ node.export_name = clean_name(node.name + VERSION_SEPARATOR + str(node.version), replace_dots=replace_dots)
44
+ else:
45
+ node.export_name = clean_name(node.name, replace_dots=replace_dots)
46
+
47
+ return node.export_name
48
+
49
+
50
+
51
+
52
+
53
+
54
+ def get_list_names(list):
55
+ names = []
56
+ for elm in list:
57
+ if issubclass(elm.__class__, TriccNodeBaseModel):
58
+ names.append(get_export_name(elm))
59
+ elif isinstance(elm, str):
60
+ names.append(elm)
61
+ return names
@@ -0,0 +1,65 @@
1
+ import logging
2
+ import re
3
+ import random
4
+ import string
5
+ import hashlib
6
+ from markdownify import markdownify as md
7
+ import warnings
8
+ from bs4 import MarkupResemblesLocatorWarning
9
+ warnings.filterwarnings("ignore", category=MarkupResemblesLocatorWarning)
10
+ logger = logging.getLogger("default")
11
+
12
+
13
+ def replace_all(text, list_char, replacement):
14
+ for i in list_char:
15
+ text = text.replace(i, replacement)
16
+ return text
17
+
18
+
19
+ def clean_str(name, replace_dots=False):
20
+ replacement_list = ["-", " ", ",", "."] if replace_dots else ["-", " ", ","]
21
+ return replace_all(name, replacement_list, "_")
22
+
23
+
24
+ def clean_name(name, prefix="", replace_dots=False):
25
+ name = clean_str(name, replace_dots)
26
+ if name[0].isdigit():
27
+ name = "id_" + name
28
+ elif name[0].isdigit() == "_":
29
+ name = name[1:]
30
+ return name
31
+
32
+
33
+ def generate_id(name=None, length=18):
34
+ if name:
35
+ h = hashlib.blake2b(digest_size=length)
36
+ h.update(name.encode("utf-8") if isinstance(name, str) else name)
37
+ return h.hexdigest()
38
+ else:
39
+ return "".join(
40
+ random.choices(
41
+ string.ascii_lowercase + string.digits + string.ascii_uppercase,
42
+ k=length,
43
+ )
44
+ )
45
+
46
+
47
+ def get_rand_name(name=None, length=8):
48
+ return "n" + generate_id(name=name, length=length)
49
+
50
+
51
+ # the soup.text strips off the html formatting also
52
+ def remove_html(string):
53
+
54
+ if ' ' in string:
55
+ text = md(
56
+ string,
57
+ strip=["img", "table", "a"],
58
+ strong_em_symbol="*",
59
+ escape_underscores=False,
60
+ escape_asterisks=False,
61
+ bullets=["-", "*"],
62
+ )
63
+
64
+ return text
65
+ return string