tricc-oo 1.5.18__tar.gz → 1.5.19__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.19}/PKG-INFO +1 -1
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/pyproject.toml +1 -1
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tests/test_cql.py +17 -7
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/converters/cql_to_operation.py +8 -4
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/models/base.py +26 -1
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo.egg-info/PKG-INFO +1 -1
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/README.md +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/setup.cfg +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tests/build.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tests/to_ocl.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/__init__.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/converters/__init__.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/converters/codesystem_to_ocl.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/converters/cql/cqlLexer.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/converters/cql/cqlListener.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/converters/cql/cqlParser.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/converters/cql/cqlVisitor.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/converters/datadictionnary.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/converters/drawio_type_map.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/converters/tricc_to_xls_form.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/converters/utils.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/converters/xml_to_tricc.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/models/__init__.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/models/calculate.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/models/lang.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/models/ocl.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/models/ordered_set.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/models/tricc.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/parsers/__init__.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/parsers/xml.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/serializers/__init__.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/serializers/planuml.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/serializers/xls_form.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/strategies/__init__.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/strategies/input/__init__.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/strategies/input/base_input_strategy.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/strategies/input/drawio.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/strategies/output/base_output_strategy.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/strategies/output/spice.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/strategies/output/xls_form.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/strategies/output/xlsform_cdss.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/strategies/output/xlsform_cht.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/strategies/output/xlsform_cht_hf.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/visitors/__init__.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/visitors/tricc.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/visitors/utils.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo/visitors/xform_pd.py +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo.egg-info/SOURCES.txt +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo.egg-info/dependency_links.txt +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/tricc_oo.egg-info/requires.txt +0 -0
- {tricc_oo-1.5.18 → tricc_oo-1.5.19}/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()
|
|
@@ -336,7 +336,8 @@ class TriccReference(TriccStatic):
|
|
|
336
336
|
|
|
337
337
|
class TriccOperator(StrEnum):
|
|
338
338
|
AND = 'and' # and between left and rights
|
|
339
|
-
ADD_OR = 'and_or' # left and one of the righs
|
|
339
|
+
ADD_OR = 'and_or' # left and one of the righs
|
|
340
|
+
#ADD_STRING: 'add_string'
|
|
340
341
|
OR = 'or' # or between left and rights
|
|
341
342
|
NATIVE = 'native' #default left is native expression
|
|
342
343
|
ISTRUE = 'istrue' # left is right
|
|
@@ -675,6 +676,30 @@ def and_join(argv):
|
|
|
675
676
|
TriccOperator.AND,
|
|
676
677
|
argv
|
|
677
678
|
)
|
|
679
|
+
|
|
680
|
+
|
|
681
|
+
def string_join(left: Union[str, TriccOperation], right: Union[str, TriccOperation]) -> TriccOperation:
|
|
682
|
+
"""
|
|
683
|
+
Concatenates two arguments (strings or TriccOperation) into a TriccOperation with CONCATENATE operator.
|
|
684
|
+
If either argument is a TriccOperation with CONCATENATE operator, its operands are merged into the result.
|
|
685
|
+
"""
|
|
686
|
+
# Initialize operands list for the new TriccOperation
|
|
687
|
+
operands: List[Union[str, TriccOperation]] = []
|
|
688
|
+
|
|
689
|
+
# Check if left is a TriccOperation with CONCATENATE
|
|
690
|
+
if isinstance(left, TriccOperation) and left.operator == TriccOperator.CONCATENATE:
|
|
691
|
+
operands.extend(left.reference) # Merge left's operands
|
|
692
|
+
else:
|
|
693
|
+
operands.append(left) # Add left as-is
|
|
694
|
+
|
|
695
|
+
# Check if right is a TriccOperation with CONCATENATE
|
|
696
|
+
if isinstance(right, TriccOperation) and right.operator == TriccOperator.CONCATENATE:
|
|
697
|
+
operands.extend(right.reference) # Merge right's operands
|
|
698
|
+
else:
|
|
699
|
+
operands.append(right) # Add right as-is
|
|
700
|
+
|
|
701
|
+
# Return a new TriccOperation with the merged operands
|
|
702
|
+
return TriccOperation(operator=TriccOperator.CONCATENATE, reference=operands)
|
|
678
703
|
|
|
679
704
|
# function that make a 2 part and
|
|
680
705
|
# @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
|