tricc-oo 1.5.15__tar.gz → 1.5.18__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.
Files changed (51) hide show
  1. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/PKG-INFO +1 -1
  2. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/pyproject.toml +1 -1
  3. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/converters/cql_to_operation.py +2 -0
  4. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/converters/drawio_type_map.py +2 -3
  5. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/converters/xml_to_tricc.py +4 -3
  6. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/models/base.py +8 -3
  7. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/serializers/xls_form.py +1 -1
  8. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/strategies/output/base_output_strategy.py +4 -0
  9. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/strategies/output/xls_form.py +8 -1
  10. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/visitors/tricc.py +41 -20
  11. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo.egg-info/PKG-INFO +1 -1
  12. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/README.md +0 -0
  13. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/setup.cfg +0 -0
  14. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tests/build.py +0 -0
  15. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tests/test_cql.py +0 -0
  16. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tests/to_ocl.py +0 -0
  17. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/__init__.py +0 -0
  18. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/converters/__init__.py +0 -0
  19. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/converters/codesystem_to_ocl.py +0 -0
  20. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/converters/cql/cqlLexer.py +0 -0
  21. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/converters/cql/cqlListener.py +0 -0
  22. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/converters/cql/cqlParser.py +0 -0
  23. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/converters/cql/cqlVisitor.py +0 -0
  24. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/converters/datadictionnary.py +0 -0
  25. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/converters/tricc_to_xls_form.py +0 -0
  26. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/converters/utils.py +0 -0
  27. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/models/__init__.py +0 -0
  28. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/models/calculate.py +0 -0
  29. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/models/lang.py +0 -0
  30. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/models/ocl.py +0 -0
  31. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/models/ordered_set.py +0 -0
  32. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/models/tricc.py +0 -0
  33. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/parsers/__init__.py +0 -0
  34. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/parsers/xml.py +0 -0
  35. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/serializers/__init__.py +0 -0
  36. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/serializers/planuml.py +0 -0
  37. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/strategies/__init__.py +0 -0
  38. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/strategies/input/__init__.py +0 -0
  39. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/strategies/input/base_input_strategy.py +0 -0
  40. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/strategies/input/drawio.py +0 -0
  41. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/strategies/output/spice.py +0 -0
  42. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/strategies/output/xlsform_cdss.py +0 -0
  43. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/strategies/output/xlsform_cht.py +0 -0
  44. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/strategies/output/xlsform_cht_hf.py +0 -0
  45. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/visitors/__init__.py +0 -0
  46. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/visitors/utils.py +0 -0
  47. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo/visitors/xform_pd.py +0 -0
  48. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo.egg-info/SOURCES.txt +0 -0
  49. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo.egg-info/dependency_links.txt +0 -0
  50. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo.egg-info/requires.txt +0 -0
  51. {tricc_oo-1.5.15 → tricc_oo-1.5.18}/tricc_oo.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tricc-oo
3
- Version: 1.5.15
3
+ Version: 1.5.18
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
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "tricc-oo"
7
- version = "1.5.15"
7
+ version = "1.5.18"
8
8
  description = "Python library that converts CDSS L2 in L3"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -21,8 +21,10 @@ FUNCTION_MAP = {
21
21
  'Concatenate': TriccOperator.CONCATENATE,
22
22
  'Izscore': TriccOperator.IZSCORE,
23
23
  'Zscore': TriccOperator.ZSCORE,
24
+ 'Round': TriccOperator.ROUND,
24
25
  'DrugDosage': TriccOperator.DRUG_DOSAGE,
25
26
  'HasQualifier': TriccOperator.HAS_QUALIFIER,
27
+ 'DateTimeToDecimal' : TriccOperator.DATETIME_TO_DECIMAL
26
28
  }
27
29
  # TODO
28
30
  # Min
@@ -45,7 +45,6 @@ TYPE_MAP = {
45
45
  "constraint_message",
46
46
  "relevance",
47
47
  "priority", "trigger", "default"
48
-
49
48
  ],
50
49
  "mandatory_attributes": ["label", "name", "list_name"],
51
50
  "model": TriccNodeSelectOne
@@ -99,13 +98,13 @@ TYPE_MAP = {
99
98
 
100
99
  TriccNodeType.text: {
101
100
  "objects": ["UserObject", "object"],
102
- "attributes": ["save", "relevance","priority", "trigger", "default"],
101
+ "attributes": ["save", "relevance","priority", "trigger", "default", "constraint", "constraint_message"],
103
102
  "mandatory_attributes": ["label", 'name'],
104
103
  "model": TriccNodeText
105
104
  },
106
105
  TriccNodeType.date: {
107
106
  "objects": ["UserObject", "object"],
108
- "attributes": ["save", "relevance","priority", "trigger", "default"],
107
+ "attributes": ["save", "relevance","priority", "trigger", "default", "constraint", "constraint_message"],
109
108
  "mandatory_attributes": ["label", "name"],
110
109
  "model": TriccNodeDate
111
110
  },
@@ -774,15 +774,15 @@ def clean_link(link):
774
774
  return link_parts[1]
775
775
 
776
776
 
777
- def get_groups(diagram, nodes, parent_group):
777
+ def get_groups(diagram, nodes, activity):
778
778
  groups = {}
779
779
  list = get_tricc_type_list(diagram, "object", TriccNodeType.page)
780
780
  for elm in list:
781
- add_group(elm, diagram, nodes, groups, parent_group)
781
+ add_group(elm, diagram, nodes, groups, activity, activity)
782
782
  return groups
783
783
 
784
784
 
785
- def add_group(elm, diagram, nodes, groups, parent_group):
785
+ def add_group(elm, diagram, nodes, groups, parent_group, activity):
786
786
  external_id = elm.attrib.get("id")
787
787
  id = get_id(external_id, diagram.attrib.get("id"))
788
788
  if id not in groups:
@@ -792,6 +792,7 @@ def add_group(elm, diagram, nodes, groups, parent_group):
792
792
  id=id,
793
793
  external_id=external_id,
794
794
  group=parent_group,
795
+ activity=activity
795
796
  )
796
797
  # get elememt witn parent = id and tricc_type defiend
797
798
  list_child = get_tricc_type_list(
@@ -192,6 +192,7 @@ class TriccEdge(TriccBaseModel):
192
192
  class TriccGroup(TriccBaseModel):
193
193
  tricc_type: TriccNodeType = TriccNodeType.page
194
194
  group: Optional[TriccBaseModel] = None
195
+ activity: TriccBaseModel
195
196
  name: Optional[str] = None
196
197
  export_name:Optional[str] = None
197
198
  label: Optional[Union[str, Dict[str,str]]] = None
@@ -356,6 +357,7 @@ class TriccOperator(StrEnum):
356
357
  NOT = 'not'
357
358
  ISNULL = 'isnull'
358
359
  ISNOTNULL= 'isnotnull'
360
+ ROUND = 'round'
359
361
 
360
362
  CASE = 'case' # ref (equal value, res), (equal value,res)
361
363
  IFS = 'ifs' #(cond, res), (cond,res)
@@ -363,7 +365,6 @@ class TriccOperator(StrEnum):
363
365
 
364
366
  # CDSS Specific
365
367
  HAS_QUALIFIER = 'has_qualifier'
366
-
367
368
  ZSCORE = 'zscore' # left table_name, right Y, gender give Z
368
369
  IZSCORE = 'izscore' #left table_name, right Z, gender give Y
369
370
  AGE_DAY = 'age_day' # age from dob
@@ -382,6 +383,7 @@ class TriccOperator(StrEnum):
382
383
  CAST_DATE = 'cast_date'
383
384
  PARENTHESIS = 'parenthesis'
384
385
  CONCATENATE = 'concatenate'
386
+ DATETIME_TO_DECIMAL = 'datetime_to_decimal'
385
387
 
386
388
  RETURNS_BOOLEAN =[
387
389
  TriccOperator.ADD_OR,
@@ -413,6 +415,8 @@ RETURNS_NUMBER = [
413
415
  TriccOperator.AGE_YEAR,
414
416
  TriccOperator.ZSCORE,
415
417
  TriccOperator.IZSCORE,
418
+ TriccOperator.ROUND,
419
+ TriccOperator.DATETIME_TO_DECIMAL,
416
420
  TriccOperator.PLUS,
417
421
  TriccOperator.MINUS,
418
422
  TriccOperator.DIVIDED,
@@ -455,7 +459,8 @@ class TriccOperation(BaseModel):
455
459
  return hash(self.__repr__())
456
460
 
457
461
  def __repr__(self):
458
- return "TriccOperation:"+self.__str__()
462
+ str_ref = map(repr, self.reference)
463
+ return f"TriccOperation:{self.operator}({', '.join(map(str, str_ref))})"
459
464
 
460
465
  def __eq__(self, other):
461
466
  return self.__str__() == str(other)
@@ -657,7 +662,7 @@ def clean_or_list(list_or, elm_and=None):
657
662
  if len(list_or) == 0:
658
663
  return []
659
664
 
660
- return sorted(list(set(list_or)), key=str)
665
+ return sorted(list(set(list_or)), key=repr)
661
666
 
662
667
  def and_join(argv):
663
668
  argv=clean_and_list(argv)
@@ -264,7 +264,7 @@ def get_xfrom_trad(strategy, node, column, mapping, clean_html=False):
264
264
  issubclass(node.__class__, TriccNodeDisplayCalculateBase)
265
265
  and column == "calculation"
266
266
  and isinstance(value, str)
267
- and not value.startswith("number")
267
+ and not (value.startswith("number") or value.startswith("round"))
268
268
  and getattr(node, "expression", None)
269
269
  and node.expression.get_datatype() in ("number", "boolean")
270
270
  ):
@@ -131,6 +131,10 @@ class BaseOutPutStrategy:
131
131
  raise NotImplementedError(f"This type of opreration is not supported in this strategy")
132
132
  def tricc_operation_zscore(self, ref_expressions):
133
133
  raise NotImplementedError(f"This type of opreration is not supported in this strategy")
134
+ def tricc_operation_datetime_to_decimal(self, ref_expressions):
135
+ raise NotImplementedError(f"This type of opreration is not supported in this strategy")
136
+ def tricc_operation_round(self, ref_expressions):
137
+ raise NotImplementedError(f"This type of opreration is not supported in this strategy")
134
138
  def tricc_operation_izscore(self, ref_expressions):
135
139
  raise NotImplementedError(f"This type of opreration is not supported in this strategy")
136
140
  def tricc_operation_age_day(self, ref_expressions):
@@ -569,6 +569,13 @@ class XLSFormStrategy(BaseOutPutStrategy):
569
569
  # return ((Math.pow((y / m), l) - 1) / (s * l));
570
570
  return f"(pow({y} div ({m}), {ll}) -1) div (({s}) div ({ll}))"
571
571
 
572
+ def tricc_operation_datetime_to_decimal(self, ref_expressions):
573
+ return f"decimal-date-time({ref_expressions[0]})"
574
+
575
+ def tricc_operation_round(self, ref_expressions):
576
+ return f"round({ref_expressions[0]})"
577
+
578
+
572
579
 
573
580
  def tricc_operation_izscore(self, ref_expressions):
574
581
  z, ll, m, s = self.get_zscore_params(ref_expressions)
@@ -671,7 +678,7 @@ class XLSFormStrategy(BaseOutPutStrategy):
671
678
  if isinstance(r, TriccOperation):
672
679
  return self.get_tricc_operation_expression(r)
673
680
  elif isinstance(r, TriccReference):
674
- logger.warning(f"reference still used in the calculate {r.value}")
681
+ logger.warning(f"reference `{r.value}` still used in a calculate")
675
682
  return f"${{{get_export_name(r.value)}}}"
676
683
  elif isinstance(r, TriccStatic):
677
684
  if isinstance(r.value, bool) :#or r.value in ('true', 'false')
@@ -607,6 +607,21 @@ def process_reference(node, processed_nodes, calculates, used_calculates=None,
607
607
  return False
608
608
  elif modified_expression and replace_reference:
609
609
  node.trigger = modified_expression
610
+ if isinstance(getattr(node, 'constraint', None), (TriccOperation, TriccReference)):
611
+ modified_expression = process_operation_reference(
612
+ node.constraint,
613
+ node,
614
+ processed_nodes=processed_nodes,
615
+ calculates=calculates,
616
+ used_calculates=used_calculates,
617
+ replace_reference=replace_reference,
618
+ warn=warn,
619
+ codesystems=codesystems
620
+ )
621
+ if modified_expression is False:
622
+ return False
623
+ elif modified_expression and replace_reference:
624
+ node.constraint = modified_expression
610
625
 
611
626
  if isinstance(getattr(node, 'default', None), (TriccOperation, TriccReference)):
612
627
  modified_expression = process_operation_reference(
@@ -1675,26 +1690,32 @@ def get_prev_instance_skip_expression(node, processed_nodes, process, expression
1675
1690
 
1676
1691
  # end def
1677
1692
  def get_process_skip_expression(node, processed_nodes, process, expression=None):
1678
-
1679
- end_expressions = []
1680
- f_end_expression = get_end_expression(processed_nodes)
1681
- if f_end_expression:
1682
- end_expressions.append(f_end_expression)
1683
- b_end_expression = get_end_expression(processed_nodes, 'pause')
1684
- if b_end_expression:
1685
- end_expressions.append(b_end_expression)
1686
- if process[0] in PROCESSES:
1687
- for p in PROCESSES[PROCESSES.index(process[0])+1:]:
1688
- p_end_expression = get_end_expression(processed_nodes, p)
1689
- if p_end_expression:
1690
- end_expressions.append(p_end_expression)
1691
- if end_expressions:
1692
- if expression:
1693
- end_expressions.append(expression)
1694
- if len(end_expressions) == 1:
1695
- expression = end_expressions[0]
1696
- else:
1697
- expression = and_join(end_expressions)
1693
+ list_ends = OrderedSet(
1694
+ filter(
1695
+ lambda x: issubclass(x.__class__, TriccNodeEnd),
1696
+ processed_nodes
1697
+ )
1698
+ )
1699
+ if list_ends:
1700
+ end_expressions = []
1701
+ f_end_expression = get_end_expression(list_ends)
1702
+ if f_end_expression:
1703
+ end_expressions.append(f_end_expression)
1704
+ b_end_expression = get_end_expression(list_ends, 'pause')
1705
+ if b_end_expression:
1706
+ end_expressions.append(b_end_expression)
1707
+ if process[0] in PROCESSES:
1708
+ for p in PROCESSES[PROCESSES.index(process[0])+1:]:
1709
+ p_end_expression = get_end_expression(list_ends, p)
1710
+ if p_end_expression:
1711
+ end_expressions.append(p_end_expression)
1712
+ if end_expressions:
1713
+ if expression:
1714
+ end_expressions.append(expression)
1715
+ if len(end_expressions) == 1:
1716
+ expression = end_expressions[0]
1717
+ else:
1718
+ expression = and_join(end_expressions)
1698
1719
  return expression
1699
1720
 
1700
1721
  def get_end_expression(processed_nodes, process=None):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tricc-oo
3
- Version: 1.5.15
3
+ Version: 1.5.18
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
File without changes
File without changes
File without changes
File without changes
File without changes