tricc-oo 1.5.18__tar.gz → 1.5.20__tar.gz
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.
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/PKG-INFO +1 -1
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/pyproject.toml +1 -1
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tests/test_cql.py +17 -7
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/converters/cql_to_operation.py +8 -4
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/models/base.py +31 -2
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo.egg-info/PKG-INFO +1 -1
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/README.md +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/setup.cfg +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tests/build.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tests/to_ocl.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/__init__.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/converters/__init__.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/converters/codesystem_to_ocl.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/converters/cql/cqlLexer.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/converters/cql/cqlListener.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/converters/cql/cqlParser.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/converters/cql/cqlVisitor.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/converters/datadictionnary.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/converters/drawio_type_map.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/converters/tricc_to_xls_form.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/converters/utils.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/converters/xml_to_tricc.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/models/__init__.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/models/calculate.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/models/lang.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/models/ocl.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/models/ordered_set.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/models/tricc.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/parsers/__init__.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/parsers/xml.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/serializers/__init__.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/serializers/planuml.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/serializers/xls_form.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/strategies/__init__.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/strategies/input/__init__.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/strategies/input/base_input_strategy.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/strategies/input/drawio.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/strategies/output/base_output_strategy.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/strategies/output/spice.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/strategies/output/xls_form.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/strategies/output/xlsform_cdss.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/strategies/output/xlsform_cht.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/strategies/output/xlsform_cht_hf.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/visitors/__init__.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/visitors/tricc.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/visitors/utils.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo/visitors/xform_pd.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo.egg-info/SOURCES.txt +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo.egg-info/dependency_links.txt +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo.egg-info/requires.txt +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.20}/tricc_oo.egg-info/top_level.txt +0 -0
|
@@ -11,13 +11,8 @@ class TestCql(unittest.TestCase):
|
|
|
11
11
|
operator=TriccOperator.AND,
|
|
12
12
|
reference=[
|
|
13
13
|
TriccOperation(
|
|
14
|
-
operator=TriccOperator.
|
|
15
|
-
reference=[
|
|
16
|
-
TriccOperation(
|
|
17
|
-
operator=TriccOperator.ISNULL,
|
|
18
|
-
reference=[TriccReference("p_weight")]
|
|
19
|
-
)
|
|
20
|
-
]
|
|
14
|
+
operator=TriccOperator.ISNOTNULL,
|
|
15
|
+
reference=[TriccReference("p_weight")]
|
|
21
16
|
),
|
|
22
17
|
TriccOperation(
|
|
23
18
|
operator=TriccOperator.MORE,
|
|
@@ -46,6 +41,21 @@ class TestCql(unittest.TestCase):
|
|
|
46
41
|
)
|
|
47
42
|
self.assertEqual(str(dg_operation), str(dg_expected))
|
|
48
43
|
|
|
44
|
+
def test_implied_concat(self):
|
|
45
|
+
if_cql = "'A' & \"B\" & 'C'"
|
|
46
|
+
cc_operation = transform_cql_to_operation(if_cql)
|
|
47
|
+
cc_expected = TriccOperation(
|
|
48
|
+
operator=TriccOperator.CONCATENATE,
|
|
49
|
+
reference=[
|
|
50
|
+
TriccStatic(value='A'),
|
|
51
|
+
TriccReference("B"),
|
|
52
|
+
TriccStatic(value='C')
|
|
53
|
+
]
|
|
54
|
+
)
|
|
55
|
+
self.assertEqual(str(cc_operation), str(cc_expected))
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
49
59
|
def test_if(self):
|
|
50
60
|
if_cql = "if AgeInDays() < 60 then 'newborn' else 'child'"
|
|
51
61
|
if_operation = transform_cql_to_operation(if_cql)
|
|
@@ -3,7 +3,7 @@ from tricc_oo.converters.cql.cqlLexer import cqlLexer
|
|
|
3
3
|
from tricc_oo.converters.cql.cqlParser import cqlParser
|
|
4
4
|
from tricc_oo.converters.cql.cqlVisitor import cqlVisitor
|
|
5
5
|
from tricc_oo.converters.utils import clean_name
|
|
6
|
-
from tricc_oo.models.base import TriccOperator, TriccOperation, TriccStatic, TriccReference, not_clean, or_join, and_join
|
|
6
|
+
from tricc_oo.models.base import TriccOperator, TriccOperation, TriccStatic, TriccReference, not_clean, or_join, and_join, string_join
|
|
7
7
|
import logging
|
|
8
8
|
|
|
9
9
|
logger = logging.getLogger("default")
|
|
@@ -216,7 +216,11 @@ class cqlToXlsFormVisitor(cqlVisitor):
|
|
|
216
216
|
if operator == TriccOperator.AND:
|
|
217
217
|
return and_join([left, right])
|
|
218
218
|
elif operator == TriccOperator.OR:
|
|
219
|
-
return or_join([left, right])
|
|
219
|
+
return or_join([left, right])
|
|
220
|
+
elif operator == TriccOperator.CONCATENATE:
|
|
221
|
+
left = "" if left is None else left
|
|
222
|
+
right = "" if right is None else right
|
|
223
|
+
return string_join(left, right)
|
|
220
224
|
else:
|
|
221
225
|
op = TriccOperation(operator, [left, right])
|
|
222
226
|
return op
|
|
@@ -287,10 +291,10 @@ class cqlToXlsFormVisitor(cqlVisitor):
|
|
|
287
291
|
op_map = {
|
|
288
292
|
'+': TriccOperator.PLUS,
|
|
289
293
|
'-': TriccOperator.MINUS,
|
|
290
|
-
'&': TriccOperator.
|
|
294
|
+
'&': TriccOperator.CONCATENATE
|
|
291
295
|
}
|
|
292
296
|
return self.__std_operator(op_map.get(op_text), ctx)
|
|
293
|
-
|
|
297
|
+
|
|
294
298
|
|
|
295
299
|
def visitTypeExpression(self, ctx):
|
|
296
300
|
to_type = ctx.getChild(2).getText()
|
|
@@ -203,7 +203,11 @@ class TriccGroup(TriccBaseModel):
|
|
|
203
203
|
super().__init__(**data)
|
|
204
204
|
if self.name is None:
|
|
205
205
|
self.name = generate_id(str(data))
|
|
206
|
-
|
|
206
|
+
|
|
207
|
+
def gen_name(self):
|
|
208
|
+
if self.name is None:
|
|
209
|
+
self.name = get_rand_name(self.id)
|
|
210
|
+
|
|
207
211
|
def get_name(self):
|
|
208
212
|
result = str(super().get_name())
|
|
209
213
|
name = getattr(self, 'name', None)
|
|
@@ -336,7 +340,8 @@ class TriccReference(TriccStatic):
|
|
|
336
340
|
|
|
337
341
|
class TriccOperator(StrEnum):
|
|
338
342
|
AND = 'and' # and between left and rights
|
|
339
|
-
ADD_OR = 'and_or' # left and one of the righs
|
|
343
|
+
ADD_OR = 'and_or' # left and one of the righs
|
|
344
|
+
#ADD_STRING: 'add_string'
|
|
340
345
|
OR = 'or' # or between left and rights
|
|
341
346
|
NATIVE = 'native' #default left is native expression
|
|
342
347
|
ISTRUE = 'istrue' # left is right
|
|
@@ -675,6 +680,30 @@ def and_join(argv):
|
|
|
675
680
|
TriccOperator.AND,
|
|
676
681
|
argv
|
|
677
682
|
)
|
|
683
|
+
|
|
684
|
+
|
|
685
|
+
def string_join(left: Union[str, TriccOperation], right: Union[str, TriccOperation]) -> TriccOperation:
|
|
686
|
+
"""
|
|
687
|
+
Concatenates two arguments (strings or TriccOperation) into a TriccOperation with CONCATENATE operator.
|
|
688
|
+
If either argument is a TriccOperation with CONCATENATE operator, its operands are merged into the result.
|
|
689
|
+
"""
|
|
690
|
+
# Initialize operands list for the new TriccOperation
|
|
691
|
+
operands: List[Union[str, TriccOperation]] = []
|
|
692
|
+
|
|
693
|
+
# Check if left is a TriccOperation with CONCATENATE
|
|
694
|
+
if isinstance(left, TriccOperation) and left.operator == TriccOperator.CONCATENATE:
|
|
695
|
+
operands.extend(left.reference) # Merge left's operands
|
|
696
|
+
else:
|
|
697
|
+
operands.append(left) # Add left as-is
|
|
698
|
+
|
|
699
|
+
# Check if right is a TriccOperation with CONCATENATE
|
|
700
|
+
if isinstance(right, TriccOperation) and right.operator == TriccOperator.CONCATENATE:
|
|
701
|
+
operands.extend(right.reference) # Merge right's operands
|
|
702
|
+
else:
|
|
703
|
+
operands.append(right) # Add right as-is
|
|
704
|
+
|
|
705
|
+
# Return a new TriccOperation with the merged operands
|
|
706
|
+
return TriccOperation(operator=TriccOperator.CONCATENATE, reference=operands)
|
|
678
707
|
|
|
679
708
|
# function that make a 2 part and
|
|
680
709
|
# @param left part
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|