tricc-oo 1.5.18__py3-none-any.whl → 1.5.19__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.
tests/test_cql.py CHANGED
@@ -11,13 +11,8 @@ class TestCql(unittest.TestCase):
11
11
  operator=TriccOperator.AND,
12
12
  reference=[
13
13
  TriccOperation(
14
- operator=TriccOperator.NOT,
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.AND
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()
tricc_oo/models/base.py CHANGED
@@ -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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tricc-oo
3
- Version: 1.5.18
3
+ Version: 1.5.19
4
4
  Summary: Python library that converts CDSS L2 in L3
5
5
  Project-URL: Homepage, https://github.com/SwissTPH/tricc
6
6
  Project-URL: Issues, https://github.com/SwissTPH/tricc/issues
@@ -1,10 +1,10 @@
1
1
  tests/build.py,sha256=aGpylfQU60xPq0AJX-UQQRIxXd7Nxb7SLulVEfZt3aA,6483
2
- tests/test_cql.py,sha256=sxAYEtiiZ-naXVaKPDYHaQFVhbw0QnYy4_MCItgv1Do,6547
2
+ tests/test_cql.py,sha256=Ut7t02T7tDeYKwu4wpsSZkmIpDF0PP9rbTaV35JSeGw,6823
3
3
  tests/to_ocl.py,sha256=f_KeKF7N1tri9ChbtH1OShgHskt_T9Wj1IfaT6qJNGY,2247
4
4
  tricc_oo/__init__.py,sha256=Els6sDXpOJiGU1zp45rTXZgEKceq_XhRZDfrx1mIMGc,255
5
5
  tricc_oo/converters/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  tricc_oo/converters/codesystem_to_ocl.py,sha256=-ZKMBeIvzgqmhJfnn6ptuwpnHQtuE-fCDDfKpfGvUSU,6066
7
- tricc_oo/converters/cql_to_operation.py,sha256=geAAS2KPA_eax30lKh56m5Lu9MTkvTUK8x9FAnWU3no,14424
7
+ tricc_oo/converters/cql_to_operation.py,sha256=uKNKtPWXBF25mBHJM39EF258ogP_75ikSNXRHDiLbrs,14646
8
8
  tricc_oo/converters/datadictionnary.py,sha256=WWKcTtKLfc4aduHcDBhr4JSfU2NqRMaslwX-wdZPIAw,3968
9
9
  tricc_oo/converters/drawio_type_map.py,sha256=I-UN-O1OKmNFnkHAJMEbPrew7r3K2_x5mKPUVM98F24,7545
10
10
  tricc_oo/converters/tricc_to_xls_form.py,sha256=bJVd-FLrivrCxGI6mO2i0V7GVVuJZdaDuwcEf3gHNR8,2327
@@ -15,7 +15,7 @@ tricc_oo/converters/cql/cqlListener.py,sha256=ketvj7XvO7t047S6A3_gTPvp2MlYk1bojm
15
15
  tricc_oo/converters/cql/cqlParser.py,sha256=hIUdR907WX24P2Jlrxk-H0IT94n51yh_ZsCmwQhnFas,414730
16
16
  tricc_oo/converters/cql/cqlVisitor.py,sha256=SWSDIqVYBhucR4VgLn_EPNs7LV9yCqsOmzFZ0bmRSGc,33865
17
17
  tricc_oo/models/__init__.py,sha256=Rdk1fsNXHrbmXTQD1O7i0NC_A6os648Ap6CtWRliOg8,92
18
- tricc_oo/models/base.py,sha256=hPY7w7ur-UTS9OvZb-xmvpjRF6mha_E0K4A9X1_eHKQ,24871
18
+ tricc_oo/models/base.py,sha256=gXjEUGD5yRCqtfATxM2DIBJ17HVJWzMifrBvacm_p54,26054
19
19
  tricc_oo/models/calculate.py,sha256=60jSL8gbcTxqGYsZe1LoGZAdScIp6_suC88XlE0xg-c,7640
20
20
  tricc_oo/models/lang.py,sha256=SwKaoxyRhE7gH_ZlYyFXzGuTQ5RE19y47LWAA35zYxg,2338
21
21
  tricc_oo/models/ocl.py,sha256=ol35Gl1jCBp0Ven0yxOKzDIZkVL5Kx9uwaR_64pjxKI,8931
@@ -40,7 +40,7 @@ tricc_oo/visitors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU
40
40
  tricc_oo/visitors/tricc.py,sha256=e_6itYSgtc6EF2sOCKFvP3nri1NuELzRah_mBJdRVik,101851
41
41
  tricc_oo/visitors/utils.py,sha256=Gol4JNozPEd30Q1l8IPIPhx5fqVyy9R81GofGVebgD8,484
42
42
  tricc_oo/visitors/xform_pd.py,sha256=jgjBLbfElVdi0NmClhw6NK6qNcIgWYm4KMXfVwiQwXM,9705
43
- tricc_oo-1.5.18.dist-info/METADATA,sha256=plF1mcu4Jthpk6S9eD5qZv3BPXsEnnoeFJb77nBONh8,7878
44
- tricc_oo-1.5.18.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
45
- tricc_oo-1.5.18.dist-info/top_level.txt,sha256=NvbfMNAiy9m4b1unBsqpeOQWh4IgA1Xa33BtKA4abxk,15
46
- tricc_oo-1.5.18.dist-info/RECORD,,
43
+ tricc_oo-1.5.19.dist-info/METADATA,sha256=L0rbZLJFADUCMrIESNtMxlOCNOop0IesDNSnLGJN3dY,7878
44
+ tricc_oo-1.5.19.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
45
+ tricc_oo-1.5.19.dist-info/top_level.txt,sha256=NvbfMNAiy9m4b1unBsqpeOQWh4IgA1Xa33BtKA4abxk,15
46
+ tricc_oo-1.5.19.dist-info/RECORD,,